From 67e868eb6c5a6dd2c5da3eabd6f583a8c9158dd0 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 26 Jun 2014 13:30:49 -0700 Subject: [PATCH 001/436] initial grouping code to develop cartridge grouping feature --- .../autoscaler/ComplexApplicationContext.java | 929 ++++++++++++++++++ .../stratos/autoscaler/PartitionContext.java | 77 ++ .../AutoscalerTopologyEventReceiver.java | 26 + .../autoscaler/monitor/AbstractMonitor.java | 27 +- .../autoscaler/monitor/ClusterMonitor.java | 24 + .../rule/AutoscalerRuleEvaluator.java | 36 + .../autoscaler/rule/RuleTasksDelegator.java | 22 +- .../cartridge/agent/CartridgeAgent.java | 15 +- .../publisher/CartridgeStatistics.java | 66 ++ .../publisher/HealthStatisticsNotifier.java | 119 ++- .../publisher/HealthStatisticsReader.java | 44 +- .../publisher/IHealthStatisticsReader.java | 55 ++ .../statistics/publisher/PluginLoader.java | 88 ++ .../java/org/apache/stratos/cli/Command.java | 5 +- .../stratos/cli/RestCommandLineService.java | 6 +- .../stratos/cli/StratosApplication.java | 8 +- .../beans/cartridge/CartridgeInfoBean.java | 12 +- .../cli/commands/ActivateTenantCommand.java | 3 +- .../cli/commands/AddDomainMappingCommand.java | 3 +- .../cli/commands/AddTenantCommand.java | 30 +- .../cli/commands/AutoscalePolicyCommand.java | 3 +- .../AutoscalingPolicyDeploymentCommand.java | 10 +- .../commands/CartridgeDeploymentCommand.java | 10 +- .../cli/commands/DeactivateTenantCommand.java | 3 +- .../cli/commands/DeleteTenantCommand.java | 3 +- .../DeployServiceDeploymentCommand.java | 10 +- .../cli/commands/DeploymentPolicyCommand.java | 3 +- .../DeploymentPolicyDeploymentCommand.java | 10 +- .../DescribeAutoScalingPolicyCommand.java | 2 +- .../commands/DescribeCartridgeCommand.java | 2 +- .../DescribeDeploymentPolicyCommand.java | 2 +- .../commands/DescribePartitionCommand.java | 3 +- .../stratos/cli/commands/ExitCommand.java | 8 +- .../stratos/cli/commands/HelpCommand.java | 3 +- .../stratos/cli/commands/InfoCommand.java | 3 +- .../stratos/cli/commands/ListAllTenants.java | 3 +- .../cli/commands/ListCartridgesCommand.java | 3 +- .../commands/ListDeployServiceCommand.java | 3 +- .../cli/commands/ListMemberCommand.java | 14 +- .../ListSubscribedCartridgesCommand.java | 9 +- .../cli/commands/PartitionCommand.java | 2 +- .../commands/PartitionDeploymentCommand.java | 10 +- .../stratos/cli/commands/PoliciesCommand.java | 3 +- .../commands/RemoveDomainMappingCommand.java | 3 +- .../cli/commands/SubscribeCommand.java | 59 +- .../SubscribedCartridgeInfoCommand.java | 6 +- .../stratos/cli/commands/SyncCommand.java | 3 +- .../UndeployCartridgeDefinitionCommand.java | 3 +- .../UndeployServiceDefinitionCommand.java | 3 +- .../cli/commands/UnsubscribeCommand.java | 9 +- .../stratos/cli/utils/CliConstants.java | 3 + .../stratos/cli/utils/CommandLineUtils.java | 14 + .../src/main/resources/log4j.properties | 2 +- ...mpositeApplicationDefinitionException.java | 44 + .../cloud/controller/iaases/AWSEC2Iaas.java | 17 +- .../controller/iaases/OpenstackNovaIaas.java | 224 ++++- .../cloud/controller/iaases/VCloudIaas.java | 2 +- .../impl/CloudControllerServiceImpl.java | 237 +++-- .../cloud/controller/interfaces/Iaas.java | 2 +- .../pojo/CompositeApplicationDefinition.java | 39 + .../controller/pojo/ConfigCartridge.java | 17 + .../controller/pojo/ConfigDependencies.java | 29 + .../controller/pojo/ConfigDependencyPair.java | 29 + .../cloud/controller/pojo/ConfigGroup.java | 35 + .../cloud/controller/pojo/Registrant.java | 9 + .../stratos/cloud/controller/pojo/Volume.java | 24 +- .../runtime/FasterLookUpDataHolder.java | 19 + .../controller/topology/TopologyBuilder.java | 343 ++++++- .../topology/TopologyEventPublisher.java | 61 +- .../controller/topology/TopologyManager.java | 2 + .../util/CloudControllerConstants.java | 1 + .../controller/util/CloudControllerUtil.java | 4 +- .../CompositeApplicationManager.java | 131 +++ .../application/utils/ApplicationUtils.java | 104 ++ .../behaviour/CartridgeMgtBehaviour.java | 6 +- .../client/CloudControllerServiceClient.java | 23 +- .../manager/deploy/service/Service.java | 2 +- .../multitenant/lb/MultiTenantLBService.java | 2 +- .../ADCManagementServerComponent.java | 14 + .../category/DefaultLoadBalancerCategory.java | 5 +- .../ExistingLoadBalancerCategory.java | 3 +- .../ServiceLevelLoadBalancerCategory.java | 5 +- .../manager/CartridgeSubscriptionManager.java | 26 +- .../stratos/manager/payload/PayloadData.java | 29 +- .../persistence/PersistenceManager.java | 9 + .../RegistryBasedPersistenceManager.java | 222 +++++ .../DataInsertionAndRetrievalManager.java | 67 ++ .../subscription/CartridgeSubscription.java | 6 +- .../DataCartridgeSubscription.java | 5 +- .../subscription/LBCartridgeSubscription.java | 5 +- .../subscription/PersistenceContext.java | 11 + .../subscription/SubscriptionData.java | 30 +- .../SubscriptionMultiTenantBehaviour.java | 5 +- .../utils/ApplicationManagementUtil.java | 9 +- .../stratos/manager/utils/Serializer.java | 22 + .../messaging/domain/topology/Cartridge.java | 81 ++ .../messaging/domain/topology/Composite.java | 15 + .../domain/topology/CompositeApplication.java | 290 ++++++ .../domain/topology/ConfigCartridge.java | 20 + .../topology/ConfigCompositeApplication.java | 42 + .../domain/topology/ConfigDependencies.java | 57 ++ .../domain/topology/ConfigGroup.java | 33 + .../domain/topology/Dependencies.java | 334 +++++++ .../messaging/domain/topology/Group.java | 503 ++++++++++ .../messaging/domain/topology/Scalable.java | 5 + .../domain/topology/Subscribable.java | 25 + .../messaging/domain/topology/Topology.java | 91 +- .../util/CompositeApplicationBuilder.java | 240 +++++ .../status/InstanceActivatedEvent.java | 9 + .../status/InstanceMaintenanceModeEvent.java | 9 + .../status/InstanceReadyToShutdownEvent.java | 9 + .../instance/status/InstanceStartedEvent.java | 9 + .../CompositeApplicationCreatedEvent.java | 52 + .../topology/CompositeApplicationEvent.java | 31 + .../CompositeApplicationRemovedEvent.java | 49 + .../event/topology/MemberActivatedEvent.java | 19 + .../topology/MemberMaintenanceModeEvent.java | 9 + .../topology/MemberReadyToShutdownEvent.java | 9 + .../event/topology/MemberStartedEvent.java | 9 + .../event/topology/MemberSuspendedEvent.java | 9 + .../event/topology/MemberTerminatedEvent.java | 9 + ...positeApplicationCreatedEventListener.java | 26 + ...positeApplicationRemovedEventListener.java | 26 + ...iteApplicationCreatedMessageProcessor.java | 98 ++ ...iteApplicationRemovedMessageProcessor.java | 100 ++ .../TopologyMessageProcessorChain.java | 27 +- .../stratos/messaging/util/Constants.java | 1 + .../apache/stratos/messaging/util/Util.java | 8 + .../rest/endpoint/bean/CartridgeInfoBean.java | 58 +- .../bean/cartridge/definition/VolumeBean.java | 6 + .../CompositeApplicationDefinitionBean.java | 17 + .../definition/ConfigCartridge.java | 8 + .../definition/ConfigDependencies.java | 57 ++ .../definition/ConfigGroup.java | 35 + .../bean/util/converter/PojoConverter.java | 153 ++- .../rest/endpoint/services/ServiceUtils.java | 221 +++++ .../rest/endpoint/services/StratosAdmin.java | 70 ++ .../distribution/src/main/bin/stratos.sh | 3 +- .../conf/templates/jndi.properties.template | 6 +- .../src/main/extensions/mount_volumes.sh | 96 +- .../modules/distribution/src/assembly/bin.xml | 6 + .../distribution/src/main/conf/mincheck.drl | 7 + .../src/main/conf/terminatedependency.drl | 52 + .../resources/CloudControllerService.wsdl | 885 ++++++++++------- 144 files changed, 6847 insertions(+), 788 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java create mode 100644 components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/CartridgeStatistics.java create mode 100644 components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/IHealthStatisticsReader.java create mode 100644 components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/PluginLoader.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidCompositeApplicationDefinitionException.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigCartridge.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencies.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencyPair.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigGroup.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Composite.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCartridge.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigDependencies.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigGroup.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scalable.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationRemovedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java create mode 100644 products/stratos/modules/distribution/src/main/conf/terminatedependency.drl diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java new file mode 100644 index 0000000000..98c4d2cbd8 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java @@ -0,0 +1,929 @@ +package org.apache.stratos.autoscaler; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +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.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.Dependencies; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Member; +import org.apache.stratos.messaging.domain.topology.MemberStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + + +public class ComplexApplicationContext { + + static { + is_kill_all_enabled_flag = new HashMap(); + is_in_kill_all_transition = new HashSet(); + } + + private static Map is_kill_all_enabled_flag; + private static HashSet is_in_kill_all_transition; + + + + private static final Log log = LogFactory.getLog(ComplexApplicationContext.class); + + // return value of true will bring up new instance (all startup dependencies are up and active) + public boolean checkStartupDependencies (String clusterId) { + String serviceType = "undefined"; + if (log.isDebugEnabled()) { + log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); + } + return checkServiceDependencies (serviceType, clusterId, false); + } + + + public boolean checkStartupDependencies (String serviceType, String clusterId) { + if (log.isDebugEnabled()) { + log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); + } + return checkServiceDependencies (serviceType, clusterId, false); + } + + + // return false will terminate instances + public boolean checkKillDependencies (String clusterId) { + String serviceType = "undefined"; + if (log.isDebugEnabled()) { + log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); + } + return checkKillTerminateDependencies (serviceType, clusterId, true); + } + + public boolean checkKillDependencies (String serviceType, String clusterId) { + if (log.isDebugEnabled()) { + log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); + } + return checkKillTerminateDependencies (serviceType, clusterId, true); + } + + + public boolean checkServiceDependencies (String serviceType, String clusterId, boolean kill_flag) { + + + if (log.isDebugEnabled()) { + log.debug("ServiceGroupContext:checkServiceDependencies for service with XY " + + " serviceType " + serviceType + + " clusterId: " + clusterId + " kill_flag: " + kill_flag); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null); + + + // no app configured + if (complexApplication == null) { + return true; + } + + String aServiceId = serviceType; + if (log.isDebugEnabled()) { + log.debug("checking dependencies for service alias " + aServiceId); + } + + if (aServiceId == null) { + if (log.isDebugEnabled()) { + log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)"); + } + return true; + } + + List service_type_groups = complexApplication.findAllGroupsForServiceType(serviceType); + + String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); + + if (clusterGroupFromClusterId == null) { + if (log.isDebugEnabled()) { + log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping dependency check (return true)"); + } + } + + for (Group service_type_group : service_type_groups) { + // check if cluster is in the group + if (log.isDebugEnabled()) { + log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_group.getAlias() + + "extracted group from clusterId is " + clusterGroupFromClusterId); + } + if (service_type_group.getAlias().equals(clusterGroupFromClusterId)) { + boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_group); + if (log.isDebugEnabled()) { + log.debug("cluster is " + clusterId + " is in the group " + service_type_group.getAlias() + " and startup dependency check is " + result_flag); + } + return result_flag; + } + } + + if (log.isDebugEnabled()) { + log.debug("no matching group found for cluster " + clusterId + " skipping dependency check (return true)" ); + } + + return true; + + } + + public boolean checkServiceDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag, Group home_group) { + + String aServiceId = serviceType; + + if (home_group == null) { + if (log.isDebugEnabled()) { + log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no dependency check)" ); + } + return true; + } + + + if (ComplexApplicationContext.isInKillAllTransition(this.getKillInTransitionKey(serviceType, home_group.getAlias()))) { + if (log.isDebugEnabled()) { + log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" ); + } + return false; + } else { + if (log.isDebugEnabled()) { + log.debug(" subscribable " + aServiceId + " is not inKillAll transition, continue with dependenciy check" ); + } + } + + Map downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); + + + if (downstreamDependencies == null || downstreamDependencies.size() == 0) { + if (log.isDebugEnabled()) { + log.debug("serviceType " + aServiceId + " has no dependencies, returning true (no kill)"); + } + return true; + } + + if (log.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("downstreamdependencies list: [ "); + + + Set downstream_keys = downstreamDependencies.keySet(); + for (String c : downstream_keys) { + String d = downstreamDependencies.get(c); + buf.append(c + ", in group: ").append(downstreamDependencies.get(d)); + } + + buf.append("] ").append(" serviceId ").append(aServiceId); + log.debug(buf.toString()); + } + + + List in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies); + if (in_active_downstreams.size() > 0) { + if (log.isDebugEnabled()) { + log.debug("found inactive downstream dependencies for serviceType " + aServiceId + " returning false"); + for (String in_active : in_active_downstreams) { + log.debug("inactive downstream dependency " + in_active + " for " + aServiceId); + } + } + + return false; + } + + if (log.isDebugEnabled()) { + log.debug("returning true for dependency check on serviceType " + serviceType); + } + return true; + } + + // return false will terminate instances + public boolean checkKillTerminateDependencies (String serviceType, String clusterId, boolean kill_flag) { + if (log.isDebugEnabled()) { + log.debug("ServiceGroupContext:checkKillTerminateDependencies for service with X " + + " serviceType " + serviceType + + " clusterId: " + clusterId + " kill_flag: " + kill_flag); + } + + if (log.isDebugEnabled()) { + log.debug("getting app from builder "); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null); + + String aServiceId = serviceType; + if (log.isDebugEnabled()) { + log.debug("checking dependencies for service alias " + + aServiceId); + } + + if (aServiceId == null) { + if (log.isDebugEnabled()) { + log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)"); + } + return true; + } + + + // no app configured, don't terminate + if (complexApplication == null) { + return true; + } + + List service_type_groups = complexApplication.findAllGroupsForServiceType(serviceType); + + String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); + + if (clusterGroupFromClusterId == null) { + if (log.isDebugEnabled()) { + log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping terminate dependency check (return true)"); + } + } + + for (Group service_type_group : service_type_groups) { + // check if cluster is in the group + if (log.isDebugEnabled()) { + log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_group.getAlias() + + "extracted group from clusterId is " + clusterGroupFromClusterId); + } + if (service_type_group.getAlias().equals(clusterGroupFromClusterId)) { + boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag, + service_type_group, complexApplication); + if (log.isDebugEnabled()) { + log.debug("cluster is " + clusterId + " is in the group " + service_type_group.getAlias() + " and kill dependency check is " + result_flag); + } + return result_flag; + } + } + + if (log.isDebugEnabled()) { + log.debug("no matching group found for cluster " + clusterId + " skipping terminate dependency check (return true)" ); + } + + return true; + } + + // return false will terminate instances + public boolean checkKillTerminateDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag, + Group home_group, CompositeApplication complexApplication ) { + + String aServiceId = serviceType; + + if (home_group == null) { + if (log.isDebugEnabled()) { + log.debug(" lone cluster without top level group " + aServiceId + "skip checking and return true (no kill)" ); + } + return true; + } else if (home_group.findGroup(aServiceId) == null) { + if (log.isDebugEnabled()) { + log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no kill)" ); + } + return true; + } + + + //Group home_group = complexApplication.getTop_level().findGroup(aServiceId); + + if (log.isDebugEnabled()) { + log.debug("checking downstream dependencies for " + aServiceId ); + } + Map downstreamDependencies = null; + downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); + if (log.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("downstreamdependencies list: [ "); + + if (downstreamDependencies != null & downstreamDependencies.keySet().size() > 0) { + Set downstream_keys = downstreamDependencies.keySet(); + for (String c : downstream_keys) { + String d = downstreamDependencies.get(c); + buf.append(c + ", in group: ").append(d); + } + + buf.append("] ").append(" serviceId ").append(aServiceId); + } else { + buf.append(" downstreamDependencies is null "); + } + log.debug(buf.toString()); + } + + + + if (log.isDebugEnabled()) { + log.debug("checking upstream dependencies for " + aServiceId ); + } + // 2. get upstream dependencies + Map upstreamDependencies = home_group.getUpstreamDependenciesAsMap(aServiceId); + + if (log.isDebugEnabled()) { + StringBuffer buf = new StringBuffer(); + buf.append("upstreamdependencies list: [ "); + + if (upstreamDependencies != null & upstreamDependencies.keySet().size() > 0) { + Set upstream_keys = upstreamDependencies.keySet(); + for (String c : upstream_keys) { + String d = upstreamDependencies.get(c); + buf.append(c + ", in group: ").append(upstreamDependencies.get(d)); + } + + buf.append("] ").append(" serviceId ").append(aServiceId); + } else { + buf.append(" upstreamDependencies is null "); + } + log.debug(buf.toString()); + } +; + List in_active_upstreams = this.getServiceSet_StateInActive(upstreamDependencies); + + if (log.isDebugEnabled()) { + log.debug("getting list of InActive upstream dependencies for " + aServiceId + " with size of " + in_active_upstreams.size()); + } + + String kill_behavior = Dependencies.KILL_UNDEFINED; + // return false if instances should be terminated, true if not + for (String serviceTypeAlias : in_active_upstreams) { + String gr_alias = upstreamDependencies.get(serviceTypeAlias); + Group gr = complexApplication.getGroupFromGroupAlias(gr_alias); + if (gr != null) { + + kill_behavior = gr.getDependencies().getKill_behavior(); + if (kill_behavior.equals(Dependencies.KILL_ALL)) { + if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) { + if (log.isDebugEnabled()) { + log.debug(" isKillAllEnabled is enabled on upstream (kill) for group " + gr.getAlias() + ", disabling kilAll and preventing " + + " serviceType " + aServiceId + " in group " + gr.getAlias() + + " to spin up a new instance (setting killAllTransitionFlag) "); + } + // adding to the killalltransition flag + // building key from alias + group alias + ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias,gr.getAlias())); + // building key from alias + group alias + ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId,home_group.getAlias())); + return false; + } else { + if (log.isDebugEnabled()) { + log.debug(" isKillAllEnabled is disabled on upstream (no kill) for group " + gr.getAlias() ); + } + return true; + } + } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { + if (log.isDebugEnabled()) { + log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + // continue to check + } else if (kill_behavior.equals(Dependencies.KILL_NONE)) { + if (log.isDebugEnabled()) { + log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + // continue to check + } else { + if (log.isDebugEnabled()) { + log.debug(" continue to check upstream for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + //continue to check + } + } else { + // skip + if (log.isDebugEnabled()) { + log.debug(" no group found for " + serviceTypeAlias + " while loopig over in_active_upstreams" ); + } + } + + } + + // check kill_all_enabled flag + Map all = complexApplication.getAllInPathOfAsMap(aServiceId, home_group); + String [] group_with_kill_all_aliases = home_group.findAllGroupsWithKill2(all, Dependencies.KILL_ALL); + // "persistent flag for each group" + this.updateEnableKillAllFlag(all, group_with_kill_all_aliases); + + //List in_active_downstreams = this.getClusterSet_StateInActive(dependeciesAliasArray);jj + List in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies); + + if (log.isDebugEnabled()) { + log.debug("getting list of InActive downstream dependencies for " + aServiceId + " with size of " + in_active_downstreams.size()); + } + + kill_behavior = Dependencies.KILL_UNDEFINED; + for (String alias : in_active_downstreams) { + Group gr = home_group.findGroup(alias); + if (gr !=null) { + kill_behavior = gr.getDependencies().getKill_behavior(); + if (kill_behavior.equals(Dependencies.KILL_ALL) ) { + if (log.isDebugEnabled()) { + log.debug(" return true on downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) { + if (log.isDebugEnabled()) { + log.debug(" isKillAllEnabled is enabled on downstream (kill) for group " + gr.getAlias() + + " setting killAllTransitionFlag for" + alias); + } + // adding to the killalltransition flag + ComplexApplicationContext.setKillAllTransitionFlag(alias); + return false; + } else { + if (log.isDebugEnabled()) { + log.debug(" isKillAllEnabled is disabled on downstream (no kill) for group " + gr.getAlias() ); + } + return true; + } + } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { + if (log.isDebugEnabled()) { + //log.debug(" continue downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + log.debug(" downstream service(s) is inactive for aServiceId " + aServiceId + + " returning false (kill) and terminating cluster members" ); + } + return false; + } else if (kill_behavior.equals(Dependencies.KILL_NONE)) { + if (log.isDebugEnabled()) { + log.debug(" continue downstream to check for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + // continue to check + } else { + if (log.isDebugEnabled()) { + log.debug(" continue downstream to check for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() ); + } + //continue to check + } + } else { + // skip + if (log.isDebugEnabled()) { + log.debug(" no group found for " + alias + " while loopig over in_active_downstreams" ); + } + } + + } + + // this cluster + Group gr = home_group.findGroup(aServiceId); + if (gr == null) { + if (log.isDebugEnabled()) { + log.debug(" cluster without group, should not reach this code ? for " + aServiceId ); + } + return true; + } + + kill_behavior = gr.getDependencies().getKill_behavior(); + + if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { + if (log.isDebugEnabled()) { + log.debug(Dependencies.KILL_DEPENDENTS + " check if any downstream cluster is inactive for aServiceId " + aServiceId ); + } + if (in_active_downstreams.size() > 0) { + if (log.isDebugEnabled()) { + log.debug(" downstream cluster(s) is inactive for aServiceId " + aServiceId + + " returning false (kill) and terminating cluster members" ); + } + return false; + } else { + if (log.isDebugEnabled()) { + log.debug(" no downstream cluster(s) is inactive for aServiceId " + aServiceId + + " returning true (no kill)" ); + } + return true; + } + } + + + if (log.isDebugEnabled()) { + log.debug("returning true (no kill) for down and upstream dependency check on clusterId " + aServiceId); + } + return true; + } + + + private boolean hasClusterActiveMember (Cluster cluster) { + boolean flag = false; + if(cluster.isLbCluster()){ + if (log.isDebugEnabled()) { + log.debug("cluster member is lbCluster, not checking " + cluster); + } + }else{ + if (log.isDebugEnabled()) { + log.debug("checking member acitve for " + + " clusterId: " + cluster.getClusterId() + + " serviceId: " + cluster.getServiceName()); + } + + Collection members = cluster.getMembers(); + for (Member member:members) { + if (log.isDebugEnabled()) { + log.debug("listing members while checking if active" + + member.getMemberId() + + " private Ip: " + member.getMemberIp() + + " public Ip:" + member.getMemberPublicIp() + + " member state: " + member.getStatus()); + } + if (member.getStatus().equals(MemberStatus.Activated)) { + log.debug("member ACTIVE found :" + member.getMemberId()); + flag = true; + break; + } + } + + } + return flag; + } + + + + private String extractAlias (String clusterId) { + String [] s = clusterId.split("\\."); + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " size: " + s.length); + } + if (s.length == 0) { + return null; + } + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " alias: " + s[0]); + } + return s[0]; + } + + private String extractClusterGroupFromClusterId (String clusterId) { + String sub1 = extractAlias(clusterId); + if (sub1 == null) { + return null; + } + + String [] s = sub1.split("-"); + if (log.isDebugEnabled()) { + log.debug("clusterGroup alias is " + sub1 + " size: " + s.length); + } + if (s.length == 0) { + return null; + } + if (log.isDebugEnabled()) { + log.debug("cluster " + clusterId + " is in group " + s[0]); + } + return s[0]; + } + + + + private void updateEnableKillAllFlag(Mapall_dependencies, String [] group_with_kill_all_aliases) { + if (log.isDebugEnabled()) { + log.debug("updating enable_kill_flag "); + } + if (group_with_kill_all_aliases == null) { + return; + } + //if (isClusterSet_StateActive(all_dependencies)) { // + if (isServiceSet_StateActive(all_dependencies)) { + for (String alias : group_with_kill_all_aliases) { + ComplexApplicationContext.setKillAllEnabled(alias); + if (log.isDebugEnabled()) { + log.debug("enable enable_kill_flag for subscribable" + alias); + } + } + //} else if (isClusterSet_StateInActive(all_dependencies)) { + } else if (isServiceSet_StateInActive(all_dependencies)) { + for (String alias : group_with_kill_all_aliases) { + ComplexApplicationContext.resetKillAllEnabled(alias); + if (log.isDebugEnabled()) { + log.debug("disable enable_kill_flag for subscribable" + alias); + } + } + + // resetting killalltransition flag for all subscribables + Set key_set = all_dependencies.keySet(); + for (String serviceTypeAlias : key_set) { + String group_alias = all_dependencies.get(serviceTypeAlias); + ComplexApplicationContext.resetKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias, group_alias)); + if (log.isDebugEnabled()) { + log.debug("resetting enable_kill_flag, is_in_kill_all_transition for subscribable " + serviceTypeAlias + " in group " + group_alias); + } + } + + } else { + // do nothing + if (log.isDebugEnabled()) { + log.debug("leaving enable_kill_flag, is_in_kill_all_transition unchanged "); + } + } + + } + + private String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) { + return serviceTypeAlias + gr_alias; + } + + + private boolean isServiceSet_StateActive(MapserviceTypes) { + List result = getServiceSet_StateActive(serviceTypes); + if (result.size() == serviceTypes.size()) { + return true; + } + + return false; + } + + private boolean isServiceSet_StateInActive(Map serviceTypes) { + List result = getServiceSet_StateInActive(serviceTypes); + if (result.size() == serviceTypes.size()) { + return true; + } + + return false; + } + + + private List getServiceSet_StateInActive (Map serviceTypesMap) { + List result = new ArrayList (); + + if (log.isDebugEnabled()) { + log.debug("checking ServiceSet_StateInActive " + serviceTypesMap.size()); + } + + if (serviceTypesMap == null) { + if (log.isDebugEnabled()) { + log.debug("skipping getting set of InActive services, serviceTypes is null "); + } + return result; + } + + if (log.isDebugEnabled()) { + log.debug("getting set of InActive clusters for serviceTypes (length)" + serviceTypesMap.size()); + } + + + Collection services = TopologyManager.getTopology().getServices(); + + Set serviceTypes = serviceTypesMap.keySet(); + + for (String serviceType : serviceTypes) { + boolean hasServiceFound = false; + for(Service service : services) { + String serviceTypeGroup = serviceTypesMap.get(serviceType); + if (log.isDebugEnabled()) { + log.debug("checking inactive state for service " + service.getServiceName() + + " with nr_of_clusters: " + service.getClusters().size() + + " against serviceType " + serviceType + " in group " + serviceTypeGroup); + } + if (serviceType.equals(service.getServiceName())) { + // matching service type - check if has active cluster + if (log.isDebugEnabled()) { + log.debug("matching service types, checking clusters for service " + serviceType); + } + hasServiceFound = true; + Collection clusters = service.getClusters(); + boolean hasClusterWithActiveMember = false; + if (clusters.size() > 0) { + // at least one cluster has to exist for service to exist + if (log.isDebugEnabled()) { + log.debug("service " + service.getServiceName() + " has at least 1 cluster "); + } + for (Cluster cluster : clusters) { + String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("checking (inactive) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + + " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); + } + // Martin TODO if (hasClusterActiveMember (cluster)) { + // check group cluster is in + + if (clusterGroup != null & clusterGroup.equals(serviceTypeGroup)) { + if (hasClusterActiveMember (cluster)) { + hasClusterWithActiveMember = true; + if (log.isDebugEnabled()) { + log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup); + } + break; + } + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("service " + service.getServiceName() + " in group " + serviceTypeGroup + " has no cluster, adding as inactive service "); + hasClusterWithActiveMember = false; + } + } + + if (!hasClusterWithActiveMember) { + result.add(serviceType); + if (log.isDebugEnabled()) { + log.debug("service has not a clutser with active member, adding " + serviceType + " as inactive"); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search "); + } + } + + } + // covers the case that service hasn't be deployed yet + if (!hasServiceFound) { + result.add(serviceType); + if (log.isDebugEnabled()) { + log.debug("no matching service found for " + serviceType + " adding as inactive"); + } + } + } + + return result; + } + + + private List getServiceSet_StateActive (Map serviceTypesMap) { + List result = new ArrayList (); + + if (log.isDebugEnabled()) { + log.debug("checking ServiceSet_StateActive " + serviceTypesMap.size()); + } + + if (serviceTypesMap == null) { + if (log.isDebugEnabled()) { + log.debug("skipping getting set of Active services, serviceTypes is null "); + } + return result; + } + + if (log.isDebugEnabled()) { + log.debug("getting set of Active clusters for serviceTypes (length)" + serviceTypesMap.size()); + } + + + Collection services = TopologyManager.getTopology().getServices(); + + Set serviceTypes = serviceTypesMap.keySet(); + + for (String serviceType : serviceTypes) { + boolean hasServiceFound = false; + for(Service service : services) { + String serviceTypeGroup = serviceTypesMap.get(serviceType); + if (log.isDebugEnabled()) { + log.debug("checking active state for service " + service.getServiceName() + + " with nr_of_clusters: " + service.getClusters().size() + + " against serviceType " + serviceType + " in group " + serviceTypeGroup); + } + if (serviceType.equals(service.getServiceName())) { + // matching service type - check if has active cluster + if (log.isDebugEnabled()) { + log.debug("matching service types, checking clusters for service " + serviceType); + } + hasServiceFound = true; + Collection clusters = service.getClusters(); + boolean hasClusterWithActiveMember = false; + if (clusters.size() > 0) { + // at least one cluster has to exist for service to exist + if (log.isDebugEnabled()) { + log.debug("service " + service.getServiceName() + " has at least 1 cluster "); + } + for (Cluster cluster : clusters) { + String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("checking (active) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + + " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); + } + // Martin TODO if (hasClusterActiveMember (cluster)) { + if (hasClusterActiveMember (cluster)) { // Martin for test only, replace with hasClusterActiveMember !!! + hasClusterWithActiveMember = true; + if (log.isDebugEnabled()) { + log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup + + " , adding as active service"); + } + result.add(serviceType); + break; + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("service " + service.getServiceName() + " has no cluster, skipping service "); + hasClusterWithActiveMember = false; + } + } + + if (!hasClusterWithActiveMember) {; + if (log.isDebugEnabled()) { + log.debug("service has not a clutser with active member, skipping " + serviceType + " as active service"); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search "); + } + } + + } + // covers the case that service hasn't be deployed yet + if (!hasServiceFound) { + if (log.isDebugEnabled()) { + log.debug("no matching service found for " + serviceType + " skipping as active service"); + } + } + } + + return result; + } + + /* + * get a list of clusters based on the subscription alias name + */ + private List getClusters (String [] clusterAliases) { + List clusters = new ArrayList(); + + for (String alias : clusterAliases) { + Cluster cluster = getClusterFromAlias(alias); + if (cluster != null) { + clusters.add(cluster); + } else { + if (log.isDebugEnabled()) { + log.debug("getting a (inactive) cluster retrieved as null for alias " + alias); + } + } + } + return clusters; + } + + /* + * get a cluster based on the subscription alias name + */ + private Cluster getClusterFromAlias(String findClusterId) { + Cluster result = null; + Collection services = TopologyManager.getTopology().getServices(); + for(Service service : services) { + // extract list of clusters, clusterId -> alias + if (log.isDebugEnabled()) { + log.debug("ServiceGroupContext:calculateKillBehaviorFlag:service:" + service.getServiceName()); + } + + for(Cluster cluster : service.getClusters()) { + String clusterId = cluster.getClusterId(); + String clusterIdAlias = this.extractAlias(clusterId); + if (log.isDebugEnabled()) { + log.debug("looping over cluster " + clusterId + + " extracted alias " + clusterIdAlias); + } + + if (clusterIdAlias != null && findClusterId.equals(clusterIdAlias)) { + return cluster; + } else { + if (log.isDebugEnabled()) { + log.debug(" ignoring cluster " + clusterId + " in cluster check for " + findClusterId); + } + } + + } + } + return result; + } + + private static void setKillAllEnabled(String groupId ) { + ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, true); + } + + private static void resetKillAllEnabled(String groupId ) { + // all cartridges are terminated after kill_all + ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, false); + } + + private static void resetKillAllTransitionFlag(String alias) { + ComplexApplicationContext.is_in_kill_all_transition.remove(alias); + } + + private static void setKillAllTransitionFlag(String alias) { + ComplexApplicationContext.is_in_kill_all_transition.add(alias); + } + + public static synchronized Boolean isKillAllEnabled(String groupId) { + Boolean flag = false; + if (ComplexApplicationContext.is_kill_all_enabled_flag == null) { + if (log.isDebugEnabled()) { + log.debug(" creating new is_kill_all_enabled_flag"); + } + ComplexApplicationContext.is_kill_all_enabled_flag = new HashMap(); + } + flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId); + if (flag == null) { + if (log.isDebugEnabled()) { + log.debug(" is_kill_all_enabled_flag not initialized for " + groupId + " initializing with true"); + } + + ComplexApplicationContext.setKillAllEnabled(groupId); + flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId); + } + return flag; + } + + + public static synchronized Boolean isInKillAllTransition(String key) { + if (ComplexApplicationContext.is_in_kill_all_transition == null) { + if (log.isDebugEnabled()) { + log.debug(" creating new is_in_kill_all_transition"); + } + ComplexApplicationContext.is_in_kill_all_transition = new HashSet(); + } + if (ComplexApplicationContext.is_in_kill_all_transition.contains(key)) { + return true; + } + return false; + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java index 86c2e49418..3a194957a7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java @@ -27,10 +27,12 @@ import java.io.Serializable; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -385,6 +387,81 @@ public boolean activeMemberExist(String memberId) { } return false; } + + public int getAllMemberForTerminationCount () { + int count = activeMembers.size() + pendingMembers.size() + terminationPendingMembers.size(); + if (log.isDebugEnabled()) { + log.debug("PartitionContext:getAllMemberForTerminationCount:size:" + count); + } + return count; + } + + // Map getMemberStatsContexts().keySet() + public Set getAllMemberForTermination () { + + List merged = new ArrayList(); + + + merged.addAll(activeMembers); + merged.addAll(pendingMembers); + merged.addAll(terminationPendingMembers); + + Set results = new HashSet(merged.size()); + + for (MemberContext ctx: merged) { + results.add(ctx.getMemberId()); + } + + + if (log.isDebugEnabled()) { + log.debug("PartitionContext:getAllMemberForTermination:size:" + results.size()); + } + + //MemberContext x = new MemberContext(); + //x.getMemberId() + + return results; + } + + public boolean checkStartupDependencies (String serviceType, String clusterId) { + if (log.isDebugEnabled()) { + log.debug("checkStartupDependencies for cluster with " + " clusterId: " + clusterId); + } + + + ComplexApplicationContext sgc = new ComplexApplicationContext(); + + String aServiceName = clusterId; + boolean flag = sgc.checkStartupDependencies(serviceType, aServiceName); + if (log.isDebugEnabled()) { + log.debug("checkStartupDependencies for cluster with " + + " clusterId: " + clusterId + " serviceType: " + serviceType + + " flag is :" + flag); + } + + return flag; + + } + + public boolean checkKillDependencies (String serviceType, String clusterId) { + if (log.isDebugEnabled()) { + log.debug("PartitionContext:checkServiceBootDependencies for cluster with " + " clusterId: " + clusterId + + "and serviceType " + serviceType); + } + + ComplexApplicationContext sgc = new ComplexApplicationContext(); + + String aServiceName = clusterId; + boolean flag = sgc.checkKillDependencies(serviceType, aServiceName); + if (log.isDebugEnabled()) { + log.debug("checkKillDependencies for cluster with " + + " clusterId: " + clusterId + " serviceType: " + serviceType + + " flag is :" + flag); + } + return flag; + + } + private class PendingMemberWatcher implements Runnable { private PartitionContext ctxt; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index cf6223c25a..520559c2e4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -342,6 +342,32 @@ protected void onEvent(Event event) { // } } }); + + // Grouping + /* + topologyEventReceiver.addEventListener(new CompositeApplicationCreatedEventListener() { + @Override + protected void onEvent(Event event) { + + try { + TopologyManager.acquireReadLock(); + + if (log.isDebugEnabled()) { + log.debug("handling application created event"); + } + + + } catch (Exception e) { + log.error("Error processing event", e); + } finally { + TopologyManager.releaseReadLock(); + } + } + });*/ + + + + } private class LBClusterMonitorAdder implements Runnable { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java index 30ed61a210..f9792eff62 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java @@ -50,9 +50,11 @@ abstract public class AbstractMonitor implements Runnable{ protected FactHandle minCheckFactHandle; protected FactHandle scaleCheckFactHandle; + protected FactHandle terminateDependencyFactHandle; protected StatefulKnowledgeSession minCheckKnowledgeSession; protected StatefulKnowledgeSession scaleCheckKnowledgeSession; + protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; protected boolean isDestroyed; protected String clusterId; @@ -92,13 +94,14 @@ public String getPartitionOfMember(String memberId){ public void destroy() { minCheckKnowledgeSession.dispose(); scaleCheckKnowledgeSession.dispose(); + terminateDependencyKnowledgeSession.dispose(); setDestroyed(true); if(log.isDebugEnabled()) { log.debug("Cluster Monitor Drools session has been disposed. "+this.toString()); } } - - public boolean isDestroyed() { + + public boolean isDestroyed() { return isDestroyed; } @@ -177,4 +180,24 @@ public FactHandle getMinCheckFactHandle() { public void setMinCheckFactHandle(FactHandle minCheckFactHandle) { this.minCheckFactHandle = minCheckFactHandle; } + + public StatefulKnowledgeSession getTerminateDependencyKnowledgeSession() { + return terminateDependencyKnowledgeSession; + } + + public void setTerminateDependencyKnowledgeSession( + StatefulKnowledgeSession terminateDependencyKnowledgeSession) { + this.terminateDependencyKnowledgeSession = terminateDependencyKnowledgeSession; + } + + public FactHandle getTerminateDependencyFactHandle() { + return terminateDependencyFactHandle; + } + + public void setTerminateDependencyFactHandle( + FactHandle terminateDependencyFactHandle) { + this.terminateDependencyFactHandle = terminateDependencyFactHandle; + } + + } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java index 6c44e4ed74..d5d02bcf92 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java @@ -47,9 +47,13 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); + this.terminateDependencyKnowledgeSession = autoscalerRuleEvaluator.getTerminateDependencyStatefulSession(); this.deploymentPolicy = deploymentPolicy; this.autoscalePolicy = autoscalePolicy; + if (log.isDebugEnabled()) { + log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); + } networkPartitionCtxts = new ConcurrentHashMap(); } @@ -91,6 +95,8 @@ private void monitor() { minCheckKnowledgeSession.setGlobal("clusterId", clusterId); minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); + minCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); + minCheckKnowledgeSession.setGlobal("serviceId", serviceId); if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); @@ -100,6 +106,24 @@ private void monitor() { , minCheckFactHandle, partitionContext); } + + //terminate dependency per partition + // rule terminates all members of a service which is a prerequisites for other services + for(PartitionContext partitionContext: networkPartitionContext.getPartitionCtxts().values()){ + + terminateDependencyKnowledgeSession.setGlobal("clusterId", clusterId); + terminateDependencyKnowledgeSession.setGlobal("lbRef", lbReferenceType); + terminateDependencyKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); + terminateDependencyKnowledgeSession.setGlobal("serviceId", serviceId); + + if (log.isDebugEnabled()) { + log.debug(String.format("Running terminate dependency for partition %s ", partitionContext.getPartitionId())); + } + + terminateDependencyFactHandle = AutoscalerRuleEvaluator.evaluateTerminateDependency(terminateDependencyKnowledgeSession + , terminateDependencyFactHandle, partitionContext); + + } boolean rifReset = networkPartitionContext.isRifReset(); boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java index b0b7f6073d..0d6de77888 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java @@ -47,10 +47,12 @@ public class AutoscalerRuleEvaluator { private static final String DRL_FILE_NAME = "mincheck.drl"; private static final String SCALING_DRL_FILE_NAME = "scaling.drl"; private static final String TERMINATE_ALL_DRL_FILE_NAME = "terminateall.drl"; + private static final String TERMINATE_DEPENDENCY_DRL_FILE_NAME = "terminatedependency.drl"; private static KnowledgeBase minCheckKbase; private static KnowledgeBase scaleCheckKbase; private static KnowledgeBase terminateAllKbase; + private static KnowledgeBase terminateDependencyKbase; public AutoscalerRuleEvaluator(){ @@ -70,6 +72,12 @@ public AutoscalerRuleEvaluator(){ if (log.isDebugEnabled()) { log.debug("Terminate all rule is parsed successfully"); } + + terminateDependencyKbase = readKnowledgeBase(TERMINATE_DEPENDENCY_DRL_FILE_NAME); + + if (log.isDebugEnabled()) { + log.debug("Terminate dependency rule is parsed successfully"); + } } @@ -124,6 +132,28 @@ public static FactHandle evaluateTerminateAll(StatefulKnowledgeSession ksession, } return handle; } + + + public static FactHandle evaluateTerminateDependency(StatefulKnowledgeSession ksession, FactHandle handle, Object obj) { + if(log.isDebugEnabled()){ + log.debug(String.format("Terminate dependency check executing for : %s ", obj)); + } + if (handle == null) { + + ksession.setGlobal("$delegator", new RuleTasksDelegator()); + handle = ksession.insert(obj); + } else { + ksession.update(handle, obj); + } + if(log.isDebugEnabled()){ + log.debug(String.format("Terminate dependency check firing rules for : %s ", ksession)); + } + ksession.fireAllRules(); + if(log.isDebugEnabled()){ + log.debug(String.format("Terminate dependency check executed for : %s ", obj)); + } + return handle; + } @@ -145,6 +175,12 @@ public StatefulKnowledgeSession getTerminateAllStatefulSession() { ksession.setGlobal("log", RuleLog.getInstance()); return ksession; } + public StatefulKnowledgeSession getTerminateDependencyStatefulSession() { + StatefulKnowledgeSession ksession; + ksession = terminateDependencyKbase.newStatefulKnowledgeSession(); + ksession.setGlobal("log", RuleLog.getInstance()); + return ksession; + } public static String getLbClusterId(PartitionContext partitionContext, String nwpartitionId) { Properties props = partitionContext.getProperties(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java index 7d8304b5b3..24047fe0d7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java @@ -149,6 +149,20 @@ public void delegateTerminate(PartitionContext partitionContext, String memberId } } + public void delegateTerminateDependency(PartitionContext partitionContext, String memberId) { + try { + //calling SM to send the instance notification event. + if (log.isDebugEnabled()) { + log.debug("delegateTerminateDependency:memberId:" + memberId); + } + //InstanceNotificationClient.getInstance().sendMemberCleanupEvent(memberId); + //partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); + //CloudControllerClient.getInstance().terminate(memberId); + } catch (Throwable e) { + log.error("Cannot terminate instance", e); + } + } + public void terminateObsoleteInstance(String memberId) { try { CloudControllerClient.getInstance().terminate(memberId); @@ -157,10 +171,16 @@ public void terminateObsoleteInstance(String memberId) { } } + //Grouping public void delegateTerminateAll(String clusterId) { try { - + if (log.isDebugEnabled()) { + log.debug("delegateTerminateAll - begin"); + } CloudControllerClient.getInstance().terminateAllInstances(clusterId); + if (log.isDebugEnabled()) { + log.debug("delegateTerminateAll - done"); + } } catch (Throwable e) { log.error("Cannot terminate instance", e); } diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java index e4ddaed5b7..c7f3603292 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java @@ -57,6 +57,11 @@ public class CartridgeAgent implements Runnable { private boolean terminated; + // We have an asynchronous activity running to respond to ADC updates. We want to ensure + // that no publishInstanceActivatedEvent() call is made *before* the port activation test + // has succeeded. This flag controls that. + private boolean portsActivated; + @Override public void run() { if(log.isInfoEnabled()) { @@ -66,6 +71,7 @@ public void run() { validateRequiredSystemProperties(); // Start instance notifier listener thread + portsActivated = false; subscribeToTopicsAndRegisterListeners(); // Publish instance started event @@ -77,6 +83,10 @@ public void run() { // Wait for all ports to be active CartridgeAgentUtils.waitUntilPortsActive(CartridgeAgentConfiguration.getInstance().getListenAddress(), CartridgeAgentConfiguration.getInstance().getPorts()); + portsActivated = true; + + // Publish instance activated event + CartridgeAgentEventPublisher.publishInstanceActivatedEvent(); // Check repo url String repoUrl = CartridgeAgentConfiguration.getInstance().getRepoUrl(); @@ -84,9 +94,6 @@ public void run() { if(log.isInfoEnabled()) { log.info("No artifact repository found"); } - - // Publish instance activated event - CartridgeAgentEventPublisher.publishInstanceActivatedEvent(); } else { //Start periodical file checker task if (CartridgeAgentConfiguration.getInstance().isCommitsEnabled()) { @@ -260,7 +267,7 @@ private void onArtifactUpdateEvent(ArtifactUpdatedEvent event) { ExtensionUtils.executeArtifactsUpdatedExtension(); - if(!cloneExists){ + if (!cloneExists && portsActivated) { // Executed git clone, publish instance activated event CartridgeAgentEventPublisher.publishInstanceActivatedEvent(); } diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/CartridgeStatistics.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/CartridgeStatistics.java new file mode 100644 index 0000000000..f92de2dd28 --- /dev/null +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/CartridgeStatistics.java @@ -0,0 +1,66 @@ +/* + * 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.cartridge.agent.statistics.publisher; + +/** + * CartridgeStatistics is an instantaneous representaion of the cartridges current process and memory usage. + */ +public class CartridgeStatistics { + + private double memoryUsage; + private double processorUsage; + + /** + * Constructor + * + * @param memUsage the consumed memory, as a percentage of the available memory to the cartridge + * @param procUsage the processing used, as a percentage of the processing available to the cartridge + */ + public CartridgeStatistics(double memUsage, double procUsage) { + memoryUsage = sanitiseUsage(memUsage); + processorUsage = sanitiseUsage(procUsage); + } + + /** + * Called by contructor, utility to check input usage is a percentage. + * throws exception if the usage is not of the correct format + */ + private double sanitiseUsage(double usage) throws IllegalArgumentException { + if ((usage < 0)) // || (usage > 100)) we currently get percentages over 100% for the procUsage is this fine? + { + throw new IllegalArgumentException("Usage statistic less than zero"); + } + return usage; + } + + /** + * Called to get memory usage + */ + public double getMemoryUsage() { + return memoryUsage; + } + + /** + * Called to get processor usage + */ + public double getProcessorUsage() { + return processorUsage; + } +} diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsNotifier.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsNotifier.java index 4bdad04b3c..40826c5650 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsNotifier.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsNotifier.java @@ -19,6 +19,8 @@ package org.apache.stratos.cartridge.agent.statistics.publisher; +import org.apache.stratos.cartridge.agent.statistics.publisher.*; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cartridge.agent.config.CartridgeAgentConfiguration; @@ -26,6 +28,9 @@ import org.apache.stratos.cartridge.agent.util.CartridgeAgentConstants; import org.apache.stratos.cartridge.agent.util.CartridgeAgentUtils; +import java.io.File; +import java.util.List; + /** * Health statistics notifier thread for publishing statistics periodically to CEP. */ @@ -33,12 +38,48 @@ public class HealthStatisticsNotifier implements Runnable { private static final Log log = LogFactory.getLog(HealthStatisticsNotifier.class); private final HealthStatisticsPublisher statsPublisher; + private IHealthStatisticsReader statsReader; private long statsPublisherInterval = 15000; private boolean terminated; public HealthStatisticsNotifier() { this.statsPublisher = new HealthStatisticsPublisher(); + /* Find all jars in the current working directory */ + String pluginFileName = System.getProperty("health.stats.reader.plugin"); + if (pluginFileName != null) + { + File pluginFile = new File(pluginFileName); + if ( (pluginFile != null) + && (pluginFile.exists())) { + List pluginClass = PluginLoader.loadPluginClassesFromJar(pluginFile, IHealthStatisticsReader.class); + if (!pluginClass.isEmpty()) + { + try + { + log.trace("Instantiating new instance of plugin type " + pluginClass); + this.statsReader = (IHealthStatisticsReader)pluginClass.get(0).newInstance( ); + } + catch(InstantiationException e) + { + log.error("Unable to instantiate plugin " + pluginClass, e); + } + catch(IllegalAccessException e) + { + log.error("Unable to instantiate plugin " + pluginClass, e); + } + } + } + else + { + log.error("Plugin not found or malformed: " + pluginFileName + ((pluginFile == null)? " NULL": "Doesn't exist")); + } + } + if (this.statsReader == null) + { + this.statsReader = new HealthStatisticsReader(); + } + String interval = System.getProperty("stats.notifier.interval"); if (interval != null) { statsPublisherInterval = Long.getLong(interval); @@ -47,48 +88,56 @@ public HealthStatisticsNotifier() { @Override public void run() { - while (!terminated) { - try { + if (this.statsReader.init() == false) + { + log.error("Health statistics reader "+this.statsReader.getClass().getName()+" could not initialise"); + } + else + { + while (!terminated) { try { - Thread.sleep(statsPublisherInterval); - } catch (InterruptedException ignore) { - } + try { + Thread.sleep(statsPublisherInterval); + } catch (InterruptedException ignore) { + } - if (statsPublisher.isEnabled()) { + if (statsPublisher.isEnabled()) { - double memoryConsumption = HealthStatisticsReader.getMemoryConsumption(); - if(log.isDebugEnabled()) { - log.debug(String.format("Publishing memory consumption: %f", memoryConsumption)); - } - statsPublisher.publish( - CartridgeAgentConfiguration.getInstance().getClusterId(), - CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(), - CartridgeAgentConfiguration.getInstance().getMemberId(), - CartridgeAgentConfiguration.getInstance().getPartitionId(), - CartridgeAgentConstants.MEMORY_CONSUMPTION, - memoryConsumption - ); + CartridgeStatistics stats = statsReader.getCartridgeStatistics(); + + if(log.isDebugEnabled()) { + log.debug(String.format("Publishing memory consumption: %f", stats.getMemoryUsage())); + } + statsPublisher.publish( + CartridgeAgentConfiguration.getInstance().getClusterId(), + CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(), + CartridgeAgentConfiguration.getInstance().getMemberId(), + CartridgeAgentConfiguration.getInstance().getPartitionId(), + CartridgeAgentConstants.MEMORY_CONSUMPTION, + stats.getMemoryUsage() + ); - double loadAverage = HealthStatisticsReader.getLoadAverage(); - if(log.isDebugEnabled()) { - log.debug(String.format("Publishing load average: %f", loadAverage)); + if(log.isDebugEnabled()) { + log.debug(String.format("Publishing load average: %f", stats.getProcessorUsage())); + } + statsPublisher.publish( + CartridgeAgentConfiguration.getInstance().getClusterId(), + CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(), + CartridgeAgentConfiguration.getInstance().getMemberId(), + CartridgeAgentConfiguration.getInstance().getPartitionId(), + CartridgeAgentConstants.LOAD_AVERAGE, + stats.getProcessorUsage() + ); + } else if (log.isWarnEnabled()) { + log.warn("Statistics publisher is disabled"); + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Could not publish health statistics", e); } - statsPublisher.publish( - CartridgeAgentConfiguration.getInstance().getClusterId(), - CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(), - CartridgeAgentConfiguration.getInstance().getMemberId(), - CartridgeAgentConfiguration.getInstance().getPartitionId(), - CartridgeAgentConstants.LOAD_AVERAGE, - loadAverage - ); - } else if (log.isWarnEnabled()) { - log.warn("Statistics publisher is disabled"); - } - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Could not publish health statistics", e); } } + this.statsReader.delete(); } } diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java index b98619134f..96e46611bc 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java @@ -26,47 +26,43 @@ import org.apache.stratos.cartridge.agent.util.CartridgeAgentUtils; import java.lang.management.ManagementFactory; +import java.io.IOException; /** * Health statistics reader. */ -public class HealthStatisticsReader { +public class HealthStatisticsReader implements IHealthStatisticsReader { + private static final int MB = 1024 * 1024; private static final Log log = LogFactory.getLog(HealthStatisticsReader.class); - public static double getMemoryConsumption() { + public boolean init() { + return true; + } + + public CartridgeStatistics getCartridgeStatistics() throws IOException { OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); double totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); double usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); - - if(log.isDebugEnabled()) { - log.debug("Calculating memory consumption: [totalMemory] "+totalMemory+" [usedMemory] "+usedMemory); - } + double loadAvg = (double)osBean.getSystemLoadAverage(); + // assume system cores = available cores to JVM + int cores = osBean.getAvailableProcessors(); double memoryConsumption = (usedMemory / totalMemory) * 100; - if(log.isDebugEnabled()) { - log.debug("Calculating memory consumption: [percentage] "+memoryConsumption); - } - return memoryConsumption; - } - - public static double getLoadAverage() { - double loadAvg = (double)ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); - // assume system cores = available cores to JVM - int cores = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); - - if(log.isDebugEnabled()) { - log.debug("Calculating load average consumption: [loadAverage] "+loadAvg+" [cores] "+cores); - } - double loadAvgPercentage = (loadAvg/cores) * 100; + if(log.isDebugEnabled()) { - log.debug("Calculating load average consumption: [percentage] "+loadAvgPercentage); + log.debug("Memory consumption: [totalMemory] "+totalMemory+"Mb [usedMemory] "+usedMemory+"Mb: "+memoryConsumption+"%"); + log.debug("Processor consumption: [loadAverage] "+loadAvg+" [cores] "+cores+": "+loadAvgPercentage+"%"); } - return loadAvgPercentage; + + return (new CartridgeStatistics(memoryConsumption, loadAvgPercentage)); } public static boolean allPortsActive() { return CartridgeAgentUtils.checkPortsActive(CartridgeAgentConfiguration.getInstance().getListenAddress(), CartridgeAgentConfiguration.getInstance().getPorts()); } -} \ No newline at end of file + + public void delete() { + } +} diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/IHealthStatisticsReader.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/IHealthStatisticsReader.java new file mode 100644 index 0000000000..ddb45393a9 --- /dev/null +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/IHealthStatisticsReader.java @@ -0,0 +1,55 @@ +/* + * 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.cartridge.agent.statistics.publisher; + +import java.io.IOException; + +/** + * Health statistics reader interface. + */ +public interface IHealthStatisticsReader { + + /** + * Called exactly once, before any other method. + * + * Should be used, along with {@link #delete()}, to manage "unmanaged" + * resources, e.g. sockets. Standard objects will of course be managed by + * GC in the usual way and should be allocated in the ctor. + */ + public boolean init(); + + /** + * Called repeatedly to obtain memory and processor use. + * + * Obtained from the cartridge agent hosti. + * + * Can throw IOException if the required metrics were not obtainable. + */ + public CartridgeStatistics getCartridgeStatistics() throws IOException; + + /** + * Called exactly once, after all other methods. + * + * Should be used, along with {@link #init()}, to manage "unmanaged" + * resources, e.g. sockets. Standard objects will of course be managed by + * GC in the usual way and will be collected when no longer referenced. + */ + public void delete(); +} diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/PluginLoader.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/PluginLoader.java new file mode 100644 index 0000000000..afd6394a64 --- /dev/null +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/PluginLoader.java @@ -0,0 +1,88 @@ +package org.apache.stratos.cartridge.agent.statistics.publisher; + +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; + +import java.io.IOException; +import java.io.File; +import java.io.FileFilter; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Enumeration; +import java.util.List; +import java.util.LinkedList; +import java.util.jar.*; +import java.util.zip.*; + + +public class PluginLoader +{ + private static final Log log = LogFactory.getLog(PluginLoader.class); + + /* Built-in plugins are listed here. This is just easier than adding this + * jar to the list of jars to search, as it contains too much random stuff, + * including stuff with unsatisfied dependencies that we otherwise wouldn't + * load. There's a nice looking library called Reflections on Google Code + * that would probably be OK, but it's more logic. + */ + + public static List loadPluginClassesFromJar( File jarPath, Class pluginInterface ) + { + List listeners = new LinkedList( ); + + try + { + URLClassLoader loader = new URLClassLoader( new URL[] { jarPath.toURI().toURL() } ); + JarFile jar = new JarFile( jarPath ); + Enumeration jarEnum = jar.entries(); + + log.trace( "Scanning jar file " + jarPath ); + + while( jarEnum.hasMoreElements() ) + { + ZipEntry zipEntry = jarEnum.nextElement(); + String fileName = zipEntry.getName(); + + if( fileName.endsWith( ".class" ) ) + { + log.trace( "Considering jar entry " + fileName ); + try + { + String className = fileName.replace( ".class", "" ).replace( "/", "." ); + Class cls = loader.loadClass( className ); + log.trace( "Loaded class " + className ); + + if( hasInterface( cls, pluginInterface ) ) + { + log.trace( "Class has " + pluginInterface.getName() + " interface; adding " ); + listeners.add( cls ); + } + } + catch( ClassNotFoundException e ) + { + log.error( "Unable to load class from " + fileName + " in " + jarPath ); + } + } + } + + } + catch( IOException e ) + { + log.error( "Unable to open JAR file " + jarPath, e ); + } + + return listeners; + } + + private static boolean hasInterface( Class cls, Class iface ) + { + for( Class in : cls.getInterfaces() ) + { + if( in == iface ) + { + return true; + } + } + return false; + } +} diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java index 65165561bc..5f777ce788 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.exception.CommandException; @@ -58,10 +59,12 @@ public interface Command { * The context assoicated with the Command Line Application * @param args * The arguments for the command + * @param already_parsed_opts + * Options parsed by any parent parsers. * @return The status code * @throws org.apache.stratos.cli.exception.CommandException * if any errors occur when executing the command */ - int execute(T context, String[] args) throws CommandException; + int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException; } 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 10c9d9e5f1..8299d0d646 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 @@ -723,7 +723,7 @@ private void printLBs(String resultString) { public void subscribe(String cartridgeType, String alias, String externalRepoURL, boolean privateRepo, String username, String password,String asPolicy, String depPolicy, String size, boolean remoOnTermination, boolean persistanceMapping, - boolean enableCommits) + boolean enableCommits, String volumeId) throws CommandException { DefaultHttpClient httpClient = new DefaultHttpClient(); @@ -737,6 +737,7 @@ public void subscribe(String cartridgeType, String alias, String externalRepoURL cartridgeInfoBean.setAutoscalePolicy(null); cartridgeInfoBean.setDeploymentPolicy(null); cartridgeInfoBean.setSize(size); + cartridgeInfoBean.setRemoveOnTermination(remoOnTermination); cartridgeInfoBean.setPersistanceRequired(persistanceMapping); cartridgeInfoBean.setCommitsEnabled(enableCommits); @@ -759,6 +760,7 @@ public void subscribe(String cartridgeType, String alias, String externalRepoURL cartridgeInfoBean.setRemoveOnTermination(remoOnTermination); cartridgeInfoBean.setPersistanceRequired(persistanceMapping); cartridgeInfoBean.setCommitsEnabled(enableCommits); + cartridgeInfoBean.setVolumeId(volumeId); jsonSubscribeString = gson.toJson(cartridgeInfoBean, CartridgeInfoBean.class); @@ -781,7 +783,7 @@ public void subscribe(String cartridgeType, String alias, String externalRepoURL return; } - String subscriptionOutputJSON= subscriptionOutput.substring(20, subscriptionOutput.length() -1); + String subscriptionOutputJSON = subscriptionOutput.substring(20, subscriptionOutput.length() -1); SubscriptionInfo subcriptionInfo = gson.fromJson(subscriptionOutputJSON, SubscriptionInfo.class); System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n", cartridgeType, alias); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java index 8a888eeb57..7450d79507 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java @@ -246,6 +246,8 @@ public int run(String[] args) { // Command action String action = null; + // Command action options + Option[] actionOptions = null; String usernameInput = null; String passwordInput = null; @@ -263,6 +265,7 @@ public int run(String[] args) { CommandLine commandLine; try { // Must add all options. Otherwise actions cannot be performed directly by command line. + // This is because the parser trips over unrecognised options. Options allCommandOptions = new Options(); for (Command command : commands.values()) { Options commandOptions = command.getOptions(); @@ -281,6 +284,7 @@ public int run(String[] args) { commandLine = parser.parse(allCommandOptions, args); remainingArgs = commandLine.getArgs(); + actionOptions = commandLine.getOptions(); if (remainingArgs != null && remainingArgs.length > 0) { // Get command action action = remainingArgs[0]; @@ -346,7 +350,7 @@ public int run(String[] args) { if (logger.isDebugEnabled()) { logger.debug("Executing Action: {} {}", action, Arrays.asList(actionArgs)); } - int returnCode = command.execute(context, actionArgs); + int returnCode = command.execute(context, actionArgs, actionOptions); if (logger.isDebugEnabled()) { logger.debug("Exiting with error code {} after executing action {}", returnCode, action); } @@ -443,7 +447,7 @@ protected int executeCommand(String line) { return CliConstants.BAD_ARGS_CODE; } try { - return command.execute(context, actionArgs); + return command.execute(context, actionArgs, new Option[0]); } catch (CommandException e) { if (logger.isErrorEnabled()) { logger.error("Error executing command: " + action, e); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/cartridge/CartridgeInfoBean.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/cartridge/CartridgeInfoBean.java index 58d6f66cd7..9e23120320 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/cartridge/CartridgeInfoBean.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/beans/cartridge/CartridgeInfoBean.java @@ -31,7 +31,7 @@ public class CartridgeInfoBean { private String autoscalePolicy; private String deploymentPolicy; private String size; - + private String volumeId; boolean privateRepo; private boolean removeOnTermination; private boolean persistanceRequired; @@ -140,6 +140,12 @@ public boolean isCommitsEnabled() { public void setCommitsEnabled(boolean commitsEnabled) { this.commitsEnabled = commitsEnabled; } - - + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java index 84acbc1098..49054bbc3d 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java index daafc61745..bac6a3bc63 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -51,7 +52,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java index b185f7d966..a025f457bd 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java @@ -29,6 +29,8 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.Option; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class AddTenantCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(AddTenantCommand.class); @@ -87,7 +89,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -105,46 +107,48 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Add tenant"); } - if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) { + if (opts.hasOption(CliConstants.USERNAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Username option is passed"); } - admin = commandLine.getOptionValue(CliConstants.USERNAME_OPTION); + admin = opts.getOption(CliConstants.USERNAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.FIRST_NAME_OPTION)) { + if (opts.hasOption(CliConstants.FIRST_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("First name option is passed"); } - firstName = commandLine.getOptionValue(CliConstants.FIRST_NAME_OPTION); + firstName = opts.getOption(CliConstants.FIRST_NAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.LAST_NAME_OPTION)) { + if (opts.hasOption(CliConstants.LAST_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Last name option is passed"); } - lastaName = commandLine.getOptionValue(CliConstants.LAST_NAME_OPTION); + lastaName = opts.getOption(CliConstants.LAST_NAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) { + if (opts.hasOption(CliConstants.PASSWORD_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Password option is passed"); } - password = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION); + password = opts.getOption(CliConstants.PASSWORD_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.DOMAIN_NAME_OPTION)) { + if (opts.hasOption(CliConstants.DOMAIN_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Domain name option is passed"); } - domain = commandLine.getOptionValue(CliConstants.DOMAIN_NAME_OPTION); + domain = opts.getOption(CliConstants.DOMAIN_NAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.EMAIL_OPTION)) { + if (opts.hasOption(CliConstants.EMAIL_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Email option is passed"); } - email = commandLine.getOptionValue(CliConstants.EMAIL_OPTION); + email = opts.getOption(CliConstants.EMAIL_OPTION).getValue(); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalePolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalePolicyCommand.java index 9c3b4ba972..41c0cc1658 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalePolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalePolicyCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -46,7 +47,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalingPolicyDeploymentCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalingPolicyDeploymentCommand.java index ae4439135f..3dcefe7997 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalingPolicyDeploymentCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AutoscalingPolicyDeploymentCommand.java @@ -30,6 +30,8 @@ import java.io.FileReader; import java.io.IOException; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class AutoscalingPolicyDeploymentCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(AutoscalingPolicyDeploymentCommand.class); @@ -63,7 +65,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -77,16 +79,18 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Autoscaling policy deployment"); } - if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + if (opts.hasOption(CliConstants.RESOURCE_PATH)) { if (logger.isTraceEnabled()) { logger.trace("Resource path option is passed"); } - resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + resourcePath = opts.getOption(CliConstants.RESOURCE_PATH).getValue(); autoscalingPolicyDeployment = readResource(resourcePath); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/CartridgeDeploymentCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/CartridgeDeploymentCommand.java index e60461c1ce..474ddaf94c 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/CartridgeDeploymentCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/CartridgeDeploymentCommand.java @@ -30,6 +30,8 @@ import java.io.FileReader; import java.io.IOException; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class CartridgeDeploymentCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(CartridgeDeploymentCommand.class); @@ -63,7 +65,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -77,16 +79,18 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Cartridge deployment"); } - if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + if (opts.hasOption(CliConstants.RESOURCE_PATH)) { if (logger.isTraceEnabled()) { logger.trace("Resource path option is passed"); } - resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + resourcePath = opts.getOption(CliConstants.RESOURCE_PATH).getValue(); cartridgeDeploymentJSON = readResource(resourcePath); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java index 83adf1f6de..19c9ba8f0d 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java index 50b4a8514e..5a5bc98eba 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceDeploymentCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceDeploymentCommand.java index 95d9647ef0..e62c9c70b8 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceDeploymentCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceDeploymentCommand.java @@ -31,6 +31,8 @@ import java.io.FileReader; import java.io.IOException; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class DeployServiceDeploymentCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(DeployServiceDeploymentCommand.class); @@ -64,7 +66,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -78,16 +80,18 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Deploy Service Deployment"); } - if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + if (opts.hasOption(CliConstants.RESOURCE_PATH)) { if (logger.isTraceEnabled()) { logger.trace("Resource path option is passed"); } - resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + resourcePath = opts.getOption(CliConstants.RESOURCE_PATH).getValue(); deployServiceDeployment = readResource(resourcePath); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyCommand.java index 1072029fea..a376ee4e6b 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -46,7 +47,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyDeploymentCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyDeploymentCommand.java index 75fe52a167..01834361a5 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyDeploymentCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeploymentPolicyDeploymentCommand.java @@ -30,6 +30,8 @@ import java.io.FileReader; import java.io.IOException; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class DeploymentPolicyDeploymentCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(DeploymentPolicyDeploymentCommand.class); @@ -63,7 +65,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -77,16 +79,18 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Deployment policy deployment"); } - if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + if (opts.hasOption(CliConstants.RESOURCE_PATH)) { if (logger.isTraceEnabled()) { logger.trace("Resource path option is passed"); } - resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + resourcePath = opts.getOption(CliConstants.RESOURCE_PATH).getValue(); deploymentPolicyDeployment = readResource(resourcePath); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java index 195b417ee6..22173b30fc 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java index 3ae2b429eb..f6bbff565b 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java index ce31127255..21c3370e9f 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java index 950a957e4d..ee79aecc1e 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java index 1dbd7d4333..65e91e53a4 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,11 +27,6 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; -import java.io.File; - -import static org.apache.stratos.cli.utils.CliConstants.STRATOS_DIR; -import static org.apache.stratos.cli.utils.CliConstants.STRATOS_HISTORY_DIR; - public class ExitCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(ExitCommand.class); @@ -54,7 +50,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { // Nothing to execute here. This is a special command. if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java index 0593b4e423..17e135d07d 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -49,7 +50,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } 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 d3c071a660..07cbfa4290 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 @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +51,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java index f9f7e09777..9a003576fb 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -46,7 +47,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java index 3874d41ee6..412bfa6506 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.RestCommandLineService; import org.slf4j.Logger; @@ -46,7 +47,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java index 7580c56775..af97c22f41 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -46,7 +47,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java index 4ce5ac71b5..28cbf48420 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java @@ -27,6 +27,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class ListMemberCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(ListMemberCommand.class); @@ -78,7 +80,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -90,21 +92,23 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE CommandLine commandLine; try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Subscribing to {} cartridge with alias {}", type, alias); } - if (commandLine.hasOption(CliConstants.CARTRIDGE_TYPE_OPTION)) { + if (opts.hasOption(CliConstants.CARTRIDGE_TYPE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Autoscaling policy option is passed"); } - type = commandLine.getOptionValue(CliConstants.CARTRIDGE_TYPE_OPTION); + type = opts.getOption(CliConstants.CARTRIDGE_TYPE_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.ALIAS_OPTION)) { + if (opts.hasOption(CliConstants.ALIAS_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Deployment policy option is passed"); } - alias = commandLine.getOptionValue(CliConstants.ALIAS_OPTION); + alias = opts.getOption(CliConstants.ALIAS_OPTION).getValue(); } if (type == null) { diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListSubscribedCartridgesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListSubscribedCartridgesCommand.java index 080a72c591..57adcce0be 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListSubscribedCartridgesCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListSubscribedCartridgesCommand.java @@ -32,6 +32,8 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class ListSubscribedCartridgesCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(ListSubscribedCartridgesCommand.class); @@ -67,7 +69,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -83,12 +85,15 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); remainingArgs = commandLine.getArgs(); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); + if (!(remainingArgs == null || remainingArgs.length == 0)) { context.getStratosApplication().printUsage(getName()); return CliConstants.BAD_ARGS_CODE; } - if (commandLine.hasOption(CliConstants.FULL_OPTION)) { + if (opts.hasOption(CliConstants.FULL_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Full option is passed"); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionCommand.java index 4e5f4a8f19..ad856e2ff6 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionCommand.java @@ -46,7 +46,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionDeploymentCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionDeploymentCommand.java index b1e5989beb..b973536ac7 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionDeploymentCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PartitionDeploymentCommand.java @@ -30,6 +30,8 @@ import java.io.FileReader; import java.io.IOException; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class PartitionDeploymentCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(PartitionDeploymentCommand.class); @@ -63,7 +65,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -77,16 +79,18 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Partition deployment"); } - if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + if (opts.hasOption(CliConstants.RESOURCE_PATH)) { if (logger.isTraceEnabled()) { logger.trace("Resource path option is passed"); } - resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + resourcePath = opts.getOption(CliConstants.RESOURCE_PATH).getValue(); partionDeployment = readResource(resourcePath); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PoliciesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PoliciesCommand.java index b63f400d6b..305440ed0f 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PoliciesCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/PoliciesCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +51,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveDomainMappingCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveDomainMappingCommand.java index 06e6b110f1..74aed7d1db 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveDomainMappingCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/RemoveDomainMappingCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.CommandLineService; import org.apache.stratos.cli.StratosCommandContext; @@ -50,7 +51,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java index 6479a06fd0..6232893385 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java @@ -33,6 +33,8 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class SubscribeCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(ListSubscribedCartridgesCommand.class); @@ -75,6 +77,10 @@ private Options constructOptions() { size.setArgName("volume-size"); options.addOption(size); + Option volumeId = new Option(CliConstants.VOLUME_ID_OPTION, CliConstants.VOLUME_ID_LONG_OPTION, true, "Volume-id"); + volumeId.setArgName("volume-id"); + options.addOption(volumeId); + Option persistance = new Option(CliConstants.PERSISTANCE_VOLUME_OPTION, CliConstants.PERSISTANCE_VOLUME_LONG_OPTION, true, "Persistance-volume"); persistance.setArgName("persistance-volume"); @@ -120,7 +126,7 @@ public String getArgumentSyntax() { return "[Cartridge type] [Cartridge alias]"; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -133,6 +139,7 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE String depPolicy = null; String repoURL = null, username = "", password = ""; String size = null; + String volumeID = null; boolean removeOnTermination = false; boolean privateRepo = false; @@ -144,6 +151,8 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); remainingArgs = commandLine.getArgs(); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (remainingArgs != null && remainingArgs.length == 2) { // Get type type = remainingArgs[0]; @@ -157,70 +166,80 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE logger.debug("Subscribing to {} cartridge with alias {}", type, alias); } - //if (commandLine.hasOption(CliConstants.POLICY_OPTION)) { + //if (opts.hasOption(CliConstants.POLICY_OPTION)) { // if (logger.isTraceEnabled()) { // logger.trace("Policy option is passed"); // } - // policy = commandLine.getOptionValue(CliConstants.POLICY_OPTION); + // policy = opts.getOptionValue(CliConstants.POLICY_OPTION); //} - if (commandLine.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { + if (opts.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Autoscaling policy option is passed"); } - asPolicy = commandLine.getOptionValue(CliConstants.AUTOSCALING_POLICY_OPTION); + asPolicy = opts.getOption(CliConstants.AUTOSCALING_POLICY_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.DEPLOYMENT_POLICY_OPTION)) { + if (opts.hasOption(CliConstants.DEPLOYMENT_POLICY_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Deployment policy option is passed"); } - depPolicy = commandLine.getOptionValue(CliConstants.DEPLOYMENT_POLICY_OPTION); + depPolicy = opts.getOption(CliConstants.DEPLOYMENT_POLICY_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.REPO_URL_OPTION)) { + if (opts.hasOption(CliConstants.REPO_URL_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("RepoURL option is passed"); } - repoURL = commandLine.getOptionValue(CliConstants.REPO_URL_OPTION); + repoURL = opts.getOption(CliConstants.REPO_URL_OPTION).getValue(); } - //if (commandLine.hasOption(CliConstants.PRIVATE_REPO_OPTION)) { + //if (opts.hasOption(CliConstants.PRIVATE_REPO_OPTION)) { // if (logger.isTraceEnabled()) { // logger.trace("privateRepo option is passed"); // } // privateRepo = true; //} - if (commandLine.hasOption(CliConstants.VOLUME_SIZE_OPTION)) { + if (opts.hasOption(CliConstants.VOLUME_SIZE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Volume size option is passed"); } - size = commandLine.getOptionValue(CliConstants.VOLUME_SIZE_OPTION); + size = opts.getOption(CliConstants.VOLUME_SIZE_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.REMOVE_ON_TERMINATION_OPTION)) { + + if (opts.hasOption(CliConstants.VOLUME_ID_OPTION)) { + if (logger.isTraceEnabled()) { + logger.trace("Volume id option is passed"); + + } + volumeID = opts.getOption(CliConstants.VOLUME_ID_OPTION).getValue(); + } + + + if (opts.hasOption(CliConstants.REMOVE_ON_TERMINATION_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Remove on termination option is passed"); } removeOnTermination = true; } - if (commandLine.hasOption(CliConstants.PERSISTANCE_VOLUME_OPTION)) { + if (opts.hasOption(CliConstants.PERSISTANCE_VOLUME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Persistance volume option is passed"); } persistanceMapping = true; } - if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) { + if (opts.hasOption(CliConstants.USERNAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Username option is passed"); } - username = commandLine.getOptionValue(CliConstants.USERNAME_OPTION); + username = opts.getOption(CliConstants.USERNAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) { + if (opts.hasOption(CliConstants.PASSWORD_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Password option is passed"); } - password = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION); + password = opts.getOption(CliConstants.PASSWORD_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.ENABLE_COMMITS_OPTION)) { + if (opts.hasOption(CliConstants.ENABLE_COMMITS_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Upstream git commits are enabled"); } @@ -251,7 +270,7 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE RestCommandLineService.getInstance().subscribe(type, alias, repoURL, privateRepo, username, password, asPolicy, depPolicy, size, removeOnTermination, - persistanceMapping, commitsEnabled); + persistanceMapping, commitsEnabled, volumeID); return CliConstants.SUCCESSFUL_CODE; diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribedCartridgeInfoCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribedCartridgeInfoCommand.java index cc002a39b4..2762b25854 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribedCartridgeInfoCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribedCartridgeInfoCommand.java @@ -18,12 +18,8 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; import org.apache.commons.lang3.StringUtils; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -76,7 +72,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java index f8668137e1..29c146f1de 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -50,7 +51,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java index 52f2a9a5e6..e69880b465 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java index c8300526f1..7c05a8fe01 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cli.commands; +import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +52,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java index e63c7999e1..20f36766b3 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java @@ -32,6 +32,8 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; + public class UnsubscribeCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(UnsubscribeCommand.class); @@ -71,7 +73,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -84,6 +86,9 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); remainingArgs = commandLine.getArgs(); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); + if (remainingArgs != null && remainingArgs.length == 1) { // Get alias alias = remainingArgs[0]; @@ -95,7 +100,7 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE return CliConstants.BAD_ARGS_CODE; } - if (commandLine.hasOption(CliConstants.FORCE_OPTION)) { + if (opts.hasOption(CliConstants.FORCE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Force option is passed"); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java index 0f6a901de9..2e898f4e70 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CliConstants.java @@ -224,6 +224,9 @@ public class CliConstants { public static final String VOLUME_SIZE_OPTION = "v"; public static final String VOLUME_SIZE_LONG_OPTION = "volume-size"; + public static final String VOLUME_ID_OPTION = "vi"; + public static final String VOLUME_ID_LONG_OPTION = "volume-id"; + public static final String PERSISTANCE_VOLUME_OPTION = "pv"; public static final String PERSISTANCE_VOLUME_LONG_OPTION = "persistance-volume"; diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CommandLineUtils.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CommandLineUtils.java index 91e2251927..d9747df5eb 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CommandLineUtils.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/utils/CommandLineUtils.java @@ -18,6 +18,9 @@ */ package org.apache.stratos.cli.utils; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; + import java.text.MessageFormat; import java.util.ResourceBundle; @@ -91,4 +94,15 @@ public static String getMessage(String key, Object... args) { } return message; } + + public static Options mergeOptionArrays(Option[] a, Option[] b) { + Options opts = new Options(); + for (Option o: a) { + opts.addOption(o); + } + for (Option o: b) { + opts.addOption(o); + } + return opts; + } } diff --git a/components/org.apache.stratos.cli/src/main/resources/log4j.properties b/components/org.apache.stratos.cli/src/main/resources/log4j.properties index c5d208460b..15304ee3e5 100644 --- a/components/org.apache.stratos.cli/src/main/resources/log4j.properties +++ b/components/org.apache.stratos.cli/src/main/resources/log4j.properties @@ -33,4 +33,4 @@ log4j.appender.file.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c #Loggers log4j.rootLogger=info, file -log4j.logger.org.wso2.carbon.adc.mgt.cli=info +log4j.logger.org.wso2.carbon.adc.mgt.cli=DEBUG diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidCompositeApplicationDefinitionException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidCompositeApplicationDefinitionException.java new file mode 100644 index 0000000000..a7c2bb6b45 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidCompositeApplicationDefinitionException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.cloud.controller.exception; + +public class InvalidCompositeApplicationDefinitionException extends Exception { + + private static final long serialVersionUID = -1L; + private String message; + + public InvalidCompositeApplicationDefinitionException(String msg) { + super(msg); + this.setMessage(msg); + } + + public InvalidCompositeApplicationDefinitionException(String msg, Exception ex) { + super(msg, ex); + this.setMessage(msg); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java index eafbade70e..e4d54773f9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java @@ -22,6 +22,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.CloudControllerException; @@ -457,7 +458,7 @@ public PartitionValidator getPartitionValidator() { } @Override - public String createVolume(int sizeGB) { + public String createVolume(int sizeGB, String snapshotId) { IaasProvider iaasInfo = getIaasProvider(); ComputeServiceContext context = iaasInfo.getComputeService() @@ -474,7 +475,19 @@ public String createVolume(int sizeGB) { ElasticBlockStoreApi blockStoreApi = context.unwrapApi(AWSEC2Api.class).getElasticBlockStoreApiForRegion(region).get(); - Volume volume = blockStoreApi.createVolumeInAvailabilityZone(zone, sizeGB); + Volume volume; + if(StringUtils.isEmpty(snapshotId)){ + if(log.isDebugEnabled()){ + log.info("Creating a volume in the zone " + zone); + } + volume = blockStoreApi.createVolumeInAvailabilityZone(zone, sizeGB); + }else{ + if(log.isDebugEnabled()){ + log.info("Creating a volume in the zone " + zone + " from the shanpshot " + snapshotId); + } + volume = blockStoreApi.createVolumeFromSnapshotInAvailabilityZone(zone, snapshotId); + } + if (volume == null) { log.fatal("Volume creation was unsuccessful. [region] : " + region diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java index dccbb2e2d4..b4b31d5b2d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java @@ -23,6 +23,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.CloudControllerException; @@ -43,6 +44,7 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.ec2.options.CreateSnapshotOptions; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.NovaApiMetadata; import org.jclouds.openstack.nova.v2_0.NovaAsyncApi; @@ -53,6 +55,7 @@ import org.jclouds.openstack.nova.v2_0.domain.Network; import org.jclouds.openstack.nova.v2_0.domain.Volume; import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; +import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI; import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi; @@ -61,12 +64,14 @@ import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi; import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions; +import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions; import org.jclouds.rest.RestContext; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; +import java.util.concurrent.TimeoutException; @SuppressWarnings("deprecation") public class OpenstackNovaIaas extends Iaas { @@ -252,7 +257,13 @@ public boolean apply(FloatingIP arg0) { // if no unassigned IP is available, we'll try to allocate an IP. if (ip == null || ip.isEmpty()) { - FloatingIP allocatedFloatingIP = floatingIp.create(); + String defaultFloatingIpPool = iaasInfo.getProperty(CloudControllerConstants.DEFAULT_FLOATING_IP_POOL); + FloatingIP allocatedFloatingIP; + if ((defaultFloatingIpPool == null) || "".equals(defaultFloatingIpPool)) { + allocatedFloatingIP = floatingIp.create(); + } else { + allocatedFloatingIP = floatingIp.allocateFromPool(defaultFloatingIpPool); + } if (allocatedFloatingIP == null) { String msg = "Failed to allocate an IP address."; log.error(msg); @@ -334,7 +345,7 @@ public boolean apply(FloatingIP arg0) { } if (ip.equals(fip.getIp())) { if(log.isDebugEnabled()) { - log.debug("OpenstackNovaIaas:associatePredefinedAddress:floating ip in use:" + fip + " /ip:" + ip); + log.debug(String.format("OpenstackNovaIaas:associatePredefinedAddress:floating ip in use:%s /ip:%s", fip, ip)); } isAvailable = true; break; @@ -485,8 +496,7 @@ public boolean isValidHost(String zone, String host) throws InvalidHostException IaasProvider iaasInfo = getIaasProvider(); if (host == null || zone == null || iaasInfo == null) { - String msg = "Host or Zone or IaaSProvider is null: host: " + host + " - zone: " + - zone + " - IaaSProvider: " + iaasInfo; + String msg = String.format("Host or Zone or IaaSProvider is null: host: %s - zone: %s - IaaSProvider: %s", host, zone, iaasInfo); log.error(msg); throw new InvalidHostException(msg); } @@ -504,7 +514,7 @@ public boolean isValidHost(String zone, String host) throws InvalidHostException } } - String msg = "Invalid host: " + host +" in the zone: "+zone+ " and of the iaas: "+iaasInfo.getType(); + String msg = String.format("Invalid host: %s in the zone: %s and of the iaas: %s", host, zone, iaasInfo.getType()); log.error(msg); throw new InvalidHostException(msg); } @@ -515,62 +525,166 @@ public PartitionValidator getPartitionValidator() { } @Override - public String createVolume(int sizeGB) { + public String createVolume(int sizeGB, String snapshotId) { IaasProvider iaasInfo = getIaasProvider(); String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); String zone = ComputeServiceBuilderUtil.extractZone(iaasInfo); if (region == null || iaasInfo == null) { - log.fatal("Cannot create a new volume in the [region] : "+region - +" of Iaas : "+iaasInfo); + log.fatal(String.format("Cannot create a new volume in the [region] : %s of Iaas : %s", region, iaasInfo)); return null; } ComputeServiceContext context = iaasInfo.getComputeService().getContext(); RestContext nova = context.unwrap(); - VolumeApi api = nova.getApi().getVolumeExtensionForZone(region).get(); - Volume volume = api.create(sizeGB, CreateVolumeOptions.Builder.availabilityZone(zone)); + VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); + Volume volume; + if(StringUtils.isEmpty(snapshotId)){ + if(log.isDebugEnabled()){ + log.info("Creating a volume in the zone " + zone); + } + volume = volumeApi.create(sizeGB, CreateVolumeOptions.Builder.availabilityZone(zone)); + }else{ + if(log.isDebugEnabled()){ + log.info("Creating a volume in the zone " + zone + " from the shanpshot " + snapshotId); + } + volume = volumeApi.create(sizeGB, CreateVolumeOptions.Builder.availabilityZone(zone).snapshotId(snapshotId)); + } + if (volume == null) { - log.fatal("Volume creation was unsuccessful. [region] : " + region+" [zone] : " + zone - + " of Iaas : " + iaasInfo); - return null; - } - - log.info("Successfully created a new volume [id]: "+volume.getId() - +" in [region] : "+region+" [zone] : "+zone+" of Iaas : "+iaasInfo); - return volume.getId(); + log.fatal(String.format("Volume creation was unsuccessful. [region] : %s [zone] : %s of Iaas : %s", region, zone, iaasInfo)); + return null; + } + + String volumeId = volume.getId(); + /* + Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); + + if(!(volumeStatus == Volume.Status.AVAILABLE || volumeStatus == Volume.Status.CREATING)){ + log.error(String.format("Error while creating [volume id] %s. Volume status is %s", volumeId, volumeStatus)); + return volumeId; + } + try { + if(!waitForStatus(volumeApi, volumeId, Volume.Status.AVAILABLE)){ + log.error("Volume did not become AVAILABLE. Current status is " + volume.getStatus()); + } + } catch (TimeoutException e) { + log.error("[Volume ID] " + volumeId + "did not become AVAILABLE within expected timeout"); + return volumeId; + } + */ + log.info(String.format("Successfully created a new volume [id]: %s in [region] : %s [zone] : %s of Iaas : %s [Volume ID]%s", volume.getId(), region, zone, iaasInfo, volume.getId())); + return volumeId; } - @Override + private boolean waitForStatus(String volumeId, Volume.Status expectedStatus, int timeoutInMins) throws TimeoutException { + long timeout = 1000 * 60 * timeoutInMins; + long timout = System.currentTimeMillis() + timeout; + + IaasProvider iaasInfo = getIaasProvider(); + String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); + ComputeServiceContext context = iaasInfo.getComputeService().getContext();; + RestContext nova = context.unwrap(); + VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); + VolumeAttachmentApi volumeAttachmentApi = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); + Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); + + while(volumeStatus != expectedStatus){ + try { + if(log.isDebugEnabled()){ + log.debug(String.format("Volume %s is still NOT in %s. Current State=%s", volumeId, expectedStatus, volumeStatus)); + } + if(volumeStatus == Volume.Status.ERROR){ + log.error("Volume " + volumeId + " is in state ERROR"); + return false; + } + Thread.sleep(1000); + volumeStatus = this.getVolumeStatus(volumeApi, volumeId); + if (System.currentTimeMillis()> timout) { + throw new TimeoutException(); + } + } catch (InterruptedException e) { + // Ignoring the exception + } + } + if(log.isDebugEnabled()){ + log.debug(String.format("Volume %s status became %s", volumeId, expectedStatus)); + } + + return true; + } + + @Override public String attachVolume(String instanceId, String volumeId, String deviceName) { - IaasProvider iaasInfo = getIaasProvider(); + IaasProvider iaasInfo = getIaasProvider(); + + if (StringUtils.isEmpty(volumeId)) { + log.error("Volume provided to attach can not be null"); + } + + if (StringUtils.isEmpty(instanceId)) { + log.error("Instance provided to attach can not be null"); + } + + ComputeServiceContext context = iaasInfo.getComputeService() + .getContext(); + String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); + String device = deviceName == null ? "/dev/vdc" : deviceName; + + if (region == null) { + log.fatal(String.format("Cannot attach the volume [id]: %s in the [region] : %s of Iaas : %s", volumeId, region, iaasInfo)); + return null; + } + + RestContext nova = context.unwrap(); + VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); + VolumeAttachmentApi volumeAttachmentApi = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); + + Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); + + if (log.isDebugEnabled()) { + log.debug("Volume " + volumeId + " is in state " + volumeStatus); + } + + if (!(volumeStatus == Volume.Status.AVAILABLE || volumeStatus == Volume.Status.CREATING)) { + log.error(String.format("Volume %s can not be attached. Volume status is %s", volumeId, volumeStatus)); + return null; + } + + boolean volumeBecameAvailable = false, volumeBecameAttached = false; + try { + volumeBecameAvailable = waitForStatus(volumeId, Volume.Status.AVAILABLE, 5); + } catch (TimeoutException e) { + log.error("[Volume ID] " + volumeId + "did not become AVAILABLE within expected timeout"); + } + + VolumeAttachment attachment = null; + if (volumeBecameAvailable) { + attachment = volumeAttachmentApi.attachVolumeToServerAsDevice(volumeId, instanceId, device); + + try { + volumeBecameAttached = waitForStatus(volumeId, Volume.Status.IN_USE, 2); + } catch (TimeoutException e) { + log.error("[Volume ID] " + volumeId + "did not become IN_USE within expected timeout"); + } + } + try { + // waiting 5seconds till volumes are actually attached. + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } - ComputeServiceContext context = iaasInfo.getComputeService() - .getContext(); - - String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); - String device = deviceName == null ? "/dev/vdc" : deviceName; - - if(region == null) { - log.fatal("Cannot attach the volume [id]: "+volumeId+" in the [region] : "+region - +" of Iaas : "+iaasInfo); - return null; - } - - RestContext nova = context.unwrap(); - VolumeAttachmentApi api = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); - VolumeAttachment attachment = api.attachVolumeToServerAsDevice(volumeId, instanceId, device); - if (attachment == null) { - log.fatal("Volume [id]: "+volumeId+" attachment for instance [id]: "+instanceId - +" was unsuccessful. [region] : " + region - + " of Iaas : " + iaasInfo); + log.fatal(String.format("Volume [id]: %s attachment for instance [id]: %s was unsuccessful. [region] : %s of Iaas : %s", volumeId, instanceId, region, iaasInfo)); return null; } - - log.info("Volume [id]: "+volumeId+" attachment for instance [id]: "+instanceId - +" was successful [status]: "+"Attaching"+". [region] : " + region - + " of Iaas : " + iaasInfo); + + if(! volumeBecameAttached){ + log.error(String.format("[Volume ID] %s attachment is called, but not yet became attached", volumeId)); + } + + log.info(String.format("Volume [id]: %s attachment for instance [id]: %s was successful [status]: Attaching. [region] : %s of Iaas : %s", volumeId, instanceId, region, iaasInfo)); return "Attaching"; } @@ -584,18 +698,19 @@ public void detachVolume(String instanceId, String volumeId) { String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); if(region == null) { - log.fatal("Cannot detach the volume [id]: "+volumeId+" from the instance [id]: "+instanceId - +" of the [region] : "+region - +" of Iaas : "+iaasInfo); + log.fatal(String.format("Cannot detach the volume [id]: %s from the instance [id]: %s of the [region] : %s of Iaas : %s", volumeId, instanceId, region, iaasInfo)); return; } - + if(log.isDebugEnabled()) { + log.debug(String.format("Starting to detach volume %s from the instance %s", volumeId, instanceId)); + } + RestContext nova = context.unwrap(); VolumeAttachmentApi api = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); if (api.detachVolumeFromServer(volumeId, instanceId)) { - log.info("Detachment of Volume [id]: "+volumeId+" from instance [id]: "+instanceId - +" was successful. [region] : " + region - + " of Iaas : " + iaasInfo); + log.info(String.format("Detachment of Volume [id]: %s from instance [id]: %s was successful. [region] : %s of Iaas : %s", volumeId, instanceId, region, iaasInfo)); + }else{ + log.error(String.format("Detachment of Volume [id]: %s from instance [id]: %s was unsuccessful. [volume Status] : %s", volumeId, instanceId, region, iaasInfo)); } } @@ -610,16 +725,14 @@ public void deleteVolume(String volumeId) { String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); if(region == null) { - log.fatal("Cannot delete the volume [id]: "+volumeId+" of the [region] : "+region - +" of Iaas : "+iaasInfo); + log.fatal(String.format("Cannot delete the volume [id]: %s of the [region] : %s of Iaas : %s", volumeId, region, iaasInfo)); return; } RestContext nova = context.unwrap(); VolumeApi api = nova.getApi().getVolumeExtensionForZone(region).get(); if (api.delete(volumeId)) { - log.info("Deletion of Volume [id]: "+volumeId+" was successful. [region] : " + region - + " of Iaas : " + iaasInfo); + log.info(String.format("Deletion of Volume [id]: %s was successful. [region] : %s of Iaas : %s", volumeId, region, iaasInfo)); } } @@ -628,4 +741,7 @@ public String getIaasDevice(String device) { return device; } + private Volume.Status getVolumeStatus(VolumeApi volumeApi, String volumeId){ + return volumeApi.get(volumeId).getStatus(); + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java index 9332d7f2df..b3d13849b0 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/VCloudIaas.java @@ -231,7 +231,7 @@ public PartitionValidator getPartitionValidator() { } @Override - public String createVolume(int sizeGB) { + public String createVolume(int sizeGB, String snapshotId) { // TODO Auto-generated method stub return null; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 56cc2b0025..e5cc05a9fc 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; - +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; @@ -39,6 +39,9 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.cloud.controller.pojo.ConfigDependencies; +import org.apache.stratos.cloud.controller.pojo.ConfigGroup; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; @@ -89,6 +92,7 @@ private void acquireData() { currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); currentData.setCartridges(serializedObj.getCartridges()); + currentData.setConfigCompositeApplication(serializedObj.getConfigCompositeApplication()); if(log.isDebugEnabled()) { @@ -107,11 +111,53 @@ private void acquireData() { } } + // restore compostie application + List apps = restoreConfigCompositeApplication(); + if (apps == null) { + this.dataHolder.setConfigCompositeApplication(new ArrayList()); + + } } - public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, + + public void deployCompositeApplicationDefinition(CompositeApplicationDefinition compositeApplicationDefinition) throws InvalidCompositeApplicationDefinitionException, + InvalidIaasProviderException { + + String alias = compositeApplicationDefinition.getAlias(); + if(log.isDebugEnabled()){ + log.debug("composite application alias : " + alias); + } + + ConfigCompositeApplication messConfigApp = TopologyBuilder.convertCompositeApplication(compositeApplicationDefinition); + String key = "compositeApplicationAlias"; //app.getAlias() + + + List data = new ArrayList(); + data.add(messConfigApp); + dataHolder.setConfigCompositeApplication(data); + + // persist + persist(); + + if(log.isDebugEnabled()){ + log.debug("deploying composite application in cloud controller: " + compositeApplicationDefinition); + } + + TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); + } + + public void unDeployCompositeApplicationDefinition(String appAlias) throws InvalidCompositeApplicationDefinitionException, InvalidIaasProviderException { + if(log.isDebugEnabled()){ + log.debug("undeploying composite application in cloud controller, removing all composite apps "); + dataHolder.removeAllConfigCompositeApplications(); + persist(); + TopologyBuilder.handleCompositeApplicationRemoved(appAlias); + } + } + public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, + InvalidIaasProviderException { if (cartridgeConfig == null) { String msg = "Invalid Cartridge Definition: Definition is null."; log.error(msg); @@ -216,7 +262,7 @@ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCart @Override public MemberContext startInstance(MemberContext memberContext) throws UnregisteredCartridgeException, InvalidIaasProviderException { - + if(log.isDebugEnabled()) { log.debug("CloudControllerServiceImpl:startInstance"); } @@ -292,15 +338,10 @@ public MemberContext startInstance(MemberContext memberContext) throws addToPayload(payload, "PARTITION_ID", partitionId); Iaas iaas = iaasProvider.getIaas(); - if(ctxt.isVolumeRequired()){ - addToPayload(payload, "PERSISTENCE_MAPPING", getPersistencePayload(cartridge, iaas).toString()); - } if (log.isDebugEnabled()) { log.debug("Payload: " + payload.toString()); } - // reloading the payload with memberID - iaasProvider.setPayload(payload.toString().getBytes()); if (iaas == null) { if(log.isDebugEnabled()) { @@ -316,8 +357,25 @@ public MemberContext startInstance(MemberContext memberContext) throws } } - + + if(ctxt.isVolumeRequired()) { + if (ctxt.getVolumes() != null) { + for (Volume volume : ctxt.getVolumes()) { + + if (volume.getId() == null) { + // create a new volume + createVolumeAndSetInClusterContext(volume, iaasProvider); + } + } + } + } + + if(ctxt.isVolumeRequired()){ + addToPayload(payload, "PERSISTENCE_MAPPING", getPersistencePayload(ctxt, iaas).toString()); + } + iaasProvider.setPayload(payload.toString().getBytes()); iaas.setDynamicPayload(); + // get the pre built ComputeService from provider or region or zone or host computeService = iaasProvider.getComputeService(); template = iaasProvider.getTemplate(); @@ -337,19 +395,7 @@ public MemberContext startInstance(MemberContext memberContext) throws // Should have a length between 3-15 String str = clusterId.length() > 10 ? clusterId.substring(0, 10) : clusterId.substring(0, clusterId.length()); String group = str.replaceAll("[^a-z0-9-]", ""); - - if(ctxt.isVolumeRequired()) { - if (ctxt.getVolumes() != null) { - for (Volume volume : ctxt.getVolumes()) { - - if (volume.getId() == null) { - // create a new volume - createVolumeAndSetInClusterContext(volume, iaasProvider); - } - } - } - } - + NodeMetadata node; // create and start a node @@ -375,7 +421,7 @@ public MemberContext startInstance(MemberContext memberContext) throws if(log.isDebugEnabled()) { log.debug("Node id was set. "+memberContext.toString()); } - + // attach volumes if (ctxt.isVolumeRequired()) { // remove region prefix @@ -391,7 +437,7 @@ public MemberContext startInstance(MemberContext memberContext) throws } catch (Exception e) { // continue without throwing an exception, since // there is an instance already running - log.error("Attaching Volume to Instance [ " + log.error("Attaching Volume " + volume.getId() + " to Instance [ " + instanceId + " ] failed!", e); } } @@ -412,39 +458,52 @@ public MemberContext startInstance(MemberContext memberContext) throws private void createVolumeAndSetInClusterContext(Volume volume, IaasProvider iaasProvider) { - // iaas cannot be null at this state #startInstance method Iaas iaas = iaasProvider.getIaas(); - int sizeGB = volume.getSize(); - String volumeId = iaas.createVolume(sizeGB); - volume.setId(volumeId); + String snapshotId = volume.getSnapshotId(); + if(StringUtils.isNotEmpty(volume.getVolumeId())){ + // volumeID is specified, so not creating additional volumes + if(log.isDebugEnabled()){ + log.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId()); + } + volume.setId(volume.getVolumeId()); + }else{ + String volumeId = iaas.createVolume(sizeGB, snapshotId); + volume.setId(volumeId); + } + volume.setIaasType(iaasProvider.getType()); } - private StringBuilder getPersistencePayload(Cartridge cartridge, Iaas iaas) { + + private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) { StringBuilder persistencePayload = new StringBuilder(); - if(isPersistenceMappingAvailable(cartridge)){ - for(Volume volume : cartridge.getPersistence().getVolumes()){ + if(isPersistenceMappingAvailable(ctx)){ + for(Volume volume : ctx.getVolumes()){ if(log.isDebugEnabled()){ log.debug("Adding persistence mapping " + volume.toString()); } if(persistencePayload.length() != 0) { persistencePayload.append("|"); } + persistencePayload.append(iaas.getIaasDevice(volume.getDevice())); persistencePayload.append("|"); + persistencePayload.append(volume.getId()); + persistencePayload.append("|"); persistencePayload.append(volume.getMappingPath()); } } if(log.isDebugEnabled()){ log.debug("Persistence payload is" + persistencePayload.toString()); } + System.out.println("****** " + persistencePayload); return persistencePayload; } - private boolean isPersistenceMappingAvailable(Cartridge cartridge) { - return cartridge.getPersistence() != null && cartridge.getPersistence().isPersistanceRequired(); + private boolean isPersistenceMappingAvailable(ClusterContext ctx) { + return ctx.getVolumes() != null && ctx.isVolumeRequired(); } private void addToPayload(StringBuilder payload, String name, String value) { @@ -775,7 +834,6 @@ private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId); if (clusterCtxt.getVolumes() != null) { for (Volume volume : clusterCtxt.getVolumes()) { - try { String volumeId = volume.getId(); if (volumeId == null) { @@ -846,7 +904,7 @@ public boolean registerService(Registrant registrant) boolean isLb = property != null ? Boolean.parseBoolean(property) : false; ClusterContext ctxt = buildClusterContext(cartridge, clusterId, - payload, hostName, props, isLb); + payload, hostName, props, isLb, registrant.getPersistence()); dataHolder.addClusterContext(ctxt); @@ -860,8 +918,8 @@ public boolean registerService(Registrant registrant) } private ClusterContext buildClusterContext(Cartridge cartridge, - String clusterId, String payload, String hostName, - Properties props, boolean isLb) { + String clusterId, String payload, String hostName, + Properties props, boolean isLb, Persistence persistence) { // initialize ClusterContext @@ -871,40 +929,65 @@ private ClusterContext buildClusterContext(Cartridge cartridge, String property; property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); long timeout = property != null ? Long.parseLong(property) : 30000; - - property = props.getProperty(Constants.IS_VOLUME_REQUIRED); - boolean isVolumeRequired = property != null ? Boolean.parseBoolean(property) : false; - - if(isVolumeRequired) { + + boolean persistanceRequired = false; + if(persistence != null){ + persistanceRequired = persistence.isPersistanceRequired(); + } + + if(persistanceRequired){ + ctxt.setVolumes(persistence.getVolumes()); + ctxt.setVolumeRequired(true); + }else{ + ctxt.setVolumeRequired(false); + } + /* + if(persistanceRequired) { Persistence persistenceData = cartridge.getPersistence(); - + if(persistenceData != null) { - Volume[] volumes = persistenceData.getVolumes(); - + Volume[] cartridge_volumes = persistenceData.getVolumes(); + + + Volume[] volumestoCreate = overideVolumes(cartridge_volumes, persistence.getVolumes()); property = props.getProperty(Constants.SHOULD_DELETE_VOLUME); - property = props.getProperty(Constants.VOLUME_SIZE); - - for (Volume volume : volumes) { - int volumeSize = property != null ? Integer.parseInt(property) : volume.getSize(); - boolean shouldDeleteVolume = property != null ? Boolean.parseBoolean(property) : volume.isRemoveOntermination(); - volume.setSize(volumeSize); - volume.setRemoveOntermination(shouldDeleteVolume); + String property_volume_zize = props.getProperty(Constants.VOLUME_SIZE); + String property_volume_id = props.getProperty(Constants.VOLUME_ID); + + List cluster_volume_list = new LinkedList(); + + for (Volume volume : cartridge_volumes) { + int volumeSize = StringUtils.isNotEmpty(property_volume_zize) ? Integer.parseInt(property_volume_zize) : volume.getSize(); + boolean shouldDeleteVolume = StringUtils.isNotEmpty(property) ? Boolean.parseBoolean(property) : volume.isRemoveOntermination(); + String volumeID = StringUtils.isNotEmpty(property_volume_id) ? property_volume_id : volume.getVolumeId(); + + Volume volume_cluster = new Volume(); + volume_cluster.setSize(volumeSize); + volume_cluster.setRemoveOntermination(shouldDeleteVolume); + volume_cluster.setDevice(volume.getDevice()); + volume_cluster.setIaasType(volume.getIaasType()); + volume_cluster.setMappingPath(volume.getMappingPath()); + volume_cluster.setVolumeId(volumeID); + cluster_volume_list.add(volume_cluster); } - ctxt.setVolumes(volumes); + //ctxt.setVolumes(cluster_volume_list.toArray(new Volume[cluster_volume_list.size()])); + ctxt.setVolumes(persistence.getVolumes()); + ctxt.setVolumeRequired(true); } else { // if we cannot find necessary data, we would not consider // this as a volume required instance. - isVolumeRequired = false; - } - - ctxt.setVolumeRequired(isVolumeRequired); + //isVolumeRequired = false; + ctxt.setVolumeRequired(false); + } + + //ctxt.setVolumeRequired(isVolumeRequired); } - + */ ctxt.setTimeoutInMillis(timeout); return ctxt; } - @Override + @Override public String[] getRegisteredCartridges() { // get the list of cartridges registered List cartridges = dataHolder @@ -1018,14 +1101,19 @@ private void deleteVolumes(ClusterContext ctxt) { for (Volume volume : ctxt.getVolumes()) { if(volume.getId() != null) { String iaasType = volume.getIaasType(); - Iaas iaas = dataHolder.getIaasProvider(iaasType).getIaas(); + //Iaas iaas = dataHolder.getIaasProvider(iaasType).getIaas(); + Iaas iaas = cartridge.getIaasProvider(iaasType).getIaas(); if(iaas != null) { try { - // delete the volume - iaas.deleteVolume(volume.getId()); + // delete the volumes if remove on unsubscription is true. + if(volume.isRemoveOntermination()) + { + iaas.deleteVolume(volume.getId()); + volume.setId(null); + } } catch(Exception ignore) { - if(log.isDebugEnabled()) { - log.debug(ignore); + if(log.isErrorEnabled()) { + log.error("Error while deleting volume [id] "+ volume.getId(), ignore); } } } @@ -1134,5 +1222,26 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } + private List restoreConfigCompositeApplication () { + List apps = this.dataHolder.getConfigCompositeApplication(); + if (apps == null) { + if (log.isDebugEnabled()) { + log.debug("composite applications for cloud controller is null while restoring "); + } + return apps; + } + if (log.isDebugEnabled()) { + log.debug("trying to restore composite applications for cloud controller " + apps.size()); + } + for (ConfigCompositeApplication messConfigApp : apps) { + if (log.isDebugEnabled()) { + log.debug(" restoring composite application for cloud controller " + messConfigApp.getAlias()); + } + TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); + } + + return apps; + } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java index 492171ddff..1ae7dc545a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/Iaas.java @@ -141,7 +141,7 @@ public void setIaasProvider(IaasProvider iaasProvider) { * @param sizeGB size of the volume in Giga Bytes. * @return Id of the created volume. */ - public abstract String createVolume(int sizeGB); + public abstract String createVolume(int sizeGB, String snapshotId); /** * Attach a given volume to an instance at the specified device path. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java new file mode 100644 index 0000000000..97a9948a4c --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java @@ -0,0 +1,39 @@ +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; +import java.util.List; + +public class CompositeApplicationDefinition implements Serializable { + + private static final long serialVersionUID = 1L; + private String applicationId; + private String alias; + private ConfigGroup[] components; + private ConfigCartridge [] cartridges; + public ConfigCartridge[] getCartridges() { + return cartridges; + } + public void setCartridges(ConfigCartridge[] cartridges) { + this.cartridges = cartridges; + } + public String getApplicationId() { + return applicationId; + } + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public ConfigGroup[] getComponents() { + return components; + } + public void setComponents(ConfigGroup[] components) { + this.components = components; + } + + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigCartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigCartridge.java new file mode 100644 index 0000000000..a3c3b1ea03 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigCartridge.java @@ -0,0 +1,17 @@ +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; + + +public class ConfigCartridge implements Serializable { + private String alias; + private static final long serialVersionUID = 1L; + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencies.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencies.java new file mode 100644 index 0000000000..fc28e67d86 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencies.java @@ -0,0 +1,29 @@ +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + + + +public class ConfigDependencies implements Serializable { + private ConfigDependencyPair[] startup_order; + private String kill_behavior; + private static final long serialVersionUID = 1L; + + public ConfigDependencyPair[] getStartup_order() { + return startup_order; + } + public void setStartup_order(ConfigDependencyPair[] startup_order) { + this.startup_order = startup_order; + } + public String getKill_behavior() { + return kill_behavior; + } + public void setKill_behavior(String kill_behavior) { + this.kill_behavior = kill_behavior; + } + + + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencyPair.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencyPair.java new file mode 100644 index 0000000000..ac2a7d372d --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigDependencyPair.java @@ -0,0 +1,29 @@ +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; + +public class ConfigDependencyPair implements Serializable { + private String key; + private String value; + private static final long serialVersionUID = 1L; + + public ConfigDependencyPair() {} + + public ConfigDependencyPair(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigGroup.java new file mode 100644 index 0000000000..65d5610ff3 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ConfigGroup.java @@ -0,0 +1,35 @@ +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; +import java.util.List; + + + +public class ConfigGroup implements Serializable { + private String alias; + private String[] subscribables; + private ConfigDependencies dependencies; + private static final long serialVersionUID = 1L; + + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public String[] getSubscribables() { + return subscribables; + } + public void setSubscribables(String[] subscribables) { + this.subscribables = subscribables; + } + public ConfigDependencies getDependencies() { + return dependencies; + } + public void setDependencies(ConfigDependencies dependencies) { + this.dependencies = dependencies; + } + + + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java index fe7a7e95cd..2c3458a0ed 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java @@ -33,6 +33,7 @@ public class Registrant { private Properties properties; private String autoScalerPolicyName; private String deploymentPolicyName; + private Persistence persistence; public String getTenantRange() { return tenantRange; @@ -91,4 +92,12 @@ public String toString() { properties + ", autoScalerPolicyName=" + autoScalerPolicyName + ", deploymentPolicyName=" + deploymentPolicyName + "]"; } + + public Persistence getPersistence() { + return persistence; + } + + public void setPersistence(Persistence persistence) { + this.persistence = persistence; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Volume.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Volume.java index b35f965a5d..b5e3b295e2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Volume.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Volume.java @@ -29,10 +29,12 @@ public class Volume implements Serializable { private boolean removeOntermination; private String mappingPath; private String iaasType; + private String snapshotId; + private String volumeId; public String toString () { return "Persistence Required: " + ", Size: " + getSize() + ", device: " + getDevice() + - " mapping path : " + mappingPath + " remove on termination " + isRemoveOntermination(); + " mapping path : " + mappingPath + " remove on termination " + isRemoveOntermination() + " SnaphotId " + snapshotId; } public int getSize() { @@ -51,9 +53,7 @@ public void setDevice(String device) { this.device = device; } - public boolean isRemoveOntermination() { - return removeOntermination; - } + public boolean isRemoveOntermination() {return removeOntermination;} public void setRemoveOntermination(boolean removeOntermination) { this.removeOntermination = removeOntermination; @@ -107,4 +107,20 @@ public String getIaasType() { public void setIaasType(String iaasType) { this.iaasType = iaasType; } + + public String getSnapshotId() { + return snapshotId; + } + + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java index 9b05b5d8cd..78abe08fb6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.registry.RegistryManager; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher; import java.io.Serializable; @@ -74,6 +75,8 @@ public class FasterLookUpDataHolder implements Serializable{ * List of registered {@link Cartridge}s */ private List cartridges; + + private List configCompositeApplication; /** * List of IaaS Providers. @@ -118,6 +121,7 @@ public static FasterLookUpDataHolder getInstance() { private FasterLookUpDataHolder() { cartridges = new ArrayList(); + configCompositeApplication = new ArrayList(); } @@ -129,6 +133,21 @@ public void setCartridges(List cartridges) { this.cartridges = cartridges; } + public List getConfigCompositeApplication() { + return configCompositeApplication; + } + + public void setConfigCompositeApplication( + List configCompositeApplication) { + this.configCompositeApplication = configCompositeApplication; + } + + public void removeAllConfigCompositeApplications() { + if (this.configCompositeApplication != null) { + this.configCompositeApplication.removeAll(configCompositeApplication); + } + } + public Cartridge getCartridge(String cartridgeType) { for (Cartridge cartridge : cartridges) { if (cartridge.getType().equals(cartridgeType)) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 9c3ea7061a..96485a4dd8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -25,12 +25,14 @@ import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.ClusterContext; +import org.apache.stratos.cloud.controller.pojo.CompositeApplicationDefinition; import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.Registrant; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -38,7 +40,9 @@ import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; +import org.apache.stratos.messaging.util.Util; +import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -223,6 +227,28 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent instanceStartedEvent.getMemberId())); return; } + + //grouping + + if (log.isDebugEnabled()) { + log.debug("checking group id in ToplogyBuilder for member started event"); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + String appAlias = "compositeApplicationAlias"; + CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); + if (app != null) { + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceStartedEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceStartedEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); + } + } + try { TopologyManager.acquireWriteLock(); member.setStatus(MemberStatus.Starting); @@ -259,6 +285,26 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate instanceActivatedEvent.getClusterId())); return; } + + // grouping + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + String appAlias = "compositeApplicationAlias"; + CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); + if (app != null) { + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for member activated " + appAlias); + } + String clusterId = instanceActivatedEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceActivatedEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); + } + } + + + Member member = cluster.getMember(instanceActivatedEvent.getMemberId()); if (member == null) { @@ -270,6 +316,8 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate MemberActivatedEvent memberActivatedEvent = new MemberActivatedEvent(instanceActivatedEvent.getServiceName(), instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); + // grouping - set grouid + memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId()); try { TopologyManager.acquireWriteLock(); member.setStatus(MemberStatus.Activated); @@ -289,6 +337,7 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate } memberActivatedEvent.setMemberIp(member.getMemberIp()); + memberActivatedEvent.setMemberPublicIp(member.getMemberPublicIp()); TopologyManager.updateTopology(topology); } finally { @@ -323,6 +372,28 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst instanceReadyToShutdownEvent.getClusterId())); return; } + + //grouping + + if (log.isDebugEnabled()) { + log.debug("checking group id in ToplogyBuilder for member started event"); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + String appAlias = "compositeApplicationAlias"; + CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); + if (app != null) { + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceReadyToShutdownEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceReadyToShutdownEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + } + } + Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", @@ -376,12 +447,37 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance instanceMaintenanceModeEvent.getClusterId())); return; } + Member member = cluster.getMember(instanceMaintenanceModeEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", instanceMaintenanceModeEvent.getMemberId())); return; } + + + //grouping + + if (log.isDebugEnabled()) { + log.debug("checking group id in ToplogyBuilder for member started event"); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + String appAlias = "compositeApplicationAlias"; + CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); + if (app != null) { + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceMaintenanceModeEvent.getClusterId(); + + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceMaintenanceModeEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + } + } + MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent( instanceMaintenanceModeEvent.getServiceName(), instanceMaintenanceModeEvent.getClusterId(), @@ -424,6 +520,27 @@ public static void handleMemberTerminated(String serviceName, String clusterId, memberId)); return; } + + //grouping + + if (log.isDebugEnabled()) { + log.debug("checking group id in ToplogyBuilder for member started event"); + } + + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + String appAlias = "compositeApplicationAlias"; + CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); + + String groupAlias = null; + if (app != null) { + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + groupAlias = app.extractClusterGroupFromClusterId(clusterId); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); + } + } try { TopologyManager.acquireWriteLock(); @@ -432,7 +549,7 @@ public static void handleMemberTerminated(String serviceName, String clusterId, } finally { TopologyManager.releaseWriteLock(); } - TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); + TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, groupAlias); } public static void handleMemberSuspended() { @@ -443,6 +560,230 @@ public static void handleMemberSuspended() { TopologyManager.releaseWriteLock(); } } + + public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { + Topology topology = TopologyManager.getTopology(); + + //ConfigCompositeApplication messConfigApp; + try { + + TopologyManager.acquireWriteLock(); + String key = "compositeApplicationAlias"; //app.getAlias() + topology.addConfigCompositeApplication(key ,messConfigApp); + TopologyManager.updateTopology(topology); + } + finally { + TopologyManager.releaseWriteLock(); + } + TopologyEventPublisher.sendConfigApplicationCreatedEventEvent(messConfigApp); + log.info("TopolgyBuilder: sending sendConfigApplicationCreatedEventEvent "); + + } + + public static void handleCompositeApplicationRemoved(String alias) { + log.info("TopolgyBuilder: sending sendConfigApplicationRemovedEventEvent "); + TopologyEventPublisher.sendConfigApplicationRemovedEventEvent(alias); + } + + + public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { + ConfigCompositeApplication messApp = new ConfigCompositeApplication(); + String alias = compositeApplicationDefinition.getAlias(); + messApp.setAlias(alias); + String applicationId = compositeApplicationDefinition.getApplicationId(); + messApp.setApplicationId(applicationId); + org.apache.stratos.cloud.controller.pojo.ConfigCartridge[] arrayMessCartridges = compositeApplicationDefinition.getCartridges(); + org.apache.stratos.cloud.controller.pojo.ConfigGroup [] messConfigGroup = compositeApplicationDefinition.getComponents(); + + List cartridges = new ArrayList(); + List messGroups = new ArrayList(); + List messDependencies= new ArrayList(); + + for (org.apache.stratos.cloud.controller.pojo.ConfigCartridge cfg : arrayMessCartridges) { + ConfigCartridge cartridge = new ConfigCartridge(); + cartridge.setAlias(cfg.getAlias()); + + cartridges.add(cartridge); + } + messApp.setCartridges(cartridges); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: messConfigGroup size: " + messConfigGroup.length); + } + for (org.apache.stratos.cloud.controller.pojo.ConfigGroup gr : messConfigGroup) { + ConfigGroup group = new ConfigGroup(); + + // alias + group.setAlias(gr.getAlias()); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: messConfigGroup group alias " + gr.getAlias()); + } + // subscribables + String [] arraySub = gr.getSubscribables(); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: messConfigGroup group nr of subscribables " + arraySub.length); + } + List subscribables = new ArrayList(); + if (arraySub != null) { + int i = 0; + for (String sub : arraySub) { + subscribables.add(arraySub[i]); + i++; + } + } else { + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: messConfigGroup group nr no subscribables is null"); + } + } + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: adding subscribables to group: " + group.getAlias() + + " and nr of subscribables " + subscribables.size()); + } + group.setSubscribables(subscribables); + // dependencies + org.apache.stratos.cloud.controller.pojo.ConfigDependencies dep = gr.getDependencies(); + ConfigDependencies messDep = new ConfigDependencies(); + org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair [] pairs = dep.getStartup_order(); + List startup_order; + if (pairs != null) { + log.debug("TopolgyBuilder: number of startup pairs " + pairs.length); + startup_order = new ArrayList(pairs.length); + //for (org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair pair : pairs) { + for (int i = 0; i < pairs.length; i++) { + org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair pair = pairs[i]; + if (pair != null) { + ConfigDependencies.Pair messPair = new ConfigDependencies.Pair(pair.getKey(), pair.getValue()); + startup_order.add(messPair); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: adding dep pairs to group: " + pair.getKey() + " / " + + pair.getValue() + " at " + i); + } + } else { + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: Error while adding pair, pair is null"); + } + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: no dependencies added"); + } + startup_order = new ArrayList(0); + } + + messDep.setStartup_order(startup_order); + messDep.setKill_behavior(dep.getKill_behavior()); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: added kill behavior " + dep.getKill_behavior()); + } + group.setDependencies(messDep); + + messGroups.add(group); + if (log.isDebugEnabled()) { + log.debug("TopolgyBuilder: number of groups " + messGroups.size()); + } + } + messApp.setComponents(messGroups); + if (log.isDebugEnabled()) { + if (messApp.getComponents() != null) { + log.debug("TopolgyBuilder: added total nr of groups to application " + messApp.getComponents().size()); + } + else { + log.debug("TopolgyBuilder: added total nr of groups to application is null"); + } + } + + + /* test + ConfigGroup grX = new ConfigGroup(); + grX.setAlias("hug"); + List subX = new ArrayList(); + subX.add("cone"); + grX.setSubscribables(subX); + ConfigDependencies cgX = new ConfigDependencies(); + cgX.setKill_behavior("kill-all"); + log.debug("verifying cgX object serialization : " + Util.ObjectToJson(cgX)); + ConfigDependencies.Pair startup_orderX = new ConfigDependencies.Pair("eins", "zwei"); + List depspairsX = new ArrayList(); + depspairsX.add(startup_orderX); + log.debug("verifying depspairsX object serialization : " + Util.ObjectToJson(depspairsX)); + cgX.setStartup_order(depspairsX); + grX.setDependencies(cgX); + log.debug("verifying grX object serialization : " + Util.ObjectToJson(grX)); + messGroups.add(grX); + messApp.setComponents(messGroups); + log.debug("verifying messApp object serialization : " + Util.ObjectToJson(messApp)); + // + test end */ + + return messApp; + } + + /* + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (log.isDebugEnabled()) { + log.debug("processing application event of type " + type + + " / topology:" + topology + " msg: " + message); + } + + if (CompositeApplicationCreatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + + if (log.isDebugEnabled()) { + log.debug("topology is not initialized .... need to add check ... Grouping"); + } + + //return false; + } + + // Parse complete message and build event + CompositeApplicationCreatedEvent event = + (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("processing application created event with application id: " + event.getApplicationAlias()); + } + + // Validate event against the existing topology + if (topology.compositeApplicationExists(event.getApplicationAlias())) { + if (log.isWarnEnabled()) { + log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias())); + } + } else { + + ConfigCompositeApplication configApp = event.getCompositeApplication(); + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(configApp); + CompositeApplication app = new CompositeApplication(); + app.setAlias(configApp.getAlias()); + app.setTop_level(builder.buildApplication()); + String key = "compositeApplicationAlias"; //app.getAlias() + topology.addCompositeApplication(key ,app); + + if (log.isInfoEnabled()) { + log.info("CompositeApplication created with alias" +app.getAlias() + " and saved with key " + "compositeApplicationAlias" ); + log.info(String.format("CompositeApplication created: [app] %s", app.getTop_level())); + if (log.isDebugEnabled()) { + log.debug("verifying CompositeApplication object serialization : " + Util.ObjectToJson(app)); + } + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + */ } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 86237d8ef9..d4489b4c4c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -25,6 +25,7 @@ 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.ConfigCompositeApplication; import org.apache.stratos.messaging.domain.topology.Port; import org.apache.stratos.messaging.domain.topology.ServiceType; import org.apache.stratos.messaging.domain.topology.Topology; @@ -113,43 +114,62 @@ public static void sendMemberStartedEvent(InstanceStartedEvent instanceStartedEv MemberStartedEvent memberStartedEventTopology = new MemberStartedEvent(instanceStartedEvent.getServiceName(), instanceStartedEvent.getClusterId(), instanceStartedEvent.getNetworkPartitionId(), instanceStartedEvent.getPartitionId(), instanceStartedEvent.getMemberId()); + // grouping + memberStartedEventTopology.setGroupId(instanceStartedEvent.getGroupId()); if(log.isInfoEnabled()) { - log.info(String.format("Publishing member started event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s", - instanceStartedEvent.getServiceName(), instanceStartedEvent.getClusterId(), instanceStartedEvent.getNetworkPartitionId(), instanceStartedEvent.getPartitionId(), instanceStartedEvent.getMemberId())); + log.info(" Grouping member started event - adding groupID " + instanceStartedEvent.getGroupId() + " for cluster " + + instanceStartedEvent.getClusterId()); } + + if(log.isInfoEnabled()) { + log.info(String.format("Publishing member started event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", + memberStartedEventTopology.getServiceName(), memberStartedEventTopology.getClusterId(), memberStartedEventTopology.getNetworkPartitionId(), + memberStartedEventTopology.getPartitionId(), memberStartedEventTopology.getMemberId(), memberStartedEventTopology.getGroupId())); + } + publishEvent(memberStartedEventTopology); } public static void sendMemberActivatedEvent(MemberActivatedEvent memberActivatedEvent) { if(log.isInfoEnabled()) { - log.info(String.format("Publishing member activated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s", - memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId(), memberActivatedEvent.getNetworkPartitionId(), memberActivatedEvent.getPartitionId(), memberActivatedEvent.getMemberId())); + log.info(String.format("Publishing member activated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", + memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId(), memberActivatedEvent.getNetworkPartitionId(), + memberActivatedEvent.getPartitionId(), memberActivatedEvent.getMemberId(), memberActivatedEvent.getGroupId())); } publishEvent(memberActivatedEvent); } public static void sendMemberReadyToShutdownEvent(MemberReadyToShutdownEvent memberReadyToShutdownEvent) { if(log.isInfoEnabled()) { - log.info(String.format("Publishing member Ready to shut down event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s", - memberReadyToShutdownEvent.getServiceName(), memberReadyToShutdownEvent.getClusterId(), memberReadyToShutdownEvent.getNetworkPartitionId(), memberReadyToShutdownEvent.getPartitionId(), memberReadyToShutdownEvent.getMemberId())); + log.info(String.format("Publishing member Ready to shut down event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", + memberReadyToShutdownEvent.getServiceName(), memberReadyToShutdownEvent.getClusterId(), memberReadyToShutdownEvent.getNetworkPartitionId(), + memberReadyToShutdownEvent.getPartitionId(), memberReadyToShutdownEvent.getMemberId(), memberReadyToShutdownEvent.getGroupId())); } + // grouping + memberReadyToShutdownEvent.setGroupId(memberReadyToShutdownEvent.getGroupId()); publishEvent(memberReadyToShutdownEvent); } public static void sendMemberMaintenanceModeEvent(MemberMaintenanceModeEvent memberMaintenanceModeEvent) { if(log.isInfoEnabled()) { - log.info(String.format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s", - memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getNetworkPartitionId(), memberMaintenanceModeEvent.getPartitionId(), memberMaintenanceModeEvent.getMemberId())); + log.info(String.format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", + memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getNetworkPartitionId(), + memberMaintenanceModeEvent.getPartitionId(), memberMaintenanceModeEvent.getMemberId(), memberMaintenanceModeEvent.getGroupId())); } + publishEvent(memberMaintenanceModeEvent); } - public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { + public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, String groupId) { MemberTerminatedEvent memberTerminatedEvent = new MemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); + // grouping + memberTerminatedEvent.setGroupId(groupId); if(log.isInfoEnabled()) { - log.info(String.format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s", serviceName, clusterId, networkPartitionId, partitionId, memberId)); + log.info(String.format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", serviceName, clusterId, networkPartitionId, + partitionId, memberId, groupId)); } + publishEvent(memberTerminatedEvent); } @@ -161,6 +181,27 @@ public static void sendCompleteTopologyEvent(Topology topology) { } publishEvent(completeTopologyEvent); } + + // Grouping + public static void sendConfigApplicationCreatedEventEvent(ConfigCompositeApplication configCompositeApplication) { + + CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = new CompositeApplicationCreatedEvent(configCompositeApplication); + + if(log.isDebugEnabled()) { + log.debug(String.format("Publishing compositeApplicationCreatedEvent: " + compositeApplicationCreatedEvent)); + } + publishEvent(compositeApplicationCreatedEvent); + } + + public static void sendConfigApplicationRemovedEventEvent(String alias) { + + CompositeApplicationRemovedEvent compositeApplicationCreatedEvent = new CompositeApplicationRemovedEvent(alias); + + if(log.isDebugEnabled()) { + log.debug(String.format("Publishing compositeApplicationRemovedEvent: " + compositeApplicationCreatedEvent)); + } + publishEvent(compositeApplicationCreatedEvent); + } public static void publishEvent(Event event) { EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java index 9862b9a49d..bc0740477c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java @@ -81,6 +81,8 @@ public static Topology getTopology() { log.debug("Topology not found in registry, creating new"); } topology = new Topology(); + } else { + topology.getConfigCompositeApplication(); } if (log.isDebugEnabled()) { log.debug("Topology initialized"); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java index 3b81dc80f4..b96ea28b41 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerConstants.java @@ -142,6 +142,7 @@ public final class CloudControllerConstants { public static final String INSTANCE_TOPIC = "instance-status"; // pre define a floating ip public static final String FLOATING_IP_PROPERTY = "floatingIp"; + public static final String DEFAULT_FLOATING_IP_POOL = "defaultFloatingIpPool"; /** diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java index a213adf2ad..e770fd1d2e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java @@ -296,7 +296,9 @@ public static Properties toJavaUtilProperties( if (properties != null && properties.getProperties() != null) { for (org.apache.stratos.cloud.controller.pojo.Property property : properties.getProperties()) { - javaProps.put(property.getName(), property.getValue()); + if(property.getValue() != null){ + javaProps.put(property.getName(), property.getValue()); + } } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java new file mode 100644 index 0000000000..863169475f --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java @@ -0,0 +1,131 @@ +package org.apache.stratos.manager.application; + +import java.util.Collection; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.application.utils.ApplicationUtils; +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.messaging.domain.topology.ConfigCompositeApplication; + +//Grouping +public class CompositeApplicationManager { + + private static Log log = LogFactory.getLog(CompositeApplicationManager.class); + + public void deployCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { + if (log.isDebugEnabled()) { + log.debug("deploying composite application " + configCompositeApplication.getAlias()); + } + registerCompositeApplication(configCompositeApplication); + if (log.isDebugEnabled()) { + log.debug("publishing composite application " + configCompositeApplication.getAlias()); + } + ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication); + if (log.isDebugEnabled()) { + log.debug("composite application successfully deployed" + configCompositeApplication.getAlias()); + } + } + + public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { + if (log.isDebugEnabled()) { + log.debug("undeploying composite application " + configApplicationAlias); + } + // unregister application + unRegisterCompositeApplication(configApplicationAlias); + if (log.isDebugEnabled()) { + log.debug("publishing composite application removed event" + configApplicationAlias); + } + ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias); + if (log.isDebugEnabled()) { + log.debug("composite application successfully removed " + configApplicationAlias); + } + } + + private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { + + try { + if (log.isDebugEnabled()) { + log.debug("registering composite application " + configCompositeApplication.getAlias()); + } + DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + mgr.persistCompositeApplication ( configCompositeApplication); + + if (log.isDebugEnabled()) { + log.debug("testing to retrieve persisted composite application "); + Collection apps = mgr.getCompositeApplications(); + log.debug("retrieved persisted composite application " + apps.size()); + for (ConfigCompositeApplication app : apps) { + log.debug("retrieved persisted composite application " + app.getAlias()); + } + } + + } catch (PersistenceManagerException e) { + String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias(); + log.error(errorMsg); + throw new ADCException(errorMsg, e); + } + + log.info("Successfully registered composite application " + configCompositeApplication.getAlias()); + + } + + private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException { + + try { + if (log.isDebugEnabled()) { + log.debug("unregistering composite application " + configApplicationAlias); + } + DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + mgr.removeCompositeApplication(configApplicationAlias); + + if (log.isDebugEnabled()) { + log.debug("removed persisted composite application successfully"); + } + + } catch (PersistenceManagerException e) { + String errorMsg = "Error undeploying composite application " + configApplicationAlias; + log.error(errorMsg); + throw new ADCException(errorMsg, e); + } + + log.info("Successfully undeployed composite application " + configApplicationAlias); + + } + + public void restoreCompositeApplications () throws ADCException { + try { + if (log.isDebugEnabled()) { + log.debug("restoring composite applications " ); + } + DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + Collection apps = mgr.getCompositeApplications(); + + if (apps == null) { + if (log.isDebugEnabled()) { + log.debug("no composite application configured"); + } + return; + } + if (log.isDebugEnabled()) { + log.debug("retrieved persisted composite application " + apps.size()); + for (ConfigCompositeApplication app : apps) { + log.debug("retrieved persisted composite application " + app.getAlias()); + } + } + // sending application created event to restore in Toplogy + for (ConfigCompositeApplication app : apps) { + log.debug("restoring composite application " + app.getAlias()); + ApplicationUtils.publishApplicationCreatedEvent(app); + } + + } catch (PersistenceManagerException e) { + String errorMsg = "Error restoring composite application "; + log.error(errorMsg); + throw new ADCException(errorMsg, e); + } + } + +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java new file mode 100644 index 0000000000..d1634b0ce0 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java @@ -0,0 +1,104 @@ +package org.apache.stratos.manager.application.utils; + +import java.util.Set; +import java.util.concurrent.Executor; + +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.topology.CompositeApplicationCreatedEvent; +import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; +import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; + + +// Grouping +public class ApplicationUtils { + + private static Log log = LogFactory.getLog(ApplicationUtils.class); + + static class ApplicationCreatedEventPublisher implements Runnable { + + private ConfigCompositeApplication configCompositeApplication; + + public ApplicationCreatedEventPublisher(ConfigCompositeApplication configCompositeApplication) { + this.configCompositeApplication = configCompositeApplication; + + } + + @Override + public void run() { + try { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplication.getAlias())); + } + CompositeApplicationCreatedEvent event = new CompositeApplicationCreatedEvent(configCompositeApplication); + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); + eventPublisher.publish(event); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error(String.format("Could not publish tenant subscribed event: [application-alias] %s ", configCompositeApplication.getAlias()), e); + } + } + + } + + } + + public static void publishApplicationCreatedEvent(ConfigCompositeApplication configCompositeApplication) { + + + Executor exec = new Executor() { + @Override + public void execute(Runnable command) { + command.run(); + } + }; + + exec.execute(new ApplicationCreatedEventPublisher(configCompositeApplication)); + } + + + static class ApplicationRemovedEventPublisher implements Runnable { + + private String configCompositeApplicationAlias; + + public ApplicationRemovedEventPublisher(String configCompositeApplicationAlias) { + this.configCompositeApplicationAlias = configCompositeApplicationAlias; + + } + + @Override + public void run() { + try { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplicationAlias)); + } + CompositeApplicationRemovedEvent event = new CompositeApplicationRemovedEvent(configCompositeApplicationAlias); + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); + eventPublisher.publish(event); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error(String.format("Could not publish composite removed event event: [application-alias] %s ", configCompositeApplicationAlias), e); + } + } + + } + + } + + public static void publishApplicationUnDeployEvent(String configApplicationAlias) { + Executor exec = new Executor() { + @Override + public void execute(Runnable command) { + command.run(); + } + }; + + exec.execute(new ApplicationRemovedEventPublisher(configApplicationAlias)); + } + + +} 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 index 56f7e10342..40f61b2c3f 100644 --- 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 @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.client.CloudControllerServiceClient; @@ -114,7 +115,7 @@ protected PayloadData createPayload (CartridgeInfo cartridgeInfo, String subscri return payloadData; } - public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException { + 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 { @@ -129,7 +130,8 @@ public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData p cluster.getHostName(), autoscalePolicyName, deploymentPolicyName, - properties); + properties, + persistence); } public void remove(String clusterId, String alias) throws ADCException, NotSubscribedException { 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 df6625e968..1729d209c5 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,6 +30,7 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidClusterExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; @@ -93,9 +94,9 @@ public void unDeployCartridgeDefinition (String cartridgeType) throws RemoteExce } public boolean register(String clusterId, String cartridgeType, - String payload, String tenantRange, + String payload, String tenantRange, String hostName, Properties properties, - String autoscalorPolicyName, String deploymentPolicyName) throws RemoteException, + String autoscalorPolicyName, String deploymentPolicyName, Persistence persistence) throws RemoteException, CloudControllerServiceUnregisteredCartridgeExceptionException { Registrant registrant = new Registrant(); registrant.setClusterId(clusterId); @@ -106,10 +107,28 @@ public boolean register(String clusterId, String cartridgeType, registrant.setPayload(payload); registrant.setAutoScalerPolicyName(autoscalorPolicyName); registrant.setDeploymentPolicyName(deploymentPolicyName); + registrant.setPersistence(persistence); return stub.registerService(registrant); } + + public void deployCompositeApplicationDefinition (CompositeApplicationDefinition compositeApplicationDefinition) + throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException + { + + stub.deployCompositeApplicationDefinition(compositeApplicationDefinition); + + } + + + public void unDeployCompositeApplicationDefinition(String appAlias) throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException { + stub.unDeployCompositeApplicationDefinition(appAlias); + } + + + + @SuppressWarnings("unused") private Properties extractProperties(java.util.Properties properties) { 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 index adfe60fcf2..b73ccf62c4 100644 --- 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 @@ -81,7 +81,7 @@ protected String generateClusterId (String alias, String cartridgeType) { public void deploy (Properties properties) throws ADCException, UnregisteredCartridgeException { - register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(), properties); + register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(), properties, null); } public void undeploy () throws ADCException, NotSubscribedException { 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 index 5a16fc5f88..ec200f3391 100644 --- 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 @@ -46,6 +46,6 @@ public void deploy(Properties properties) throws ADCException, UnregisteredCartr //register the service loadBalancerCategory.register(getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), getDeploymentPolicyName(), - properties); + properties, null); } } 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 index 6857bd6b16..68f6a6e896 100644 --- 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 @@ -20,6 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.application.CompositeApplicationManager; +import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.listener.InstanceStatusListener; import org.apache.stratos.manager.publisher.TenantEventPublisher; import org.apache.stratos.manager.publisher.TenantSynchronizerTaskScheduler; @@ -108,6 +110,18 @@ protected void activate(ComponentContext componentContext) throws Exception { // retrieve persisted CartridgeSubscriptions new DataInsertionAndRetrievalManager().cachePersistedSubscriptions(); + + //Grouping + /* + if (log.isDebugEnabled()) { + log.debug("restoring composite applications ..."); + } + new CompositeApplicationManager().restoreCompositeApplications (); + + if (log.isDebugEnabled()) { + log.debug("done restoring composite applications ..."); + } + */ //Component activated successfully log.info("ADC management server component is activated"); 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 index e49dbde7c8..e1248830d2 100644 --- 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 @@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; @@ -94,13 +95,13 @@ public PayloadData create(String alias, Cluster cluster, Subscriber subscriber, } } - public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException { + 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); + super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, persistence); }else { log.info(" Default LB exists... Not registering..."); } 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 index b6ecfacf51..594ad4ca02 100644 --- 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 @@ -20,6 +20,7 @@ package org.apache.stratos.manager.lb.category; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; @@ -41,7 +42,7 @@ public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, return null; } - public void register (CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException { + public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { //TODO } 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 index fc47261f0e..e713d7d188 100644 --- 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 @@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; @@ -102,7 +103,7 @@ public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, } } - public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties) throws ADCException, UnregisteredCartridgeException { + public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { if (!serviceLbExists) { @@ -110,7 +111,7 @@ public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData p log.info("Payload: " + payloadData.getCompletePayloadData().toString()); } - super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties); + super.register(cartridgeInfo, cluster, payloadData, autoscalePolicyName, deploymentPolicyName, properties, persistence); }else { log.info("Service LB already exists for cartridge type: " + getLoadBalancedServiceType() + ", deployment policy: " + getDeploymentPolicyName()); } 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 index e7058f569d..88641fc86a 100644 --- 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 @@ -22,10 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dto.SubscriptionInfo; @@ -162,11 +159,11 @@ public SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subs if(log.isDebugEnabled()) { log.debug(" Registering LB Cartridge subscription "); } - registerCartridgeSubscription(lbCartridgeSubscription, lbCartridgeSubscriptionProperties); + registerCartridgeSubscription(lbCartridgeSubscription, lbCartridgeSubscriptionProperties, subscriptionData.getPersistence()); } // register service cartridge subscription - return registerCartridgeSubscription(serviceCartridgeSubscription, serviceCartridgeSubscriptionProperties); + return registerCartridgeSubscription(serviceCartridgeSubscription, serviceCartridgeSubscriptionProperties, subscriptionData.getPersistence()); } private boolean activeInstancesAvailable(SubscriptionData subscriptionData) { @@ -335,7 +332,15 @@ private CartridgeSubscription subscribe (SubscriptionData subscriptionData, Cart 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), property.getValue()); + } + } + } log.info("Tenant [" + subscriptionData.getTenantId() + "] with username [" + subscriptionData.getTenantAdminUsername() + " subscribed to " + "] Cartridge with Alias " + subscriptionData.getCartridgeAlias() + ", Cartridge Type: " + @@ -350,14 +355,15 @@ private CartridgeSubscription subscribe (SubscriptionData subscriptionData, Cart * * @param cartridgeSubscription CartridgeSubscription subscription * + * @param persistence * @return SubscriptionInfo object populated with relevant information * @throws ADCException * @throws UnregisteredCartridgeException */ - private SubscriptionInfo registerCartridgeSubscription(CartridgeSubscription cartridgeSubscription, Properties properties) + private SubscriptionInfo registerCartridgeSubscription(CartridgeSubscription cartridgeSubscription, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { - CartridgeSubscriptionInfo cartridgeSubscriptionInfo = cartridgeSubscription.registerSubscription(properties); + CartridgeSubscriptionInfo cartridgeSubscriptionInfo = cartridgeSubscription.registerSubscription(properties, persistence); //set status as 'SUBSCRIBED' cartridgeSubscription.setSubscriptionStatus(CartridgeConstants.SUBSCRIBED); @@ -464,7 +470,7 @@ private Properties getPersistenceMappingProperties (PersistenceContext persisten Properties persistenceMappingProperties = new Properties(); persistenceMappingProperties.setProperties(new Property[]{persistenceCtxt.getPersistanceRequiredProperty(), persistenceCtxt.getSizeProperty(), - persistenceCtxt.getDeleteOnTerminationProperty()}); + persistenceCtxt.getDeleteOnTerminationProperty(), persistenceCtxt.getVolumeIdProperty()}); return persistenceMappingProperties; } 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 index 59bf664269..aa38780943 100644 --- 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 @@ -20,30 +20,39 @@ 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 StringBuilder completePayloadDataBuilder; - + private Map completePayloadMap; public PayloadData(BasicPayloadData basicPayloadData) { this.setBasicPayloadData(basicPayloadData); - completePayloadDataBuilder = new StringBuilder(basicPayloadData.getPayloadData()); + completePayloadMap = new HashMap(); } public void add (String payloadDataName, String payloadDataValue) { - - if(completePayloadDataBuilder.length() > 0) { - completePayloadDataBuilder.append(","); - } - - completePayloadDataBuilder.append(payloadDataName + "=" + payloadDataValue); + completePayloadMap.put(payloadDataName, payloadDataValue); } public StringBuilder getCompletePayloadData () { - return completePayloadDataBuilder; + //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() { 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 index d971273d6f..d5712c340b 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import java.util.Collection; @@ -46,5 +47,13 @@ public abstract Collection getCartridgeSubscriptions(int public abstract Service getService (String cartridgeType) throws PersistenceManagerException; public abstract void removeService (String cartridgeType) throws PersistenceManagerException; + + //Grouping + public abstract void persistDeployedCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException; + + //Grouping + public abstract void removeDeployedCompositeApplication(String configCompositeApplicationAlias) throws PersistenceManagerException; + + public abstract Collection getDeployedCompositeApplications () throws PersistenceManagerException; } 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 index 6ecee93b7b..408c1bb392 100644 --- 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 @@ -27,6 +27,7 @@ import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.utils.Deserializer; import org.apache.stratos.manager.utils.Serializer; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; @@ -45,6 +46,7 @@ public class RegistryBasedPersistenceManager extends PersistenceManager { 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 COMPOSITE_APPLICATION = "/composite_applications"; @Override public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscription) throws PersistenceManagerException { @@ -216,6 +218,196 @@ public Collection getCartridgeSubscriptions (int tenantId return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + "/" + Integer.toString(tenantId)); } + + + //Grouping + public void persistDeployedCompositeApplication (ConfigCompositeApplication configCompositeAapplication) + throws PersistenceManagerException { + + if (log.isDebugEnabled()) { + log.debug("trying to persiste ConfigCompositeApplication [ " + configCompositeAapplication.getAlias() + " ]"); + } + 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); + + persistCompApplication(configCompositeAapplication); + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + + } else { + persistCompApplication(configCompositeAapplication); + } + } + + // Grouping + private void persistCompApplication (ConfigCompositeApplication configCompositeAapplication) throws PersistenceManagerException { + + // persist Service + try { + //RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + configCompositeAapplication.getAlias(), + RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + "compositeApplicationAlias", + Serializer.serializeServiceToByteArray(configCompositeAapplication), null); + + if (log.isDebugEnabled()) { + log.debug("Persisted ConfigCompositeApplication successfully: hardcoded [ " + configCompositeAapplication.getAlias() + " ]"); + } + + } catch (RegistryException e) { + throw new PersistenceManagerException(e); + + } catch (IOException e) { + throw new PersistenceManagerException(e); + } + } + + public void removeDeployedCompositeApplication(String configCompositeApplicationAlias) 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); + + if (log.isDebugEnabled()) { + log.debug("removing persisted ConfigCompositeApplication : [ " + configCompositeApplicationAlias + " ]"); + } + removeCompApplication(configCompositeApplicationAlias); + + if (log.isDebugEnabled()) { + log.debug("successfully removed persisted ConfigCompositeApplication : [ " + configCompositeApplicationAlias + " ]"); + } + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("removing persisted ConfigCompositeApplication 1 : [ " + configCompositeApplicationAlias + " ]"); + } + removeCompApplication(configCompositeApplicationAlias); + + if (log.isDebugEnabled()) { + log.debug("successfully removed persisted ConfigCompositeApplication 1 : [ " + configCompositeApplicationAlias + " ]"); + } + } + } + + + public Collection getDeployedCompositeApplications () throws PersistenceManagerException {; + if (log.isDebugEnabled()) { + log.debug("retrieving persisted ConfigCompositeApplication "); + } + + 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); + if (log.isDebugEnabled()) { + log.debug("traversing ConfigCompositeApplications "); + } + return traverseAndGetDeloyedCompositeApplication(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION); + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + + } else { + return traverseAndGetDeloyedCompositeApplication(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION); + } + + } + + + public Collection traverseAndGetDeloyedCompositeApplication (String resourcePath) throws PersistenceManagerException { + + if (log.isDebugEnabled()) { + log.debug("traverseAndGetDeloyedCompositeApplication: Root resource path: " + resourcePath); + } + + Object resourceObj; + + try { + resourceObj = RegistryManager.getInstance().retrieve(resourcePath); + if (log.isDebugEnabled()) { + log.debug("traversing com apps , retrieving resource: " + resourceObj); + } + + } catch (RegistryException e) { + throw new PersistenceManagerException(e); + } + + Collection comApps = new ArrayList(); + + 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[] compAppResourcePaths = (String[]) resourceObj; + if (log.isDebugEnabled()) { + for (String retrievedResourcePath : compAppResourcePaths) { + log.debug("Retrieved resource sub-path " + retrievedResourcePath); + } + } + + // traverse the paths recursively + for (String compAppResourcePath : compAppResourcePaths) { + + if (log.isDebugEnabled()) { + log.debug("Traversing resource path " + compAppResourcePath); + } + + comApps.addAll(traverseAndGetDeloyedCompositeApplication(compAppResourcePath)); + } + + } else { + // De-serialize + Object compAppObj; + + try { + compAppObj = 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 (compAppObj != null && compAppObj instanceof ConfigCompositeApplication) { + + ConfigCompositeApplication deserilizedCompApp = (ConfigCompositeApplication) compAppObj; + if (log.isDebugEnabled()) { + log.debug("Successfully de-serialized ConfigCompositeApplication: " + deserilizedCompApp.toString()); + } + + comApps.add(deserilizedCompApp); + + } + } + + // remove any nulls + comApps.removeAll(Collections.singleton(null)); + return comApps; + } + @Override public void persistService(Service service) throws PersistenceManagerException { @@ -445,5 +637,35 @@ private void removeDeployedService (String cartridgeType) throws PersistenceMana 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); + } + } } 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 index 386758febe..8250b3fd9c 100644 --- 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 @@ -27,6 +27,7 @@ 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.messaging.domain.topology.ConfigCompositeApplication; import java.util.Collection; import java.util.Set; @@ -334,4 +335,70 @@ public CartridgeSubscription getCartridgeSubscriptionForAlias (String subscripti LookupDataHolder.getInstance().releaseReadLock(); } } + + // Grouping + public void persistCompositeApplication (ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException { + + // get the write lock + //LookupDataHolder.getInstance().acquireWriteLock(); + + try { + // store in LookupDataHolder + //ToDo ... add to data holder + // LookupDataHolder.getInstance().putSubscription(cartridgeSubscription); + + try { + // store in Persistence Manager + persistenceManager.persistDeployedCompositeApplication(configCompositeApplication); + + } 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 + /* TODO + 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(); + } + } + + // Grouping + + public void removeCompositeApplication (String configCompositeApplicationAlias) throws PersistenceManagerException { + + LookupDataHolder.getInstance().acquireWriteLock(); + + try { + // remove from persistence manager + try { + persistenceManager.removeDeployedCompositeApplication(configCompositeApplicationAlias); + + } catch (PersistenceManagerException e) { + String errorMsg = "Error in removing Composite application from Persistence Manager"; + log.error(errorMsg, e); + throw e; + } + + } finally { + LookupDataHolder.getInstance().releaseWriteLock(); + } + } + + + // Grouping + + + public Collection getCompositeApplications() throws PersistenceManagerException { + + return persistenceManager.getDeployedCompositeApplications(); + } + + } 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 index e143bc3b64..b974f54128 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.Cluster; @@ -134,18 +135,19 @@ public void removeSubscription() throws ADCException, NotSubscribedException { * * @param properties Any additional properties needed * + * @param persistence * @return CartridgeSubscriptionInfo subscription populated with relevant data * @throws ADCException * @throws UnregisteredCartridgeException */ - public CartridgeSubscriptionInfo registerSubscription(Properties properties) + 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); + getDeploymentPolicyName(), properties, persistence); return ApplicationManagementUtil.createCartridgeSubscription(getCartridgeInfo(), getAutoscalingPolicyName(), getType(), getAlias(), getSubscriber().getTenantId(), getSubscriber().getTenantDomain(), 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 index 4cefa4587d..c97bcd3271 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.stratos.manager.subscription; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.DataCartridge; import org.apache.stratos.manager.exception.ADCException; @@ -54,11 +55,11 @@ public DataCartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenanc } @Override - public CartridgeSubscriptionInfo registerSubscription(Properties properties) throws ADCException, + public CartridgeSubscriptionInfo registerSubscription(Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { getSubscriptionTenancyBehaviour().register (getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), - getDeploymentPolicyName(), properties); + getDeploymentPolicyName(), properties, persistence); DataCartridge dataCartridge = new DataCartridge(); dataCartridge.setUserName(getDBUsername()); 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 index 3bad5fdce6..f6555f8689 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.exception.ADCException; @@ -80,13 +81,13 @@ public void createSubscription (Subscriber subscriber, String alias, String auto @Override - public CartridgeSubscriptionInfo registerSubscription(Properties properties) throws ADCException, UnregisteredCartridgeException { + 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); + getDeploymentPolicyName(), properties, persistence); } 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 index e3b4c13378..63a13a1fd2 100644 --- 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 @@ -30,11 +30,13 @@ public class PersistenceContext { 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(); } @@ -64,4 +66,13 @@ public void setDeleteOnTerminationProperty(String propertyName, String propertyV 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); + } } 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 index e267c24a28..0b257d5e7b 100644 --- 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 @@ -18,6 +18,8 @@ */ package org.apache.stratos.manager.subscription; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; /** @@ -38,10 +40,11 @@ public class SubscriptionData { private boolean isPrivateRepository; private String repositoryUsername; private String repositoryPassword; - private Property[] properties; private PersistenceContext persistanceCtxt; private boolean isCommitsEnabled; private String serviceGroup; + private Persistence persistence; + private Properties properties; public String getCartridgeType() { return cartridgeType; @@ -139,14 +142,6 @@ public void setRepositoryPassword(String repositoryPassword) { this.repositoryPassword = repositoryPassword; } - public Property[] getProperties() { - return properties; - } - - public void setProperties(Property[] properties) { - this.properties = properties; - } - public PersistenceContext getPersistanceContext() { return persistanceCtxt; } @@ -170,5 +165,20 @@ public String getServiceGroup() { public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } - + + 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; + } } 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 index 1b96734aed..664a2b3793 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.deploy.service.Service; @@ -111,8 +112,8 @@ public PayloadData create (String alias, Cluster cluster, Subscriber subscriber, return null; } - public void register (CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, - String deploymentPolicyName, Properties properties) + public void register(CartridgeInfo cartridgeInfo, Cluster cluster, PayloadData payloadData, String autoscalePolicyName, + String deploymentPolicyName, Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { //nothing to do 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 d0136f50a2..7282253d1e 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 @@ -36,6 +36,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; @@ -247,14 +248,14 @@ public static SubscriptionInfo createSubscriptionResponse(CartridgeSubscriptionI public static void registerService(String cartridgeType, String domain, String subDomain, - StringBuilder payload, String tenantRange, String hostName, - String autoscalingPoliyName, String deploymentPolicyName, - Properties properties) + StringBuilder payload, String tenantRange, String hostName, + String autoscalingPoliyName, String deploymentPolicyName, + Properties properties, Persistence persistence) throws ADCException, UnregisteredCartridgeException { log.info("Register service.."); try { CloudControllerServiceClient.getServiceClient().register(domain, cartridgeType, payload.toString(), tenantRange, - hostName, properties, autoscalingPoliyName, deploymentPolicyName ); + hostName, properties, autoscalingPoliyName, deploymentPolicyName, persistence ); } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { String msg = "Exception is occurred in register service operation. Reason :" + e.getMessage(); log.error(msg, e); 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 index fa56b244dc..d31b1a17c8 100644 --- 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 @@ -22,6 +22,7 @@ import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.lookup.ClusterIdToSubscription; import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -101,4 +102,25 @@ public static byte[] serializeServiceToByteArray(Service service) } } + + // Grouping + public static byte[] serializeServiceToByteArray(ConfigCompositeApplication configCompositeApplication) + throws IOException { + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutput out = null; + try { + out = new ObjectOutputStream(bos); + out.writeObject(configCompositeApplication); + + return bos.toByteArray(); + + } finally { + if (out != null) { + out.close(); + } + bos.close(); + } + + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java new file mode 100644 index 0000000000..55d99f0f81 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java @@ -0,0 +1,81 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class Cartridge implements Subscribable, Scalable { + + private String alias; // type + private String cartridgeId; + private Dependencies dependencies; + private Subscribable parent; + private Group homeGroup; + private static final Log log = LogFactory.getLog(Cartridge.class); + + public Cartridge(String alias) { + this.alias = alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getAlias() { + return alias; + } + + public String getCartridgeId() { + return cartridgeId; + } + + public void setCartridgeId(String cartridgeId) { + this.cartridgeId = cartridgeId; + } + + public Subscribable getParent() { + return parent; + } + + public Group getHomeGroup() { + return homeGroup; + } + + public void setHomeGroup(Group homeGroup) { + this.homeGroup = homeGroup; + } + + public void setParent(Subscribable parent) { + this.parent = parent; + } + + public Dependencies getDependencies() { + return dependencies; + } + + public List getAllDependencies() { + return new ArrayList(0); + } + + public void setDependencies(Dependencies dependencies) { + this.dependencies = dependencies; + } + + public void subscribe() { + } + + public void unsubscribe() { + } + + public String toString() { + String result = ""; + result = alias; + if (dependencies != null) { + result = result + " dependencies:" + dependencies.toString(); + } + return result; + } + +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Composite.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Composite.java new file mode 100644 index 0000000000..8b0d75d14a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Composite.java @@ -0,0 +1,15 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.util.List; + +public interface Composite { + + public void add(Subscribable subscribable); + + public void remove(Subscribable subscribable); + + public Subscribable getParent(); + + public void setParent(Subscribable subscribable); + +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java new file mode 100644 index 0000000000..c63f448926 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java @@ -0,0 +1,290 @@ +/* + * 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.messaging.domain.topology; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + + + +/** + * Defines a topology of serviceMap in Stratos. + */ +// Grouping +public class CompositeApplication implements Serializable { + private static final long serialVersionUID = -1L; + // Key: Service.serviceName + private String alias; + private Group top_level; + private Map all_groups = null; + private static final Log log = LogFactory.getLog(CompositeApplication.class); + + public CompositeApplication() { + + } + + public String getAlias() { + return alias; + } + + + public void setAlias(String alias) { + this.alias = alias; + } + + /* + public Group getTop_level() { + return this.top_level; + }*/ + /* + public void setTop_level(Group top_level) { + this.top_level = top_level; + } */ + + + public Map getAll_groups() { + return all_groups; + } + + public void setAll_groups(Map all_groups) { + this.all_groups = all_groups; + } + + + public List findAllGroupsForServiceType(String serviceType) { + Set group_names = this.all_groups.keySet(); + List found_groups = new ArrayList(); + + for (String group_name: group_names) { + Group gr = this.all_groups.get(group_name); + Subscribable sub = gr.getSubscribable(serviceType); + if (sub != null) { + found_groups.add(gr); + } + } + + return found_groups; + } + + public Group getGroupFromGroupAlias(String alias) { + return this.all_groups.get(alias); + } + + + public String [] getDependencies (String alias, boolean kill_flag) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.top_level); + } + + String [] dependenciesAliasArray = null; + List results = null; + if (kill_flag && top_level.getDependencies().getKill_behavior().equals("kill-all")) { + if (log.isDebugEnabled()) { + log.debug("kill-all: returning all dependencies for " + alias); + } + + results = top_level.getAllDependencies(); + dependenciesAliasArray = new String [results.size()]; + } else { + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.top_level.getDependencies(); + results = group_deps.getDependencies(alias, kill_flag); + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + dependenciesAliasArray[i] = s.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " to dependency array"); + } + } + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependenciesAliasArray; + } + + public String [] getDownStreamDependencies (String alias) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.top_level); + } + + String [] dependenciesAliasArray = null; + List results = null; + + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.top_level.getDependencies(); + results = group_deps.getDownStreamDependents(alias); + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + dependenciesAliasArray[i] = s.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " to dependency array"); + } + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependenciesAliasArray; + } + + public String extractClusterGroupFromClusterId (String clusterId) { + String sub1 = extractAlias(clusterId); + if (sub1 == null) { + return null; + } + + String [] s = sub1.split("-"); + if (log.isDebugEnabled()) { + log.debug("clusterGroup alias is " + sub1 + " size: " + s.length); + } + if (s.length == 0) { + return null; + } + if (log.isDebugEnabled()) { + log.debug("cluster " + clusterId + " is in group " + s[0]); + } + return s[0]; + } + + private String extractAlias (String clusterId) { + String [] s = clusterId.split("\\."); + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " size: " + s.length); + } + if (s.length == 0) { + return null; + } + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " alias: " + s[0]); + } + return s[0]; + } + + + /* + public String [] getUpstreamDependencies (String alias) { + String [] dependenciesAliasArray = new String[0]; + if (log.isDebugEnabled()) { + log.debug("searching home group for : " + alias); + } + Group gr = getTop_level().findGroup(alias); + if (gr == null) { + if (log.isDebugEnabled()) { + log.debug("no home group found for : " + alias); + } + return dependenciesAliasArray; + } + Subscribable sub = gr.getSubscribable(alias); + if (log.isDebugEnabled()) { + log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); + } + //List results = gr.getUpstreamDependencies(sub); + List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); + if (log.isDebugEnabled()) { + log.debug("home group upstream result for : " + alias + " is " + results.size()); + } + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++) { + Subscribable item = results.get(i); + if (item != null) { + dependenciesAliasArray[i] = item.getAlias(); + } else { + if (log.isDebugEnabled()) { + log.debug("dependenciesAliasArray in getUpstreamDependencies has null value"); + dependenciesAliasArray[i] = null; + } + } + } + return dependenciesAliasArray; + } */ + + public String extractAliasFromClusterId (String clusterId) { + String [] s = clusterId.split("\\."); + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " size: " + s.length); + } + if (s.length == 0) { + return null; + } + if (log.isDebugEnabled()) { + log.debug("clusterId alias is " + clusterId + " alias: " + s[0]); + } + return s[0]; + } + + /* + public String [] getAllInPathOf(String aServiceId) { + // check kill_all_enabled flag + String [] upstreamDependencies = this.getUpstreamDependencies(aServiceId); + String [] downstreamDependencies = this.getDownStreamDependencies(aServiceId); + + List all = new ArrayList(upstreamDependencies.length + downstreamDependencies.length + 1); + for (String str : upstreamDependencies) { + all.add(str); + } + for (String str : downstreamDependencies) { + all.add(str); + } + all.add(aServiceId); + String [] arrayAll = new String[all.size()]; + arrayAll = all.toArray(arrayAll); + return arrayAll; + } */ + + public Map getAllInPathOfAsMap(String aServiceId, Group home_group) { + // check kill_all_enabled flag + Map upstreamDependencies = home_group.getUpstreamDependenciesAsMap(aServiceId); + Map downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); + + Map all = new HashMap(); + all.putAll(upstreamDependencies); + all.putAll(downstreamDependencies); + + all.put(aServiceId, home_group.getAlias()); + + return all; + } + + + @Override + public String toString() { + String result = "compositeApplication [" + alias + "]"; + if (top_level != null) { + result = result + top_level.toString(); + } + return result; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCartridge.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCartridge.java new file mode 100644 index 0000000000..ad494ee016 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCartridge.java @@ -0,0 +1,20 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; + + +public class ConfigCartridge implements Serializable { + /** + * + */ + private static final long serialVersionUID = 1L; + private String alias; + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java new file mode 100644 index 0000000000..eb0564b3b6 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java @@ -0,0 +1,42 @@ +package org.apache.stratos.messaging.domain.topology; + + +import java.io.Serializable; +import java.util.List; + + + +public class ConfigCompositeApplication implements Serializable { + + private String applicationId; + private String alias; + private List components; + private List cartridges; + + public String getApplicationId() { + return applicationId; + } + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public List getComponents() { + return components; + } + public void setComponents(List components) { + this.components = components; + } + public List getCartridges() { + return cartridges; + } + public void setCartridges(List cartridges) { + this.cartridges = cartridges; + } + + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigDependencies.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigDependencies.java new file mode 100644 index 0000000000..f8281d92a3 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigDependencies.java @@ -0,0 +1,57 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + + +public class ConfigDependencies implements Serializable { + private static final long serialVersionUID = 1L; + private List startup_order = new ArrayList(); + private String kill_behavior; + + + public String getKill_behavior() { + return kill_behavior; + } + + public void setKill_behavior(String kill_behavior) { + this.kill_behavior = kill_behavior; + } + + public List getStartup_order() { + return startup_order; + } + + public void setStartup_order(List startup_order) { + this.startup_order = startup_order; + } + + + + public static class Pair implements Serializable { + private String key; + private String value; + + private Pair() {} + + public Pair(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigGroup.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigGroup.java new file mode 100644 index 0000000000..25b4991302 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigGroup.java @@ -0,0 +1,33 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; +import java.util.List; + + +public class ConfigGroup implements Serializable { + private static final long serialVersionUID = 1L; + private String alias; + private List subscribables; + private ConfigDependencies dependencies; + + + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public List getSubscribables() { + return subscribables; + } + public void setSubscribables(List subscribables) { + this.subscribables = subscribables; + } + public ConfigDependencies getDependencies() { + return dependencies; + } + public void setDependencies(ConfigDependencies dependencies) { + this.dependencies = dependencies; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java new file mode 100644 index 0000000000..7e97143434 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java @@ -0,0 +1,334 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class Dependencies implements Serializable{ + + /** + * + */ + private static final long serialVersionUID = 1L; + private Map> dependencies = new HashMap>(); + private String kill_behavior = KILL_UNDEFINED; + private boolean isKillAllEnabled = false; + private Group group; + private static final Log log = LogFactory.getLog(Dependencies.class); + public static String KILL_NONE = "kill-none"; + public static String KILL_ALL = "kill-all"; + public static String KILL_DEPENDENTS = "kill-dependents"; + public static String KILL_UNDEFINED = "kill-undefined"; + + + public String getKill_behavior() { + return kill_behavior; + } + + public void enableKillAll() { + isKillAllEnabled = true; + } + + public void disableKillAll() { + isKillAllEnabled = false; + } + + public boolean isKillAllEnabled() { + return isKillAllEnabled; + } + + public String getKill_behavior_for_alias(String alias) { + if (dependencies.containsKey(alias)) { + return kill_behavior; + } + return KILL_UNDEFINED; + } + + public void setKill_behavior(String kill_behavior) { + this.kill_behavior = kill_behavior; + } + + public void addDependency (String alias, Subscribable dependency) { + List my_dep = dependencies.get(alias); + if (my_dep != null) { + log.debug(" adding another dependency " + dependency.getAlias() + " for " + alias); + my_dep.add(dependency); + } else { + log.debug("initializing dependency list for " + alias + " with dependency " + dependency.getAlias() ); + my_dep = new ArrayList(); + my_dep.add(dependency); + dependencies.put(alias, my_dep); + } + } + + + public List getDependencies(Subscribable subscribable, boolean kill_flag) { + String alias = subscribable.getAlias(); + return getDependencies(alias, kill_flag); + } + + public List getDependencies(String alias, boolean kill_flag) { + if (log.isDebugEnabled()) { + log.debug("checking dependency tree for " + alias + " kill_flag is " + kill_flag); + } + + if (kill_flag) { + if (kill_behavior.equals("kill-none")) { + if (log.isDebugEnabled()) { + log.debug(KILL_NONE + ": returning none dependencies for " + alias); + } + return new ArrayList(0); + } else if (kill_behavior.equals("KILL_DEPENDENTS")) { + if (log.isDebugEnabled()) { + log.debug(KILL_DEPENDENTS + ": returning all dependencies for " + alias); + } + return getDependents (alias, kill_flag); + } + log.error("invalid kill option:" + kill_behavior + "rwhile checking dependencies for " + alias); + } + // kill_flag false, get "startup dependencies" + return getDependents (alias, false); + } + + + public List getDownStreamDependents (String alias) { + List results = new ArrayList(); + if (log.isDebugEnabled()) { + log.debug("in dependency tree for " + alias + " / " + dependencies.size()); + } + if (dependencies.containsKey(alias)) { + log.debug("adding the list of dependencies for :" + alias); + List my_dep = dependencies.get(alias); + Iterator it = my_dep.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + if (obj instanceof Scalable) { + log.debug("adding scalable " + obj.getAlias() + " as dependency for " + alias); + results.add(obj); + log.debug("adding subsequent downstream dependencies for " + obj.getAlias() + " as dependency for " + alias); + List sub2 = this.getDownStreamDependents(obj.getAlias()); + results.addAll(sub2); + if (log.isDebugEnabled()) { + log.debug("added " + sub2.size() + " elements as subsequent downstream dependencies for " + obj.getAlias() + + " as dependency for " + alias); + } + } else { + log.debug("adding nested dependencies from " + obj.getAlias() + " for " + alias); + List sub_results = obj.getAllDependencies(); + results.addAll(sub_results); + } + } + } else { + log.debug("continue to check nested dependencies for :" + alias); + // convert map to List + Set keys = dependencies.keySet(); + for (String key : keys) { + if (log.isDebugEnabled()) { + log.debug("looping over dependency list with key:" + key + " for alias " + alias); + } + List my_dep = dependencies.get(key); + if (my_dep != null) { + Iterator it = my_dep.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + Dependencies deps = obj.getDependencies(); + if (deps != null) { + if (log.isDebugEnabled()) { + log.debug("found nested nested dependencies while looping with key:" + key + " for alias " + alias); + } + results = deps.getDownStreamDependents(alias); + } + } + } + } + } + return results; + } + + private List getDependents (String alias, boolean kill_flag) { + List results = new ArrayList(); + if (log.isDebugEnabled()) { + log.debug("in dependency tree for " + alias + " kill_flag is " + kill_flag + " / " + dependencies.size()); + } + if (dependencies.containsKey(alias)) { + log.debug("adding the list of dependencies for :" + alias); + List my_dep = dependencies.get(alias); + Iterator it = my_dep.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + if (obj instanceof Scalable) { + log.debug("adding scalable " + obj.getAlias() + " as dependency for " + alias); + results.add(obj); + } else { + log.debug("adding nested dependencies from " + obj.getAlias() + " for " + alias); + List sub_results = obj.getAllDependencies(); + results.addAll(sub_results); + } + } + } else { + log.debug("continue to check nested dependencies for :" + alias); + // convert map to List + Set keys = dependencies.keySet(); + for (String key : keys) { + if (log.isDebugEnabled()) { + log.debug("looping over dependency list with key:" + key + " for alias " + alias); + } + List my_dep = dependencies.get(key); + if (my_dep != null) { + Iterator it = my_dep.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + Dependencies deps = obj.getDependencies(); + if (deps != null) { + if (log.isDebugEnabled()) { + log.debug("found nested nested dependencies while looping with key:" + key + " for alias " + alias); + } + results = deps.getDependencies(alias, kill_flag); + } + } + } + } + } + + + return results; + } + + public List getUpstreamDependents (String alias) { + List results = new ArrayList(); + Set keys = dependencies.keySet(); + for (String key : keys) { + if (log.isDebugEnabled()) { + log.debug("looping over dependency list with key:" + key + " for alias " + alias + + " in group " + this.getGroup().getAlias()); + } + List my_dep = dependencies.get(key); + if (my_dep != null) { + Iterator it = my_dep.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + if (alias.equals(obj.getAlias())) { + //results.add(obj); + // adding "key" + Subscribable key_upstreamdep = this.group.getSubscribable(key); + if (log.isDebugEnabled()) { + log.debug("adding subscribalbe " + key_upstreamdep.getAlias() + " to upstream dependency list"); + } + results.add(key_upstreamdep); + if (log.isDebugEnabled()) { + log.debug("adding subsequent upstream dependencies for " + key_upstreamdep.getAlias() + + " as dependency for " + alias); + } + List sub2 = this.getUpstreamDependents(key); + results.addAll(sub2); + if (log.isDebugEnabled()) { + log.debug("added " + sub2.size() + " elements as subsequent upstream dependencies for " + key_upstreamdep.getAlias() + + " as dependency for " + alias); + } + } + + } + } + } + // get upstream subscribables which have group as dependency + Subscribable parent = group.getParent(); + if (parent instanceof Group) { + Group gr = (Group)parent; + List results2 = gr.getUpstreamDependencies(this.group); + for (Subscribable s : results2) { + if (!results.contains(s)) { + results.add(s); + } + } + if (log.isDebugEnabled()) { + log.debug("added " + results2.size() + " elements as subsequent upstream dependencies for " + this.group.getAlias() + + " as dependency for " + alias); + } + + } + + return results; + + } + + /* + public List getAllDependencies() { + List results = new ArrayList(); + + if (log.isDebugEnabled()) { + log.debug("adding all nested dependencies to result list"); + } + + Set keys = dependencies.keySet(); + if (log.isDebugEnabled()) { + log.debug("adding all nested dependencies to result list with number of keys " + keys.size()); + } + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + List values = dependencies.get(key); + + Iterator it = values.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + if (obj instanceof Scalable) { + if (log.isDebugEnabled()) { + log.debug("adding scalable / cartridge " + obj.getAlias() + " to result list"); + } + results.add(obj); + } else { + if (log.isDebugEnabled()) { + log.debug("adding nested dependencies to result list"); + } + List sub_results = obj.getDependencies().getAllDependencies(); + results.addAll(sub_results); + } + } + + } + + return results; + } */ + + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + + public String toString() { + String result = ""; + StringBuffer buf = new StringBuffer(); + + Set keys = dependencies.keySet(); + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + buf.append("Key:" + key).append(" "); + List values = dependencies.get(key); + + Iterator it = values.iterator(); + while (it.hasNext()) { + Subscribable obj = it.next(); + buf.append("value:" + obj.getAlias()).append(" "); + } + } + + + return buf.toString(); + } + +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java new file mode 100644 index 0000000000..fd76bfb795 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -0,0 +1,503 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; + +public class Group implements Subscribable,Composite, Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String alias; + private Map subscribables = new HashMap(); + private Dependencies dependencies; + private Subscribable parent = null; + private Group homeGroup; + private static final Log log = LogFactory.getLog(Group.class); + + public Group(String alias) { + this.alias = alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getAlias() { + return alias; + } + + public Map getSubscribables() { + return subscribables; + } + + public Subscribable getSubscribable(String alias) { + return subscribables.get(alias); + } + + public Subscribable getParent() { + return parent; + } + + public Group getHomeGroup() { + return homeGroup; + } + + public void setHomeGroup(Group homeGroup) { + this.homeGroup = homeGroup; + } + + public void setParent(Subscribable parent) { + this.parent = parent; + } + + public String getKillBehaviorForAlias(String alias) { + if (this.dependencies != null) { + return this.dependencies.getKill_behavior_for_alias(alias); + } else { + return Dependencies.KILL_UNDEFINED; + } + } + + public String findKillBehavior(String alias) { + + List all_groups = getAllGroups(); + String kill_behavior = Dependencies.KILL_UNDEFINED; + + if (log.isDebugEnabled()) { + log.debug("searching kill behavior for " + alias + " in group " + this.alias); + } + + for (Group group : all_groups) { + kill_behavior = group.getKillBehaviorForAlias(alias); + if (Dependencies.KILL_UNDEFINED.equals(kill_behavior)) { + if (log.isDebugEnabled()) { + log.debug("kill behavior for " + alias + " in group " + this.alias + " is undefined"); + } + } else { + if (log.isDebugEnabled()) { + log.debug("found kill behavior for " + alias + " in group " + this.alias); + } + return group.getKillBehaviorForAlias(alias); + } + } + return dependencies.getKill_behavior(); + } + + public List getAllGroups () { + List results = new ArrayList(); + // adding the group to list + results.add(this); + Set keys = subscribables.keySet(); + if (log.isDebugEnabled()) { + log.debug("adding all nested groups to result list with number of keys " + keys.size() + " in group " + this.alias); + } + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + Object obj = subscribables.get(key); + if (!(obj instanceof Group)) { + if (log.isDebugEnabled()) { + log.debug("skipping non composite obj " + obj); + } + + } else { + + Group group = (Group) obj; + if (log.isDebugEnabled()) { + log.debug("adding nested groups / composite to result list " + group.getAlias()); + } + List sub_results = group.getAllGroups(); + results.addAll(sub_results); + } + } + + return results; + } + + public Dependencies findDependencies(String alias) { + Group gr = findGroup(alias); + if (gr !=null) { + return gr.dependencies; + } + return null; + } + + public Group findGroup(String alias) { + List all_groups = getAllGroups(); + for (Group group : all_groups) { + if (log.isDebugEnabled()) { + log.debug("findGroup in group " + group.getAlias() + " for alias " + alias); + } + if (group.subscribables.containsKey(alias)) { + return group; + } else { + // does it need to be checked ? + } + } + + return null; + } + + // returns all groups which equal the kill_behavior as parameter + public String [] findAllGroupsWithKill(String [] aliases, String kill_behavior) { + List results = new ArrayList(); + for (String alias : aliases) { + Group gr = findGroup(alias); + // no null check, shouldn't be null + if (gr != null) { + Dependencies dep = gr.getDependencies(); + if (dep != null) { + if (kill_behavior.equals(dep.getKill_behavior())) { + results.add(gr.getAlias()); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("no group found for alias " + alias); + } + } + } + String [] arr = new String[results.size()]; + arr = results.toArray(arr); + return arr; + } + + public String [] findAllGroupsWithKill2(Map aliasesMap, String kill_behavior) { + List results = new ArrayList(); + Set aliases = aliasesMap.keySet(); + for (String alias : aliases) { + Group gr = findGroup(alias); + // no null check, shouldn't be null + if (gr != null) { + Dependencies dep = gr.getDependencies(); + if (dep != null) { + if (kill_behavior.equals(dep.getKill_behavior())) { + results.add(gr.getAlias()); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("no group found for alias " + alias); + } + } + } + String [] arr = new String[results.size()]; + arr = results.toArray(arr); + return arr; + } + + + public Dependencies getDependencies() { + return dependencies; + } + + public List getAllDependencies() { + List results = new ArrayList(); + + if (log.isDebugEnabled()) { + log.debug("adding all nested subscribables to result list in subscribable " + this.alias); + } + + Set keys = subscribables.keySet(); + if (log.isDebugEnabled()) { + log.debug("adding all nested dependencies to result list with number of keys " + keys.size()); + } + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + Subscribable obj = subscribables.get(key); + if (obj instanceof Scalable) { + if (log.isDebugEnabled()) { + log.debug("adding scalable / cartridge " + obj.getAlias() + " to result list"); + } + results.add(obj); + } else { + if (log.isDebugEnabled()) { + log.debug("adding nested dependencies to result list"); + } + List sub_results = obj.getAllDependencies(); + results.addAll(sub_results); + } + } + if (log.isDebugEnabled()) { + log.debug("returning " + results.size() + " subscribables while getting all dependent subscribables "); + } + return results; + } + + public String [] getDownStreamDependenciesAsArray (String alias) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.getAlias()); + } + + String [] dependenciesAliasArray = null; + List results = null; + + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.getDependencies(); + results = group_deps.getDownStreamDependents(alias); + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + dependenciesAliasArray[i] = s.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " to dependency array"); + } + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependenciesAliasArray; + } + + public Map getDownStreamDependenciesAsMap (String alias) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.getAlias()); + } + + Map dependencies_map= null; + List results = null; + + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.getDependencies(); + results = group_deps.getDownStreamDependents(alias); + dependencies_map = new HashMap(results.size()); + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + + Group gr = s.getHomeGroup(); // TODO - need to change return type to Group + String gr_alias = null; + if (gr != null) { + gr_alias = gr.getAlias(); + } else { + if (log.isDebugEnabled()) { + log.debug("home group is null for subscribable " + s.getAlias()); + } + } + dependencies_map.put(s.getAlias(), gr_alias); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " in group " + gr_alias + " to downstream dependency map "); + } + + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependencies_map; + } + + public String [] getUpstreamDependenciesAsArray (String alias) { + String [] dependenciesAliasArray = new String[0]; + if (log.isDebugEnabled()) { + log.debug("searching home group for : " + alias); + } + Group gr = this; + Subscribable sub = gr.getSubscribable(alias); + if (log.isDebugEnabled()) { + log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); + } + //List results = gr.getUpstreamDependencies(sub); + List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); + if (log.isDebugEnabled()) { + log.debug("home group upstream result for : " + alias + " is " + results.size()); + } + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++) { + Subscribable item = results.get(i); + if (item != null) { + dependenciesAliasArray[i] = item.getAlias(); + } else { + if (log.isDebugEnabled()) { + log.debug("dependenciesAliasArray in getUpstreamDependencies has null value"); + dependenciesAliasArray[i] = null; + } + } + } + return dependenciesAliasArray; + } + + public Map getUpstreamDependenciesAsMap (String alias) { + if (log.isDebugEnabled()) { + log.debug("searching home group for : " + alias); + } + Group gr = this; + Map dependencies_map = null; + Subscribable sub = gr.getSubscribable(alias); + if (log.isDebugEnabled()) { + log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); + } + + List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); + if (log.isDebugEnabled()) { + log.debug("home group upstream result for : " + alias + " is " + results.size()); + } + dependencies_map = new HashMap(results.size()); + for (int i = 0; i < results.size(); i++) { + Subscribable s = results.get(i); + if (s != null) { + Group home_gr = s.getHomeGroup(); // TODO - need to change return type to Group + String key = null; + String val = null; + if (home_gr != null) { + key = s.getAlias(); + val = home_gr.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + key + " in group " + val + " to upstream dependency map "); + } + dependencies_map.put(key, val); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("dependenciesAliasMap in getUpstreamDependencies has null value"); + } + } + + + } + return dependencies_map; + } + + public List getUpstreamDependencies(Subscribable subscribable) { + List upstream = new ArrayList(); + Subscribable parentSubscribable = this.getParent(); + if (log.isDebugEnabled()) { + log.debug("getting upstream dependencies for " + subscribable.getAlias() + " in group " + this.alias); + } + if (subscribable instanceof Scalable) { + // this would be typically where the upstream search starts + if (log.isDebugEnabled()) { + log.debug("subscribable is cartridge with alias " + subscribable.getAlias() + " in group " + this.alias); + } + if (parent == null) { + if (log.isDebugEnabled()) { + log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); + } + return upstream; + } else if (parent instanceof Group) { + + Group parentGroup = (Group) parentSubscribable; + if (log.isDebugEnabled()) { + log.debug("continue upstream search in parent group " + parentGroup.alias + " for " + alias ); + } + // continue with group alias as dependency alias (dependent would be group) + List list = parentGroup.getUpstreamDependencies(this); + if (log.isDebugEnabled()) { + log.debug("found " + list.size() + " items in upstream search in parent group " + parentGroup.alias + " for " + alias ); + } + upstream.addAll(list); + } + } else if (subscribable instanceof Group) { + // get local dependencies + if (log.isDebugEnabled()) { + log.debug(subscribable.getAlias() + " is a group, checking in dependencies list of this group " + this.alias + " for " + alias ); + } + List listlocal = dependencies.getUpstreamDependents(subscribable.getAlias()); + if (log.isDebugEnabled()) { + log.debug("found " + listlocal.size() + " items in upstream search in group " + this.alias + " for " + alias ); + } + // add local cartridges which depend on the group + upstream.addAll(listlocal); + // continue upstream with parent of this group + Subscribable parent = this.getParent(); + if (parent == null) { + if (log.isDebugEnabled()) { + log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); + } + return upstream; + } else if (parent instanceof Group) { + if (log.isDebugEnabled()) { + log.debug("continue upstream search in parent group " + parent.getAlias() + " for " + alias ); + } + // continue with group alias as dependency alias (dependent would be group) + List list = ((Group) parent).getUpstreamDependencies(this); + if (log.isDebugEnabled()) { + log.debug("found " + list.size() + " items in upstream search in parent group " + parent.getAlias() + " for " + alias ); + } + // merge upstream dependencies and local dependencies + upstream.addAll(list); + } + + } + return upstream; + } + + public void setDependencies(Dependencies dependencies) { + this.dependencies = dependencies; + } + + + + + + @Override + public void subscribe() { + // TODO Auto-generated method stub + log.debug("subscribing to group: " + alias); + + Iterator it = subscribables.keySet().iterator(); + + while (it.hasNext()) { + String key = it.next(); + Subscribable subscribable = subscribables.get(key); + subscribable.subscribe(); + } + + } + + @Override + public void unsubscribe() { + // TODO Auto-generated method stub + + } + + @Override + public void add(Subscribable subscribale) { + // TODO Auto-generated method stub + if (log.isDebugEnabled()) { + log.debug("building the group, adding subscribable " + subscribale.getAlias() + " to group " + this.getAlias()); + } + subscribables.put(subscribale.getAlias(), subscribale); + } + + @Override + public void remove(Subscribable subscribale) { + // TODO Auto-generated method stub + subscribables.remove(subscribale.getAlias()); + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + Iterator it = subscribables.keySet().iterator(); + + while (it.hasNext()) { + String key = it.next(); + Subscribable subscribable = subscribables.get(key); + buf.append("subscribable: " + subscribable.toString()); + + } + return buf.toString(); + } + + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scalable.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scalable.java new file mode 100644 index 0000000000..ba4c000a87 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Scalable.java @@ -0,0 +1,5 @@ +package org.apache.stratos.messaging.domain.topology; + +public interface Scalable { + +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java new file mode 100644 index 0000000000..4f0245f4b1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java @@ -0,0 +1,25 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.util.List; + + + +public interface Subscribable { + + + + public String getAlias(); + + public Dependencies getDependencies(); + + public List getAllDependencies(); + + public void subscribe(); + + public void unsubscribe(); + + public void setHomeGroup(Group homeGroup); + + public Group getHomeGroup(); + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index 760478c3a5..ae0e112ee2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -24,6 +24,11 @@ import java.util.HashMap; import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + /** * Defines a topology of serviceMap in Stratos. */ @@ -31,10 +36,16 @@ public class Topology implements Serializable { private static final long serialVersionUID = -2453583548027402122L; // Key: Service.serviceName private Map serviceMap; + //Grouping + private Map compositeApplicationMap; + private Map configCompositeApplicationMap; private boolean initialized; + private static Log log = LogFactory.getLog(Topology.class); public Topology() { this.serviceMap = new HashMap(); + this.compositeApplicationMap = new HashMap(); + this.configCompositeApplicationMap = new HashMap(); } public Collection getServices() { @@ -70,8 +81,86 @@ public boolean serviceExists(String serviceName) { public void clear() { this.serviceMap.clear(); } + + // Grouping + public Collection getCompositeApplication() { + return this.compositeApplicationMap.values(); + } + + public void addCompositeApplication(String alias, CompositeApplication app) { + this.compositeApplicationMap.put(alias, app); + } + + public void removeCompositeApplication(String alias) { + this.compositeApplicationMap.remove(alias); + } + + public Collection getConfigCompositeApplication() { + + if (this.configCompositeApplicationMap == null) { + log.info("adding new config comp in topology while retrieving it, ConfigCompositeApplication is null"); + this.configCompositeApplicationMap = new HashMap(); + } + return this.configCompositeApplicationMap.values(); + } + + public void addConfigCompositeApplication(String alias, ConfigCompositeApplication configApp) { + log.info("adding config comp in topology" + alias + " / " + configApp); + if (this.configCompositeApplicationMap != null) { + log.info("adding config comp in topology, ConfigCompositeApplication is not null"); + this.configCompositeApplicationMap.put(alias, configApp); + log.info("successful config comp in topology, ConfigCompositeApplication is not null"); + } else { + log.info("adding config comp in topology, ConfigCompositeApplication is null, adding one"); + this.configCompositeApplicationMap = new HashMap(); + this.configCompositeApplicationMap.put(alias, configApp); + } + } + + public void removeConfigCompositeApplication(String alias) { + this.configCompositeApplicationMap.remove(alias); + } + + public void removeAllCompositeApplication() { + java.util.Set keys = this.compositeApplicationMap.keySet(); + for (String key : keys) { + compositeApplicationMap.remove(key); + } + } + + public void removeAllConfigCompositeApplication() { + java.util.Set keys = this.configCompositeApplicationMap.keySet(); + for (String key : keys) { + configCompositeApplicationMap.remove(key); + } + } + + public CompositeApplication getCompositeApplication(String appAlias) { + return this.compositeApplicationMap.get(appAlias); + } + + public boolean compositeApplicationExists(String appAlias) { + return this.compositeApplicationMap.containsKey(appAlias); + } + + public ConfigCompositeApplication getConfigCompositeApplication(String appAlias) { + return this.configCompositeApplicationMap.get(appAlias); + } + + public boolean configCompositeApplicationExists(String appAlias) { + return this.configCompositeApplicationMap.containsKey(appAlias); + } + + + public Map getConfigCompositeApplicationMap() { + return configCompositeApplicationMap; + } + + public void setConfigCompositeApplicationMap(Map configCompositeApplicationMap) { + this.configCompositeApplicationMap = configCompositeApplicationMap; + } - public void setInitialized(boolean initialized) { + public void setInitialized(boolean initialized) { this.initialized = initialized; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java new file mode 100644 index 0000000000..73d6f9d455 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java @@ -0,0 +1,240 @@ +package org.apache.stratos.messaging.domain.topology.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.ConfigCartridge; +import org.apache.stratos.messaging.domain.topology.ConfigGroup; +import org.apache.stratos.messaging.domain.topology.ConfigDependencies; +import org.apache.stratos.messaging.domain.topology.Cartridge; +import org.apache.stratos.messaging.domain.topology.Composite; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.Dependencies; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Scalable; +import org.apache.stratos.messaging.domain.topology.Topology; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + +public class CompositeApplicationBuilder { + + private Map groups = null; + private Map cartridgesTypes = null; + + private List configGroupArray = null; + private List configCartridgeArray = null; + + private static Log log = LogFactory.getLog(CompositeApplicationBuilder.class); + + public CompositeApplication buildCompositeApplication(Topology topology, String appAlias) { + if (log.isDebugEnabled()) { + log.debug("buildCompositeApplication configComplexApplication with topology " + topology); + } + Collection configComplexApplications = topology.getConfigCompositeApplication(); + CompositeApplication complexApplication = new CompositeApplication(); + if (configComplexApplications.size() > 0) { + ConfigCompositeApplication [] complexConfigAppArray = new ConfigCompositeApplication[configComplexApplications.size()]; + complexConfigAppArray = configComplexApplications.toArray(complexConfigAppArray); + + // assuming only 1 complex app is configured + + ConfigCompositeApplication configComplexApplication = complexConfigAppArray[0]; + if (log.isDebugEnabled()) { + log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication); + } + if (configComplexApplication!= null) { + if (log.isDebugEnabled()) { + log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication); + } + setConfigConfiguration(configComplexApplication); + + Group top_level = this.buildApplication(); + if (top_level != null) { + if (log.isDebugEnabled()) { + log.debug("ServiceGroupContext:configComplexApplication toplevel is " + top_level.getAlias()); + } + } else { + if (log.isDebugEnabled()) { + log.debug("buildCompositeApplication toplevel is null"); + } + } + if (top_level == null) { + log.debug("buildCompositeApplication top level group is null ..."); + return null; + } else { + log.debug("buildCompositeApplication setting top level group " + top_level.getAlias()); + //complexApplication.setTop_level(top_level); + complexApplication.setAll_groups(this.groups); + return complexApplication; + } + } else { + log.debug("buildCompositeApplication configComplexApplication is null"); + } + } else { + log.debug("buildCompositeApplication configComplexApplications is null"); + return null; + } + return null; + } + + + + public Group buildApplication() { + + for (ConfigGroup configGroup : configGroupArray) { + log.debug("deploying group " + configGroup.getAlias()); + Group realGroup = new Group(configGroup.getAlias()); + groups.put(realGroup.getAlias(), realGroup); + } + + + for (ConfigCartridge configCartridge : configCartridgeArray) { + log.debug("deploying cartridge component " + configCartridge.getAlias()); + Cartridge realCartridge = new Cartridge(configCartridge.getAlias()); + cartridgesTypes.put(realCartridge.getAlias(), realCartridge); + } + + // building groups + // this should be done when reading the topology event in autoscaler + log.debug("converting group configuration to groups and assembling application"); + for (ConfigGroup configGroup : configGroupArray) { + Group assembleGroup = groups.get(configGroup.getAlias()); + Map groupCartridges = new HashMap(); + log.debug("converting configuration for group " + assembleGroup.getAlias()); + for (String key : configGroup.getSubscribables()) { + Group realgroup = groups.get(key); + if (realgroup != null) { + // try cartridges + assembleGroup.add(realgroup); + realgroup.setParent(assembleGroup); + realgroup.setHomeGroup(assembleGroup); + } else { + Cartridge realcartridge_type = cartridgesTypes.get(key); + if (realcartridge_type != null) { + // create a copy of the cartridge type + Cartridge groupCartridge = new Cartridge(realcartridge_type.getAlias()); + groupCartridge.setCartridgeId(getCartridgeId(assembleGroup.getAlias(), realcartridge_type.getAlias())); + assembleGroup.add(groupCartridge); + groupCartridge.setParent(assembleGroup); + groupCartridge.setHomeGroup(assembleGroup); // TODO need to consolidate parent / home group + groupCartridges.put(groupCartridge.getAlias(), groupCartridge); + if (log.isDebugEnabled()) { + log.debug("added new cartrdige of type " + groupCartridge.getAlias() + " and cartrdigeId " + groupCartridge.getCartridgeId() + + " to group " + assembleGroup.getAlias()); + } + } else { + log.debug("Error: no group, cartridge found for alias: " + key); + } + } + } + // build dependencies + log.debug("building dependencies for group " + assembleGroup.getAlias()); + Dependencies real_dependencies = buildDependency(configGroup, groups, groupCartridges); + assembleGroup.setDependencies(real_dependencies); + real_dependencies.setGroup(assembleGroup); + } + + Group application = getTopLevelGroup(); + log.debug("top level group is: " + application.getAlias()); + + return application; + } + + public Group getTopLevelGroup () { + String alias = null; + for (ConfigGroup configGroup : configGroupArray) { + alias = configGroup.getAlias(); + boolean isTopLevelGroup = true; + log.debug("checking if group " + alias + " is a sub component"); + for (ConfigGroup configGroupInner : configGroupArray) { + for (String key : configGroupInner.getSubscribables()) { + log.debug("in group " + configGroupInner.getAlias() ); + if (key.equals(alias)) { + log.debug("found group " + alias + " as sub component in " + configGroupInner.getAlias()); + isTopLevelGroup = false; + break; + } + } + } + if (isTopLevelGroup) { + log.debug("is top level group: " + alias); + break; + } + } + Group application = groups.get(alias); + log.debug("top level group is: " + alias); + return application; + } + + public Dependencies buildDependency(ConfigGroup configGroup, Map groups, Map groupCartridges) { + + // building dependencies + ConfigDependencies config_dep = configGroup.getDependencies(); + Dependencies real_dependencies = new Dependencies(); + if (config_dep != null) { + String kill_behavior = config_dep.getKill_behavior(); + real_dependencies.setKill_behavior(kill_behavior); + List startup_order = config_dep.getStartup_order(); + for (ConfigDependencies.Pair pair: startup_order) { + String key = pair.getKey(); + String value = pair.getValue(); + //check groups + Group gr = groups.get(value); + log.debug("checking dependency for key " + key + " /val: " + value + " in groups"); + if (gr != null) { + real_dependencies.addDependency(key, gr); + } else { + log.debug("checking dependency for key " + key + " /val: " + value + " in group cartridges"); + Cartridge cr = groupCartridges.get(value); + if (cr != null) { + real_dependencies.addDependency(key, cr); + if (log.isDebugEnabled()) { + log.debug("adding group cartridge " + cr.getCartridgeId()+ " as dependency"); + } + } else { + cr = this.cartridgesTypes.get(value); + if (cr != null) { + real_dependencies.addDependency(key, cr); + if (log.isDebugEnabled()) { + log.debug("adding a lone cartridge " + cr.getAlias() + " as dependency"); + } + } else { + log.debug("error retrieving group with name " + key); + } + } + } + + } + } + return real_dependencies; + } + + private void setConfigConfiguration(ConfigCompositeApplication configApp) { + this.groups = new HashMap(); + this.cartridgesTypes = new HashMap(); + + if (configApp.getComponents() != null) { + configGroupArray = configApp.getComponents(); + } else { + configGroupArray = new ArrayList(); + } + + if (configApp.getCartridges() != null) { + configCartridgeArray = configApp.getCartridges(); + } else { + configCartridgeArray = new ArrayList(); + } + + } + + private String getCartridgeId (String homeGroupId, String cartridgeType) { + String id = homeGroupId +":"+ cartridgeType; + return id; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceActivatedEvent.java index db6022d2f7..10175742a6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceActivatedEvent.java @@ -35,6 +35,7 @@ public class InstanceActivatedEvent extends InstanceStatusEvent implements Seria private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public InstanceActivatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -63,4 +64,12 @@ public String getMemberId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceMaintenanceModeEvent.java index 209ad78eff..6fb61beec2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceMaintenanceModeEvent.java @@ -26,6 +26,7 @@ public class InstanceMaintenanceModeEvent extends InstanceStatusEvent implements private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public InstanceMaintenanceModeEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { @@ -56,4 +57,12 @@ public String getNetworkPartitionId() { return networkPartitionId; } + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceReadyToShutdownEvent.java index 8bc614037f..27411722e9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceReadyToShutdownEvent.java @@ -30,6 +30,7 @@ public class InstanceReadyToShutdownEvent extends InstanceStatusEvent implements private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public InstanceReadyToShutdownEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { @@ -60,5 +61,13 @@ public String getNetworkPartitionId() { return networkPartitionId; } + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } + } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceStartedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceStartedEvent.java index 3c568bd0ac..a459d90206 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceStartedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/instance/status/InstanceStartedEvent.java @@ -32,6 +32,7 @@ public class InstanceStartedEvent extends InstanceStatusEvent implements Seriali private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public InstanceStartedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -60,4 +61,12 @@ public String getMemberId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java new file mode 100644 index 0000000000..e7a62c9464 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.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.messaging.event.topology; + +import java.io.Serializable; +import java.util.*; + +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; + + +/** + * + * @author netiq + * event is fired when application is created + */ +public class CompositeApplicationCreatedEvent extends TopologyEvent implements Serializable{ + private static final long serialVersionUID = -1L; + private ConfigCompositeApplication compositeApplication; + + public CompositeApplicationCreatedEvent(ConfigCompositeApplication configCompositeApplication) { + this.compositeApplication = configCompositeApplication; + + } + + public String getApplicationAlias() { + return compositeApplication.getAlias(); + } + + public ConfigCompositeApplication getCompositeApplication () { + return this.compositeApplication; + } +} + + diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationEvent.java new file mode 100644 index 0000000000..cf2a6af4a3 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationEvent.java @@ -0,0 +1,31 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + +/** + * Tenant event definition. + */ +public abstract class CompositeApplicationEvent extends Event implements Serializable { + private static final long serialVersionUID = -1L; +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationRemovedEvent.java new file mode 100644 index 0000000000..94bdfca3a1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationRemovedEvent.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.messaging.event.topology; + +import java.io.Serializable; +import java.util.*; + +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; + + +/** + * + * @author netiq + * event is fired when application is created + */ +public class CompositeApplicationRemovedEvent extends TopologyEvent implements Serializable{ + private static final long serialVersionUID = -1L; + private String compositeApplicationAlias; + + public CompositeApplicationRemovedEvent(String compositeApplicationAlias) { + this.compositeApplicationAlias = compositeApplicationAlias; + + } + + public String getApplicationAlias() { + return compositeApplicationAlias; + } + +} + + diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java index 3cda807490..98d82e19e5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java @@ -39,7 +39,9 @@ public class MemberActivatedEvent extends TopologyEvent implements Serializable private final String partitionId; private final String memberId; private Map portMap; + private String memberPublicIp; private String memberIp; + private String groupId; public MemberActivatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -101,4 +103,21 @@ public String getMemberIp() { public void setMemberIp(String memberIp) { this.memberIp = memberIp; } + + public String getMemberPublicIp() { + return memberPublicIp; + } + + public void setMemberPublicIp(String memberPublicIp) { + this.memberPublicIp = memberPublicIp; + } + + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberMaintenanceModeEvent.java index 032b8ccdbe..8a8ea35e8f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberMaintenanceModeEvent.java @@ -31,6 +31,7 @@ public class MemberMaintenanceModeEvent extends TopologyEvent implements Seriali private final String memberId; private MemberStatus status; private Properties properties; + private String groupId; public MemberMaintenanceModeEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { @@ -76,4 +77,12 @@ public String getPartitionId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberReadyToShutdownEvent.java index b521e76f52..893160c778 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberReadyToShutdownEvent.java @@ -31,6 +31,7 @@ public class MemberReadyToShutdownEvent extends TopologyEvent implements Seriali private final String memberId; private MemberStatus status; private Properties properties; + private String groupId; public MemberReadyToShutdownEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { @@ -76,4 +77,12 @@ public String getPartitionId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberStartedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberStartedEvent.java index 6a89100e73..c9ab532120 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberStartedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberStartedEvent.java @@ -36,6 +36,7 @@ public class MemberStartedEvent extends TopologyEvent implements Serializable { private final String memberId; private MemberStatus status; private Properties properties; + private String groupId; public MemberStartedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -80,4 +81,12 @@ public String getPartitionId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberSuspendedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberSuspendedEvent.java index ed67d4b1f8..5b5b113cb2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberSuspendedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberSuspendedEvent.java @@ -32,6 +32,7 @@ public class MemberSuspendedEvent extends TopologyEvent implements Serializable private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public MemberSuspendedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -60,4 +61,12 @@ public String getNetworkPartitionId() { public String getPartitionId() { return partitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java index 986b309dab..c35f80c562 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java @@ -33,6 +33,7 @@ private final String networkPartitionId; private final String partitionId; private final String memberId; + private String groupId; public MemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -61,4 +62,12 @@ public String getMemberId() { public String getNetworkPartitionId() { return networkPartitionId; } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java new file mode 100644 index 0000000000..6c3aa7ace8 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class CompositeApplicationCreatedEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java new file mode 100644 index 0000000000..04dce2bf8a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class CompositeApplicationRemovedEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java new file mode 100644 index 0000000000..1b4faa5861 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java @@ -0,0 +1,98 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; + +//Grouping +public class CompositeApplicationCreatedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(CompositeApplicationCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (log.isDebugEnabled()) { + log.debug("processing application event of type " + type + + " / topology:" + topology + " msg: " + message); + } + + if (CompositeApplicationCreatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + + if (log.isDebugEnabled()) { + log.debug("topology is not initialized .... need to add check ... Grouping"); + } + + //return false; + } + + // Parse complete message and build event + CompositeApplicationCreatedEvent event = + (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("processing application created event with application id: " + event.getApplicationAlias()); + } + + // Validate event against the existing topology + if (topology.compositeApplicationExists(event.getApplicationAlias())) { + if (log.isWarnEnabled()) { + log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias())); + } + } else { + + ConfigCompositeApplication configApp = event.getCompositeApplication(); + String alias = "compositeApplicationAlias"; + if (log.isInfoEnabled()) { + log.info("adding ConfigCompositeApplication with alias " + alias + " to topology"); + } + topology.addConfigCompositeApplication(alias, configApp); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java new file mode 100644 index 0000000000..2bb688a585 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java @@ -0,0 +1,100 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; +import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; + +//Grouping +public class CompositeApplicationRemovedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(CompositeApplicationRemovedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (log.isDebugEnabled()) { + log.debug("processing application event of type " + type + + " / topology:" + topology + " msg: " + message); + } + + if (CompositeApplicationRemovedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + + if (!topology.isInitialized()) { + + if (log.isDebugEnabled()) { + log.debug("topology is not initialized .... need to add check ... Grouping"); + } + //return false; + } + + // Parse complete message and build event + CompositeApplicationRemovedEvent event = + (CompositeApplicationRemovedEvent) Util.jsonToObject(message, CompositeApplicationRemovedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("processing application removed event with application id: " + event.getApplicationAlias()); + } + + // Validate event against the existing topology + if (topology.configCompositeApplicationExists(event.getApplicationAlias())) { + topology.removeAllConfigCompositeApplication(); + if (log.isDebugEnabled()) { + log.debug("CompositeApplication exists, removing all ConfigCompositeApplication" + event.getApplicationAlias()) ; + } + } else { + topology.removeAllConfigCompositeApplication(); + if (log.isWarnEnabled()) { + log.warn("ConfigCompositeApplication " + event.getApplicationAlias() + " does not exist, removing all ") ; + } + } + + + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 7415c1f6b1..56c5f7c60c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -28,6 +28,7 @@ /** * Defines default topology message processor chain. */ +// Grouping public class TopologyMessageProcessorChain extends MessageProcessorChain { private static final Log log = LogFactory.getLog(TopologyMessageProcessorChain.class); @@ -43,6 +44,8 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor; private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; + private CompositeApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; + private CompositeApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; public void initialize() { // Add topology event processors @@ -82,8 +85,19 @@ public void initialize() { memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor(); add(memberTerminatedMessageProcessor); + applicationCreatedMessageProcessor = new CompositeApplicationCreatedMessageProcessor(); + add(applicationCreatedMessageProcessor); + + applicationRemovedMessageProcessor = new CompositeApplicationRemovedMessageProcessor(); + add(applicationRemovedMessageProcessor); + if (log.isDebugEnabled()) { - log.debug("Topology message processor chain initialized"); + log.debug("Grouping: added applicationCreatedMessageProcessor, applicationRemovedMessageProcessor: " + + applicationCreatedMessageProcessor + " / " + applicationRemovedMessageProcessor); + } + + if (log.isDebugEnabled()) { + log.debug("Topology message processor chain initialized X1"); } } @@ -113,6 +127,17 @@ public void addEventListener(EventListener eventListener) { serviceRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof MemberMaintenanceListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); + } else if (eventListener instanceof CompositeApplicationCreatedEventListener) { + applicationCreatedMessageProcessor.addEventListener(eventListener); + if (log.isDebugEnabled()) { + log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); + } + + } else if (eventListener instanceof CompositeApplicationRemovedEventListener) { + applicationRemovedMessageProcessor.addEventListener(eventListener); + if (log.isDebugEnabled()) { + log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); + } } else { throw new RuntimeException("Unknown event listener"); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index 8b3c814cb5..d624d6c629 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -60,6 +60,7 @@ public class Constants { public static final String IS_VOLUME_REQUIRED = "volume.required"; public static final String SHOULD_DELETE_VOLUME = "volume.delete.on.unsubscription"; public static final String VOLUME_SIZE = "volume.size.gb"; + public static final String VOLUME_ID = "volume.id"; public static final String DEVICE_NAME = "volume.device.name"; public static final String GRACEFUL_SHUTDOWN_TIMEOUT = "graceful.shutdown.timeout"; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java index eb0035e380..ec15b097d2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Util.java @@ -22,6 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.message.JsonMessage; +import com.google.gson.Gson; + import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -104,5 +106,11 @@ public static boolean isNumber(String s) { public static Object jsonToObject(String json, Class type) { return (new JsonMessage(json, type)).getObject(); } + + public static String ObjectToJson(Object obj) { + Gson gson = new Gson(); + String result = gson.toJson(obj); + return result; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java index e29d028fa7..eec247dc9e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java @@ -18,7 +18,12 @@ */ package org.apache.stratos.rest.endpoint.bean; +import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean; +import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean; + import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; @XmlRootElement public class CartridgeInfoBean { @@ -34,11 +39,15 @@ public class CartridgeInfoBean { String dataCartridgeAlias; boolean commitsEnabled; - private boolean persistanceRequired; - private String size; - private boolean removeOnTermination; private String serviceGroup; + private PersistenceBean persistence; + + private List property; + + public CartridgeInfoBean() { + } + public String getCartridgeType() { return cartridgeType; } @@ -119,31 +128,7 @@ public void setDeploymentPolicy(String deploymentPolicy) { this.deploymentPolicy = deploymentPolicy; } - public boolean isPersistanceRequired() { - return persistanceRequired; - } - - public void setPersistanceRequired(boolean persistanceRequired) { - this.persistanceRequired = persistanceRequired; - } - - public String getSize() { - return size; - } - - public void setSize(String size) { - this.size = size; - } - - public boolean isRemoveOnTermination() { - return removeOnTermination; - } - - public void setRemoveOnTermination(boolean removeOnTermination) { - this.removeOnTermination = removeOnTermination; - } - - public boolean isCommitsEnabled() { + public boolean isCommitsEnabled() { return commitsEnabled; } @@ -158,5 +143,20 @@ public String getServiceGroup() { public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } - + + public PersistenceBean getPersistence() { + return persistence; + } + + public void setPersistence(PersistenceBean persistenceBean) { + this.persistence = persistenceBean; + } + + public List getProperty() { + return property; + } + + public void setProperty(List property) { + this.property = property; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/VolumeBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/VolumeBean.java index 7eabb451dc..a9d74418d6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/VolumeBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/VolumeBean.java @@ -23,6 +23,8 @@ @XmlRootElement public class VolumeBean { + public String id; + public String size; public String device; @@ -30,6 +32,10 @@ public class VolumeBean { public boolean removeOnTermination; public String mappingPath; + + public String snapshotId; + + public String volumeId; public String toString () { return " [ Persistence Required : " + ", Size: " + size + ", device: " + diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java new file mode 100644 index 0000000000..2efc62bf62 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java @@ -0,0 +1,17 @@ +package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; + +import javax.xml.bind.annotation.XmlRootElement; + +import java.util.List; + +@XmlRootElement(name = "applicationDefinitionBean") + +public class CompositeApplicationDefinitionBean { + + public String applicationId; + public String alias; + public List components; + public List cartridges; + + +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java new file mode 100644 index 0000000000..85d57ce14a --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java @@ -0,0 +1,8 @@ +package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "cartridge") +public class ConfigCartridge { + public String alias; +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java new file mode 100644 index 0000000000..5efd201665 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java @@ -0,0 +1,57 @@ +package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "dependencies") +public class ConfigDependencies { + public List startup_order = new ArrayList(); + public String kill_behavior; + + /* + public String getKill_behavior() { + return kill_behavior; + } + + public void setKill_behavior(String kill_behavior) { + this.kill_behavior = kill_behavior; + } + + public List getStartup_order() { + return startup_order; + } + + public void setStartup_order(List startup_order) { + this.startup_order = startup_order; + } + */ + + + public static class Pair { + private String key; + private String value; + + private Pair() {} + + public Pair(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + public void setKey(String key) { + this.key = key; + } + public String getValue() { + return value; + } + public void setValue(String value) { + this.value = value; + } + } + +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java new file mode 100644 index 0000000000..bbdd0e3c7e --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java @@ -0,0 +1,35 @@ +package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "components") +public class ConfigGroup { + public String alias; + public List subscribables; + public ConfigDependencies dependencies; + + /* + public String getAlias() { + return alias; + } + public void setAlias(String alias) { + this.alias = alias; + } + public List getSubscribables() { + return subscribables; + } + public void setSubscribables(List subscribables) { + this.subscribables = subscribables; + } + public ConfigDependencies getDependencies() { + return dependencies; + } + public void setDependencies(ConfigDependencies dependencies) { + this.dependencies = dependencies; + } + */ + + +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 1208967f36..84ddfbfcc2 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -19,15 +19,31 @@ package org.apache.stratos.rest.endpoint.bean.util.converter; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.manager.application.utils.ApplicationUtils; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.*; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigCartridge; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup; import org.apache.stratos.rest.endpoint.bean.topology.Member; +import org.apache.stratos.messaging.domain.topology.Cartridge; +import org.apache.stratos.messaging.domain.topology.Composite; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.Dependencies; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Scalable; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; +import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.Arrays; @@ -145,18 +161,25 @@ private static IaasConfig[] getIaasConfigsAsArray (List iaasPr return iaasConfigsArray; } - private static Persistence getPersistence(PersistenceBean persistenceBean) { + public static Persistence getPersistence(PersistenceBean persistenceBean) { Persistence persistence = new Persistence(); persistence.setPersistanceRequired(persistenceBean.isRequired); VolumeBean[] volumeBean = new VolumeBean[persistenceBean.volume.size()]; persistenceBean.volume.toArray(volumeBean); - Volume[] volumes = new Volume[persistenceBean.volume.size()]; - for (int i = 0 ; i < volumes.length ; i++) { + Volume[] volumes = new Volume[persistenceBean.volume.size()]; + for (int i = 0 ; i < volumes.length ; i++) { Volume volume = new Volume(); - volume.setSize(Integer.parseInt(volumeBean[i].size)); + volume.setId(volumeBean[i].id); + volume.setVolumeId(volumeBean[i].volumeId); + if(StringUtils.isEmpty(volume.getVolumeId())){ + volume.setSize(Integer.parseInt(volumeBean[i].size)); + } + volume.setDevice(volumeBean[i].device); volume.setRemoveOntermination(volumeBean[i].removeOnTermination); volume.setMappingPath(volumeBean[i].mappingPath); + volume.setSnapshotId(volumeBean[i].snapshotId); + volumes[i] = volume; } persistence.setVolumes(volumes); @@ -164,7 +187,7 @@ private static Persistence getPersistence(PersistenceBean persistenceBean) { } - private static Properties getProperties (List propertyBeans) { + public static Properties getProperties(List propertyBeans) { //convert to an array PropertyBean [] propertyBeansArray = new PropertyBean[propertyBeans.size()]; @@ -636,4 +659,124 @@ public static List convertToServiceDefinitionBeans (Colle return serviceDefinitionBeans; } + + private static Log log = LogFactory.getLog(PojoConverter.class); + + + public static ConfigCompositeApplication convertToCompositeApplication(CompositeApplicationDefinitionBean appBean) { + ConfigCompositeApplication configApp = new ConfigCompositeApplication(); + + configApp.setAlias(appBean.alias); + configApp.setApplicationId(appBean.applicationId); + + List configCartridges = + new ArrayList(); + + for (ConfigCartridge beanCartridge : appBean.cartridges ) { + org.apache.stratos.messaging.domain.topology.ConfigCartridge configCartridge = + new org.apache.stratos.messaging.domain.topology.ConfigCartridge(); + configCartridge.setAlias(beanCartridge.alias); + configCartridges.add(configCartridge); + } + configApp.setCartridges(configCartridges); + + // converting groups / components + List configGroups = + new ArrayList(); + + for (ConfigGroup beanGroup : appBean.components ) { + org.apache.stratos.messaging.domain.topology.ConfigGroup configGroup = + new org.apache.stratos.messaging.domain.topology.ConfigGroup(); + configGroup.setAlias(beanGroup.alias); + configGroup.setSubscribables(beanGroup.subscribables); + org.apache.stratos.messaging.domain.topology.ConfigDependencies configDep = + new org.apache.stratos.messaging.domain.topology.ConfigDependencies(); + + + // convert dependencies + configDep.setKill_behavior(beanGroup.dependencies.kill_behavior); + List configPairs = + new ArrayList(); + for (ConfigDependencies.Pair beanPair : beanGroup.dependencies.startup_order) { + configPairs.add(new org.apache.stratos.messaging.domain.topology.ConfigDependencies.Pair(beanPair.getKey(), beanPair.getValue())); + } + configDep.setStartup_order(configPairs); + configGroup.setDependencies(configDep); + + configGroups.add(configGroup); + } + configApp.setComponents(configGroups); + + return configApp; + } + + // grouping + public static CompositeApplicationDefinition convertToCompositeApplicationForCC (CompositeApplicationDefinitionBean appBean) { + CompositeApplicationDefinition configApp = new CompositeApplicationDefinition(); + + configApp.setAlias(appBean.alias); + configApp.setApplicationId(appBean.applicationId); + + + + List configCartridges = + new ArrayList(); + + for (ConfigCartridge beanCartridge : appBean.cartridges ) { + org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge configCartridge = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge(); + configCartridge.setAlias(beanCartridge.alias); + configCartridges.add(configCartridge); + } + org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge [] arrayConfigCartridge = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge[configCartridges.size()]; + arrayConfigCartridge = configCartridges.toArray(arrayConfigCartridge); + configApp.setCartridges(arrayConfigCartridge); + + // converting groups / components + List configGroups = + new ArrayList(); + + for (ConfigGroup beanGroup : appBean.components ) { + org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup configGroup = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup(); + configGroup.setAlias(beanGroup.alias); + String [] arraySubscribables = new String[beanGroup.subscribables.size()]; + arraySubscribables = beanGroup.subscribables.toArray(arraySubscribables); + configGroup.setSubscribables(arraySubscribables); + org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencies configDep = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencies(); + + + // convert dependencies + configDep.setKill_behavior(beanGroup.dependencies.kill_behavior); + int i = 0; + org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair[] configPairs = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair[beanGroup.dependencies.startup_order.size()]; + + for (ConfigDependencies.Pair beanPair : beanGroup.dependencies.startup_order) { + //configPairs.add(new org.apache.stratos.messaging.domain.topology.ConfigDependencies.Pair(beanPair.getKey(), beanPair.getValue())); + + org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair pair = new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair(); + pair.setKey(beanPair.getKey()); + pair.setValue(beanPair.getValue()); + + configPairs[i] = pair; + i++; + } + configDep.setStartup_order(configPairs); + configGroup.setDependencies(configDep); + + configGroups.add(configGroup); + + } + org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup [] configGroupArray = + new org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup[configGroups.size()]; + configGroupArray = configGroups.toArray(configGroupArray); + configApp.setComponents(configGroupArray); + + return configApp; + } + + } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 44b2c2640b..c88acf11a5 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -23,14 +23,19 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; +import org.apache.stratos.manager.application.CompositeApplicationManager; +import org.apache.stratos.manager.application.utils.ApplicationUtils; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.service.Service; @@ -48,6 +53,7 @@ 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.ConfigCompositeApplication; 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; @@ -58,10 +64,15 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.AutoscalePolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; import javax.ws.rs.core.Response; @@ -74,6 +85,7 @@ public class ServiceUtils { public static final String SHOULD_DELETE_VOLUME = "volume.delete.on.unsubscription"; public static final String VOLUME_SIZE = "volume.size.gb"; public static final String DEVICE_NAME = "volume.device.name"; + public static final String VOLUME_ID = "volume.id"; private static Log log = LogFactory.getLog(ServiceUtils.class); private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager(); @@ -120,6 +132,197 @@ static StratosAdminResponse deployCartridge (CartridgeDefinitionBean cartridgeDe stratosAdminResponse.setMessage("Successfully deployed cartridge definition with type " + cartridgeDefinitionBean.type); return stratosAdminResponse; } + + // Grouping + /* + static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean applicationDefinitionBean, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + + log.info("Starting to deploy a application " + applicationDefinitionBean); + + if (log.isDebugEnabled()) { + log.debug("application data id:" + applicationDefinitionBean.applicationId + " /alias: " + + applicationDefinitionBean.alias); + if (applicationDefinitionBean.components != null) { + log.debug("application config groups size " + applicationDefinitionBean.components.size()); + for (ConfigGroup cfg : applicationDefinitionBean.components) { + log.debug("listing application config groups " + cfg.alias + " /sub " + + cfg.subscribables + " /dep " + cfg.dependencies); + if (cfg.dependencies != null) { + log.debug("listing application group dependencies: kill: " + + cfg.dependencies.kill_behavior + " / startup: " + + cfg.dependencies.startup_order); + if (cfg.dependencies.startup_order != null) { + for (ConfigDependencies.Pair pair : cfg.dependencies.startup_order) { + log.debug("listing dependencies pairs : " + pair.getKey() + " / " + pair.getValue()); + } + } + } + } + } else { + log.debug("no config group in application"); + } + + } + + // convert to json + String applicationId = applicationDefinitionBean.applicationId; + + if (log.isDebugEnabled()) { + log.debug("publishing application created event " + applicationId); + } + + // convert to domain object - move to ojoConverted + ConfigCompositeApplication app = PojoConverter.convertToCompositeApplication(applicationDefinitionBean); + if (log.isDebugEnabled()) { + log.debug("converted application to CompositeApplication " + app); + } + CompositeApplicationManager manager = new CompositeApplicationManager(); + + + try { + manager.deployCompositeApplication(app); + } catch (ADCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = e.getMessage(); + log.error(message, e); + throw new RestAPIException(message, e); + } + + log.info("l [type] " + applicationDefinitionBean); + // deploy to cloud controller + CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); + + + if (log.isDebugEnabled()) { + log.debug("deployeing composite app in cloud controller"); + } + + ServiceUtils.deployCompositeApplicationDefinition(applicationDefinitionBean, ctxt, userName, tenantDomain); + + if (log.isDebugEnabled()) { + log.debug("done deployeing composite app in cloud controller"); + } + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully deployed application definition w" + applicationDefinitionBean); + return stratosAdminResponse; + } */ + + static StratosAdminResponse deployCompositeApplicationDefinition (CompositeApplicationDefinitionBean compositeApplicationDefinition, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + + log.info("Starting to deploy composite application definition "+ compositeApplicationDefinition); + + CompositeApplicationDefinition appConfig = PojoConverter.convertToCompositeApplicationForCC(compositeApplicationDefinition); + + + CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); + + if (cloudControllerServiceClient != null) { + // call CC + try { + cloudControllerServiceClient + .deployCompositeApplicationDefinition(appConfig); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + log.error(e.getMessage(), e); + throw new RestAPIException(e.getMessage(), e); + } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + //String message = e.getFaultMessage().getInvalidCompositeApplicationDefinitionException().getMessage(); + String message = "CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException"; + log.error(message, e); + throw new RestAPIException(message, e); + } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = e.getFaultMessage().getInvalidIaasProviderException().getMessage(); + log.error(message, e); + throw new RestAPIException(message, e); + } + + log.info("Successfully composite application to cloud controller"); + + } + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully composite application to cloud controller"); + return stratosAdminResponse; + } + + static StratosAdminResponse unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + + log.info("Starting to undeploy a composite application definition " + configCompositeApplicationAlias); + + CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); + + if (cloudControllerServiceClient != null) { + try { + if (log.isDebugEnabled()) { + log.debug("trying to undeploy composite application definition " + configCompositeApplicationAlias); + } + cloudControllerServiceClient.unDeployCompositeApplicationDefinition(configCompositeApplicationAlias); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = "Remote ExceptionException"; + log.error(message, e); + throw new RestAPIException(message, e); + } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = "CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException"; + log.error(message, e); + throw new RestAPIException(message, e); + } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = "CloudControllerServiceInvalidIaasProviderExceptionException"; + log.error(message, e); + throw new RestAPIException(message, e); + } + } else { + if (log.isDebugEnabled()) { + log.debug("cloud controller client is null while trying to undeploy composite application definition"); + } + } + + log.info("l [type] " + configCompositeApplicationAlias); + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); + return stratosAdminResponse; + } + + + static StratosAdminResponse unDeployApplicationOld(String configCompositeApplicationAlias, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + + log.info("Starting to undeploy a composite application " + configCompositeApplicationAlias); + + CompositeApplicationManager manager = new CompositeApplicationManager(); + + try { + manager.unDeployCompositeApplication(configCompositeApplicationAlias); + } catch (ADCException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + String message = e.getMessage(); + log.error(message, e); + throw new RestAPIException(message, e); + } + + log.info("l [type] " + configCompositeApplicationAlias); + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); + return stratosAdminResponse; + } @SuppressWarnings("unused") private static DeploymentPolicy[] intersection( @@ -993,14 +1196,30 @@ private static SubscriptionInfo subscribe (CartridgeInfoBean cartridgeInfoBean, subscriptionData.setCommitsEnabled(cartridgeInfoBean.isCommitsEnabled()); subscriptionData.setServiceGroup(cartridgeInfoBean.getServiceGroup()); + + PersistenceBean persistenceBean = cartridgeInfoBean.getPersistence(); + if(persistenceBean != null) { + subscriptionData.setPersistence(PojoConverter.getPersistence(persistenceBean)); + } + if(cartridgeInfoBean.getProperty() != null){ + subscriptionData.setProperties(PojoConverter.getProperties(cartridgeInfoBean.getProperty())); + } + + /* + if (cartridgeInfoBean.getPersistence() != null) { + if (cartridgeInfoBean.isPersistanceRequired()) { // Add persistence related properties to PersistenceContext PersistenceContext persistenceContext = new PersistenceContext(); persistenceContext.setPersistanceRequiredProperty(IS_VOLUME_REQUIRED, String.valueOf(cartridgeInfoBean.isPersistanceRequired())); persistenceContext.setSizeProperty(VOLUME_SIZE, cartridgeInfoBean.getSize()); persistenceContext.setDeleteOnTerminationProperty(SHOULD_DELETE_VOLUME, String.valueOf(cartridgeInfoBean.isRemoveOnTermination())); + if(cartridgeInfoBean.getVolumeId() != null) { + persistenceContext.setVolumeIdProperty(VOLUME_ID, String.valueOf(cartridgeInfoBean.getVolumeId())); + } subscriptionData.setPersistanceCtxt(persistenceContext); } + */ //subscribe return cartridgeSubsciptionManager.subscribeToCartridgeWithProperties(subscriptionData); @@ -1072,6 +1291,7 @@ public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getCluste subscriptionData.setTenantId(ApplicationManagementUtil.getTenantId(configurationContext)); subscriptionData.setTenantAdminUsername(userName); subscriptionData.setRepositoryType("git"); + //subscriptionData.setPayloadProperties(props); //subscriptionData.setProperties(props); subscriptionData.setPrivateRepository(false); @@ -1082,6 +1302,7 @@ public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getCluste cartridgeSubscription.getPayloadData().add("LOAD_BALANCED_SERVICE_TYPE", loadBalancedCartridgeType); Properties lbProperties = new Properties(); + lbProperties.setPayloadProperties(props); lbProperties.setProperties(props); cartridgeSubsciptionManager.registerCartridgeSubscription(cartridgeSubscription, lbProperties); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 7b744a53c2..a836fb7def 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -39,6 +39,7 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; @@ -105,6 +106,75 @@ public Response getCookie(){ return Response.ok().header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON). entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build(); } + + @POST + @Path("/application/definition/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + // Grouping + public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefinitionBean applicationDefinitionBean) + throws RestAPIException { + + /*return ServiceUtils.deployApplication(applicationDefinitionBean, getConfigContext(), getUsername(), + getTenantDomain()); + */ + return ServiceUtils.deployCompositeApplicationDefinition(applicationDefinitionBean, getConfigContext(), getUsername(), + getTenantDomain()); + + } + + @POST + @Path("/application/definition/undeploy") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + // Grouping + public StratosAdminResponse unDeployApplicationDefinition(String alias) + throws RestAPIException { + + return ServiceUtils.unDeployApplication(alias, getConfigContext(), getUsername(), + getTenantDomain()); + + } + + + + @DELETE + @Path("/application/definition/{applicationAlias}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + // Grouping + public StratosAdminResponse unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) + throws RestAPIException { + + return ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), + getTenantDomain()); + + } + + + + /* + * Grouping --- fix API, use this instead of POST to remove application !!!! + + @DELETE + @Path("/cartridge/definition/{cartridgeType}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public StratosAdminResponse unDeployCartridgeDefinition (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { + + return ServiceUtils.undeployCartridge(cartridgeType); + } + nnnnnn + */ + @POST @Path("/cartridge/definition/") diff --git a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh index db86d7daa9..317da88821 100644 --- a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh +++ b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh @@ -44,7 +44,8 @@ properties="-Dmb.ip=MB-IP -Dmonitoring.server.port=MONITORING-SERVER-PORT -Dmonitoring.server.secure.port=MONITORING-SERVER-SECURE-PORT -Dmonitoring.server.admin.username=MONITORING-SERVER-ADMIN-USERNAME - -Dmonitoring.server.admin.password=MONITORING-SERVER-ADMIN-PASSWORD" + -Dmonitoring.server.admin.password=MONITORING-SERVER-ADMIN-PASSWORD + -DAPP_PATH=APP-PATH" # Uncomment below line to enable remote debugging #debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" diff --git a/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template b/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template index c6b062a0d4..45b8d7ae6c 100644 --- a/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template +++ b/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template @@ -20,6 +20,6 @@ # Please use loadbalancer.conf for updating mb-ip, mb-port and templates/jndi.properties.template # file for updating other configurations. # -connectionfactoryName=topicConnectionfactory -connectionfactory.topicConnectionfactory=amqp://admin:admin@carbon/carbon?brokerlist='tcp://$mb_ip:$mb_port' -java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory +connectionfactoryName=TopicConnectionFactory +connectionfactory.topicConnectionfactory=tcp://$mb_ip:$mb_port +java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory diff --git a/products/cartridge-agent/modules/distribution/src/main/extensions/mount_volumes.sh b/products/cartridge-agent/modules/distribution/src/main/extensions/mount_volumes.sh index 48f3ceb777..63e303f315 100755 --- a/products/cartridge-agent/modules/distribution/src/main/extensions/mount_volumes.sh +++ b/products/cartridge-agent/modules/distribution/src/main/extensions/mount_volumes.sh @@ -28,8 +28,8 @@ log=/var/log/apache-stratos/cartridge-agent-extensions.log echo -e "Starting mounting volumes" 2>&1 | tee -a $log # $1 is passed from Cartridge Agent code. -echo -e "launh param file location $1" | tee -a $log -#source /opt/apache-stratos-cartridge-agent/launch.params +echo -e "launch param file location $1" | tee -a $log + PERSISTENCE_MAPPING=$1 echo -e "Persistance mappings : $PERSISTENCE_MAPPING" 2>&1 | tee -a $log @@ -37,8 +37,29 @@ mount_volume(){ device=$1; mount_point=$2; - echo "device $device" - echo "point $mount_point" + echo -e "device $device" | tee -a $log + echo -e "mount point $mount_point"| tee -a $log + + + if [ "$mount_point" = "null" ] + then + echo -e "[ERROR] Mount point can not be null" | tee -a $log + return + fi + + if [ "$device" = "null" ] + then + echo -e "[ERROR] Device can not be null" | tee -a $log + return + fi + + device_exist=`sudo fdisk -l $device`; + if [ "$device_exist" = "" ] + then + echo -e "[ERROR] Device $device does not exist in this instance." | tee -a $log + return + fi + # check if the volume has a file system output=`sudo file -s $device`; echo $output | tee -a $log @@ -59,15 +80,15 @@ mount_volume(){ if [ ! -d "$mount_point" ] then echo "creating the mount point directory $mount_point since it does not exist." | tee -a $log - sudo mkdir $mount_point + sudo mkdir -p $mount_point fi #mounting the device if it is not already mounted if [ ! "$device_mounted" = "" ] then - echo -e "Device $device is already mounted." | tee -a $log + echo -e "[WARNING] Device $device is already mounted." | tee -a $log else - sudo mount $device $mount_point + sudo mount $device $mount_point 2>&1 | tee -a $log fi } @@ -75,12 +96,65 @@ mount_volume(){ IFS='|' read -ra ADDR <<< "${PERSISTENCE_MAPPING}" echo "${ADDR[@]}" | tee -a $log +echo -e "\n Volumes before mounting...." | tee -a $log +output=`/bin/lsblk` +echo -e "\n$output\n" | tee -a $log +output=`/sbin/blkid` +echo -e "\n$output\n" | tee -a $log + +totalcount=0 for i in "${!ADDR[@]}"; do - # expected PERSISTANCE_MAPPING format is device1|mountPoint1|device2|mountpoint2... - # so that even indexes are devices and odd indexes are mount points.. - if (( $i % 2 == 0 )) + # expected PERSISTANCE_MAPPING format is device1|volumeID1|mountPoint1|device2|volumeID2|mountpoint2... + if (( $i % 3 == 0 )) then - mount_volume ${ADDR[$i]} ${ADDR[$i + 1]} + devicelist[$totalcount]=${ADDR[$i]} + mountpathlist[$totalcount]=${ADDR[$i + 2]} + totalcount=$((totalcount+1)) + lastdevice=${ADDR[$i]} fi done + +device_exist=`sudo fdisk -l $lastdevice`; +if [ "$device_exist" = "" ] +then +# Last device doesn't exist, which means devices are not attached as per the order given in the payload +# So start mounting from the last available device and come down + devlist=`sudo lsblk -n | cut -f 1 -d " "` + devcount=`echo ${devlist} | awk '{print NF}'` + totalcount=$((totalcount-1)) + counter=0 + for ((i=${devcount}-1; totalcount>=0; i--)); do + devnum=`expr ${devcount} - ${counter}` + currdevice=`echo ${devlist} | cut -d " " -f ${devnum}` + fileout=`sudo file -s /dev/${currdevice}` + if [[ $fileout == *ROM* ]] || [[ $fileout == *boot* ]] || [[ $fileout == *cloud* ]] || [[ $fileout == *not-regular* ]] || [[ $fileout == *empty* ]] || [[ $fileout == *swap* ]] + then + # Ignore special files as checked above... + counter=`expr ${counter} + 1` + continue + fi + mountpath=${mountpathlist[$totalcount]} + totalcount=$((totalcount-1)) + echo "device is $currdevice" + echo "mount path is $mountpath" + counter=`expr ${counter} + 1` + mount_volume "/dev/${currdevice}" ${mountpath} + done +else +# Last device exists, which means the volumes are created or few might have been skipped in the first part since the device is already present +# Mount of rest of the volumes will be fine and contine + for i in "${!ADDR[@]}"; do + # expected PERSISTANCE_MAPPING format is device1|volumeID1|mountPoint1|device2|volumeID2|mountpoint2... + if (( $i % 3 == 0 )) + then + mount_volume ${ADDR[$i]} ${ADDR[$i + 2]} + fi + done +fi + +echo -e "\n Volumes after mounting...." | tee -a $log +output=`/bin/lsblk` +echo -e "\n$output\n" | tee -a $log +output=`/sbin/blkid` +echo -e "\n$output\n" | tee -a $log diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 6e1d9913ab..0cefc0c81e 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -643,6 +643,12 @@ ${pom.artifactId}-${pom.version}/repository/conf true 755 + + + src/main/conf/terminatedependency.drl + ${pom.artifactId}-${pom.version}/repository/conf + true + 755 diff --git a/products/stratos/modules/distribution/src/main/conf/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/mincheck.drl index b1c0f7c518..b29e991ed8 100755 --- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl +++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl @@ -48,6 +48,10 @@ global org.apache.stratos.messaging.domain.topology.Topology $topology; global java.util.Map partitionCtxts; global java.lang.String clusterId; global java.lang.String lbRef; +global java.lang.String serviceId; + +global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy; + rule "Minimum Rule" dialect "mvel" @@ -57,6 +61,9 @@ dialect "mvel" eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount())) eval($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount()) + eval(log.debug("Grouping ... checking startup dependencies for " + clusterId)) + eval($ctxt.checkStartupDependencies(serviceId, clusterId)) + eval(log.debug("startup dependencies successfully checked for" + clusterId)) then $delegator.delegateSpawn($ctxt, clusterId, lbRef); diff --git a/products/stratos/modules/distribution/src/main/conf/terminatedependency.drl b/products/stratos/modules/distribution/src/main/conf/terminatedependency.drl new file mode 100644 index 0000000000..9ea243cbec --- /dev/null +++ b/products/stratos/modules/distribution/src/main/conf/terminatedependency.drl @@ -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.autoscaler.rule; + +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.autoscaler.PartitionContext; + +global org.apache.stratos.autoscaler.rule.RuleLog log; +global org.apache.stratos.autoscaler.rule.RuleTasksDelegator $delegator; +global java.util.Map partitionCtxts; +global java.lang.String clusterId; +global java.lang.String lbRef; +global java.lang.String serviceId; + +global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy; + +rule "Terminate Dependency Rule" + +dialect "mvel" + when + $ctxt : PartitionContext () + eval(log.debug("Running terminate dependency rule: [partition] " + $ctxt.getPartitionId() + " [network-partition] " + $ctxt.getNetworkPartitionId())) + eval(log.debug("[terminate dependency] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() +" Member count: " + $ctxt.getMemberStatsContexts().size())) + eval(log.debug("Grouping ... in terminatedependency rule terminating all members " + $ctxt.getAllMemberForTerminationCount())) + eval(!$ctxt.checkKillDependencies(serviceId, clusterId)) + eval(log.debug("[terminate dependency] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " successfully terminated members")) + + eval(log.debug("Grouping:terminatedependency:terminating all")) + + then + $delegator.delegateTerminateAll(clusterId); +end + + + diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index ac1682135f..f5280644c1 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,960 +1,1081 @@ - - - + CloudControllerService - + - + - + - + - + - + - + - + - + - + - + - + + + + + + - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + + + + + + + + - + - + + + + + + + + + + + + + - - + + - + + + + + + + + - + - - + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - - - - - + + + - + - - - + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - + + - + - - - - - - - - - - - + + + + - + - + - + - - - + + + - + - - - - - - - - - - - - + + - + - - - - - - - - + + - + - - - - - - - - + + + + + + + + + + + + - - - - + - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + + + + - - + + - - + + - - + + - - - - + + + + - - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + \ No newline at end of file From 991d7856dd96fcb1d530a9fd447fea7d45f2c7fc Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 26 Jun 2014 17:44:44 -0700 Subject: [PATCH 002/436] fixing kill-all (multiple groups with same cartridge type), adding check for cartridge_type and group when determining active cluster state --- .../autoscaler/ComplexApplicationContext.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java index 98c4d2cbd8..07cb48f37f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java @@ -298,13 +298,12 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, StringBuffer buf = new StringBuffer(); buf.append("downstreamdependencies list: [ "); - if (downstreamDependencies != null & downstreamDependencies.keySet().size() > 0) { + if (downstreamDependencies != null && downstreamDependencies.keySet().size() > 0) { Set downstream_keys = downstreamDependencies.keySet(); for (String c : downstream_keys) { String d = downstreamDependencies.get(c); - buf.append(c + ", in group: ").append(d); + buf.append(c + ", in group: ").append(d).append(" "); } - buf.append("] ").append(" serviceId ").append(aServiceId); } else { buf.append(" downstreamDependencies is null "); @@ -324,11 +323,11 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, StringBuffer buf = new StringBuffer(); buf.append("upstreamdependencies list: [ "); - if (upstreamDependencies != null & upstreamDependencies.keySet().size() > 0) { + if (upstreamDependencies != null && upstreamDependencies.keySet().size() > 0) { Set upstream_keys = upstreamDependencies.keySet(); for (String c : upstream_keys) { String d = upstreamDependencies.get(c); - buf.append(c + ", in group: ").append(upstreamDependencies.get(d)); + buf.append(c + ", in group: ").append(upstreamDependencies.get(d)).append(" "); } buf.append("] ").append(" serviceId ").append(aServiceId); @@ -685,10 +684,10 @@ private List getServiceSet_StateInActive (Map serviceTyp log.debug("checking (inactive) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); } - // Martin TODO if (hasClusterActiveMember (cluster)) { + // TODO if (hasClusterActiveMember (cluster)) { // check group cluster is in - if (clusterGroup != null & clusterGroup.equals(serviceTypeGroup)) { + if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup)) { if (hasClusterActiveMember (cluster)) { hasClusterWithActiveMember = true; if (log.isDebugEnabled()) { @@ -782,8 +781,8 @@ private List getServiceSet_StateActive (Map serviceTypes log.debug("checking (active) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); } - // Martin TODO if (hasClusterActiveMember (cluster)) { - if (hasClusterActiveMember (cluster)) { // Martin for test only, replace with hasClusterActiveMember !!! + + if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup) && hasClusterActiveMember (cluster)) { hasClusterWithActiveMember = true; if (log.isDebugEnabled()) { log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup + From f8b27de43b5defc567f2961ec3d840cf4a923ce3 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 3 Jul 2014 19:53:33 +0530 Subject: [PATCH 003/436] persisting Service Groups - initial impl. --- .../InvalidServiceGroupException.java | 47 ++++++++ .../ServiceGroupDefinitioException.java | 47 ++++++++ .../definitions/DependencyDefinitions.java | 48 ++++++++ .../definitions/ServiceGroupDefinition.java | 68 +++++++++++ .../definitions/StartupOrderDefinition.java | 47 ++++++++ .../manager/ServiceGroupingManager.java | 114 ++++++++++++++++++ .../persistence/PersistenceManager.java | 7 ++ .../RegistryBasedPersistenceManager.java | 73 +++++++++++ .../DataInsertionAndRetrievalManager.java | 14 +++ .../stratos/manager/utils/Serializer.java | 20 +++ .../rest/endpoint/services/ServiceUtils.java | 58 +++++++-- .../rest/endpoint/services/StratosAdmin.java | 37 +++++- 12 files changed, 572 insertions(+), 8 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java create mode 100644 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/exception/InvalidServiceGroupException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java new file mode 100644 index 0000000000..063cebbf22 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/InvalidServiceGroupException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class InvalidServiceGroupException extends Exception { + + private String message; + + public InvalidServiceGroupException () { + super(); + } + + public InvalidServiceGroupException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public InvalidServiceGroupException (String message) { + super(message); + this.message = message; + } + + public InvalidServiceGroupException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java new file mode 100644 index 0000000000..5644ddb949 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ServiceGroupDefinitioException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class ServiceGroupDefinitioException extends Exception { + + private String message; + + public ServiceGroupDefinitioException () { + super(); + } + + public ServiceGroupDefinitioException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public ServiceGroupDefinitioException (String message) { + super(message); + this.message = message; + } + + public ServiceGroupDefinitioException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} 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 new file mode 100644 index 0000000000..eee4634188 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/DependencyDefinitions.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.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 List startupOrder; + + private String killBehaviour; + + public List getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(List startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } +} 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 new file mode 100644 index 0000000000..ac8321ff19 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.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.grouping.definitions; + +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.List; + +@XmlRootElement(name = "serviceGroup") +public class ServiceGroupDefinition implements Serializable { + + private String name; + + private List subGroups; + + private List cartridges; + + private DependencyDefinitions dependencies; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getSubGroups() { + return subGroups; + } + + public void setSubGroups(List subGroups) { + this.subGroups = subGroups; + } + + public List getCartridges() { + return cartridges; + } + + public void setCartridges(List cartridges) { + this.cartridges = cartridges; + } + + public DependencyDefinitions getDependencies() { + return dependencies; + } + + public void setDependencies(DependencyDefinitions dependencies) { + this.dependencies = dependencies; + } +} 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 new file mode 100644 index 0000000000..522e3a2606 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StartupOrderDefinition.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.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; + } +} 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 new file mode 100644 index 0000000000..49565fe3c4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/manager/ServiceGroupingManager.java @@ -0,0 +1,114 @@ +/* + * 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.axis2.AxisFault; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +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.PersistenceManagerException; +import org.apache.stratos.manager.exception.ServiceGroupDefinitioException; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; + +import java.rmi.RemoteException; +import java.util.List; + +public class ServiceGroupingManager { + + private static Log log = LogFactory.getLog(ServiceGroupingManager.class); + + private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; + + public ServiceGroupingManager () { + dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); + } + + public void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws InvalidServiceGroupException, + CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException { + + + // if any cartridges are specified in the group, they should be already deployed + if (serviceGroupDefinition.getCartridges() != null) { + List cartridgeTypes = serviceGroupDefinition.getCartridges(); + + 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 + throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType); + } + } catch (RemoteException e) { + throw new ADCException(e); + } + } + } + + // if any sub groups are specified in the group, they should be already deployed + if (serviceGroupDefinition.getSubGroups() != null) { + List subGroupNames = serviceGroupDefinition.getSubGroups(); + for (String subGroupName : subGroupNames) { + if (getServiceGroupDefinition(subGroupName) == null) { + // sub group not deployed, can't continue + throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); + } + } + } + + try { + dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition); + + } catch (PersistenceManagerException e) { + throw new InvalidServiceGroupException(e); + } + } + + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + + try { + return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (PersistenceManagerException e) { + throw new ServiceGroupDefinitioException(e); + } + } + + public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + + try { + dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (PersistenceManagerException e) { + throw new ServiceGroupDefinitioException(e); + } + } +} 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 index d5712c340b..65b31c40c1 100644 --- 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 @@ -21,6 +21,7 @@ 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.messaging.domain.topology.ConfigCompositeApplication; @@ -47,6 +48,12 @@ public abstract Collection getCartridgeSubscriptions(int 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; //Grouping public abstract void persistDeployedCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException; 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 index 408c1bb392..f4eb8ba96e 100644 --- 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 @@ -23,6 +23,7 @@ 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.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.registry.RegistryManager; import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.utils.Deserializer; @@ -47,6 +48,8 @@ public class RegistryBasedPersistenceManager extends PersistenceManager { private static final String INACTIVE_SUBSCRIPTIONS = "/subscriptions/inactive"; private static final String SERVICES = "/services"; private static final String COMPOSITE_APPLICATION = "/composite_applications"; + 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 { @@ -668,4 +671,74 @@ private void removeCompApplication(String alias) throws PersistenceManagerExcept } } + @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); + } + } + } 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 index 8250b3fd9c..4dd61fb639 100644 --- 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 @@ -23,6 +23,7 @@ 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.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.lookup.LookupDataHolder; import org.apache.stratos.manager.persistence.PersistenceManager; import org.apache.stratos.manager.persistence.RegistryBasedPersistenceManager; @@ -400,5 +401,18 @@ public Collection getCompositeApplications() throws return persistenceManager.getDeployedCompositeApplications(); } + 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); + } } 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 index d31b1a17c8..5de12131f0 100644 --- 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 @@ -20,6 +20,7 @@ package org.apache.stratos.manager.utils; 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.messaging.domain.topology.ConfigCompositeApplication; @@ -123,4 +124,23 @@ public static byte[] serializeServiceToByteArray(ConfigCompositeApplication conf } } + + 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(); + } + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index c88acf11a5..c3781f8dc0 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; @@ -35,7 +35,6 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; import org.apache.stratos.manager.application.CompositeApplicationManager; -import org.apache.stratos.manager.application.utils.ApplicationUtils; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.service.Service; @@ -43,17 +42,17 @@ import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; 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.CartridgeSubscription; import org.apache.stratos.manager.subscription.DataCartridgeSubscription; -import org.apache.stratos.manager.subscription.PersistenceContext; import org.apache.stratos.manager.subscription.SubscriptionData; 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.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; 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; @@ -67,12 +66,9 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; import javax.ws.rs.core.Response; @@ -89,6 +85,7 @@ public class ServiceUtils { private static Log log = LogFactory.getLog(ServiceUtils.class); private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager(); + private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager(); private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager(); static StratosAdminResponse deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt, @@ -1408,4 +1405,51 @@ static StratosAdminResponse synchronizeRepository(CartridgeSubscription cartridg return stratosAdminResponse; } + static StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException { + + try { + serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition); + + } catch (InvalidServiceGroupException e) { + throw new RestAPIException(e); + } catch (ServiceGroupDefinitioException e) { + throw new RestAPIException(e); + } catch (ADCException e) { + throw new RestAPIException(e); + } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { + throw new RestAPIException(e); + } + + log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName()); + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully deplpoyed Service Group Definition with name " + serviceGroupDefinition.getName()); + return stratosAdminResponse; + } + + static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { + + try { + return serviceGropingManager.getServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (ServiceGroupDefinitioException e) { + throw new RestAPIException(e); + } + } + + static StratosAdminResponse undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { + + try { + serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (ServiceGroupDefinitioException e) { + throw new RestAPIException(e); + } + + log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName); + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully undeplpoyed Service Group Definition with name " + serviceGroupDefinitionName); + return stratosAdminResponse; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index a836fb7def..b43f04d722 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -26,6 +26,7 @@ import org.apache.stratos.common.util.CommonUtil; import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.rest.endpoint.ServiceHolder; import org.apache.stratos.rest.endpoint.Utils; @@ -41,7 +42,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; -import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; import org.apache.stratos.tenant.mgt.core.TenantPersistor; @@ -201,6 +201,41 @@ public StratosAdminResponse unDeployCartridgeDefinition (@PathParam("cartridgeTy return ServiceUtils.undeployCartridge(cartridgeType); } + @POST + @Path("/group/definition/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) + throws RestAPIException { + + return ServiceUtils.deployServiceGroupDefinition(serviceGroupDefinition); + } + + @GET + @Path("/group/definition/{groupDefinitionName}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public ServiceGroupDefinition dgetServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) + throws RestAPIException { + + return ServiceUtils.getServiceGroupDefinition(groupDefinitionName); + } + + @DELETE + @Path("/group/definition/{groupDefinitionName}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + public StratosAdminResponse undeployServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) + throws RestAPIException { + + return ServiceUtils.undeployServiceGroupDefinition(groupDefinitionName); + } + @POST @Path("/policy/deployment/partition") @Produces("application/json") From 62dc96e9f9cb07106887b3f7adadca52ba4bde81 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 7 Jul 2014 12:10:37 +0530 Subject: [PATCH 004/436] initial impl. for composite application deployment and subscription --- .../CompositeApplicationManager.java | 40 +++-- .../beans/CompositeAppDefinition.java | 68 +++++++ .../application/beans/GroupDefinition.java | 87 +++++++++ .../beans/SubscribableDefinition.java | 47 +++++ .../application/beans/SubscribableInfo.java | 93 ++++++++++ .../parser/CompositeApplicationParser.java | 29 +++ .../DefaultCompositeApplicationParser.java | 166 ++++++++++++++++++ .../application/utils/ApplicationUtils.java | 4 +- ...mpositeApplicationDefinitionException.java | 47 +++++ .../deployer/DefaultServiceGroupDeployer.java | 125 +++++++++++++ .../deployer/ServiceGroupDeployer.java | 36 ++++ .../manager/ServiceGroupingManager.java | 73 +------- .../ADCManagementServerComponent.java | 2 - .../bean/util/converter/PojoConverter.java | 8 - .../rest/endpoint/services/ServiceUtils.java | 20 ++- .../rest/endpoint/services/StratosAdmin.java | 17 +- 16 files changed, 768 insertions(+), 94 deletions(-) rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/{ => composite}/application/CompositeApplicationManager.java (73%) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/{ => composite}/application/utils/ApplicationUtils.java (95%) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java create mode 100644 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/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java similarity index 73% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 863169475f..c905320e30 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -1,11 +1,15 @@ -package org.apache.stratos.manager.application; +package org.apache.stratos.manager.composite.application; import java.util.Collection; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.application.utils.ApplicationUtils; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.parser.CompositeApplicationParser; +import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser; +import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.exception.ADCException; +import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; @@ -15,18 +19,26 @@ public class CompositeApplicationManager { private static Log log = LogFactory.getLog(CompositeApplicationManager.class); - public void deployCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { - if (log.isDebugEnabled()) { - log.debug("deploying composite application " + configCompositeApplication.getAlias()); - } - registerCompositeApplication(configCompositeApplication); - if (log.isDebugEnabled()) { - log.debug("publishing composite application " + configCompositeApplication.getAlias()); - } - ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication); - if (log.isDebugEnabled()) { - log.debug("composite application successfully deployed" + configCompositeApplication.getAlias()); - } + public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException { +// if (log.isDebugEnabled()) { +// log.debug("deploying composite application " + configCompositeApplication.getAlias()); +// } +// registerCompositeApplication(configCompositeApplication); +// if (log.isDebugEnabled()) { +// log.debug("publishing composite application " + configCompositeApplication.getAlias()); +// } +// ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication); +// if (log.isDebugEnabled()) { +// log.debug("composite application successfully deployed" + configCompositeApplication.getAlias()); +// } + + CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); + compositeAppParser.parse(compositeAppDefinition); + + // TODO: traverse the data structure and create the subscriptions + + log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + + compositeAppDefinition.getAlias() + " ] deployed successfully"); } public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java new file mode 100644 index 0000000000..2eea073c54 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.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.composite.application.beans; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class CompositeAppDefinition { + + private String applicationId; + + private String alias; + + private List groups; + + private List subscribableInfo; + + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } + + public List getSubscribableInfo() { + return subscribableInfo; + } + + public void setSubscribableInfo(List subscribableInfo) { + this.subscribableInfo = subscribableInfo; + } +} 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 new file mode 100644 index 0000000000..3e92eb521d --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/GroupDefinition.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.composite.application.beans; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +public class GroupDefinition { + + private String name; + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private List subscribables; + + private List 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 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 List getSubscribables() { + return subscribables; + } + + public void setSubscribables(List subscribableDefinitions) { + this.subscribables = subscribableDefinitions; + } + + public List getGroups() { + return groups; + } + + public void setGroups(List groups) { + this.groups = groups; + } +} 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 new file mode 100644 index 0000000000..291594bdbb --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableDefinition.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.composite.application.beans; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +public class SubscribableDefinition { + + 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; + } +} 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 new file mode 100644 index 0000000000..e3b26ba1b7 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/SubscribableInfo.java @@ -0,0 +1,93 @@ +/* + * 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; + +public class SubscribableInfo { + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private String repoUrl; + + private boolean privateRepo; + + private String username; + + private String password; + + 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 getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java new file mode 100644 index 0000000000..829da0f489 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java @@ -0,0 +1,29 @@ +/* + * 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.parser; + +import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; +import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; + + +public interface CompositeApplicationParser { + + public CompositeApplicationDefinition parse (Object obj) throws CompositeApplicationDefinitionException; +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java new file mode 100644 index 0000000000..da560a951d --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -0,0 +1,166 @@ +/* + * 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.parser; + +import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; +import org.apache.stratos.manager.exception.PersistenceManagerException; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; + +import java.util.List; + +public class DefaultCompositeApplicationParser implements CompositeApplicationParser { + + DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager; + + public DefaultCompositeApplicationParser () { + dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + } + + @Override + public CompositeApplicationDefinition parse (Object compositeAppObj) throws CompositeApplicationDefinitionException { + + CompositeAppDefinition compositeAppDefinition = null; + + if (compositeAppObj instanceof CompositeAppDefinition) { + compositeAppDefinition = (CompositeAppDefinition) compositeAppObj; + + } else { + throw new CompositeApplicationDefinitionException("Invalid Composite Application definition"); + } + + if (compositeAppDefinition == null) { + throw new CompositeApplicationDefinitionException("Composite Application definition not found"); + } + + String compositeAppId = compositeAppDefinition.getApplicationId(); + String compositeAppAlias = compositeAppDefinition.getAlias(); + + // groups + processGroups(compositeAppDefinition.getGroups()); + + // get subscription related information + if (compositeAppDefinition.getSubscribableInfo() != null) { + // get the set (flat structure, not recursive) iterate and fill in.. + } + + return null; + } + + // TODO: should return the relevant object type to send to CC + private void processGroups (List groups) throws CompositeApplicationDefinitionException { + + if (groups == null) { + return; + } + + for (GroupDefinition group : groups) { + // process the group definitions + String groupName = group.getName(); + String groupAlias = group.getAlias(); + + // neither group name nor alias can be empty + if (groupName == null || groupName.isEmpty()) { + throw new CompositeApplicationDefinitionException("Group Name is invalid"); + } + if (groupAlias == null || groupAlias.isEmpty()) { + throw new CompositeApplicationDefinitionException("Group Alias is invalid"); + } + + // check if the group is deployed. if not can't continue + if (!isGroupDeployed(groupName)) { + throw new CompositeApplicationDefinitionException("No Service Group found with name [ " + groupName + " ]"); + } + + // get group level policy information + String groupDepPolicy = group.getDeploymentPolicy(); + String groupScalePolicy = group.getAutoscalingPolicy(); + + // subscribables + processSubscribables(group.getSubscribables()); + + // nested groups + processGroups(group.getGroups()); + } + } + + private boolean isGroupDeployed (String groupName) throws CompositeApplicationDefinitionException { + + ServiceGroupDefinition serviceGroupDefinition = null; + + try { + serviceGroupDefinition = dataInsertionAndRetrievalManager.getServiceGroupDefinition(groupName); + + } catch (PersistenceManagerException e) { + throw new CompositeApplicationDefinitionException(e); + } + + return serviceGroupDefinition != null; + } + + // TODO: should return the relevant object type to send to CC + private void processSubscribables (List subscribables) throws CompositeApplicationDefinitionException { + + if (subscribables == null) { + return; + } + + for (SubscribableDefinition subscribable : subscribables) { + + String cartridgeType = subscribable.getType(); + String subscriptionAlias = subscribable.getAlias(); + + // neither cartridge type nor alias can be empty + if (cartridgeType == null || cartridgeType.isEmpty()) { + throw new CompositeApplicationDefinitionException("Cartridge Type is invalid"); + } + if (subscriptionAlias == null || subscriptionAlias.isEmpty()) { + throw new CompositeApplicationDefinitionException("Subscription Alias is invalid"); + } + + + } + } + + // TODO: should return the relevant object type to send to CC + private void getSubscriptionInformation (List subscribables, String subscriptionAlias) throws CompositeApplicationDefinitionException { + + for (SubscribableInfo subscribable : subscribables) { + + if (subscribable.getAlias().equals(subscriptionAlias)) { + // match found, retrieve the information + String deploymentPolicy = subscribable.getDeploymentPolicy(); + String autoscalingPolicy = subscribable.getAutoscalingPolicy(); + String repoUrl = subscribable.getRepoUrl(); + if (repoUrl != null && !repoUrl.isEmpty()) { + boolean privateRepo = subscribable.isPrivateRepo(); + String repoUsername = subscribable.getUsername(); + String repoPassword = subscribable.getPassword(); + } + } + } + } + +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java similarity index 95% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java index d1634b0ce0..8b7cdbbd46 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/application/utils/ApplicationUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java @@ -1,6 +1,5 @@ -package org.apache.stratos.manager.application.utils; +package org.apache.stratos.manager.composite.application.utils; -import java.util.Set; import java.util.concurrent.Executor; import org.apache.commons.logging.Log; @@ -10,7 +9,6 @@ import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; import org.apache.stratos.messaging.util.Constants; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java new file mode 100644 index 0000000000..bda75ab4ea --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationDefinitionException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class CompositeApplicationDefinitionException extends Exception { + + private String message; + + public CompositeApplicationDefinitionException () { + super(); + } + + public CompositeApplicationDefinitionException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public CompositeApplicationDefinitionException (String message) { + super(message); + this.message = message; + } + + public CompositeApplicationDefinitionException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} 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 new file mode 100644 index 0000000000..4744f9fd0f --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/DefaultServiceGroupDeployer.java @@ -0,0 +1,125 @@ +/* + * 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.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +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.PersistenceManagerException; +import org.apache.stratos.manager.exception.ServiceGroupDefinitioException; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; + +import java.rmi.RemoteException; +import java.util.List; + +public class DefaultServiceGroupDeployer implements ServiceGroupDeployer { + + private static Log log = LogFactory.getLog(DefaultServiceGroupDeployer.class); + + private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; + + public DefaultServiceGroupDeployer () { + dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); + } + + public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) throws InvalidServiceGroupException, + CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException { + + ServiceGroupDefinition serviceGroupDefinition = null; + + if (serviceGroupDefinitionObj instanceof ServiceGroupDefinition) { + serviceGroupDefinition = (ServiceGroupDefinition) serviceGroupDefinitionObj; + } else { + throw new InvalidServiceGroupException("Invalid Service Group definition"); + } + + if (serviceGroupDefinition == null) { + throw new InvalidServiceGroupException("Service Group definition not found"); + } + + // if any cartridges are specified in the group, they should be already deployed + if (serviceGroupDefinition.getCartridges() != null) { + List cartridgeTypes = serviceGroupDefinition.getCartridges(); + + 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 + throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType); + } + } catch (RemoteException e) { + throw new ADCException(e); + } + } + } + + // if any sub groups are specified in the group, they should be already deployed + if (serviceGroupDefinition.getSubGroups() != null) { + List subGroupNames = serviceGroupDefinition.getSubGroups(); + for (String subGroupName : subGroupNames) { + if (getServiceGroupDefinition(subGroupName) == null) { + // sub group not deployed, can't continue + throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); + } + } + } + + try { + dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition); + + } catch (PersistenceManagerException e) { + throw new InvalidServiceGroupException(e); + } + } + + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + + try { + return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (PersistenceManagerException e) { + throw new ServiceGroupDefinitioException(e); + } + } + + public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + + try { + dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName); + + } catch (PersistenceManagerException e) { + throw new ServiceGroupDefinitioException(e); + } + } +} 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 new file mode 100644 index 0000000000..da8ff531e1 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/deployer/ServiceGroupDeployer.java @@ -0,0 +1,36 @@ +/* + * 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.CloudControllerServiceUnregisteredCartridgeExceptionException; +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, CloudControllerServiceUnregisteredCartridgeExceptionException; + + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException; + + public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException; +} 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 index 49565fe3c4..3c42e01ce0 100644 --- 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 @@ -19,96 +19,39 @@ package org.apache.stratos.manager.grouping.manager; -import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -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.PersistenceManagerException; import org.apache.stratos.manager.exception.ServiceGroupDefinitioException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; -import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; +import org.apache.stratos.manager.grouping.deployer.DefaultServiceGroupDeployer; +import org.apache.stratos.manager.grouping.deployer.ServiceGroupDeployer; -import java.rmi.RemoteException; -import java.util.List; public class ServiceGroupingManager { - private static Log log = LogFactory.getLog(ServiceGroupingManager.class); - - private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; + //private static Log log = LogFactory.getLog(ServiceGroupingManager.class); + private ServiceGroupDeployer serviceGroupDeployer; public ServiceGroupingManager () { - dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); + serviceGroupDeployer = new DefaultServiceGroupDeployer(); } public void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws InvalidServiceGroupException, CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException { - - // if any cartridges are specified in the group, they should be already deployed - if (serviceGroupDefinition.getCartridges() != null) { - List cartridgeTypes = serviceGroupDefinition.getCartridges(); - - 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 - throw new InvalidServiceGroupException("No Cartridge Definition found with type " + cartridgeType); - } - } catch (RemoteException e) { - throw new ADCException(e); - } - } - } - - // if any sub groups are specified in the group, they should be already deployed - if (serviceGroupDefinition.getSubGroups() != null) { - List subGroupNames = serviceGroupDefinition.getSubGroups(); - for (String subGroupName : subGroupNames) { - if (getServiceGroupDefinition(subGroupName) == null) { - // sub group not deployed, can't continue - throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); - } - } - } - - try { - dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition); - - } catch (PersistenceManagerException e) { - throw new InvalidServiceGroupException(e); - } + serviceGroupDeployer.deployServiceGroupDefinition(serviceGroupDefinition); } public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { - try { - return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName); - - } catch (PersistenceManagerException e) { - throw new ServiceGroupDefinitioException(e); - } + return serviceGroupDeployer.getServiceGroupDefinition(serviceGroupDefinitionName); } public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { - try { - dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName); - - } catch (PersistenceManagerException e) { - throw new ServiceGroupDefinitioException(e); - } + serviceGroupDeployer.undeployServiceGroupDefinition(serviceGroupDefinitionName); } } 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 index 68f6a6e896..c408eac9ea 100644 --- 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 @@ -20,8 +20,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.application.CompositeApplicationManager; -import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.listener.InstanceStatusListener; import org.apache.stratos.manager.publisher.TenantEventPublisher; import org.apache.stratos.manager.publisher.TenantSynchronizerTaskScheduler; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 84ddfbfcc2..6a771aa813 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -22,10 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.manager.application.utils.ApplicationUtils; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; @@ -36,13 +34,7 @@ import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup; import org.apache.stratos.rest.endpoint.bean.topology.Member; -import org.apache.stratos.messaging.domain.topology.Cartridge; -import org.apache.stratos.messaging.domain.topology.Composite; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; -import org.apache.stratos.messaging.domain.topology.Dependencies; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.Scalable; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.commons.logging.Log; import java.util.ArrayList; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index c3781f8dc0..b357eedf52 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -34,7 +34,8 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; -import org.apache.stratos.manager.application.CompositeApplicationManager; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.CompositeApplicationManager; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.service.Service; @@ -87,6 +88,7 @@ public class ServiceUtils { private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager(); private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager(); private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager(); + private static CompositeApplicationManager compositeApplicationManager = new CompositeApplicationManager(); static StratosAdminResponse deployCartridge (CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { @@ -250,6 +252,22 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli stratosAdminResponse.setMessage("Successfully composite application to cloud controller"); return stratosAdminResponse; } + + static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition) + throws RestAPIException { + + try { + compositeApplicationManager.deployCompositeApplication(compositeAppDefinition); + + } catch (CompositeApplicationDefinitionException e) { + e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); + stratosAdminResponse.setMessage("Successfully deployed Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + + " , alias: " + compositeAppDefinition.getAlias() + " ]"); + return stratosAdminResponse; + } static StratosAdminResponse unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index b43f04d722..dd30f09fea 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -24,6 +24,7 @@ import org.apache.stratos.common.exception.StratosException; import org.apache.stratos.common.util.ClaimsMgtUtil; import org.apache.stratos.common.util.CommonUtil; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -106,7 +107,7 @@ public Response getCookie(){ return Response.ok().header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON). entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build(); } - + @POST @Path("/application/definition/") @Produces("application/json") @@ -124,6 +125,20 @@ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefi getTenantDomain()); } + + /* @POST + @Path("/application/definition/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + // Grouping + public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition compositeAppDefinition) + throws RestAPIException { + + return ServiceUtils.deployCompositeApplicationDefintion(compositeAppDefinition); + } */ + @POST @Path("/application/definition/undeploy") From 807522a37d66042960e177d3a3cd72b9588979b0 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 7 Jul 2014 12:47:28 +0530 Subject: [PATCH 005/436] correcting spelling mistakes in getServiceGroupDefinition --- .../org/apache/stratos/rest/endpoint/services/StratosAdmin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index b43f04d722..ba2ef42d1e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -218,7 +218,7 @@ public StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public ServiceGroupDefinition dgetServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) + public ServiceGroupDefinition getServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) throws RestAPIException { return ServiceUtils.getServiceGroupDefinition(groupDefinitionName); From 19273e1d596f0c294b65968c0841a4ded60916da Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 8 Jul 2014 15:31:57 +0530 Subject: [PATCH 006/436] fixing minor log issues --- .../stratos/rest/endpoint/services/ServiceUtils.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index b357eedf52..879370bbc9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -222,8 +222,7 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli if (cloudControllerServiceClient != null) { // call CC try { - cloudControllerServiceClient - .deployCompositeApplicationDefinition(appConfig); + cloudControllerServiceClient.deployCompositeApplicationDefinition(appConfig); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -244,12 +243,12 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli throw new RestAPIException(message, e); } - log.info("Successfully composite application to cloud controller"); + log.info("Successfully deployed composite application to Cloud Controller"); } StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully composite application to cloud controller"); + stratosAdminResponse.setMessage("Successfully deployed composite application to cloud controller"); return stratosAdminResponse; } @@ -307,7 +306,7 @@ static StratosAdminResponse unDeployApplication(String configCompositeApplicatio } } - log.info("l [type] " + configCompositeApplicationAlias); + log.info(String.format("[type] %s", configCompositeApplicationAlias)); StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); From e22f59f3bbd3a516d20c05202ce9fdb0dd81dabc Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 11 Jul 2014 12:02:36 +0530 Subject: [PATCH 007/436] change CompositeApplication according to the last Json format --- .../beans/SubscribableDefinition.java | 55 +++++++++++++++++++ .../RegistryBasedPersistenceManager.java | 2 +- .../definition/CartridgeDefinition.java | 15 +++++ ...figGroup.java => ComponentDefinition.java} | 11 +++- .../CompositeApplicationDefinitionBean.java | 4 +- .../definition/ConfigCartridge.java | 8 --- .../bean/util/converter/PojoConverter.java | 16 +++--- .../rest/endpoint/services/ServiceUtils.java | 4 +- 8 files changed, 91 insertions(+), 24 deletions(-) create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java rename components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/{ConfigGroup.java => ComponentDefinition.java} (71%) delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.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 index 291594bdbb..d85f235313 100644 --- 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 @@ -28,6 +28,13 @@ public class SubscribableDefinition { private String alias; + private String deploymentPolicy; + private String autoscalingPolicy; + private String repoUrl; + private boolean isPrivateRepo; + private String repoUsername; + private String repoPassword; + public String getType() { return type; @@ -44,4 +51,52 @@ public String getAlias() { 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 isPrivateRepo; + } + + public void setPrivateRepo(boolean isPrivateRepo) { + this.isPrivateRepo = isPrivateRepo; + } + + 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; + } } 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 index f4eb8ba96e..50bd56b6e6 100644 --- 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 @@ -228,7 +228,7 @@ public void persistDeployedCompositeApplication (ConfigCompositeApplication conf throws PersistenceManagerException { if (log.isDebugEnabled()) { - log.debug("trying to persiste ConfigCompositeApplication [ " + configCompositeAapplication.getAlias() + " ]"); + log.debug(String.format("trying to persist ConfigCompositeApplication [ %s ]", configCompositeAapplication.getAlias())); } int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (tenantId != MultitenantConstants.SUPER_TENANT_ID) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java new file mode 100644 index 0000000000..ccd16626b1 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java @@ -0,0 +1,15 @@ +package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "cartridge") +public class CartridgeDefinition { + public String alias; + public String type; + private String deploymentPolicy; + private String autoscalingPolicy; + private String repoUrl; + private boolean privateRepo; + private String username; + private String password; +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java similarity index 71% rename from components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java rename to components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java index bbdd0e3c7e..3207557388 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigGroup.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java @@ -1,14 +1,19 @@ package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; + import java.util.List; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "components") -public class ConfigGroup { - public String alias; - public List subscribables; +public class ComponentDefinition { + public String group; + public String alias; + public List subscribables; public ConfigDependencies dependencies; + public String deploymentPolicy; + public String autoscalingPolicy; /* public String getAlias() { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java index 2efc62bf62..a0b1624c58 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java @@ -10,8 +10,8 @@ public class CompositeApplicationDefinitionBean { public String applicationId; public String alias; - public List components; - public List cartridges; + public List components; + public List cartridges; } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java deleted file mode 100644 index 85d57ce14a..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigCartridge.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "cartridge") -public class ConfigCartridge { - public String alias; -} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 6a771aa813..4abbefcde6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -29,10 +29,10 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.*; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CartridgeDefinition; +import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ComponentDefinition; import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigCartridge; import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigGroup; import org.apache.stratos.rest.endpoint.bean.topology.Member; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.commons.logging.Log; @@ -654,7 +654,7 @@ public static List convertToServiceDefinitionBeans (Colle private static Log log = LogFactory.getLog(PojoConverter.class); - + /* public static ConfigCompositeApplication convertToCompositeApplication(CompositeApplicationDefinitionBean appBean) { ConfigCompositeApplication configApp = new ConfigCompositeApplication(); @@ -664,7 +664,7 @@ public static ConfigCompositeApplication convertToCompositeApplication(Composite List configCartridges = new ArrayList(); - for (ConfigCartridge beanCartridge : appBean.cartridges ) { + for (CartridgeDefinition beanCartridge : appBean.cartridges ) { org.apache.stratos.messaging.domain.topology.ConfigCartridge configCartridge = new org.apache.stratos.messaging.domain.topology.ConfigCartridge(); configCartridge.setAlias(beanCartridge.alias); @@ -676,7 +676,7 @@ public static ConfigCompositeApplication convertToCompositeApplication(Composite List configGroups = new ArrayList(); - for (ConfigGroup beanGroup : appBean.components ) { + for (ComponentDefinition beanGroup : appBean.components ) { org.apache.stratos.messaging.domain.topology.ConfigGroup configGroup = new org.apache.stratos.messaging.domain.topology.ConfigGroup(); configGroup.setAlias(beanGroup.alias); @@ -701,7 +701,7 @@ public static ConfigCompositeApplication convertToCompositeApplication(Composite return configApp; } - + */ // grouping public static CompositeApplicationDefinition convertToCompositeApplicationForCC (CompositeApplicationDefinitionBean appBean) { CompositeApplicationDefinition configApp = new CompositeApplicationDefinition(); @@ -714,7 +714,7 @@ public static CompositeApplicationDefinition convertToCompositeApplicationForCC List configCartridges = new ArrayList(); - for (ConfigCartridge beanCartridge : appBean.cartridges ) { + for (CartridgeDefinition beanCartridge : appBean.cartridges ) { org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge configCartridge = new org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge(); configCartridge.setAlias(beanCartridge.alias); @@ -729,7 +729,7 @@ public static CompositeApplicationDefinition convertToCompositeApplicationForCC List configGroups = new ArrayList(); - for (ConfigGroup beanGroup : appBean.components ) { + for (ComponentDefinition beanGroup : appBean.components ) { org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup configGroup = new org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup(); configGroup.setAlias(beanGroup.alias); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 879370bbc9..7458b96b0d 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -144,7 +144,7 @@ static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean applicationDefinitionBean.alias); if (applicationDefinitionBean.components != null) { log.debug("application config groups size " + applicationDefinitionBean.components.size()); - for (ConfigGroup cfg : applicationDefinitionBean.components) { + for (ComponentDefinition cfg : applicationDefinitionBean.components) { log.debug("listing application config groups " + cfg.alias + " /sub " + cfg.subscribables + " /dep " + cfg.dependencies); if (cfg.dependencies != null) { @@ -1440,7 +1440,7 @@ static StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName()); StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deplpoyed Service Group Definition with name " + serviceGroupDefinition.getName()); + stratosAdminResponse.setMessage("Successfully deployed Service Group Definition with name " + serviceGroupDefinition.getName()); return stratosAdminResponse; } From fad15e2d66a7fe8b648241f43602e42a8d0d1800 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 11 Jul 2014 20:01:58 +0530 Subject: [PATCH 008/436] moving beans to manager --- .../beans/CartridgeDefinition.java | 69 +++++++++++++++++++ .../beans/ComponentDefinition.java | 54 +++++++++++++++ .../beans/CompositeAppDefinition.java | 21 +++--- .../application/beans/SubscribableInfo.java | 10 +++ .../DefaultCompositeApplicationParser.java | 49 ++++++------- .../definition/CartridgeDefinition.java | 15 ---- .../definition/ComponentDefinition.java | 40 ----------- .../CompositeApplicationDefinitionBean.java | 17 ----- .../definition/ConfigDependencies.java | 57 --------------- .../bean/util/converter/PojoConverter.java | 8 +-- .../rest/endpoint/services/ServiceUtils.java | 5 +- .../rest/endpoint/services/StratosAdmin.java | 18 +++-- 12 files changed, 182 insertions(+), 181 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.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 new file mode 100644 index 0000000000..7788dc6c52 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java @@ -0,0 +1,69 @@ +package org.apache.stratos.manager.composite.application.beans; + + +public class CartridgeDefinition { + private String alias; + private String type; + private String deploymentPolicy; + private String autoscalingPolicy; + private String repoUrl; + private boolean privateRepo; + private String username; + private String password; + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + 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 getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } +} 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 new file mode 100644 index 0000000000..6a2ab2b5ee --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ComponentDefinition.java @@ -0,0 +1,54 @@ +package org.apache.stratos.manager.composite.application.beans; + +import java.util.List; + +/** + * Created by udara on 7/11/14. + */ +public class ComponentDefinition { + private String group; + private String alias; + private List subscribables; + private String deploymentPolicy; + private String autoscalingPolicy; + + public String getGroup() { + return group; + } + + public void setGroup(String group) { + this.group = group; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public List getSubscribables() { + return subscribables; + } + + public void setSubscribables(List subscribables) { + this.subscribables = subscribables; + } + + 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; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java index 2eea073c54..477e098c8f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java @@ -29,10 +29,9 @@ public class CompositeAppDefinition { private String alias; - private List groups; - - private List subscribableInfo; + private List components; + private List cartridges; public String getApplicationId() { return applicationId; @@ -50,19 +49,19 @@ public void setAlias(String alias) { this.alias = alias; } - public List getGroups() { - return groups; + public List getComponents() { + return components; } - public void setGroups(List groups) { - this.groups = groups; + public void setComponents(List components) { + this.components = components; } - public List getSubscribableInfo() { - return subscribableInfo; + public List getCartridges() { + return cartridges; } - public void setSubscribableInfo(List subscribableInfo) { - this.subscribableInfo = subscribableInfo; + public void setCartridges(List cartridges) { + this.cartridges = cartridges; } } 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 index e3b26ba1b7..01905993fd 100644 --- 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 @@ -21,6 +21,8 @@ public class SubscribableInfo { + private String type; + private String alias; private String deploymentPolicy; @@ -90,4 +92,12 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index da560a951d..8e67c804df 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -19,11 +19,9 @@ package org.apache.stratos.manager.composite.application.parser; +import org.apache.commons.lang3.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; -import org.apache.stratos.manager.composite.application.beans.GroupDefinition; -import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; -import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.beans.*; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -56,53 +54,48 @@ public CompositeApplicationDefinition parse (Object compositeAppObj) throws Comp } String compositeAppId = compositeAppDefinition.getApplicationId(); + if(StringUtils.isEmpty(compositeAppId)){ + throw new CompositeApplicationDefinitionException("Application ID can not be empty"); + } String compositeAppAlias = compositeAppDefinition.getAlias(); - // groups - processGroups(compositeAppDefinition.getGroups()); - - // get subscription related information - if (compositeAppDefinition.getSubscribableInfo() != null) { - // get the set (flat structure, not recursive) iterate and fill in.. - } + // components + processComponents(compositeAppDefinition.getComponents()); return null; } // TODO: should return the relevant object type to send to CC - private void processGroups (List groups) throws CompositeApplicationDefinitionException { + private void processComponents(List components) throws CompositeApplicationDefinitionException { - if (groups == null) { + if (components == null) { return; } - for (GroupDefinition group : groups) { + for (ComponentDefinition component : components) { // process the group definitions - String groupName = group.getName(); - String groupAlias = group.getAlias(); + String groupName = component.getGroup(); + String groupAlias = component.getAlias(); // neither group name nor alias can be empty - if (groupName == null || groupName.isEmpty()) { + if (StringUtils.isEmpty(groupName)) { throw new CompositeApplicationDefinitionException("Group Name is invalid"); } - if (groupAlias == null || groupAlias.isEmpty()) { + if (StringUtils.isEmpty(groupAlias)) { throw new CompositeApplicationDefinitionException("Group Alias is invalid"); } // check if the group is deployed. if not can't continue if (!isGroupDeployed(groupName)) { - throw new CompositeApplicationDefinitionException("No Service Group found with name [ " + groupName + " ]"); + throw new CompositeApplicationDefinitionException(String.format("No Service Group found with name [ %s ]", groupName)); } // get group level policy information - String groupDepPolicy = group.getDeploymentPolicy(); - String groupScalePolicy = group.getAutoscalingPolicy(); + String groupDepPolicy = component.getDeploymentPolicy(); + String groupScalePolicy = component.getAutoscalingPolicy(); // subscribables - processSubscribables(group.getSubscribables()); - - // nested groups - processGroups(group.getGroups()); + processSubscribables(component.getSubscribables()); } } @@ -121,13 +114,13 @@ private boolean isGroupDeployed (String groupName) throws CompositeApplicationDe } // TODO: should return the relevant object type to send to CC - private void processSubscribables (List subscribables) throws CompositeApplicationDefinitionException { + private void processSubscribables (List subscribables) throws CompositeApplicationDefinitionException { if (subscribables == null) { return; } - for (SubscribableDefinition subscribable : subscribables) { + for (SubscribableInfo subscribable : subscribables) { String cartridgeType = subscribable.getType(); String subscriptionAlias = subscribable.getAlias(); @@ -139,7 +132,7 @@ private void processSubscribables (List subscribables) t if (subscriptionAlias == null || subscriptionAlias.isEmpty()) { throw new CompositeApplicationDefinitionException("Subscription Alias is invalid"); } - + // TODO should validate if there exist a cartridge with $cartridgeType } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java deleted file mode 100644 index ccd16626b1..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CartridgeDefinition.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "cartridge") -public class CartridgeDefinition { - public String alias; - public String type; - private String deploymentPolicy; - private String autoscalingPolicy; - private String repoUrl; - private boolean privateRepo; - private String username; - private String password; -} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java deleted file mode 100644 index 3207557388..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ComponentDefinition.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; - -import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; - -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "components") -public class ComponentDefinition { - public String group; - public String alias; - public List subscribables; - public ConfigDependencies dependencies; - public String deploymentPolicy; - public String autoscalingPolicy; - - /* - public String getAlias() { - return alias; - } - public void setAlias(String alias) { - this.alias = alias; - } - public List getSubscribables() { - return subscribables; - } - public void setSubscribables(List subscribables) { - this.subscribables = subscribables; - } - public ConfigDependencies getDependencies() { - return dependencies; - } - public void setDependencies(ConfigDependencies dependencies) { - this.dependencies = dependencies; - } - */ - - -} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java deleted file mode 100644 index a0b1624c58..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/CompositeApplicationDefinitionBean.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; - -import javax.xml.bind.annotation.XmlRootElement; - -import java.util.List; - -@XmlRootElement(name = "applicationDefinitionBean") - -public class CompositeApplicationDefinitionBean { - - public String applicationId; - public String alias; - public List components; - public List cartridges; - - -} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java deleted file mode 100644 index 5efd201665..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/compositeapplication/definition/ConfigDependencies.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.apache.stratos.rest.endpoint.bean.compositeapplication.definition; - -import java.util.ArrayList; -import java.util.List; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name = "dependencies") -public class ConfigDependencies { - public List startup_order = new ArrayList(); - public String kill_behavior; - - /* - public String getKill_behavior() { - return kill_behavior; - } - - public void setKill_behavior(String kill_behavior) { - this.kill_behavior = kill_behavior; - } - - public List getStartup_order() { - return startup_order; - } - - public void setStartup_order(List startup_order) { - this.startup_order = startup_order; - } - */ - - - public static class Pair { - private String key; - private String value; - - private Pair() {} - - public Pair(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - public String getValue() { - return value; - } - public void setValue(String value) { - this.value = value; - } - } - -} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 4abbefcde6..b47ac0d840 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -29,12 +29,7 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.*; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CartridgeDefinition; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ComponentDefinition; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.ConfigDependencies; import org.apache.stratos.rest.endpoint.bean.topology.Member; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.commons.logging.Log; import java.util.ArrayList; @@ -703,6 +698,7 @@ public static ConfigCompositeApplication convertToCompositeApplication(Composite } */ // grouping + /* public static CompositeApplicationDefinition convertToCompositeApplicationForCC (CompositeApplicationDefinitionBean appBean) { CompositeApplicationDefinition configApp = new CompositeApplicationDefinition(); @@ -770,5 +766,5 @@ public static CompositeApplicationDefinition convertToCompositeApplicationForCC return configApp; } - + */ } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 7458b96b0d..468c67a468 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -66,7 +66,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; @@ -208,7 +207,7 @@ static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean stratosAdminResponse.setMessage("Successfully deployed application definition w" + applicationDefinitionBean); return stratosAdminResponse; } */ - + /* static StratosAdminResponse deployCompositeApplicationDefinition (CompositeApplicationDefinitionBean compositeApplicationDefinition, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { @@ -251,7 +250,7 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli stratosAdminResponse.setMessage("Successfully deployed composite application to cloud controller"); return stratosAdminResponse; } - +*/ static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition) throws RestAPIException { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 5262163254..8cdf16b0f3 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -41,7 +41,6 @@ import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.deployment.DeploymentPolicy; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; -import org.apache.stratos.rest.endpoint.bean.compositeapplication.definition.CompositeApplicationDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; @@ -108,6 +107,7 @@ public Response getCookie(){ entity(Utils.buildAuthenticationSuccessMessage(sessionId)).build(); } + /* @POST @Path("/application/definition/") @Produces("application/json") @@ -118,13 +118,23 @@ public Response getCookie(){ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefinitionBean applicationDefinitionBean) throws RestAPIException { - /*return ServiceUtils.deployApplication(applicationDefinitionBean, getConfigContext(), getUsername(), - getTenantDomain()); - */ return ServiceUtils.deployCompositeApplicationDefinition(applicationDefinitionBean, getConfigContext(), getUsername(), getTenantDomain()); } +*/ + @POST + @Path("/application/definition/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + @SuperTenantService(true) + // Grouping + public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition applicationDefinitionBean) + throws RestAPIException { + return ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean); + + } /* @POST @Path("/application/definition/") From 308f6d34fd22c4e02c3f7c6b7f8476f005385503 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 11 Jul 2014 21:15:28 +0530 Subject: [PATCH 009/436] persist CompositeApplication --- .../CompositeApplicationManager.java | 5 +- .../beans/CartridgeDefinition.java | 8 +++ .../beans/ComponentDefinition.java | 3 -- .../persistence/PersistenceManager.java | 2 + .../RegistryBasedPersistenceManager.java | 50 ++++++++++++++++++- .../DataInsertionAndRetrievalManager.java | 34 ++++++++++++- .../stratos/manager/utils/Serializer.java | 22 ++++++++ .../rest/endpoint/services/ServiceUtils.java | 4 +- 8 files changed, 121 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index c905320e30..2a02646c27 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -19,7 +19,7 @@ public class CompositeApplicationManager { private static Log log = LogFactory.getLog(CompositeApplicationManager.class); - public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException { + public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException, PersistenceManagerException { // if (log.isDebugEnabled()) { // log.debug("deploying composite application " + configCompositeApplication.getAlias()); // } @@ -34,6 +34,9 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); compositeAppParser.parse(compositeAppDefinition); + + DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + mgr.persistCompositeApplication(compositeAppDefinition); // TODO: traverse the data structure and create the subscriptions 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 index 7788dc6c52..bb191452fd 100644 --- 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 @@ -66,4 +66,12 @@ public String getUsername() { public void setUsername(String username) { this.username = username; } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } } 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 index 6a2ab2b5ee..55be3fe223 100644 --- 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 @@ -2,9 +2,6 @@ import java.util.List; -/** - * Created by udara on 7/11/14. - */ public class ComponentDefinition { private String group; private String alias; 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 index 65b31c40c1..c0203eba6c 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.stratos.manager.persistence; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -57,6 +58,7 @@ public abstract Collection getCartridgeSubscriptions(int //Grouping public abstract void persistDeployedCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException; + public abstract void persistCompositeApplication(CompositeAppDefinition compositeApplication) throws PersistenceManagerException; //Grouping public abstract void removeDeployedCompositeApplication(String configCompositeApplicationAlias) throws PersistenceManagerException; 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 index 50bd56b6e6..2ef26802fc 100644 --- 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 @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -249,7 +250,33 @@ public void persistDeployedCompositeApplication (ConfigCompositeApplication conf persistCompApplication(configCompositeAapplication); } } - + + public void persistCompositeApplication (CompositeAppDefinition configCompositeApplication) + throws PersistenceManagerException { + + if (log.isDebugEnabled()) { + log.debug(String.format("trying to persist ConfigCompositeApplication [ %s ]", configCompositeApplication.getAlias())); + } + 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); + + persistCompApplication(configCompositeApplication); + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + + } else { + persistCompApplication(configCompositeApplication); + } + } + // Grouping private void persistCompApplication (ConfigCompositeApplication configCompositeAapplication) throws PersistenceManagerException { @@ -270,6 +297,27 @@ private void persistCompApplication (ConfigCompositeApplication configCompositeA throw new PersistenceManagerException(e); } } + + // Grouping + private void persistCompApplication (CompositeAppDefinition configCompositeAapplication) throws PersistenceManagerException { + + // persist Service + try { + //RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + configCompositeAapplication.getAlias(), + RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + "compositeApplicationAlias", + Serializer.serializeServiceToByteArray(configCompositeAapplication), null); + + if (log.isDebugEnabled()) { + log.debug("Persisted ConfigCompositeApplication successfully: hardcoded [ " + configCompositeAapplication.getAlias() + " ]"); + } + + } catch (RegistryException e) { + throw new PersistenceManagerException(e); + + } catch (IOException e) { + throw new PersistenceManagerException(e); + } + } public void removeDeployedCompositeApplication(String configCompositeApplicationAlias) throws PersistenceManagerException { 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 index 4dd61fb639..4f88f2c9b9 100644 --- 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 @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -369,7 +370,38 @@ public void persistCompositeApplication (ConfigCompositeApplication configCompos //LookupDataHolder.getInstance().releaseWriteLock(); } } - + + public void persistCompositeApplication (CompositeAppDefinition compositeApplication) throws PersistenceManagerException { + + // get the write lock + //LookupDataHolder.getInstance().acquireWriteLock(); + + try { + // store in LookupDataHolder + //ToDo ... add to data holder + // LookupDataHolder.getInstance().putSubscription(cartridgeSubscription); + + try { + // store in Persistence Manager + persistenceManager.persistCompositeApplication(compositeApplication); + + } 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 + /* TODO + 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(); + } + } // Grouping public void removeCompositeApplication (String configCompositeApplicationAlias) throws PersistenceManagerException { 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 index 5de12131f0..6597499c91 100644 --- 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 @@ -19,6 +19,7 @@ package org.apache.stratos.manager.utils; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.lookup.ClusterIdToSubscription; @@ -125,6 +126,27 @@ public static byte[] serializeServiceToByteArray(ConfigCompositeApplication conf } + // Grouping + public static byte[] serializeServiceToByteArray(CompositeAppDefinition configCompositeApplication) + throws IOException { + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutput out = null; + try { + out = new ObjectOutputStream(bos); + out.writeObject(configCompositeApplication); + + return bos.toByteArray(); + + } finally { + if (out != null) { + out.close(); + } + bos.close(); + } + + } + public static byte [] serializeServiceGroupDefinitionToByteArray (ServiceGroupDefinition serviceGroupDefinition) throws IOException { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 468c67a468..d09451c134 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -259,8 +259,10 @@ static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDef } catch (CompositeApplicationDefinitionException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + } catch (PersistenceManagerException e) { + e.printStackTrace(); } - + //TODO send to CC StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); stratosAdminResponse.setMessage("Successfully deployed Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ]"); From 5cb4ffcfb0e98f10903dfc172a03836d2f4e3e13 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 13 Jul 2014 14:55:17 +0530 Subject: [PATCH 010/436] initial composite applicaiton parser impl. --- .../CompositeApplicationManager.java | 4 +- .../beans/ComponentDefinition.java | 46 +-- .../beans/CompositeAppDefinition.java | 16 +- .../application/beans/GroupDefinition.java | 13 +- .../beans/SubscribableDefinition.java | 56 +-- .../application/beans/SubscribableInfo.java | 13 +- .../parser/CompositeApplicationParser.java | 6 +- .../DefaultCompositeApplicationParser.java | 333 ++++++++++++++---- .../application/parser/ParserUtils.java | 62 ++++ .../structure/CompositeAppContext.java | 75 ++++ .../application/structure/GroupContext.java | 106 ++++++ .../application/structure/StartupOrder.java | 48 +++ .../SubscribableContext.java} | 55 ++- .../manager/CartridgeSubscriptionManager.java | 29 ++ .../CompositeAppSubscription.java | 47 +++ .../rest/endpoint/services/ServiceUtils.java | 7 +- 16 files changed, 717 insertions(+), 199 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/{beans/CartridgeDefinition.java => structure/SubscribableContext.java} (52%) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 2a02646c27..a1d87a6d29 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -35,8 +35,8 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); compositeAppParser.parse(compositeAppDefinition); - DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - mgr.persistCompositeApplication(compositeAppDefinition); + //DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + //mgr.persistCompositeApplication(compositeAppDefinition); // TODO: traverse the data structure and create the subscriptions 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 index 55be3fe223..176ab149b6 100644 --- 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 @@ -1,51 +1,41 @@ package org.apache.stratos.manager.composite.application.beans; +import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; + +import javax.xml.bind.annotation.XmlRootElement; import java.util.List; +@XmlRootElement(name = "components") public class ComponentDefinition { - private String group; - private String alias; - private List subscribables; - private String deploymentPolicy; - private String autoscalingPolicy; - - public String getGroup() { - return group; - } - public void setGroup(String group) { - this.group = group; - } + private List groups; - public String getAlias() { - return alias; - } + private List subscribables; - public void setAlias(String alias) { - this.alias = alias; - } + private DependencyDefinitions dependencies; - public List getSubscribables() { + public List getSubscribables() { return subscribables; } - public void setSubscribables(List subscribables) { + public void setSubscribables(List subscribables) { this.subscribables = subscribables; } - public String getDeploymentPolicy() { - return deploymentPolicy; + public List getGroups() { + return groups; } - public void setDeploymentPolicy(String deploymentPolicy) { - this.deploymentPolicy = deploymentPolicy; + public void setGroups(List groups) { + this.groups = groups; } - public String getAutoscalingPolicy() { - return autoscalingPolicy; + public DependencyDefinitions getDependencies() { + return dependencies; } - public void setAutoscalingPolicy(String autoscalingPolicy) { - this.autoscalingPolicy = autoscalingPolicy; + public void setDependencies(DependencyDefinitions dependencies) { + this.dependencies = dependencies; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java index 477e098c8f..353d7db12b 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java @@ -29,9 +29,9 @@ public class CompositeAppDefinition { private String alias; - private List components; + private ComponentDefinition components; - private List cartridges; + private List subscribableInfo; public String getApplicationId() { return applicationId; @@ -49,19 +49,19 @@ public void setAlias(String alias) { this.alias = alias; } - public List getComponents() { + public ComponentDefinition getComponents() { return components; } - public void setComponents(List components) { + public void setComponents(ComponentDefinition components) { this.components = components; } - public List getCartridges() { - return cartridges; + public List getSubscribableInfo() { + return subscribableInfo; } - public void setCartridges(List cartridges) { - this.cartridges = cartridges; + public void setSubscribableInfo(List subscribableInfo) { + this.subscribableInfo = subscribableInfo; } } 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 index 3e92eb521d..4cb77f98c3 100644 --- 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 @@ -19,10 +19,11 @@ package org.apache.stratos.manager.composite.application.beans; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; -@XmlRootElement +@XmlRootElement(name = "groups") public class GroupDefinition { private String name; @@ -35,7 +36,7 @@ public class GroupDefinition { private List subscribables; - private List groups; + private List subGroups; public String getName() { return name; @@ -77,11 +78,11 @@ public void setSubscribables(List subscribableDefinition this.subscribables = subscribableDefinitions; } - public List getGroups() { - return groups; + public List getSubGroups() { + return subGroups; } - public void setGroups(List groups) { - this.groups = groups; + public void setSubGroups(List subGroups) { + this.subGroups = subGroups; } } 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 index d85f235313..77d409a298 100644 --- 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 @@ -21,20 +21,13 @@ import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement +@XmlRootElement (name = "subscribables") public class SubscribableDefinition { private String type; private String alias; - private String deploymentPolicy; - private String autoscalingPolicy; - private String repoUrl; - private boolean isPrivateRepo; - private String repoUsername; - private String repoPassword; - public String getType() { return type; @@ -52,51 +45,4 @@ 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 isPrivateRepo; - } - - public void setPrivateRepo(boolean isPrivateRepo) { - this.isPrivateRepo = isPrivateRepo; - } - - 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; - } } 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 index 01905993fd..09130c3394 100644 --- 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 @@ -19,9 +19,10 @@ package org.apache.stratos.manager.composite.application.beans; -public class SubscribableInfo { +import javax.xml.bind.annotation.XmlRootElement; - private String type; +@XmlRootElement(name = "subscribableInfo") +public class SubscribableInfo { private String alias; @@ -92,12 +93,4 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java index 829da0f489..1c494a327a 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java @@ -19,11 +19,13 @@ package org.apache.stratos.manager.composite.application.parser; -import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; +import org.apache.stratos.manager.composite.application.tmp.CompositeAppRegistrants; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; + public interface CompositeApplicationParser { - public CompositeApplicationDefinition parse (Object obj) throws CompositeApplicationDefinitionException; + public CompositeAppContext parse (Object obj) throws CompositeApplicationDefinitionException; } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 8e67c804df..6fc15cd6f7 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -19,141 +19,328 @@ package org.apache.stratos.manager.composite.application.parser; -import org.apache.commons.lang3.StringUtils; -import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; -import org.apache.stratos.manager.composite.application.beans.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.StartupOrder; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; -import java.util.List; +import java.util.*; public class DefaultCompositeApplicationParser implements CompositeApplicationParser { - DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager; + private static Log log = LogFactory.getLog(DefaultCompositeApplicationParser.class); + + DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; public DefaultCompositeApplicationParser () { - dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); } @Override - public CompositeApplicationDefinition parse (Object compositeAppObj) throws CompositeApplicationDefinitionException { + public CompositeAppContext parse(Object obj) throws CompositeApplicationDefinitionException { CompositeAppDefinition compositeAppDefinition = null; - if (compositeAppObj instanceof CompositeAppDefinition) { - compositeAppDefinition = (CompositeAppDefinition) compositeAppObj; - - } else { - throw new CompositeApplicationDefinitionException("Invalid Composite Application definition"); + if (obj instanceof CompositeAppDefinition) { + compositeAppDefinition = (CompositeAppDefinition) obj; } if (compositeAppDefinition == null) { - throw new CompositeApplicationDefinitionException("Composite Application definition not found"); + throw new CompositeApplicationDefinitionException("Invlaid Composite Application Defintion"); } - String compositeAppId = compositeAppDefinition.getApplicationId(); - if(StringUtils.isEmpty(compositeAppId)){ - throw new CompositeApplicationDefinitionException("Application ID can not be empty"); + if (compositeAppDefinition.getAlias() == null || compositeAppDefinition.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid alias specified"); } - String compositeAppAlias = compositeAppDefinition.getAlias(); - // components - processComponents(compositeAppDefinition.getComponents()); + if (compositeAppDefinition.getApplicationId() == null || compositeAppDefinition.getApplicationId().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Composite App id specified"); + } - return null; + // get the defined groups + Map definedGroups = getDefinedGroups(compositeAppDefinition); + if (log.isDebugEnabled()) { + Set> groupEntries = definedGroups.entrySet(); + log.debug("Defined Groups: [ "); + for (Map.Entry groupEntry : groupEntries) { + log.debug("Group alias: " + groupEntry.getKey()); + } + log.debug(" ]"); + } + + // get the Subscribables Information + Map subscribablesInfo = getSubscribableInformation(compositeAppDefinition); + if (log.isDebugEnabled()) { + Set> subscribableInfoEntries = subscribablesInfo.entrySet(); + log.debug("Defined Subscribable Information: [ "); + for (Map.Entry subscribableInfoEntry : subscribableInfoEntries) { + log.debug("Subscribable Information alias: " + subscribableInfoEntry.getKey()); + } + log.debug(" ]"); + } + + return buildCompositeAppStructure (compositeAppDefinition, definedGroups, subscribablesInfo); + } + + private Map getDefinedGroups (CompositeAppDefinition compositeAppDefinition) throws + CompositeApplicationDefinitionException { + + // map [group alias -> Group Definition] + Map definedGroups = null; + + if (compositeAppDefinition.getComponents() != null) { + if (compositeAppDefinition.getComponents().getGroups() != null) { + definedGroups = new HashMap(); + + for (GroupDefinition group : compositeAppDefinition.getComponents().getGroups()) { + + // check validity of group name + if (group.getName() == null || group.getName().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Group name specified"); + } + + // check if group is deployed + if(isGroupDeployed(group.getName())) { + throw new CompositeApplicationDefinitionException("Group with name " + group.getName() + " not deployed"); + } + + // check validity of group alias + if (group.getAlias() == null || group.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Group alias specified"); + } + + // check if a group is already defined under the same alias + if(definedGroups.get(group.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new CompositeApplicationDefinitionException("A Group with alias " + group.getAlias() + " already exists"); + } + + definedGroups.put(group.getAlias(), group); + if (log.isDebugEnabled()) { + log.debug("Added Group Definition [ " + group.getName() +" , " + group.getAlias() + " ] to map [group alias -> Group Definition]"); + } + } + } + } + + return definedGroups; + } + + private Map getSubscribableInformation (CompositeAppDefinition compositeAppDefinition) throws + CompositeApplicationDefinitionException { + + // map [cartridge alias -> Subscribable Information] + Map subscribableInformation = null; + + if (compositeAppDefinition.getSubscribableInfo() != null) { + subscribableInformation = new HashMap(); + + for (SubscribableInfo subscribableInfo : compositeAppDefinition.getSubscribableInfo()) { + + if (subscribableInfo.getAlias() == null || subscribableInfo.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj"); + } + + // check if a group is already defined under the same alias + if(subscribableInformation.get(subscribableInfo.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new CompositeApplicationDefinitionException("A Subscribable Info obj with alias " + subscribableInfo.getAlias() + " already exists"); + } + + subscribableInformation.put(subscribableInfo.getAlias(), subscribableInfo); + if (log.isDebugEnabled()) { + log.debug("Added Subcribables Info obj [ " + subscribableInfo.getAlias() + " ] to map [cartridge alias -> Subscribable Information]"); + } + } + } + + return subscribableInformation; } - // TODO: should return the relevant object type to send to CC - private void processComponents(List components) throws CompositeApplicationDefinitionException { + private boolean isGroupDeployed (String serviceGroupName) throws CompositeApplicationDefinitionException { - if (components == null) { - return; + try { + return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName) != null; + + } catch (PersistenceManagerException e) { + throw new CompositeApplicationDefinitionException(e); } - for (ComponentDefinition component : components) { - // process the group definitions - String groupName = component.getGroup(); - String groupAlias = component.getAlias(); + } + + private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition compositeAppDefinition, + Map definedGroups, + Map subscribableInformation) + throws CompositeApplicationDefinitionException { - // neither group name nor alias can be empty - if (StringUtils.isEmpty(groupName)) { - throw new CompositeApplicationDefinitionException("Group Name is invalid"); + CompositeAppContext compositeAppContext = new CompositeAppContext(); + + // get top level Subscribables + if (compositeAppDefinition.getComponents() != null) { + if (compositeAppDefinition.getComponents().getSubscribables() != null) { + compositeAppContext.setSubscribableContexts(getSubsribableContexts(compositeAppDefinition.getComponents().getSubscribables(), + subscribableInformation)); } - if (StringUtils.isEmpty(groupAlias)) { - throw new CompositeApplicationDefinitionException("Group Alias is invalid"); + + // get Groups + if (compositeAppDefinition.getComponents().getGroups() != null) { + compositeAppContext.setGroupContexts(getGroupContexts(compositeAppDefinition.getComponents().getGroups(), + subscribableInformation, definedGroups)); } - // check if the group is deployed. if not can't continue - if (!isGroupDeployed(groupName)) { - throw new CompositeApplicationDefinitionException(String.format("No Service Group found with name [ %s ]", groupName)); + // get top level Dependency definitions + if (compositeAppDefinition.getComponents().getDependencies() != null) { + compositeAppContext.setStartupOrder(getStartupOrderForApplicationComponents(compositeAppDefinition.getComponents(). + getDependencies().getStartupOrder())); + + compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour()); } + } + + return compositeAppContext; + } + + private List getGroupContexts (List groupDefinitions, + Map subscribableInformation, + Map definedGroups) + throws CompositeApplicationDefinitionException { + + List groupContexts = new ArrayList(); + + for (GroupDefinition group : groupDefinitions) { + groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); + } + + return groupContexts; + } + + private GroupContext getGroupContext (GroupDefinition group, Map subscribableInformation, + Map definedGroups) throws CompositeApplicationDefinitionException { + + // check if are in the defined Group set + GroupDefinition definedGroupDef = definedGroups.get(group.getAlias()); + if (definedGroupDef == null) { + throw new CompositeApplicationDefinitionException("Group Definition with name: " + group.getName() + ", alias: " + + group.getAlias() + " is not found in the all Group Definitions collection"); + } - // get group level policy information - String groupDepPolicy = component.getDeploymentPolicy(); - String groupScalePolicy = component.getAutoscalingPolicy(); + GroupContext groupContext = new GroupContext(); + // get group level Subscribables + if (group.getSubscribables() != null) { + groupContext.setName(group.getName()); + groupContext.setAlias(group.getAlias()); + groupContext.setAutoscalingPolicy(group.getAutoscalingPolicy()); + groupContext.setDeploymentPolicy(group.getDeploymentPolicy()); + groupContext.setSubscribableContexts(getSubsribableContexts(group.getSubscribables(), subscribableInformation)); + groupContext.setStartupOrder(getStartupOrderForGroup(group.getName())); + groupContext.setKillBehaviour(getKillbehaviour(group.getName())); + } + // get nested groups + if (group.getSubGroups() != null) { + List nestedGroupContexts = new ArrayList(); + // check sub groups + for (GroupDefinition subGroup : group.getSubGroups()) { + nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); + } - // subscribables - processSubscribables(component.getSubscribables()); + groupContext.setGroupContexts(nestedGroupContexts); } + + return groupContext; } - private boolean isGroupDeployed (String groupName) throws CompositeApplicationDefinitionException { + private List getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { - ServiceGroupDefinition serviceGroupDefinition = null; + ServiceGroupDefinition groupDefinition; try { - serviceGroupDefinition = dataInsertionAndRetrievalManager.getServiceGroupDefinition(groupName); + groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); } catch (PersistenceManagerException e) { throw new CompositeApplicationDefinitionException(e); } - return serviceGroupDefinition != null; + if (groupDefinition == null) { + throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + } + + if (groupDefinition.getDependencies() != null) { + if (groupDefinition.getDependencies().getStartupOrder() != null) { + return ParserUtils.convert(groupDefinition.getDependencies().getStartupOrder()); + } + } + + return null; } - // TODO: should return the relevant object type to send to CC - private void processSubscribables (List subscribables) throws CompositeApplicationDefinitionException { + private List getStartupOrderForApplicationComponents (List startupOrderDefinitions) + throws CompositeApplicationDefinitionException { - if (subscribables == null) { - return; + if (startupOrderDefinitions == null) { + return null; } - for (SubscribableInfo subscribable : subscribables) { + List startupOrders = new ArrayList(); - String cartridgeType = subscribable.getType(); - String subscriptionAlias = subscribable.getAlias(); + for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { + startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); + } - // neither cartridge type nor alias can be empty - if (cartridgeType == null || cartridgeType.isEmpty()) { - throw new CompositeApplicationDefinitionException("Cartridge Type is invalid"); - } - if (subscriptionAlias == null || subscriptionAlias.isEmpty()) { - throw new CompositeApplicationDefinitionException("Subscription Alias is invalid"); - } - // TODO should validate if there exist a cartridge with $cartridgeType + return startupOrders; + } + + private String getKillbehaviour (String serviceGroupName) throws CompositeApplicationDefinitionException { + + ServiceGroupDefinition groupDefinition; + + try { + groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); + + } catch (PersistenceManagerException e) { + throw new CompositeApplicationDefinitionException(e); + } + if (groupDefinition == null) { + throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); } + + if (groupDefinition.getDependencies() != null) { + return groupDefinition.getDependencies().getKillBehaviour(); + } + + return null; + } - // TODO: should return the relevant object type to send to CC - private void getSubscriptionInformation (List subscribables, String subscriptionAlias) throws CompositeApplicationDefinitionException { + private List getSubsribableContexts (List subscribableDefinitions, + Map subscribableInformation) + throws CompositeApplicationDefinitionException { - for (SubscribableInfo subscribable : subscribables) { + List subscribableContexts = new ArrayList(); - if (subscribable.getAlias().equals(subscriptionAlias)) { - // match found, retrieve the information - String deploymentPolicy = subscribable.getDeploymentPolicy(); - String autoscalingPolicy = subscribable.getAutoscalingPolicy(); - String repoUrl = subscribable.getRepoUrl(); - if (repoUrl != null && !repoUrl.isEmpty()) { - boolean privateRepo = subscribable.isPrivateRepo(); - String repoUsername = subscribable.getUsername(); - String repoPassword = subscribable.getPassword(); - } + for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { + // check is there is a related Subscribable Information + SubscribableInfo subscribableInfo = subscribableInformation.get(subscribableDefinition.getAlias()); + if (subscribableInfo == null) { + throw new CompositeApplicationDefinitionException("Related Subscribable Information not found for Subscribable with alias: " + + subscribableDefinition.getAlias()); } + + subscribableContexts.add(ParserUtils.convert(subscribableDefinition, subscribableInfo)); } + + return subscribableContexts; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java new file mode 100644 index 0000000000..8e3939f020 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.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.composite.application.parser; + +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.StartupOrder; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; + +import java.util.ArrayList; +import java.util.List; + +public class ParserUtils { + + public static SubscribableContext convert (SubscribableDefinition subscribable, SubscribableInfo subscribableInfo) { + + SubscribableContext subscribableContext = new SubscribableContext(subscribable.getType(), subscribable.getAlias()); + subscribableContext.setAutoscalingPolicy(subscribableInfo.getAutoscalingPolicy()); + subscribableContext.setDeploymentPolicy(subscribableInfo.getDeploymentPolicy()); + + if (subscribableInfo.getRepoUrl() != null && !subscribableInfo.getRepoUrl().isEmpty()) { + subscribableContext.setRepoUrl(subscribableInfo.getRepoUrl()); + subscribableContext.setPrivateRepo(subscribableInfo.isPrivateRepo()); + subscribableContext.setUsername(subscribableInfo.getUsername()); + subscribableContext.setPassword(subscribableInfo.getPassword()); + } + + return subscribableContext; + } + + public static List convert (List startupOrderDefinitions) { + + List startupOrders = new ArrayList(); + for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { + StartupOrder startupOrder = new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter()); + startupOrders.add(startupOrder); + } + + return startupOrders; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java new file mode 100644 index 0000000000..98c3afcd69 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.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.composite.application.structure; + +import java.util.List; + +public class CompositeAppContext { + + private String appId; + + private List groupContexts; + + private List subscribableContexts; + + private List startupOrder; + + private String killBehaviour; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public List getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(List groupContexts) { + this.groupContexts = groupContexts; + } + + public List getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(List subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public List getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(List startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java new file mode 100644 index 0000000000..216d89c36f --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java @@ -0,0 +1,106 @@ +/* + * 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.structure; + +import java.util.List; + +public class GroupContext { + + private String name; + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private List groupContexts; + + private List subscribableContexts; + + private List startupOrder; + + private String killBehaviour; + + + public List getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(List startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } + + 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 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 List getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(List groupContexts) { + this.groupContexts = groupContexts; + } + + public List getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(List subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java new file mode 100644 index 0000000000..4553a9f04e --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.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.composite.application.structure; + +public class StartupOrder { + + private String start; + + private String after; + + public StartupOrder (String start, String after) { + this.start = start; + this.after = 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; + } +} 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/structure/SubscribableContext.java similarity index 52% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java index bb191452fd..2e30c1bff9 100644 --- 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/structure/SubscribableContext.java @@ -1,30 +1,61 @@ -package org.apache.stratos.manager.composite.application.beans; +/* + * 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.structure; + +public class SubscribableContext { + + private String cartridgeType; - -public class CartridgeDefinition { private String alias; - private String type; + private String deploymentPolicy; + private String autoscalingPolicy; + private String repoUrl; + private boolean privateRepo; + private String username; + private String password; - public String getAlias() { - return alias; + public SubscribableContext (String cartridgeType, String alias) { + this.cartridgeType = cartridgeType; + this.alias = alias; } - public void setAlias(String alias) { - this.alias = alias; + public String getCartridgeType() { + return cartridgeType; } - public String getType() { - return type; + public void setCartridgeType(String cartridgeType) { + this.cartridgeType = cartridgeType; } - public void setType(String type) { - this.type = type; + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; } public String getDeploymentPolicy() { 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 index 88641fc86a..f778760a0e 100644 --- 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 @@ -59,6 +59,35 @@ public class CartridgeSubscriptionManager { private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class); //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + + 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 (CloudControllerServiceUnregisteredCartridgeExceptionException 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 SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws ADCException, InvalidCartridgeAliasException, diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java new file mode 100644 index 0000000000..d60e9393e4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.subscription; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class CompositeAppSubscription implements Serializable { + + private static Log log = LogFactory.getLog(CompositeAppSubscription.class); + + private Map compositeAppToCartridgeSubcription; + + public CompositeAppSubscription () { + compositeAppToCartridgeSubcription = new HashMap(); + } + + public void addCartridgeSubscription (String compositeAppAlias, String cartridgeSubscriptionAlias) { + + compositeAppToCartridgeSubcription.put(compositeAppAlias, cartridgeSubscriptionAlias); + if (log.isDebugEnabled()) { + log.debug("Cartridge Subscription alias [ "+ cartridgeSubscriptionAlias +" ] stored against Composite Application alias [ " + + compositeAppAlias + " ]"); + } + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index d09451c134..12c01cf857 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -258,11 +258,12 @@ static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDef compositeApplicationManager.deployCompositeApplication(compositeAppDefinition); } catch (CompositeApplicationDefinitionException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + throw new RestAPIException(e); } catch (PersistenceManagerException e) { - e.printStackTrace(); + throw new RestAPIException(e); } - //TODO send to CC + + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); stratosAdminResponse.setMessage("Successfully deployed Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ]"); From cf72ef4ccb5b7b35ca30ce475ef0fa4cc9cef6ca Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 13 Jul 2014 16:52:37 +0530 Subject: [PATCH 011/436] Creating Subscriptions from Composite App structure --- .../CompositeApplicationManager.java | 131 +++++++++++++++--- .../parser/CompositeApplicationParser.java | 1 - .../DefaultCompositeApplicationParser.java | 16 +-- .../application/parser/ParserUtils.java | 6 +- .../structure/CompositeAppContext.java | 20 +-- .../application/structure/GroupContext.java | 19 +-- .../CompositeApplicationException.java | 47 +++++++ .../rest/endpoint/services/ServiceUtils.java | 9 +- .../rest/endpoint/services/StratosAdmin.java | 3 +- 9 files changed, 200 insertions(+), 52 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index a1d87a6d29..02893e8358 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -1,17 +1,23 @@ package org.apache.stratos.manager.composite.application; import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.composite.application.parser.CompositeApplicationParser; import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; -import org.apache.stratos.manager.exception.ADCException; -import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; -import org.apache.stratos.manager.exception.PersistenceManagerException; +import org.apache.stratos.manager.exception.*; +import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; +import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.manager.subscription.SubscriptionData; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; //Grouping @@ -19,30 +25,117 @@ public class CompositeApplicationManager { private static Log log = LogFactory.getLog(CompositeApplicationManager.class); - public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException, PersistenceManagerException { -// if (log.isDebugEnabled()) { -// log.debug("deploying composite application " + configCompositeApplication.getAlias()); -// } -// registerCompositeApplication(configCompositeApplication); -// if (log.isDebugEnabled()) { -// log.debug("publishing composite application " + configCompositeApplication.getAlias()); -// } -// ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication); -// if (log.isDebugEnabled()) { -// log.debug("composite application successfully deployed" + configCompositeApplication.getAlias()); -// } + public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition, int tenantId, String tenantDomain, + String tenantAdminUsername) throws CompositeApplicationException, CompositeApplicationDefinitionException, + PersistenceManagerException { CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); - compositeAppParser.parse(compositeAppDefinition); + CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); + + log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + + compositeAppDefinition.getAlias() + " ] deployed successfully"); //DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); //mgr.persistCompositeApplication(compositeAppDefinition); + Set cartridgeSubscriptions = new HashSet(); - // TODO: traverse the data structure and create the subscriptions + // traverse through the Composite App Structure and create Cartridge Subscriptions + if(compositeAppContext.getSubscribableContexts() != null) { + // Subscription relevant to top level Subscribables + cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), + tenantId, tenantDomain, tenantAdminUsername)); + } - log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " - + compositeAppDefinition.getAlias() + " ] deployed successfully"); + if (compositeAppContext.getGroupContexts() != null) { + // Subscriptions relevant to Groups + cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, + tenantDomain, tenantAdminUsername)); + } } + + private Set getCartridgeSubscriptionForGroups (Set groupContexts, + int tenantId, String tenantDomain, + String tenantAdminUsername) + throws CompositeApplicationException { + + Set cartridgeSubscriptions = new HashSet(); + for (GroupContext groupContext : groupContexts) { + // create Subscriptions for the Group's top level Subscribables + if (groupContext.getSubscribableContexts() != null) { + cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(groupContext.getSubscribableContexts(), + tenantId, tenantDomain, tenantAdminUsername)); + } + // create Subscriptions for the nested Group's Subscribables + if (groupContext.getGroupContexts() != null) { + cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(groupContext.getGroupContexts(), tenantId, + tenantDomain, tenantAdminUsername)); + } + } + + return cartridgeSubscriptions; + } + + private Set getCartridgeSybscriptionsForSubscribables (Set subscribableContexts, + int tenantId, String tenantDomain, + String tenantAdminUsername) + throws CompositeApplicationException { + + Set cartridgeSubscriptions = new HashSet(); + + for (SubscribableContext subscribableContext : subscribableContexts) { + cartridgeSubscriptions.add(getCartridgeSubscription(subscribableContext, tenantId, tenantDomain, tenantAdminUsername)); + } + + return cartridgeSubscriptions; + } + + private CartridgeSubscription getCartridgeSubscription (SubscribableContext subscribableContext, int tenantId, String tenantDomain, + String tenantAdminUsername) throws CompositeApplicationException { + + SubscriptionData subscriptionData = new SubscriptionData(); + subscriptionData.setCartridgeType(subscribableContext.getCartridgeType()); + subscriptionData.setCartridgeAlias(subscribableContext.getAlias()); + subscriptionData.setAutoscalingPolicyName(subscribableContext.getAutoscalingPolicy()); + subscriptionData.setDeploymentPolicyName(subscribableContext.getDeploymentPolicy()); + subscriptionData.setTenantId(tenantId); + subscriptionData.setTenantDomain(tenantDomain); + subscriptionData.setTenantAdminUsername(tenantAdminUsername); + + if (subscribableContext.getRepoUrl() != null && !subscribableContext.getRepoUrl().isEmpty()) { + subscriptionData.setRepositoryType("git"); + subscriptionData.setRepositoryURL(subscribableContext.getRepoUrl()); + subscriptionData.setPrivateRepository(subscribableContext.isPrivateRepo()); + subscriptionData.setRepositoryUsername(subscribableContext.getUsername()); + subscriptionData.setRepositoryPassword(subscribableContext.getPassword()); + } + + CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); + try { + return cartridgeSubscriptionManager.createCartridgeSubscription(subscriptionData); + + } catch (ADCException e) { + throw new CompositeApplicationException(e); + } catch (InvalidCartridgeAliasException e) { + throw new CompositeApplicationException(e); + } catch (DuplicateCartridgeAliasException e) { + throw new CompositeApplicationException(e); + } catch (PolicyException e) { + throw new CompositeApplicationException(e); + } catch (UnregisteredCartridgeException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryRequiredException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryCredentialsRequiredException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryTransportException e) { + throw new CompositeApplicationException(e); + } catch (AlreadySubscribedException e) { + throw new CompositeApplicationException(e); + } catch (InvalidRepositoryException e) { + throw new CompositeApplicationException(e); + } + + } public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java index 1c494a327a..e31974296f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java @@ -20,7 +20,6 @@ package org.apache.stratos.manager.composite.application.parser; import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; -import org.apache.stratos.manager.composite.application.tmp.CompositeAppRegistrants; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 6fc15cd6f7..9bfc864239 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -211,12 +211,12 @@ private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition c return compositeAppContext; } - private List getGroupContexts (List groupDefinitions, + private Set getGroupContexts (List groupDefinitions, Map subscribableInformation, Map definedGroups) throws CompositeApplicationDefinitionException { - List groupContexts = new ArrayList(); + Set groupContexts = new HashSet(); for (GroupDefinition group : groupDefinitions) { groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); @@ -248,7 +248,7 @@ private GroupContext getGroupContext (GroupDefinition group, Map nestedGroupContexts = new ArrayList(); + Set nestedGroupContexts = new HashSet(); // check sub groups for (GroupDefinition subGroup : group.getSubGroups()) { nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); @@ -260,7 +260,7 @@ private GroupContext getGroupContext (GroupDefinition group, Map getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { + private Set getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { ServiceGroupDefinition groupDefinition; @@ -284,14 +284,14 @@ private List getStartupOrderForGroup(String serviceGroupName) thro return null; } - private List getStartupOrderForApplicationComponents (List startupOrderDefinitions) + private Set getStartupOrderForApplicationComponents (List startupOrderDefinitions) throws CompositeApplicationDefinitionException { if (startupOrderDefinitions == null) { return null; } - List startupOrders = new ArrayList(); + Set startupOrders = new HashSet(); for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); @@ -323,11 +323,11 @@ private String getKillbehaviour (String serviceGroupName) throws CompositeApplic } - private List getSubsribableContexts (List subscribableDefinitions, + private Set getSubsribableContexts (List subscribableDefinitions, Map subscribableInformation) throws CompositeApplicationDefinitionException { - List subscribableContexts = new ArrayList(); + Set subscribableContexts = new HashSet(); for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { // check is there is a related Subscribable Information diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java index 8e3939f020..be9e7035b3 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java @@ -29,7 +29,9 @@ import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class ParserUtils { @@ -49,9 +51,9 @@ public static SubscribableContext convert (SubscribableDefinition subscribable, return subscribableContext; } - public static List convert (List startupOrderDefinitions) { + public static Set convert (List startupOrderDefinitions) { - List startupOrders = new ArrayList(); + Set startupOrders = new HashSet(); for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { StartupOrder startupOrder = new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter()); startupOrders.add(startupOrder); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java index 98c3afcd69..6a589e7841 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java @@ -19,17 +19,17 @@ package org.apache.stratos.manager.composite.application.structure; -import java.util.List; +import java.util.Set; public class CompositeAppContext { private String appId; - private List groupContexts; + private Set groupContexts; - private List subscribableContexts; + private Set subscribableContexts; - private List startupOrder; + private Set startupOrder; private String killBehaviour; @@ -41,27 +41,27 @@ public void setAppId(String appId) { this.appId = appId; } - public List getGroupContexts() { + public Set getGroupContexts() { return groupContexts; } - public void setGroupContexts(List groupContexts) { + public void setGroupContexts(Set groupContexts) { this.groupContexts = groupContexts; } - public List getSubscribableContexts() { + public Set getSubscribableContexts() { return subscribableContexts; } - public void setSubscribableContexts(List subscribableContexts) { + public void setSubscribableContexts(Set subscribableContexts) { this.subscribableContexts = subscribableContexts; } - public List getStartupOrder() { + public Set getStartupOrder() { return startupOrder; } - public void setStartupOrder(List startupOrder) { + public void setStartupOrder(Set startupOrder) { this.startupOrder = startupOrder; } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java index 216d89c36f..e7736ea6ca 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java @@ -20,6 +20,7 @@ package org.apache.stratos.manager.composite.application.structure; import java.util.List; +import java.util.Set; public class GroupContext { @@ -31,20 +32,20 @@ public class GroupContext { private String autoscalingPolicy; - private List groupContexts; + private Set groupContexts; - private List subscribableContexts; + private Set subscribableContexts; - private List startupOrder; + private Set startupOrder; private String killBehaviour; - public List getStartupOrder() { + public Set getStartupOrder() { return startupOrder; } - public void setStartupOrder(List startupOrder) { + public void setStartupOrder(Set startupOrder) { this.startupOrder = startupOrder; } @@ -88,19 +89,19 @@ public void setAutoscalingPolicy(String autoscalingPolicy) { this.autoscalingPolicy = autoscalingPolicy; } - public List getGroupContexts() { + public Set getGroupContexts() { return groupContexts; } - public void setGroupContexts(List groupContexts) { + public void setGroupContexts(Set groupContexts) { this.groupContexts = groupContexts; } - public List getSubscribableContexts() { + public Set getSubscribableContexts() { return subscribableContexts; } - public void setSubscribableContexts(List subscribableContexts) { + public void setSubscribableContexts(Set subscribableContexts) { this.subscribableContexts = subscribableContexts; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java new file mode 100644 index 0000000000..ea475364f4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class CompositeApplicationException extends Exception { + + private String message; + + public CompositeApplicationException () { + super(); + } + + public CompositeApplicationException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public CompositeApplicationException (String message) { + super(message); + this.message = message; + } + + public CompositeApplicationException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 12c01cf857..8e10fda356 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -251,16 +251,21 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli return stratosAdminResponse; } */ - static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition) + static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + int tenantId = ApplicationManagementUtil.getTenantId(ctxt); + try { - compositeApplicationManager.deployCompositeApplication(compositeAppDefinition); + compositeApplicationManager.deployCompositeApplication(compositeAppDefinition, tenantId, tenantDomain, userName); } catch (CompositeApplicationDefinitionException e) { throw new RestAPIException(e); } catch (PersistenceManagerException e) { throw new RestAPIException(e); + } catch (CompositeApplicationException e) { + throw new RestAPIException(e); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 8cdf16b0f3..dc24984fdc 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -132,7 +132,8 @@ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefi // Grouping public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition applicationDefinitionBean) throws RestAPIException { - return ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean); + return ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean, getConfigContext(), + getUsername(), getTenantDomain()); } From fabc64a0639218e952b1927495a70b0f14c90c1b Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 15 Jul 2014 11:55:54 +0530 Subject: [PATCH 012/436] change application definition to allow inner groups subscribable details --- .../pojo/CompositeApplicationDefinition.java | 1 - .../CompositeApplicationManager.java | 135 +++++-- .../beans/ComponentDefinition.java | 46 +-- .../beans/CompositeAppDefinition.java | 16 +- .../application/beans/GroupDefinition.java | 13 +- .../beans/SubscribableDefinition.java | 56 +-- .../application/beans/SubscribableInfo.java | 13 +- .../parser/CompositeApplicationParser.java | 5 +- .../DefaultCompositeApplicationParser.java | 333 ++++++++++++++---- .../application/parser/ParserUtils.java | 64 ++++ .../structure/CompositeAppContext.java | 75 ++++ .../application/structure/GroupContext.java | 107 ++++++ .../application/structure/StartupOrder.java | 48 +++ .../SubscribableContext.java} | 55 ++- .../CompositeApplicationException.java | 47 +++ .../manager/CartridgeSubscriptionManager.java | 29 ++ .../CompositeAppSubscription.java | 47 +++ .../rest/endpoint/services/ServiceUtils.java | 36 +- .../rest/endpoint/services/StratosAdmin.java | 43 ++- 19 files changed, 913 insertions(+), 256 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/{beans/CartridgeDefinition.java => structure/SubscribableContext.java} (52%) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java index 97a9948a4c..04476f6a95 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CompositeApplicationDefinition.java @@ -1,7 +1,6 @@ package org.apache.stratos.cloud.controller.pojo; import java.io.Serializable; -import java.util.List; public class CompositeApplicationDefinition implements Serializable { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 2a02646c27..02893e8358 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -1,17 +1,23 @@ package org.apache.stratos.manager.composite.application; import java.util.Collection; +import java.util.HashSet; +import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.composite.application.parser.CompositeApplicationParser; import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; -import org.apache.stratos.manager.exception.ADCException; -import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; -import org.apache.stratos.manager.exception.PersistenceManagerException; +import org.apache.stratos.manager.exception.*; +import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; +import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.manager.subscription.SubscriptionData; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; //Grouping @@ -19,30 +25,117 @@ public class CompositeApplicationManager { private static Log log = LogFactory.getLog(CompositeApplicationManager.class); - public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException, PersistenceManagerException { -// if (log.isDebugEnabled()) { -// log.debug("deploying composite application " + configCompositeApplication.getAlias()); -// } -// registerCompositeApplication(configCompositeApplication); -// if (log.isDebugEnabled()) { -// log.debug("publishing composite application " + configCompositeApplication.getAlias()); -// } -// ApplicationUtils.publishApplicationCreatedEvent(configCompositeApplication); -// if (log.isDebugEnabled()) { -// log.debug("composite application successfully deployed" + configCompositeApplication.getAlias()); -// } + public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition, int tenantId, String tenantDomain, + String tenantAdminUsername) throws CompositeApplicationException, CompositeApplicationDefinitionException, + PersistenceManagerException { CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); - compositeAppParser.parse(compositeAppDefinition); - - DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - mgr.persistCompositeApplication(compositeAppDefinition); - - // TODO: traverse the data structure and create the subscriptions + CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ] deployed successfully"); + + //DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); + //mgr.persistCompositeApplication(compositeAppDefinition); + Set cartridgeSubscriptions = new HashSet(); + + // traverse through the Composite App Structure and create Cartridge Subscriptions + if(compositeAppContext.getSubscribableContexts() != null) { + // Subscription relevant to top level Subscribables + cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), + tenantId, tenantDomain, tenantAdminUsername)); + } + + if (compositeAppContext.getGroupContexts() != null) { + // Subscriptions relevant to Groups + cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, + tenantDomain, tenantAdminUsername)); + } } + + private Set getCartridgeSubscriptionForGroups (Set groupContexts, + int tenantId, String tenantDomain, + String tenantAdminUsername) + throws CompositeApplicationException { + + Set cartridgeSubscriptions = new HashSet(); + for (GroupContext groupContext : groupContexts) { + // create Subscriptions for the Group's top level Subscribables + if (groupContext.getSubscribableContexts() != null) { + cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(groupContext.getSubscribableContexts(), + tenantId, tenantDomain, tenantAdminUsername)); + } + // create Subscriptions for the nested Group's Subscribables + if (groupContext.getGroupContexts() != null) { + cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(groupContext.getGroupContexts(), tenantId, + tenantDomain, tenantAdminUsername)); + } + } + + return cartridgeSubscriptions; + } + + private Set getCartridgeSybscriptionsForSubscribables (Set subscribableContexts, + int tenantId, String tenantDomain, + String tenantAdminUsername) + throws CompositeApplicationException { + + Set cartridgeSubscriptions = new HashSet(); + + for (SubscribableContext subscribableContext : subscribableContexts) { + cartridgeSubscriptions.add(getCartridgeSubscription(subscribableContext, tenantId, tenantDomain, tenantAdminUsername)); + } + + return cartridgeSubscriptions; + } + + private CartridgeSubscription getCartridgeSubscription (SubscribableContext subscribableContext, int tenantId, String tenantDomain, + String tenantAdminUsername) throws CompositeApplicationException { + + SubscriptionData subscriptionData = new SubscriptionData(); + subscriptionData.setCartridgeType(subscribableContext.getCartridgeType()); + subscriptionData.setCartridgeAlias(subscribableContext.getAlias()); + subscriptionData.setAutoscalingPolicyName(subscribableContext.getAutoscalingPolicy()); + subscriptionData.setDeploymentPolicyName(subscribableContext.getDeploymentPolicy()); + subscriptionData.setTenantId(tenantId); + subscriptionData.setTenantDomain(tenantDomain); + subscriptionData.setTenantAdminUsername(tenantAdminUsername); + + if (subscribableContext.getRepoUrl() != null && !subscribableContext.getRepoUrl().isEmpty()) { + subscriptionData.setRepositoryType("git"); + subscriptionData.setRepositoryURL(subscribableContext.getRepoUrl()); + subscriptionData.setPrivateRepository(subscribableContext.isPrivateRepo()); + subscriptionData.setRepositoryUsername(subscribableContext.getUsername()); + subscriptionData.setRepositoryPassword(subscribableContext.getPassword()); + } + + CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); + try { + return cartridgeSubscriptionManager.createCartridgeSubscription(subscriptionData); + + } catch (ADCException e) { + throw new CompositeApplicationException(e); + } catch (InvalidCartridgeAliasException e) { + throw new CompositeApplicationException(e); + } catch (DuplicateCartridgeAliasException e) { + throw new CompositeApplicationException(e); + } catch (PolicyException e) { + throw new CompositeApplicationException(e); + } catch (UnregisteredCartridgeException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryRequiredException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryCredentialsRequiredException e) { + throw new CompositeApplicationException(e); + } catch (RepositoryTransportException e) { + throw new CompositeApplicationException(e); + } catch (AlreadySubscribedException e) { + throw new CompositeApplicationException(e); + } catch (InvalidRepositoryException e) { + throw new CompositeApplicationException(e); + } + + } public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { if (log.isDebugEnabled()) { 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 index 55be3fe223..176ab149b6 100644 --- 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 @@ -1,51 +1,41 @@ package org.apache.stratos.manager.composite.application.beans; +import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; + +import javax.xml.bind.annotation.XmlRootElement; import java.util.List; +@XmlRootElement(name = "components") public class ComponentDefinition { - private String group; - private String alias; - private List subscribables; - private String deploymentPolicy; - private String autoscalingPolicy; - - public String getGroup() { - return group; - } - public void setGroup(String group) { - this.group = group; - } + private List groups; - public String getAlias() { - return alias; - } + private List subscribables; - public void setAlias(String alias) { - this.alias = alias; - } + private DependencyDefinitions dependencies; - public List getSubscribables() { + public List getSubscribables() { return subscribables; } - public void setSubscribables(List subscribables) { + public void setSubscribables(List subscribables) { this.subscribables = subscribables; } - public String getDeploymentPolicy() { - return deploymentPolicy; + public List getGroups() { + return groups; } - public void setDeploymentPolicy(String deploymentPolicy) { - this.deploymentPolicy = deploymentPolicy; + public void setGroups(List groups) { + this.groups = groups; } - public String getAutoscalingPolicy() { - return autoscalingPolicy; + public DependencyDefinitions getDependencies() { + return dependencies; } - public void setAutoscalingPolicy(String autoscalingPolicy) { - this.autoscalingPolicy = autoscalingPolicy; + public void setDependencies(DependencyDefinitions dependencies) { + this.dependencies = dependencies; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java index 477e098c8f..353d7db12b 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java @@ -29,9 +29,9 @@ public class CompositeAppDefinition { private String alias; - private List components; + private ComponentDefinition components; - private List cartridges; + private List subscribableInfo; public String getApplicationId() { return applicationId; @@ -49,19 +49,19 @@ public void setAlias(String alias) { this.alias = alias; } - public List getComponents() { + public ComponentDefinition getComponents() { return components; } - public void setComponents(List components) { + public void setComponents(ComponentDefinition components) { this.components = components; } - public List getCartridges() { - return cartridges; + public List getSubscribableInfo() { + return subscribableInfo; } - public void setCartridges(List cartridges) { - this.cartridges = cartridges; + public void setSubscribableInfo(List subscribableInfo) { + this.subscribableInfo = subscribableInfo; } } 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 index 3e92eb521d..4cb77f98c3 100644 --- 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 @@ -19,10 +19,11 @@ package org.apache.stratos.manager.composite.application.beans; +import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; -@XmlRootElement +@XmlRootElement(name = "groups") public class GroupDefinition { private String name; @@ -35,7 +36,7 @@ public class GroupDefinition { private List subscribables; - private List groups; + private List subGroups; public String getName() { return name; @@ -77,11 +78,11 @@ public void setSubscribables(List subscribableDefinition this.subscribables = subscribableDefinitions; } - public List getGroups() { - return groups; + public List getSubGroups() { + return subGroups; } - public void setGroups(List groups) { - this.groups = groups; + public void setSubGroups(List subGroups) { + this.subGroups = subGroups; } } 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 index d85f235313..77d409a298 100644 --- 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 @@ -21,20 +21,13 @@ import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement +@XmlRootElement (name = "subscribables") public class SubscribableDefinition { private String type; private String alias; - private String deploymentPolicy; - private String autoscalingPolicy; - private String repoUrl; - private boolean isPrivateRepo; - private String repoUsername; - private String repoPassword; - public String getType() { return type; @@ -52,51 +45,4 @@ 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 isPrivateRepo; - } - - public void setPrivateRepo(boolean isPrivateRepo) { - this.isPrivateRepo = isPrivateRepo; - } - - 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; - } } 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 index 01905993fd..09130c3394 100644 --- 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 @@ -19,9 +19,10 @@ package org.apache.stratos.manager.composite.application.beans; -public class SubscribableInfo { +import javax.xml.bind.annotation.XmlRootElement; - private String type; +@XmlRootElement(name = "subscribableInfo") +public class SubscribableInfo { private String alias; @@ -92,12 +93,4 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java index 829da0f489..e31974296f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/CompositeApplicationParser.java @@ -19,11 +19,12 @@ package org.apache.stratos.manager.composite.application.parser; -import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; + public interface CompositeApplicationParser { - public CompositeApplicationDefinition parse (Object obj) throws CompositeApplicationDefinitionException; + public CompositeAppContext parse (Object obj) throws CompositeApplicationDefinitionException; } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 8e67c804df..9bfc864239 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -19,141 +19,328 @@ package org.apache.stratos.manager.composite.application.parser; -import org.apache.commons.lang3.StringUtils; -import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; -import org.apache.stratos.manager.composite.application.beans.*; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.StartupOrder; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; -import java.util.List; +import java.util.*; public class DefaultCompositeApplicationParser implements CompositeApplicationParser { - DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager; + private static Log log = LogFactory.getLog(DefaultCompositeApplicationParser.class); + + DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; public DefaultCompositeApplicationParser () { - dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); } @Override - public CompositeApplicationDefinition parse (Object compositeAppObj) throws CompositeApplicationDefinitionException { + public CompositeAppContext parse(Object obj) throws CompositeApplicationDefinitionException { CompositeAppDefinition compositeAppDefinition = null; - if (compositeAppObj instanceof CompositeAppDefinition) { - compositeAppDefinition = (CompositeAppDefinition) compositeAppObj; - - } else { - throw new CompositeApplicationDefinitionException("Invalid Composite Application definition"); + if (obj instanceof CompositeAppDefinition) { + compositeAppDefinition = (CompositeAppDefinition) obj; } if (compositeAppDefinition == null) { - throw new CompositeApplicationDefinitionException("Composite Application definition not found"); + throw new CompositeApplicationDefinitionException("Invlaid Composite Application Defintion"); } - String compositeAppId = compositeAppDefinition.getApplicationId(); - if(StringUtils.isEmpty(compositeAppId)){ - throw new CompositeApplicationDefinitionException("Application ID can not be empty"); + if (compositeAppDefinition.getAlias() == null || compositeAppDefinition.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid alias specified"); } - String compositeAppAlias = compositeAppDefinition.getAlias(); - // components - processComponents(compositeAppDefinition.getComponents()); + if (compositeAppDefinition.getApplicationId() == null || compositeAppDefinition.getApplicationId().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Composite App id specified"); + } - return null; + // get the defined groups + Map definedGroups = getDefinedGroups(compositeAppDefinition); + if (log.isDebugEnabled()) { + Set> groupEntries = definedGroups.entrySet(); + log.debug("Defined Groups: [ "); + for (Map.Entry groupEntry : groupEntries) { + log.debug("Group alias: " + groupEntry.getKey()); + } + log.debug(" ]"); + } + + // get the Subscribables Information + Map subscribablesInfo = getSubscribableInformation(compositeAppDefinition); + if (log.isDebugEnabled()) { + Set> subscribableInfoEntries = subscribablesInfo.entrySet(); + log.debug("Defined Subscribable Information: [ "); + for (Map.Entry subscribableInfoEntry : subscribableInfoEntries) { + log.debug("Subscribable Information alias: " + subscribableInfoEntry.getKey()); + } + log.debug(" ]"); + } + + return buildCompositeAppStructure (compositeAppDefinition, definedGroups, subscribablesInfo); + } + + private Map getDefinedGroups (CompositeAppDefinition compositeAppDefinition) throws + CompositeApplicationDefinitionException { + + // map [group alias -> Group Definition] + Map definedGroups = null; + + if (compositeAppDefinition.getComponents() != null) { + if (compositeAppDefinition.getComponents().getGroups() != null) { + definedGroups = new HashMap(); + + for (GroupDefinition group : compositeAppDefinition.getComponents().getGroups()) { + + // check validity of group name + if (group.getName() == null || group.getName().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Group name specified"); + } + + // check if group is deployed + if(isGroupDeployed(group.getName())) { + throw new CompositeApplicationDefinitionException("Group with name " + group.getName() + " not deployed"); + } + + // check validity of group alias + if (group.getAlias() == null || group.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid Group alias specified"); + } + + // check if a group is already defined under the same alias + if(definedGroups.get(group.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new CompositeApplicationDefinitionException("A Group with alias " + group.getAlias() + " already exists"); + } + + definedGroups.put(group.getAlias(), group); + if (log.isDebugEnabled()) { + log.debug("Added Group Definition [ " + group.getName() +" , " + group.getAlias() + " ] to map [group alias -> Group Definition]"); + } + } + } + } + + return definedGroups; + } + + private Map getSubscribableInformation (CompositeAppDefinition compositeAppDefinition) throws + CompositeApplicationDefinitionException { + + // map [cartridge alias -> Subscribable Information] + Map subscribableInformation = null; + + if (compositeAppDefinition.getSubscribableInfo() != null) { + subscribableInformation = new HashMap(); + + for (SubscribableInfo subscribableInfo : compositeAppDefinition.getSubscribableInfo()) { + + if (subscribableInfo.getAlias() == null || subscribableInfo.getAlias().isEmpty()) { + throw new CompositeApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj"); + } + + // check if a group is already defined under the same alias + if(subscribableInformation.get(subscribableInfo.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new CompositeApplicationDefinitionException("A Subscribable Info obj with alias " + subscribableInfo.getAlias() + " already exists"); + } + + subscribableInformation.put(subscribableInfo.getAlias(), subscribableInfo); + if (log.isDebugEnabled()) { + log.debug("Added Subcribables Info obj [ " + subscribableInfo.getAlias() + " ] to map [cartridge alias -> Subscribable Information]"); + } + } + } + + return subscribableInformation; } - // TODO: should return the relevant object type to send to CC - private void processComponents(List components) throws CompositeApplicationDefinitionException { + private boolean isGroupDeployed (String serviceGroupName) throws CompositeApplicationDefinitionException { - if (components == null) { - return; + try { + return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName) != null; + + } catch (PersistenceManagerException e) { + throw new CompositeApplicationDefinitionException(e); } - for (ComponentDefinition component : components) { - // process the group definitions - String groupName = component.getGroup(); - String groupAlias = component.getAlias(); + } + + private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition compositeAppDefinition, + Map definedGroups, + Map subscribableInformation) + throws CompositeApplicationDefinitionException { - // neither group name nor alias can be empty - if (StringUtils.isEmpty(groupName)) { - throw new CompositeApplicationDefinitionException("Group Name is invalid"); + CompositeAppContext compositeAppContext = new CompositeAppContext(); + + // get top level Subscribables + if (compositeAppDefinition.getComponents() != null) { + if (compositeAppDefinition.getComponents().getSubscribables() != null) { + compositeAppContext.setSubscribableContexts(getSubsribableContexts(compositeAppDefinition.getComponents().getSubscribables(), + subscribableInformation)); } - if (StringUtils.isEmpty(groupAlias)) { - throw new CompositeApplicationDefinitionException("Group Alias is invalid"); + + // get Groups + if (compositeAppDefinition.getComponents().getGroups() != null) { + compositeAppContext.setGroupContexts(getGroupContexts(compositeAppDefinition.getComponents().getGroups(), + subscribableInformation, definedGroups)); } - // check if the group is deployed. if not can't continue - if (!isGroupDeployed(groupName)) { - throw new CompositeApplicationDefinitionException(String.format("No Service Group found with name [ %s ]", groupName)); + // get top level Dependency definitions + if (compositeAppDefinition.getComponents().getDependencies() != null) { + compositeAppContext.setStartupOrder(getStartupOrderForApplicationComponents(compositeAppDefinition.getComponents(). + getDependencies().getStartupOrder())); + + compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour()); } + } + + return compositeAppContext; + } + + private Set getGroupContexts (List groupDefinitions, + Map subscribableInformation, + Map definedGroups) + throws CompositeApplicationDefinitionException { + + Set groupContexts = new HashSet(); + + for (GroupDefinition group : groupDefinitions) { + groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); + } + + return groupContexts; + } + + private GroupContext getGroupContext (GroupDefinition group, Map subscribableInformation, + Map definedGroups) throws CompositeApplicationDefinitionException { + + // check if are in the defined Group set + GroupDefinition definedGroupDef = definedGroups.get(group.getAlias()); + if (definedGroupDef == null) { + throw new CompositeApplicationDefinitionException("Group Definition with name: " + group.getName() + ", alias: " + + group.getAlias() + " is not found in the all Group Definitions collection"); + } - // get group level policy information - String groupDepPolicy = component.getDeploymentPolicy(); - String groupScalePolicy = component.getAutoscalingPolicy(); + GroupContext groupContext = new GroupContext(); + // get group level Subscribables + if (group.getSubscribables() != null) { + groupContext.setName(group.getName()); + groupContext.setAlias(group.getAlias()); + groupContext.setAutoscalingPolicy(group.getAutoscalingPolicy()); + groupContext.setDeploymentPolicy(group.getDeploymentPolicy()); + groupContext.setSubscribableContexts(getSubsribableContexts(group.getSubscribables(), subscribableInformation)); + groupContext.setStartupOrder(getStartupOrderForGroup(group.getName())); + groupContext.setKillBehaviour(getKillbehaviour(group.getName())); + } + // get nested groups + if (group.getSubGroups() != null) { + Set nestedGroupContexts = new HashSet(); + // check sub groups + for (GroupDefinition subGroup : group.getSubGroups()) { + nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); + } - // subscribables - processSubscribables(component.getSubscribables()); + groupContext.setGroupContexts(nestedGroupContexts); } + + return groupContext; } - private boolean isGroupDeployed (String groupName) throws CompositeApplicationDefinitionException { + private Set getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { - ServiceGroupDefinition serviceGroupDefinition = null; + ServiceGroupDefinition groupDefinition; try { - serviceGroupDefinition = dataInsertionAndRetrievalManager.getServiceGroupDefinition(groupName); + groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); } catch (PersistenceManagerException e) { throw new CompositeApplicationDefinitionException(e); } - return serviceGroupDefinition != null; + if (groupDefinition == null) { + throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + } + + if (groupDefinition.getDependencies() != null) { + if (groupDefinition.getDependencies().getStartupOrder() != null) { + return ParserUtils.convert(groupDefinition.getDependencies().getStartupOrder()); + } + } + + return null; } - // TODO: should return the relevant object type to send to CC - private void processSubscribables (List subscribables) throws CompositeApplicationDefinitionException { + private Set getStartupOrderForApplicationComponents (List startupOrderDefinitions) + throws CompositeApplicationDefinitionException { - if (subscribables == null) { - return; + if (startupOrderDefinitions == null) { + return null; } - for (SubscribableInfo subscribable : subscribables) { + Set startupOrders = new HashSet(); - String cartridgeType = subscribable.getType(); - String subscriptionAlias = subscribable.getAlias(); + for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { + startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); + } - // neither cartridge type nor alias can be empty - if (cartridgeType == null || cartridgeType.isEmpty()) { - throw new CompositeApplicationDefinitionException("Cartridge Type is invalid"); - } - if (subscriptionAlias == null || subscriptionAlias.isEmpty()) { - throw new CompositeApplicationDefinitionException("Subscription Alias is invalid"); - } - // TODO should validate if there exist a cartridge with $cartridgeType + return startupOrders; + } + + private String getKillbehaviour (String serviceGroupName) throws CompositeApplicationDefinitionException { + + ServiceGroupDefinition groupDefinition; + + try { + groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); + + } catch (PersistenceManagerException e) { + throw new CompositeApplicationDefinitionException(e); + } + if (groupDefinition == null) { + throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); } + + if (groupDefinition.getDependencies() != null) { + return groupDefinition.getDependencies().getKillBehaviour(); + } + + return null; + } - // TODO: should return the relevant object type to send to CC - private void getSubscriptionInformation (List subscribables, String subscriptionAlias) throws CompositeApplicationDefinitionException { + private Set getSubsribableContexts (List subscribableDefinitions, + Map subscribableInformation) + throws CompositeApplicationDefinitionException { - for (SubscribableInfo subscribable : subscribables) { + Set subscribableContexts = new HashSet(); - if (subscribable.getAlias().equals(subscriptionAlias)) { - // match found, retrieve the information - String deploymentPolicy = subscribable.getDeploymentPolicy(); - String autoscalingPolicy = subscribable.getAutoscalingPolicy(); - String repoUrl = subscribable.getRepoUrl(); - if (repoUrl != null && !repoUrl.isEmpty()) { - boolean privateRepo = subscribable.isPrivateRepo(); - String repoUsername = subscribable.getUsername(); - String repoPassword = subscribable.getPassword(); - } + for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { + // check is there is a related Subscribable Information + SubscribableInfo subscribableInfo = subscribableInformation.get(subscribableDefinition.getAlias()); + if (subscribableInfo == null) { + throw new CompositeApplicationDefinitionException("Related Subscribable Information not found for Subscribable with alias: " + + subscribableDefinition.getAlias()); } + + subscribableContexts.add(ParserUtils.convert(subscribableDefinition, subscribableInfo)); } + + return subscribableContexts; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java new file mode 100644 index 0000000000..be9e7035b3 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.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.composite.application.parser; + +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.structure.GroupContext; +import org.apache.stratos.manager.composite.application.structure.StartupOrder; +import org.apache.stratos.manager.composite.application.structure.SubscribableContext; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class ParserUtils { + + public static SubscribableContext convert (SubscribableDefinition subscribable, SubscribableInfo subscribableInfo) { + + SubscribableContext subscribableContext = new SubscribableContext(subscribable.getType(), subscribable.getAlias()); + subscribableContext.setAutoscalingPolicy(subscribableInfo.getAutoscalingPolicy()); + subscribableContext.setDeploymentPolicy(subscribableInfo.getDeploymentPolicy()); + + if (subscribableInfo.getRepoUrl() != null && !subscribableInfo.getRepoUrl().isEmpty()) { + subscribableContext.setRepoUrl(subscribableInfo.getRepoUrl()); + subscribableContext.setPrivateRepo(subscribableInfo.isPrivateRepo()); + subscribableContext.setUsername(subscribableInfo.getUsername()); + subscribableContext.setPassword(subscribableInfo.getPassword()); + } + + return subscribableContext; + } + + public static Set convert (List startupOrderDefinitions) { + + Set startupOrders = new HashSet(); + for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { + StartupOrder startupOrder = new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter()); + startupOrders.add(startupOrder); + } + + return startupOrders; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java new file mode 100644 index 0000000000..6a589e7841 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.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.composite.application.structure; + +import java.util.Set; + +public class CompositeAppContext { + + private String appId; + + private Set groupContexts; + + private Set subscribableContexts; + + private Set startupOrder; + + private String killBehaviour; + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public Set getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(Set groupContexts) { + this.groupContexts = groupContexts; + } + + public Set getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(Set subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public Set getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(Set startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java new file mode 100644 index 0000000000..e7736ea6ca --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java @@ -0,0 +1,107 @@ +/* + * 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.structure; + +import java.util.List; +import java.util.Set; + +public class GroupContext { + + private String name; + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private Set groupContexts; + + private Set subscribableContexts; + + private Set startupOrder; + + private String killBehaviour; + + + public Set getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(Set startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } + + 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 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 Set getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(Set groupContexts) { + this.groupContexts = groupContexts; + } + + public Set getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(Set subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java new file mode 100644 index 0000000000..4553a9f04e --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.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.composite.application.structure; + +public class StartupOrder { + + private String start; + + private String after; + + public StartupOrder (String start, String after) { + this.start = start; + this.after = 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; + } +} 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/structure/SubscribableContext.java similarity index 52% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CartridgeDefinition.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java index bb191452fd..2e30c1bff9 100644 --- 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/structure/SubscribableContext.java @@ -1,30 +1,61 @@ -package org.apache.stratos.manager.composite.application.beans; +/* + * 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.structure; + +public class SubscribableContext { + + private String cartridgeType; - -public class CartridgeDefinition { private String alias; - private String type; + private String deploymentPolicy; + private String autoscalingPolicy; + private String repoUrl; + private boolean privateRepo; + private String username; + private String password; - public String getAlias() { - return alias; + public SubscribableContext (String cartridgeType, String alias) { + this.cartridgeType = cartridgeType; + this.alias = alias; } - public void setAlias(String alias) { - this.alias = alias; + public String getCartridgeType() { + return cartridgeType; } - public String getType() { - return type; + public void setCartridgeType(String cartridgeType) { + this.cartridgeType = cartridgeType; } - public void setType(String type) { - this.type = type; + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; } public String getDeploymentPolicy() { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java new file mode 100644 index 0000000000..ea475364f4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeApplicationException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class CompositeApplicationException extends Exception { + + private String message; + + public CompositeApplicationException () { + super(); + } + + public CompositeApplicationException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public CompositeApplicationException (String message) { + super(message); + this.message = message; + } + + public CompositeApplicationException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} 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 index 88641fc86a..f778760a0e 100644 --- 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 @@ -59,6 +59,35 @@ public class CartridgeSubscriptionManager { private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class); //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + + 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 (CloudControllerServiceUnregisteredCartridgeExceptionException 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 SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws ADCException, InvalidCartridgeAliasException, diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java new file mode 100644 index 0000000000..d60e9393e4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.subscription; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class CompositeAppSubscription implements Serializable { + + private static Log log = LogFactory.getLog(CompositeAppSubscription.class); + + private Map compositeAppToCartridgeSubcription; + + public CompositeAppSubscription () { + compositeAppToCartridgeSubcription = new HashMap(); + } + + public void addCartridgeSubscription (String compositeAppAlias, String cartridgeSubscriptionAlias) { + + compositeAppToCartridgeSubcription.put(compositeAppAlias, cartridgeSubscriptionAlias); + if (log.isDebugEnabled()) { + log.debug("Cartridge Subscription alias [ "+ cartridgeSubscriptionAlias +" ] stored against Composite Application alias [ " + + compositeAppAlias + " ]"); + } + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index d09451c134..804e4b58f6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -251,25 +251,25 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli return stratosAdminResponse; } */ - static StratosAdminResponse deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition) + static void deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition, ConfigurationContext ctxt, + String userName, String tenantDomain) throws RestAPIException { + int tenantId = ApplicationManagementUtil.getTenantId(ctxt); + try { - compositeApplicationManager.deployCompositeApplication(compositeAppDefinition); + compositeApplicationManager.deployCompositeApplication(compositeAppDefinition, tenantId, tenantDomain, userName); } catch (CompositeApplicationDefinitionException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + throw new RestAPIException(e); } catch (PersistenceManagerException e) { - e.printStackTrace(); + throw new RestAPIException(e); + } catch (CompositeApplicationException e) { + throw new RestAPIException(e); } - //TODO send to CC - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deployed Composite Application [ Id: " + compositeAppDefinition.getApplicationId() - + " , alias: " + compositeAppDefinition.getAlias() + " ]"); - return stratosAdminResponse; } - static StratosAdminResponse unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt, + static void unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { log.info("Starting to undeploy a composite application definition " + configCompositeApplicationAlias); @@ -308,10 +308,6 @@ static StratosAdminResponse unDeployApplication(String configCompositeApplicatio } log.info(String.format("[type] %s", configCompositeApplicationAlias)); - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); - return stratosAdminResponse; } @@ -1423,7 +1419,7 @@ static StratosAdminResponse synchronizeRepository(CartridgeSubscription cartridg return stratosAdminResponse; } - static StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException { + static void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException { try { serviceGropingManager.deployServiceGroupDefinition(serviceGroupDefinition); @@ -1439,10 +1435,6 @@ static StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition } log.info("Successfully deployed the Service Group Definition with name " + serviceGroupDefinition.getName()); - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deployed Service Group Definition with name " + serviceGroupDefinition.getName()); - return stratosAdminResponse; } static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { @@ -1455,7 +1447,7 @@ static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefi } } - static StratosAdminResponse undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { + static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { try { serviceGropingManager.undeployServiceGroupDefinition(serviceGroupDefinitionName); @@ -1465,9 +1457,5 @@ static StratosAdminResponse undeployServiceGroupDefinition (String serviceGroupD } log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName); - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully undeplpoyed Service Group Definition with name " + serviceGroupDefinitionName); - return stratosAdminResponse; } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 8cdf16b0f3..98b3725989 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -63,7 +63,9 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; +import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.UUID; @@ -73,6 +75,8 @@ public class StratosAdmin extends AbstractAdmin { private static Log log = LogFactory.getLog(StratosAdmin.class); @Context HttpServletRequest httpServletRequest; + @Context + UriInfo uriInfo; @POST @Path("/init") @@ -130,10 +134,13 @@ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefi @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) // Grouping - public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition applicationDefinitionBean) + public Response deployApplicationDefinition(CompositeAppDefinition applicationDefinitionBean) throws RestAPIException { - return ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean); + ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean, getConfigContext(), + getUsername(), getTenantDomain()); + URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinitionBean.getApplicationId()).build(); + return Response.created(url).build(); } /* @POST @@ -157,12 +164,12 @@ public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition c @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) // Grouping - public StratosAdminResponse unDeployApplicationDefinition(String alias) + public Response unDeployApplicationDefinition(String alias) throws RestAPIException { - return ServiceUtils.unDeployApplication(alias, getConfigContext(), getUsername(), - getTenantDomain()); - + ServiceUtils.unDeployApplication(alias, getConfigContext(), getUsername(), + getTenantDomain()); + return Response.noContent().build(); } @@ -174,11 +181,12 @@ public StratosAdminResponse unDeployApplicationDefinition(String alias) @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) // Grouping - public StratosAdminResponse unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) + public Response unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) throws RestAPIException { - return ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), - getTenantDomain()); + ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), + getTenantDomain()); + return Response.noContent().build(); } @@ -232,10 +240,12 @@ public StratosAdminResponse unDeployCartridgeDefinition (@PathParam("cartridgeTy @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) + public Response deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws RestAPIException { - return ServiceUtils.deployServiceGroupDefinition(serviceGroupDefinition); + ServiceUtils.deployServiceGroupDefinition(serviceGroupDefinition); + URI url = uriInfo.getAbsolutePathBuilder().path(serviceGroupDefinition.getName()).build(); + return Response.created(url).build(); } @GET @@ -243,10 +253,10 @@ public StratosAdminResponse deployServiceGroupDefinition (ServiceGroupDefinition @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public ServiceGroupDefinition getServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) + public Response getServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) throws RestAPIException { - - return ServiceUtils.getServiceGroupDefinition(groupDefinitionName); + Response.ResponseBuilder rb = Response.ok().entity(ServiceUtils.getServiceGroupDefinition(groupDefinitionName)); + return rb.build(); } @DELETE @@ -255,10 +265,11 @@ public ServiceGroupDefinition getServiceGroupDefinition (@PathParam("groupDefini @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse undeployServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) + public Response undeployServiceGroupDefinition (@PathParam("groupDefinitionName") String groupDefinitionName) throws RestAPIException { - return ServiceUtils.undeployServiceGroupDefinition(groupDefinitionName); + ServiceUtils.undeployServiceGroupDefinition(groupDefinitionName); + return Response.noContent().build(); } @POST From a8182aca92707eab3e185ba05e8b861869640233 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 15 Jul 2014 13:06:22 +0530 Subject: [PATCH 013/436] Subscription structure initial impl. --- .../CompositeApplicationManager.java | 83 +++++++++++++++++-- .../CompositeAppSubscription.java | 39 +++++++-- .../subscription/GroupSubscription.java | 64 ++++++++++++++ 3 files changed, 168 insertions(+), 18 deletions(-) create mode 100644 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/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 02893e8358..0ca6ebc552 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -1,8 +1,6 @@ package org.apache.stratos.manager.composite.application; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -17,6 +15,8 @@ import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.manager.subscription.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.manager.subscription.SubscriptionData; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; @@ -37,22 +37,87 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin //DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); //mgr.persistCompositeApplication(compositeAppDefinition); - Set cartridgeSubscriptions = new HashSet(); + + // create the CompositeAppSubscription + CompositeAppSubscription compositeAppSubscription = new CompositeAppSubscription(compositeAppContext.getAppId()); + + // keep track of all CartridgeSubscriptions, against the alias + Map aliasToCartridgeSubscription = new HashMap(); + + // Keep track of all Group Subscriptions + Set groupSubscriptions = new HashSet(); // traverse through the Composite App Structure and create Cartridge Subscriptions if(compositeAppContext.getSubscribableContexts() != null) { - // Subscription relevant to top level Subscribables - cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), - tenantId, tenantDomain, tenantAdminUsername)); + // Subscriptions relevant to top level Subscribables + + for (CartridgeSubscription cartridgeSubscription : getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), + tenantId, tenantDomain, tenantAdminUsername)) { + aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); + } + // get top level cartridge aliases to add to Composite App Subscription + compositeAppSubscription.addCartridgeSubscriptionAliases(getCartrigdeSubscriptionAliases(compositeAppContext.getSubscribableContexts())); } if (compositeAppContext.getGroupContexts() != null) { // Subscriptions relevant to Groups - cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, - tenantDomain, tenantAdminUsername)); + + for (CartridgeSubscription cartridgeSubscription : getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, + tenantDomain, tenantAdminUsername)) { + aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); + } + + // set top level group aliases to Composite App Subscription + compositeAppSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(compositeAppContext.getGroupContexts())); + + groupSubscriptions.addAll(getGroupSubscriptions(compositeAppContext.getGroupContexts())); } } + private Set getCartrigdeSubscriptionAliases (Set subscribableContexts) throws CompositeApplicationException { + + Set cartridgeSubscriptionAliases = new HashSet(); + for (SubscribableContext subscribableContext : subscribableContexts) { + cartridgeSubscriptionAliases.add(subscribableContext.getAlias()); + } + + return cartridgeSubscriptionAliases; + } + + private Set getGroupSubscriptions (Set groupContexts) throws CompositeApplicationException { + + Set groupSubscriptions = new HashSet(); + for (GroupContext groupContext : groupContexts) { + // create Group Subscriptions for this Group + GroupSubscription groupSubscription = new GroupSubscription(groupContext.getAlias()); + if (groupContext.getSubscribableContexts() != null) { + groupSubscription.addCartridgeSubscriptionAliases(getCartrigdeSubscriptionAliases(groupContext.getSubscribableContexts())); + } + + // nested Group + if (groupContext.getGroupContexts() != null) { + groupSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(groupContext.getGroupContexts())); + // need to recurse to get other nested groups, if any + getGroupSubscriptions(groupContext.getGroupContexts()); + } + + groupSubscriptions.add(groupSubscription); + } + + return groupSubscriptions; + } + + private Set getGroupSubscriptionAliases (Set groupContexts) throws CompositeApplicationException { + + Set topLevelGroupAliases = new HashSet(); + + for (GroupContext topLevelGroupCtxt : groupContexts) { + topLevelGroupAliases.add(topLevelGroupCtxt.getAlias()); + } + + return topLevelGroupAliases; + } + private Set getCartridgeSubscriptionForGroups (Set groupContexts, int tenantId, String tenantDomain, String tenantAdminUsername) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java index d60e9393e4..86fb0cd2df 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -21,27 +21,48 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +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 CompositeAppSubscription implements Serializable { private static Log log = LogFactory.getLog(CompositeAppSubscription.class); - private Map compositeAppToCartridgeSubcription; + private String appId; - public CompositeAppSubscription () { - compositeAppToCartridgeSubcription = new HashMap(); + private Set cartridgeSubscriptionAliases; + + private Set groupSubscriptionAliases; + + public CompositeAppSubscription (String appId) { + + this.appId = appId; + cartridgeSubscriptionAliases = new HashSet(); + groupSubscriptionAliases = new HashSet(); + } + + public Set getGroupSubscriptionAliases() { + return groupSubscriptionAliases; } - public void addCartridgeSubscription (String compositeAppAlias, String cartridgeSubscriptionAlias) { + public void addCartridgeSubscriptionAlias (String cartridgeSubscriptionAlias) { + cartridgeSubscriptionAliases.add(cartridgeSubscriptionAlias); + } + + public void addCartridgeSubscriptionAliases (Set cartridgeSubscriptionAliases) { + cartridgeSubscriptionAliases.addAll(cartridgeSubscriptionAliases); + } + + public void addGroupSubscriptionAlias (String groupSubscriptionAlias) { + groupSubscriptionAliases.add(groupSubscriptionAlias); + } - compositeAppToCartridgeSubcription.put(compositeAppAlias, cartridgeSubscriptionAlias); - if (log.isDebugEnabled()) { - log.debug("Cartridge Subscription alias [ "+ cartridgeSubscriptionAlias +" ] stored against Composite Application alias [ " - + compositeAppAlias + " ]"); - } + public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { + cartridgeSubscriptionAliases.addAll(groupSubscriptionAliases); } } 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 new file mode 100644 index 0000000000..31fcb731b4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/GroupSubscription.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.subscription; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +public class GroupSubscription implements Serializable { + + private String groupAlias; + + private Set cartridgeSubscriptionAliases; + + private Set groupSubscriptionAliases; + + public GroupSubscription (String groupAlias) { + + this.groupAlias = groupAlias; + cartridgeSubscriptionAliases = new HashSet(); + groupSubscriptionAliases = new HashSet(); + } + + public Set getGroupSubscriptionAliases() { + return groupSubscriptionAliases; + } + + public void addCartridgeSubscriptionAlias (String cartridgeSubscriptionAlias) { + cartridgeSubscriptionAliases.add(cartridgeSubscriptionAlias); + } + + public void addGroupSubscriptionAlias (String groupSubscriptionAlias) { + groupSubscriptionAliases.add(groupSubscriptionAlias); + } + + public void addCartridgeSubscriptionAliases (Set cartridgeSubscriptionAliases) { + cartridgeSubscriptionAliases.addAll(cartridgeSubscriptionAliases); + } + + public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { + groupSubscriptionAliases.addAll(groupSubscriptionAliases); + } + + public String getGroupAlias() { + return groupAlias; + } +} From 1fa2d667d94debcbc2e63f7170c87fddb0e8fed5 Mon Sep 17 00:00:00 2001 From: rekathiru Date: Wed, 16 Jul 2014 06:53:31 +0530 Subject: [PATCH 014/436] adding composite application monitor --- .../stratos/autoscaler/AutoscalerContext.java | 37 +- .../autoscaler/ComplexApplicationContext.java | 38 +- .../AutoscalerTopologyEventReceiver.java | 393 +++++++++++------- .../autoscaler/monitor/AbstractMonitor.java | 145 ++++--- .../autoscaler/monitor/ClusterMonitor.java | 38 +- .../monitor/CompositeApplicationMonitor.java | 254 +++++++++++ .../autoscaler/monitor/LbClusterMonitor.java | 25 +- .../messaging/domain/topology/Cartridge.java | 14 +- .../domain/topology/CompositeApplication.java | 24 +- .../util/CompositeApplicationBuilder.java | 18 +- .../event/topology/MemberActivatedEvent.java | 13 +- 11 files changed, 681 insertions(+), 318 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 8bfb8e6b9a..d02d7fc1d8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.monitor.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.CompositeApplicationMonitor; import org.apache.stratos.autoscaler.monitor.LbClusterMonitor; import java.util.HashMap; @@ -44,13 +45,28 @@ private AutoscalerContext() { log.error("Rule evaluateMinCheck error", e); } } - + // Map private Map monitors; // Map private Map lbMonitors; - private static class Holder { + private Map appMonitors; + + public Map getAppMonitors() { + return appMonitors; + } + + public CompositeApplicationMonitor getAppMonitor(String applicationId) { + return appMonitors.get(applicationId); + } + + public void setAppMonitors(Map appMonitors) { + this.appMonitors = appMonitors; + } + + + private static class Holder { private static final AutoscalerContext INSTANCE = new AutoscalerContext(); } @@ -111,4 +127,21 @@ public void setLbMonitors(Map monitors) { public void addLbMonitor(LbClusterMonitor monitor) { lbMonitors.put(monitor.getClusterId(), monitor); } + + public void addAppMonitor(CompositeApplicationMonitor monitor) { + appMonitors.put(monitor.getAppId(), monitor); + } + + public CompositeApplicationMonitor removeAppMonitor(String appId) { + if(!appMonitorExist(appId)) { + log.fatal("LB monitor not found for App id: "+ appId); + return null; + } + log.info("Removed APP monitor [App id]: " + appId); + return appMonitors.remove(appId); + } + + public boolean appMonitorExist(String appId) { + return appMonitors.containsKey(appId); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java index 07cb48f37f..547483540f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java @@ -1,26 +1,14 @@ package org.apache.stratos.autoscaler; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - 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.CompositeApplication; -import org.apache.stratos.messaging.domain.topology.Dependencies; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.Member; -import org.apache.stratos.messaging.domain.topology.MemberStatus; -import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import java.util.*; + public class ComplexApplicationContext { @@ -37,7 +25,7 @@ public class ComplexApplicationContext { private static final Log log = LogFactory.getLog(ComplexApplicationContext.class); // return value of true will bring up new instance (all startup dependencies are up and active) - public boolean checkStartupDependencies (String clusterId) { + public static boolean checkStartupDependencies (String clusterId) { String serviceType = "undefined"; if (log.isDebugEnabled()) { log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); @@ -71,7 +59,7 @@ public boolean checkKillDependencies (String serviceType, String clusterId) { } - public boolean checkServiceDependencies (String serviceType, String clusterId, boolean kill_flag) { + public static boolean checkServiceDependencies(String serviceType, String clusterId, boolean kill_flag) { if (log.isDebugEnabled()) { @@ -134,7 +122,7 @@ public boolean checkServiceDependencies (String serviceType, String clusterId, b } - public boolean checkServiceDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag, Group home_group) { + public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, Group home_group) { String aServiceId = serviceType; @@ -146,7 +134,7 @@ public boolean checkServiceDependenciesForServiceType (String serviceType, Strin } - if (ComplexApplicationContext.isInKillAllTransition(this.getKillInTransitionKey(serviceType, home_group.getAlias()))) { + if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_group.getAlias()))) { if (log.isDebugEnabled()) { log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" ); } @@ -183,7 +171,7 @@ public boolean checkServiceDependenciesForServiceType (String serviceType, Strin } - List in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies); + List in_active_downstreams = getServiceSet_StateInActive(downstreamDependencies); if (in_active_downstreams.size() > 0) { if (log.isDebugEnabled()) { log.debug("found inactive downstream dependencies for serviceType " + aServiceId + " returning false"); @@ -496,7 +484,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, } - private boolean hasClusterActiveMember (Cluster cluster) { + private static boolean hasClusterActiveMember (Cluster cluster) { boolean flag = false; if(cluster.isLbCluster()){ if (log.isDebugEnabled()) { @@ -531,7 +519,7 @@ private boolean hasClusterActiveMember (Cluster cluster) { - private String extractAlias (String clusterId) { + private static String extractAlias(String clusterId) { String [] s = clusterId.split("\\."); if (log.isDebugEnabled()) { log.debug("clusterId alias is " + clusterId + " size: " + s.length); @@ -545,7 +533,7 @@ private String extractAlias (String clusterId) { return s[0]; } - private String extractClusterGroupFromClusterId (String clusterId) { + private static String extractClusterGroupFromClusterId(String clusterId) { String sub1 = extractAlias(clusterId); if (sub1 == null) { return null; @@ -609,7 +597,7 @@ private void updateEnableKillAllFlag(Mapall_dependencies, String } - private String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) { + private static String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) { return serviceTypeAlias + gr_alias; } @@ -633,7 +621,7 @@ private boolean isServiceSet_StateInActive(Map serviceTypes) { } - private List getServiceSet_StateInActive (Map serviceTypesMap) { + private static List getServiceSet_StateInActive(Map serviceTypesMap) { List result = new ArrayList (); if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 520559c2e4..53eff1651d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -23,17 +23,14 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.monitor.AbstractMonitor; -import org.apache.stratos.autoscaler.monitor.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.CompositeApplicationMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.autoscaler.util.AutoscalerUtil; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.listener.topology.*; @@ -92,10 +89,8 @@ protected void onEvent(Event event) { try { TopologyManager.acquireReadLock(); - for (Service service : TopologyManager.getTopology().getServices()) { - for (Cluster cluster : service.getClusters()) { - startClusterMonitor(cluster); - } + for (CompositeApplication compositeApplication : TopologyManager.getTopology().getCompositeApplication()) { + } } catch (Exception e) { log.error("Error processing event", e); @@ -107,24 +102,54 @@ protected void onEvent(Event event) { }); - topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - log.info("Event received: " + event); - ClusterCreatedEvent e = (ClusterCreatedEvent) event; - TopologyManager.acquireReadLock(); - Service service = TopologyManager.getTopology().getService(e.getServiceName()); - Cluster cluster = service.getCluster(e.getClusterId()); - startClusterMonitor(cluster); - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - TopologyManager.releaseReadLock(); - } - } + topologyEventReceiver.addEventListener(new CompositeApplicationCreatedEventListener() { + @Override + protected void onEvent(Event event) { - }); + log.info("[ClusterCreatedEventListener] Received: " + event.getClass()); + + CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = (CompositeApplicationCreatedEvent) event; + + ConfigCompositeApplication configCompositeApplication = + compositeApplicationCreatedEvent.getCompositeApplication(); + + //acquire read lock + TopologyManager.acquireReadLock(); + + try { + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + CompositeApplication compositeApplication = + builder.buildCompositeApplication(TopologyManager.getTopology(), + configCompositeApplication.getAlias()); + //start the app monitor + + + } finally { + //release read lock + TopologyManager.releaseReadLock(); + } + + } + }); + +// topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { +// @Override +// protected void onEvent(Event event) { +// try { +// log.info("Event received: " + event); +// ClusterCreatedEvent e = (ClusterCreatedEvent) event; +// TopologyManager.acquireReadLock(); +// Service service = TopologyManager.getTopology().getService(e.getServiceName()); +// Cluster cluster = service.getCluster(e.getClusterId()); +// startClusterMonitor(cluster); +// } catch (Exception e) { +// log.error("Error processing event", e); +// } finally { +// TopologyManager.releaseReadLock(); +// } +// } +// +// }); topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override @@ -258,19 +283,33 @@ protected void onEvent(Event event) { String memberId = e.getMemberId(); String partitionId = e.getPartitionId(); String networkPartitionId = e.getNetworkPartitionId(); + String applicationId = e.getApplicationId(); - PartitionContext partitionContext; + PartitionContext partitionContext = null; String clusterId = e.getClusterId(); - AbstractMonitor monitor; - - if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = AutoscalerContext.getInstance().getMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + CompositeApplicationMonitor appMonitor; + AbstractMonitor clusterMonitor; + + if (AutoscalerContext.getInstance().appMonitorExist(applicationId)) { + appMonitor = AutoscalerContext.getInstance().getAppMonitor(applicationId); + if((appMonitor).clusterMonitorExists(clusterId)) { + clusterMonitor = appMonitor.getClusterMonitor(clusterId); + partitionContext = clusterMonitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + } + else if(appMonitor.lbMonitorExists(clusterId)) { + clusterMonitor = appMonitor.getLBclusterMonitor(clusterId); + partitionContext = clusterMonitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + } else { + log.error(String.format("Couldn't find the Cluster [monitor] %s for the [member] %s", clusterId, memberId)); + return; + } + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); + //starting the pending clusters which are waiting for this member activation in a cluster + appMonitor.registerClusterMonitor(); } else { - monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + log.error(String.format("Couldn't find the Application [monitor] %s for the [member] %s", applicationId, memberId)); + return; } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isInfoEnabled()) { log.info(String.format("Member stat context has been added successfully: [member] %s", memberId)); } @@ -342,92 +381,72 @@ protected void onEvent(Event event) { // } } }); - - // Grouping - /* - topologyEventReceiver.addEventListener(new CompositeApplicationCreatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - TopologyManager.acquireReadLock(); - - if (log.isDebugEnabled()) { - log.debug("handling application created event"); - } - - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - TopologyManager.releaseReadLock(); - } - } - });*/ } - private class LBClusterMonitorAdder implements Runnable { - private Cluster cluster; - - public LBClusterMonitorAdder(Cluster cluster) { - this.cluster = cluster; - } - - public void run() { - LbClusterMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - monitor = AutoscalerUtil.getLBClusterMonitor(cluster); - success = true; - - } catch (PolicyValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); - retries--; - - } catch (PartitionValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); - retries--; - } - } while (!success && retries <= 0); - - if (monitor == null) { - String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); - log.error(msg); - throw new RuntimeException(msg); - } - - Thread th = new Thread(monitor); - th.start(); - AutoscalerContext.getInstance().addLbMonitor(monitor); - if (log.isInfoEnabled()) { - log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); - } - } - } - - private class ClusterMonitorAdder implements Runnable { - private Cluster cluster; - - public ClusterMonitorAdder(Cluster cluster) { - this.cluster = cluster; +// private class LBClusterMonitorAdder implements Runnable { +// private Cluster cluster; +// +// public LBClusterMonitorAdder(Cluster cluster) { +// this.cluster = cluster; +// } +// +// public void run() { +// LbClusterMonitor monitor = null; +// int retries = 5; +// boolean success = false; +// do { +// try { +// Thread.sleep(5000); +// } catch (InterruptedException e1) { +// } +// try { +// monitor = AutoscalerUtil.getLBClusterMonitor(cluster); +// success = true; +// +// } catch (PolicyValidationException e) { +// String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); +// log.debug(msg, e); +// retries--; +// +// } catch (PartitionValidationException e) { +// String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); +// log.debug(msg, e); +// retries--; +// } +// } while (!success && retries <= 0); +// +// if (monitor == null) { +// String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " +// + "for cluster: " + cluster.getClusterId(); +// log.error(msg); +// throw new RuntimeException(msg); +// } +// +// Thread th = new Thread(monitor); +// th.start(); +// AutoscalerContext.getInstance().addLbMonitor(monitor); +// if (log.isInfoEnabled()) { +// log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", +// cluster.getClusterId())); +// } +// } +// } + + + private class AppMonitorAdder implements Runnable { + private CompositeApplication compositeApplication; + + public AppMonitorAdder(CompositeApplication compositeApplication) { + this.compositeApplication = compositeApplication; } public void run() { - ClusterMonitor monitor = null; + CompositeApplicationMonitor monitor = null; int retries = 5; boolean success = false; do { @@ -435,39 +454,78 @@ public void run() { Thread.sleep(5000); } catch (InterruptedException e1) { } + monitor = new CompositeApplicationMonitor(compositeApplication); + success = true; - try { - monitor = AutoscalerUtil.getClusterMonitor(cluster); - success = true; - - } catch (PolicyValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); - retries--; - - } catch (PartitionValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); - retries--; - } - } while (!success && retries != 0); + } while (!success && retries <= 0); if (monitor == null) { - String msg = "Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); + String msg = "App monitor creation failed, even after retrying for 5 times, " + + "for Composite Application: " + compositeApplication.getAlias(); log.error(msg); throw new RuntimeException(msg); } Thread th = new Thread(monitor); th.start(); - AutoscalerContext.getInstance().addMonitor(monitor); + AutoscalerContext.getInstance().addAppMonitor(monitor); if (log.isInfoEnabled()) { - log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); + log.info(String.format("App monitor has been added successfully: [Composite Application] %s", + compositeApplication.getAlias())); } } } +// +// +// private class ClusterMonitorAdder implements Runnable { +// private Cluster cluster; +// +// public ClusterMonitorAdder(Cluster cluster) { +// this.cluster = cluster; +// } +// +// public void run() { +// ClusterMonitor monitor = null; +// int retries = 5; +// boolean success = false; +// do { +// try { +// Thread.sleep(5000); +// } catch (InterruptedException e1) { +// } +// +// try { +// monitor = AutoscalerUtil.getClusterMonitor(cluster); +// success = true; +// +// } catch (PolicyValidationException e) { +// String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); +// log.debug(msg, e); +// retries--; +// +// } catch (PartitionValidationException e) { +// String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); +// log.debug(msg, e); +// retries--; +// } +// } while (!success && retries != 0); +// +// if (monitor == null) { +// String msg = "Cluster monitor creation failed, even after retrying for 5 times, " +// + "for cluster: " + cluster.getClusterId(); +// log.error(msg); +// throw new RuntimeException(msg); +// } +// +// Thread th = new Thread(monitor); +// th.start(); +// AutoscalerContext.getInstance().addMonitor(monitor); +// if (log.isInfoEnabled()) { +// log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", +// cluster.getClusterId())); +// } +// } +// } private void runTerminateAllRule(AbstractMonitor monitor) { @@ -490,31 +548,54 @@ public void terminate() { terminated = true; } - protected synchronized void startClusterMonitor(Cluster cluster) { - Thread th = null; - if (cluster.isLbCluster() - && !AutoscalerContext.getInstance() - .lbMonitorExist( - cluster.getClusterId())) { - th = new Thread(new LBClusterMonitorAdder( - cluster)); - } else if (!cluster.isLbCluster() && !AutoscalerContext.getInstance() - .monitorExist(cluster.getClusterId())) { - th = new Thread( - new ClusterMonitorAdder(cluster)); - } - if (th != null) { - th.start(); - try { - th.join(); - } catch (InterruptedException ignore) { +// protected synchronized void startClusterMonitor(Cluster cluster) { +// Thread th = null; +// if (cluster.isLbCluster() +// && !AutoscalerContext.getInstance() +// .lbMonitorExist( +// cluster.getClusterId())) { +// th = new Thread(new LBClusterMonitorAdder( +// cluster)); +// } else if (!cluster.isLbCluster() && !AutoscalerContext.getInstance() +// .monitorExist(cluster.getClusterId())) { +// th = new Thread( +// new ClusterMonitorAdder(cluster)); +// } +// if (th != null) { +// th.start(); +// try { +// th.join(); +// } catch (InterruptedException ignore) { +// } +// +// if (log.isDebugEnabled()) { +// log.debug(String +// .format("Cluster monitor thread has been started successfully: [cluster] %s ", +// cluster.getClusterId())); +// } +// } +// } + + protected synchronized void startAppMonitor(CompositeApplication compositeApplication) { + Thread th = null; + if (AutoscalerContext.getInstance() + .appMonitorExist( + compositeApplication.getAlias())) { + th = new Thread(new AppMonitorAdder( + compositeApplication)); } + if (th != null) { + th.start(); + try { + th.join(); + } catch (InterruptedException ignore) { + } - if (log.isDebugEnabled()) { - log.debug(String - .format("Cluster monitor thread has been started successfully: [cluster] %s ", - cluster.getClusterId())); + if (log.isDebugEnabled()) { + log.debug(String + .format("Composite Application monitor thread has been started successfully: [Composite Application] %s ", + compositeApplication.getAlias())); + } } } - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java index f9792eff62..02eb62ea96 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java @@ -18,8 +18,6 @@ */ package org.apache.stratos.autoscaler.monitor; -import java.util.Map; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; @@ -33,75 +31,76 @@ import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; +import java.util.Map; + /** * Is responsible for monitoring a service cluster. This runs periodically * and perform minimum instance check and scaling check using the underlying * rules engine. - * */ - abstract public class AbstractMonitor implements Runnable{ - - private static final Log log = LogFactory.getLog(AbstractMonitor.class); - // Map - protected Map networkPartitionCtxts; - protected DeploymentPolicy deploymentPolicy; - protected AutoscalePolicy autoscalePolicy; - - - protected FactHandle minCheckFactHandle; - protected FactHandle scaleCheckFactHandle; - protected FactHandle terminateDependencyFactHandle; - - protected StatefulKnowledgeSession minCheckKnowledgeSession; - protected StatefulKnowledgeSession scaleCheckKnowledgeSession; - protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; - protected boolean isDestroyed; - - protected String clusterId; - protected String serviceId; - - protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; - - @Override - public void run() { - // TODO Auto-generated method stub - - } - - - public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { - log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); - String networkPartitionId = member.getNetworkPartitionId(); - if(networkPartitionCtxts.containsKey(networkPartitionId)) { - log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); - return networkPartitionCtxts.get(networkPartitionId); - } - log.info("returning null getNetworkPartitionCtxt"); - return null; - } - - public String getPartitionOfMember(String memberId){ - for(Service service: TopologyManager.getTopology().getServices()){ - for(Cluster cluster: service.getClusters()){ - if(cluster.memberExists(memberId)){ +abstract public class AbstractMonitor implements Runnable { + + private static final Log log = LogFactory.getLog(AbstractMonitor.class); + // Map + protected Map networkPartitionCtxts; + protected DeploymentPolicy deploymentPolicy; + protected AutoscalePolicy autoscalePolicy; + + + protected FactHandle minCheckFactHandle; + protected FactHandle scaleCheckFactHandle; + protected FactHandle terminateDependencyFactHandle; + + protected StatefulKnowledgeSession minCheckKnowledgeSession; + protected StatefulKnowledgeSession scaleCheckKnowledgeSession; + protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; + protected boolean isDestroyed; + + protected String clusterId; + protected String serviceId; + + protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; + + @Override + public void run() { + // TODO Auto-generated method stub + + } + + + public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { + log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); + String networkPartitionId = member.getNetworkPartitionId(); + if (networkPartitionCtxts.containsKey(networkPartitionId)) { + log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); + return networkPartitionCtxts.get(networkPartitionId); + } + log.info("returning null getNetworkPartitionCtxt"); + return null; + } + + public String getPartitionOfMember(String memberId) { + for (Service service : TopologyManager.getTopology().getServices()) { + for (Cluster cluster : service.getClusters()) { + if (cluster.memberExists(memberId)) { return cluster.getMember(memberId).getPartitionId(); } } } return null; - } - + } + public void destroy() { minCheckKnowledgeSession.dispose(); scaleCheckKnowledgeSession.dispose(); terminateDependencyKnowledgeSession.dispose(); setDestroyed(true); - if(log.isDebugEnabled()) { - log.debug("Cluster Monitor Drools session has been disposed. "+this.toString()); + if (log.isDebugEnabled()) { + log.debug("Cluster Monitor Drools session has been disposed. " + this.toString()); } } - public boolean isDestroyed() { + public boolean isDestroyed() { return isDestroyed; } @@ -131,8 +130,8 @@ public AutoscalePolicy getAutoscalePolicy() { public void setAutoscalePolicy(AutoscalePolicy autoscalePolicy) { this.autoscalePolicy = autoscalePolicy; - } - + } + public String getClusterId() { return clusterId; } @@ -160,7 +159,7 @@ public boolean partitionCtxtAvailable(String partitionId) { public void addNetworkPartitionCtxt(NetworkPartitionContext ctxt) { this.networkPartitionCtxts.put(ctxt.getId(), ctxt); } - + public NetworkPartitionContext getPartitionCtxt(String id) { return this.networkPartitionCtxts.get(id); } @@ -180,24 +179,24 @@ public FactHandle getMinCheckFactHandle() { public void setMinCheckFactHandle(FactHandle minCheckFactHandle) { this.minCheckFactHandle = minCheckFactHandle; } - + public StatefulKnowledgeSession getTerminateDependencyKnowledgeSession() { - return terminateDependencyKnowledgeSession; - } - - public void setTerminateDependencyKnowledgeSession( - StatefulKnowledgeSession terminateDependencyKnowledgeSession) { - this.terminateDependencyKnowledgeSession = terminateDependencyKnowledgeSession; - } - - public FactHandle getTerminateDependencyFactHandle() { - return terminateDependencyFactHandle; - } - - public void setTerminateDependencyFactHandle( - FactHandle terminateDependencyFactHandle) { - this.terminateDependencyFactHandle = terminateDependencyFactHandle; - } + return terminateDependencyKnowledgeSession; + } + + public void setTerminateDependencyKnowledgeSession( + StatefulKnowledgeSession terminateDependencyKnowledgeSession) { + this.terminateDependencyKnowledgeSession = terminateDependencyKnowledgeSession; + } + + public FactHandle getTerminateDependencyFactHandle() { + return terminateDependencyFactHandle; + } + + public void setTerminateDependencyFactHandle( + FactHandle terminateDependencyFactHandle) { + this.terminateDependencyFactHandle = terminateDependencyFactHandle; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java index d5d02bcf92..3358469a78 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java @@ -32,11 +32,10 @@ * Is responsible for monitoring a service cluster. This runs periodically * and perform minimum instance check and scaling check using the underlying * rules engine. - * */ -public class ClusterMonitor extends AbstractMonitor{ +public class ClusterMonitor extends AbstractMonitor { - private static final Log log = LogFactory.getLog(ClusterMonitor.class); + private static final Log log = LogFactory.getLog(ClusterMonitor.class); private String lbReferenceType; public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, @@ -52,13 +51,12 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo this.deploymentPolicy = deploymentPolicy; this.autoscalePolicy = autoscalePolicy; if (log.isDebugEnabled()) { - log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); + log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); } networkPartitionCtxts = new ConcurrentHashMap(); } - @Override public void run() { @@ -70,12 +68,12 @@ public void run() { } while (!isDestroyed()) { if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. "+this.toString()); + log.debug("Cluster monitor is running.. " + this.toString()); } try { monitor(); } catch (Exception e) { - log.error("Cluster monitor: Monitor failed."+this.toString(), e); + log.error("Cluster monitor: Monitor failed." + this.toString(), e); } try { // TODO make this configurable @@ -84,20 +82,20 @@ public void run() { } } } - + private void monitor() { // if(clusterCtxt != null ) { - //TODO make this concurrent + //TODO make this concurrent for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { //minimum check per partition - for(PartitionContext partitionContext: networkPartitionContext.getPartitionCtxts().values()){ + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { minCheckKnowledgeSession.setGlobal("clusterId", clusterId); minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); minCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); minCheckKnowledgeSession.setGlobal("serviceId", serviceId); - + if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); } @@ -106,16 +104,16 @@ private void monitor() { , minCheckFactHandle, partitionContext); } - + //terminate dependency per partition // rule terminates all members of a service which is a prerequisites for other services - for(PartitionContext partitionContext: networkPartitionContext.getPartitionCtxts().values()){ + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { terminateDependencyKnowledgeSession.setGlobal("clusterId", clusterId); terminateDependencyKnowledgeSession.setGlobal("lbRef", lbReferenceType); terminateDependencyKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); terminateDependencyKnowledgeSession.setGlobal("serviceId", serviceId); - + if (log.isDebugEnabled()) { log.debug(String.format("Running terminate dependency for partition %s ", partitionContext.getPartitionId())); } @@ -128,7 +126,7 @@ private void monitor() { boolean rifReset = networkPartitionContext.isRifReset(); boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); - if(rifReset || memoryConsumptionReset || loadAverageReset){ + if (rifReset || memoryConsumptionReset || loadAverageReset) { scaleCheckKnowledgeSession.setGlobal("clusterId", clusterId); //scaleCheckKnowledgeSession.setGlobal("deploymentPolicy", deploymentPolicy); @@ -148,9 +146,9 @@ private void monitor() { networkPartitionContext.setRifReset(false); networkPartitionContext.setMemoryConsumptionReset(false); networkPartitionContext.setLoadAverageReset(false); - } else if(log.isDebugEnabled()){ - log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " + - "cycle for network partition %s", networkPartitionContext.getId()) ); + } else if (log.isDebugEnabled()) { + log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " + + "cycle for network partition %s", networkPartitionContext.getId())); } } } @@ -158,8 +156,8 @@ private void monitor() { @Override public String toString() { return "ClusterMonitor [clusterId=" + clusterId + ", serviceId=" + serviceId + - ", deploymentPolicy=" + deploymentPolicy + ", autoscalePolicy=" + autoscalePolicy + - ", lbReferenceType=" + lbReferenceType + "]"; + ", deploymentPolicy=" + deploymentPolicy + ", autoscalePolicy=" + autoscalePolicy + + ", lbReferenceType=" + lbReferenceType + "]"; } public String getLbReferenceType() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java new file mode 100644 index 0000000000..c685cd3d2c --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java @@ -0,0 +1,254 @@ +/* + * 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.autoscaler.monitor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.ComplexApplicationContext; +import org.apache.stratos.autoscaler.exception.PartitionValidationException; +import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.util.AutoscalerUtil; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.CompositeApplication; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +import java.util.List; +import java.util.Map; + +public class CompositeApplicationMonitor extends AbstractMonitor { + private static final Log log = LogFactory.getLog(CompositeApplicationMonitor.class); + private CompositeApplication compositeApplication; + private Map clusterMonitors; + //private Map activeClusterMonitors; + //private Map pausedClusterMonitors; + //cluster ids need to be checked upon the instance activation or group activation + private List clusterIds; + + + private Map lbClusterMonitors; + private String appId; + + public CompositeApplicationMonitor(CompositeApplication compositeApplication) { + this.compositeApplication = compositeApplication; + } + + public void registerClusterMonitor() { + clusterIds = compositeApplication.getClusterIds(); + for (String clusterId : clusterIds) { + if (ComplexApplicationContext.checkStartupDependencies(clusterId)) { + startClusterMonitor(TopologyManager.getTopology().getService("").getCluster(clusterId)); + clusterIds.remove(clusterId); + } else { + //need to wait as it has start up dependency + } + } + } + + @Override + public void run() { + + try { + // TODO make this configurable, + // this is the delay the min check of normal cluster monitor to wait until LB monitor is added + Thread.sleep(60000); + } catch (InterruptedException ignore) { + } + while (!isDestroyed()) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } + try { + if(clusterIds.size() > 0) { + registerClusterMonitor(); + } + deRegisterClusterMonitorOnTermination(); + } catch (Exception e) { + log.error("Cluster monitor: Monitor failed." + this.toString(), e); + } + try { + // TODO make this configurable + Thread.sleep(30000); + } catch (InterruptedException ignore) { + } + } + } + + public void deRegisterClusterMonitorOnTermination() { + //need to remove the cluster monitor and add it to the pending list + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + protected synchronized void startClusterMonitor(Cluster cluster) { + Thread th = null; + if (cluster.isLbCluster() + && !this.lbClusterMonitors.containsKey(cluster.getClusterId())) { + th = new Thread(new LBClusterMonitorAdder( + cluster)); + } else if (!cluster.isLbCluster() && !this.clusterMonitors.containsKey(cluster.getClusterId())) { + th = new Thread( + new ClusterMonitorAdder(cluster)); + } + if (th != null) { + th.start(); + try { + th.join(); + } catch (InterruptedException ignore) { + } + + if (log.isDebugEnabled()) { + log.debug(String + .format("Cluster monitor thread has been started successfully: [cluster] %s ", + cluster.getClusterId())); + } + } + } + + public void setLbClusterMonitors(Map lbClusterMonitors) { + this.lbClusterMonitors = lbClusterMonitors; + } + + public void setClusterMonitors(Map clusterMonitors) { + clusterMonitors = clusterMonitors; + } + + public boolean clusterMonitorExists(String clusterId) { + return clusterMonitors.containsKey(clusterId); + } + + public boolean lbMonitorExists(String clusterId) { + return lbClusterMonitors.containsKey(clusterId); + } + + public LbClusterMonitor getLBclusterMonitor(String clusterId) { + return lbClusterMonitors.get(clusterId); + } + + public ClusterMonitor getClusterMonitor(String clusterId) { + return clusterMonitors.get(clusterId); + } + + private class ClusterMonitorAdder implements Runnable { + private Cluster cluster; + + public ClusterMonitorAdder(Cluster cluster) { + this.cluster = cluster; + } + + public void run() { + ClusterMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + + try { + monitor = AutoscalerUtil.getClusterMonitor(cluster); + success = true; + + } catch (PolicyValidationException e) { + String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.debug(msg, e); + retries--; + + } catch (PartitionValidationException e) { + String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.debug(msg, e); + retries--; + } + } while (!success && retries != 0); + + if (monitor == null) { + String msg = "Cluster monitor creation failed, even after retrying for 5 times, " + + "for cluster: " + cluster.getClusterId(); + log.error(msg); + throw new RuntimeException(msg); + } + + Thread th = new Thread(monitor); + th.start(); + //AutoscalerContext.getInstance().addMonitor(monitor); + clusterMonitors.put(cluster.getClusterId(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", + cluster.getClusterId())); + } + } + } + + private class LBClusterMonitorAdder implements Runnable { + private Cluster cluster; + + public LBClusterMonitorAdder(Cluster cluster) { + this.cluster = cluster; + } + + public void run() { + LbClusterMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + monitor = AutoscalerUtil.getLBClusterMonitor(cluster); + success = true; + + } catch (PolicyValidationException e) { + String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.debug(msg, e); + retries--; + + } catch (PartitionValidationException e) { + String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.debug(msg, e); + retries--; + } + } while (!success && retries <= 0); + + if (monitor == null) { + String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " + + "for cluster: " + cluster.getClusterId(); + log.error(msg); + throw new RuntimeException(msg); + } + + Thread th = new Thread(monitor); + th.start(); + //AutoscalerContext.getInstance().addLbMonitor(monitor); + lbClusterMonitors.put(cluster.getClusterId(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", + cluster.getClusterId())); + } + } + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java index d5c1c92bc9..052220608d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java @@ -18,8 +18,6 @@ */ package org.apache.stratos.autoscaler.monitor; -import java.util.concurrent.ConcurrentHashMap; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; @@ -28,13 +26,14 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import java.util.concurrent.ConcurrentHashMap; + /** * Is responsible for monitoring a service cluster. This runs periodically * and perform minimum instance check and scaling check using the underlying * rules engine. - * */ -public class LbClusterMonitor extends AbstractMonitor{ +public class LbClusterMonitor extends AbstractMonitor { private static final Log log = LogFactory.getLog(LbClusterMonitor.class); @@ -57,12 +56,12 @@ public void run() { while (!isDestroyed()) { if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. "+this.toString()); + log.debug("Cluster monitor is running.. " + this.toString()); } try { monitor(); } catch (Exception e) { - log.error("Cluster monitor: Monitor failed. "+this.toString(), e); + log.error("Cluster monitor: Monitor failed. " + this.toString(), e); } try { // TODO make this configurable @@ -71,27 +70,27 @@ public void run() { } } } - + private void monitor() { // TODO make this concurrent for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { // minimum check per partition for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts() - .values()) { + .values()) { if (partitionContext != null) { minCheckKnowledgeSession.setGlobal("clusterId", clusterId); if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", - partitionContext.getPartitionId())); + partitionContext.getPartitionId())); } minCheckFactHandle = - AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession, - minCheckFactHandle, - partitionContext); + AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession, + minCheckFactHandle, + partitionContext); // start only in the first partition context break; } @@ -99,7 +98,7 @@ private void monitor() { } } - } + } @Override public String toString() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java index 55d99f0f81..a51fcdbf59 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java @@ -1,11 +1,11 @@ package org.apache.stratos.messaging.domain.topology; -import java.util.ArrayList; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.util.ArrayList; +import java.util.List; + public class Cartridge implements Subscribable, Scalable { private String alias; // type @@ -13,6 +13,7 @@ public class Cartridge implements Subscribable, Scalable { private Dependencies dependencies; private Subscribable parent; private Group homeGroup; + private Cluster cluster; private static final Log log = LogFactory.getLog(Cartridge.class); public Cartridge(String alias) { @@ -78,4 +79,11 @@ public String toString() { return result; } + public Cluster getCluster() { + return cluster; + } + + public void setCluster(Cluster cluster) { + this.cluster = cluster; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java index c63f448926..d336a0b369 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java @@ -19,17 +19,12 @@ package org.apache.stratos.messaging.domain.topology; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.io.Serializable; +import java.util.*; + /** @@ -42,6 +37,7 @@ public class CompositeApplication implements Serializable { private String alias; private Group top_level; private Map all_groups = null; + private List clusterIds; private static final Log log = LogFactory.getLog(CompositeApplication.class); public CompositeApplication() { @@ -287,4 +283,16 @@ public String toString() { } return result; } + + public List getClusterIds() { + return clusterIds; + } + + public void setClusterIds(List clusterIds) { + this.clusterIds = clusterIds; + } + + public void addClusterIdToApp(String clusterId) { + this.clusterIds.add(clusterId); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java index 73d6f9d455..671b953dbd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java @@ -2,23 +2,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.ConfigCartridge; -import org.apache.stratos.messaging.domain.topology.ConfigGroup; -import org.apache.stratos.messaging.domain.topology.ConfigDependencies; -import org.apache.stratos.messaging.domain.topology.Cartridge; -import org.apache.stratos.messaging.domain.topology.Composite; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; -import org.apache.stratos.messaging.domain.topology.Dependencies; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.Scalable; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java index 98d82e19e5..38d4f92731 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java @@ -19,13 +19,13 @@ package org.apache.stratos.messaging.event.topology; +import org.apache.stratos.messaging.domain.topology.Port; + import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import org.apache.stratos.messaging.domain.topology.Port; - /** * This event is fired by Cloud Controller when a member has started it's server and * applications are ready to serve the incoming requests. @@ -42,6 +42,7 @@ public class MemberActivatedEvent extends TopologyEvent implements Serializable private String memberPublicIp; private String memberIp; private String groupId; + private String applicationId; public MemberActivatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -120,4 +121,12 @@ public String getGroupId() { public void setGroupId(String groupId) { this.groupId = groupId; } + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } } From 7f5f19b5ef8bd811fd4094d1c47226c81dc46c59 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 16 Jul 2014 18:52:49 +0530 Subject: [PATCH 015/436] persisting composite app subscriptions and group subscriptions --- .../CompositeApplicationManager.java | 269 +++++++++++------- .../CompositeAppSubscriptionException.java | 47 +++ .../exception/GroupSubscriptionException.java | 47 +++ .../manager/CartridgeSubscriptionManager.java | 52 +++- .../persistence/PersistenceManager.java | 32 ++- .../RegistryBasedPersistenceManager.java | 259 ++--------------- .../DataInsertionAndRetrievalManager.java | 107 ++----- .../CompositeAppSubscription.java | 15 + .../subscription/GroupSubscription.java | 21 +- .../rest/endpoint/services/ServiceUtils.java | 46 +-- 10 files changed, 432 insertions(+), 463 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/GroupSubscriptionException.java diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 0ca6ebc552..fafcdcfe19 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -10,20 +10,23 @@ import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; import org.apache.stratos.manager.composite.application.structure.GroupContext; import org.apache.stratos.manager.composite.application.structure.SubscribableContext; -import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.exception.*; import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; -import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.subscription.CompositeAppSubscription; import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.manager.subscription.SubscriptionData; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; //Grouping public class CompositeApplicationManager { private static Log log = LogFactory.getLog(CompositeApplicationManager.class); + + CartridgeSubscriptionManager cartridgeSubscriptionManager; + + public CompositeApplicationManager () { + cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); + } public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition, int tenantId, String tenantDomain, String tenantAdminUsername) throws CompositeApplicationException, CompositeApplicationDefinitionException, @@ -34,18 +37,22 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ] deployed successfully"); - - //DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - //mgr.persistCompositeApplication(compositeAppDefinition); // create the CompositeAppSubscription - CompositeAppSubscription compositeAppSubscription = new CompositeAppSubscription(compositeAppContext.getAppId()); + CompositeAppSubscription compositeAppSubscription; + try { + compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(compositeAppContext.getAppId(), + tenantAdminUsername, tenantDomain, tenantId); + + } catch (CompositeAppSubscriptionException e) { + throw new CompositeApplicationDefinitionException(e); + } // keep track of all CartridgeSubscriptions, against the alias Map aliasToCartridgeSubscription = new HashMap(); // Keep track of all Group Subscriptions - Set groupSubscriptions = new HashSet(); + Map groupAliasToGroupSubscription = new HashMap(); // traverse through the Composite App Structure and create Cartridge Subscriptions if(compositeAppContext.getSubscribableContexts() != null) { @@ -53,6 +60,13 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin for (CartridgeSubscription cartridgeSubscription : getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), tenantId, tenantDomain, tenantAdminUsername)) { + + // check if a Cartridge Subscription already exists with this alias for this Composite App + if (cartridgeSubscriptionExistsForAlias(aliasToCartridgeSubscription, cartridgeSubscription.getAlias())) { + throw new CompositeApplicationException("Cartridge Subscription with alias [ " + cartridgeSubscription.getAlias() + + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); + } + aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); } // get top level cartridge aliases to add to Composite App Subscription @@ -64,13 +78,31 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin for (CartridgeSubscription cartridgeSubscription : getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, tenantDomain, tenantAdminUsername)) { + + // check if a Cartridge Subscription already exists with this alias for this Composite App + if (cartridgeSubscriptionExistsForAlias(aliasToCartridgeSubscription, cartridgeSubscription.getAlias())) { + throw new CompositeApplicationException("Cartridge Subscription with alias [ " + cartridgeSubscription.getAlias() + + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); + } + aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); } + // create Group Subscriptions and collect them + for (GroupSubscription groupSubscription : getGroupSubscriptions(compositeAppContext.getGroupContexts(), + tenantAdminUsername, tenantDomain, tenantId)) { + + // check if a Group Subscription already exists with this alias for this Composite App + if (groupSubscriptionExistsForAlias(groupAliasToGroupSubscription, groupSubscription.getGroupAlias())) { + throw new CompositeApplicationException("Group Subscription with alias [ " + groupSubscription.getGroupAlias() + + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); + } + + groupAliasToGroupSubscription.put(groupSubscription.getGroupAlias(), groupSubscription); + } + // set top level group aliases to Composite App Subscription compositeAppSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(compositeAppContext.getGroupContexts())); - - groupSubscriptions.addAll(getGroupSubscriptions(compositeAppContext.getGroupContexts())); } } @@ -84,12 +116,20 @@ private Set getCartrigdeSubscriptionAliases (Set su return cartridgeSubscriptionAliases; } - private Set getGroupSubscriptions (Set groupContexts) throws CompositeApplicationException { + private Set getGroupSubscriptions (Set groupContexts, String tenantAdminUsername, + String tenantDomain, int tenantID) throws CompositeApplicationException { Set groupSubscriptions = new HashSet(); for (GroupContext groupContext : groupContexts) { // create Group Subscriptions for this Group - GroupSubscription groupSubscription = new GroupSubscription(groupContext.getAlias()); + GroupSubscription groupSubscription; + try { + groupSubscription = cartridgeSubscriptionManager.createGroupSubscription(groupContext.getName(), + groupContext.getAlias(), tenantAdminUsername, tenantDomain, tenantID); + + } catch (GroupSubscriptionException e) { + throw new CompositeApplicationException(e); + } if (groupContext.getSubscribableContexts() != null) { groupSubscription.addCartridgeSubscriptionAliases(getCartrigdeSubscriptionAliases(groupContext.getSubscribableContexts())); } @@ -98,7 +138,7 @@ private Set getGroupSubscriptions (Set groupCon if (groupContext.getGroupContexts() != null) { groupSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(groupContext.getGroupContexts())); // need to recurse to get other nested groups, if any - getGroupSubscriptions(groupContext.getGroupContexts()); + getGroupSubscriptions(groupContext.getGroupContexts(),tenantAdminUsername, tenantDomain, tenantID); } groupSubscriptions.add(groupSubscription); @@ -201,104 +241,117 @@ private CartridgeSubscription getCartridgeSubscription (SubscribableContext subs } } + + private boolean cartridgeSubscriptionExistsForAlias (Map aliasToCartridgeSubscription, + String newCartridgeSubscriptionAlias) { + + return aliasToCartridgeSubscription.get(newCartridgeSubscriptionAlias) != null; + } + + + private boolean groupSubscriptionExistsForAlias (Map groupAliasToGroupSubscription, + String newGroupSubscriptionAlias) { + + return groupAliasToGroupSubscription.get(newGroupSubscriptionAlias) != null; + } - public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { - if (log.isDebugEnabled()) { - log.debug("undeploying composite application " + configApplicationAlias); - } - // unregister application - unRegisterCompositeApplication(configApplicationAlias); - if (log.isDebugEnabled()) { - log.debug("publishing composite application removed event" + configApplicationAlias); - } - ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias); - if (log.isDebugEnabled()) { - log.debug("composite application successfully removed " + configApplicationAlias); - } - } +// public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { +// if (log.isDebugEnabled()) { +// log.debug("undeploying composite application " + configApplicationAlias); +// } +// // unregister application +// unRegisterCompositeApplication(configApplicationAlias); +// if (log.isDebugEnabled()) { +// log.debug("publishing composite application removed event" + configApplicationAlias); +// } +// ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias); +// if (log.isDebugEnabled()) { +// log.debug("composite application successfully removed " + configApplicationAlias); +// } +// } - private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { - - try { - if (log.isDebugEnabled()) { - log.debug("registering composite application " + configCompositeApplication.getAlias()); - } - DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - mgr.persistCompositeApplication ( configCompositeApplication); - - if (log.isDebugEnabled()) { - log.debug("testing to retrieve persisted composite application "); - Collection apps = mgr.getCompositeApplications(); - log.debug("retrieved persisted composite application " + apps.size()); - for (ConfigCompositeApplication app : apps) { - log.debug("retrieved persisted composite application " + app.getAlias()); - } - } - - } catch (PersistenceManagerException e) { - String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias(); - log.error(errorMsg); - throw new ADCException(errorMsg, e); - } - - log.info("Successfully registered composite application " + configCompositeApplication.getAlias()); - - } +// private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { +// +// try { +// if (log.isDebugEnabled()) { +// log.debug("registering composite application " + configCompositeApplication.getAlias()); +// } +// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); +// mgr.persistCompositeApplication ( configCompositeApplication); +// +// if (log.isDebugEnabled()) { +// log.debug("testing to retrieve persisted composite application "); +// Collection apps = mgr.getCompositeApplications(); +// log.debug("retrieved persisted composite application " + apps.size()); +// for (ConfigCompositeApplication app : apps) { +// log.debug("retrieved persisted composite application " + app.getAlias()); +// } +// } +// +// } catch (PersistenceManagerException e) { +// String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias(); +// log.error(errorMsg); +// throw new ADCException(errorMsg, e); +// } +// +// log.info("Successfully registered composite application " + configCompositeApplication.getAlias()); +// +// } - private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException { - - try { - if (log.isDebugEnabled()) { - log.debug("unregistering composite application " + configApplicationAlias); - } - DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - mgr.removeCompositeApplication(configApplicationAlias); - - if (log.isDebugEnabled()) { - log.debug("removed persisted composite application successfully"); - } - - } catch (PersistenceManagerException e) { - String errorMsg = "Error undeploying composite application " + configApplicationAlias; - log.error(errorMsg); - throw new ADCException(errorMsg, e); - } - - log.info("Successfully undeployed composite application " + configApplicationAlias); - - } +// private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException { +// +// try { +// if (log.isDebugEnabled()) { +// log.debug("unregistering composite application " + configApplicationAlias); +// } +// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); +// mgr.removeCompositeApplication(configApplicationAlias); +// +// if (log.isDebugEnabled()) { +// log.debug("removed persisted composite application successfully"); +// } +// +// } catch (PersistenceManagerException e) { +// String errorMsg = "Error undeploying composite application " + configApplicationAlias; +// log.error(errorMsg); +// throw new ADCException(errorMsg, e); +// } +// +// log.info("Successfully undeployed composite application " + configApplicationAlias); +// +// } - public void restoreCompositeApplications () throws ADCException { - try { - if (log.isDebugEnabled()) { - log.debug("restoring composite applications " ); - } - DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); - Collection apps = mgr.getCompositeApplications(); - - if (apps == null) { - if (log.isDebugEnabled()) { - log.debug("no composite application configured"); - } - return; - } - if (log.isDebugEnabled()) { - log.debug("retrieved persisted composite application " + apps.size()); - for (ConfigCompositeApplication app : apps) { - log.debug("retrieved persisted composite application " + app.getAlias()); - } - } - // sending application created event to restore in Toplogy - for (ConfigCompositeApplication app : apps) { - log.debug("restoring composite application " + app.getAlias()); - ApplicationUtils.publishApplicationCreatedEvent(app); - } - - } catch (PersistenceManagerException e) { - String errorMsg = "Error restoring composite application "; - log.error(errorMsg); - throw new ADCException(errorMsg, e); - } - } +// public void restoreCompositeApplications () throws ADCException { +// try { +// if (log.isDebugEnabled()) { +// log.debug("restoring composite applications " ); +// } +// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); +// Collection apps = mgr.getCompositeApplications(); +// +// if (apps == null) { +// if (log.isDebugEnabled()) { +// log.debug("no composite application configured"); +// } +// return; +// } +// if (log.isDebugEnabled()) { +// log.debug("retrieved persisted composite application " + apps.size()); +// for (ConfigCompositeApplication app : apps) { +// log.debug("retrieved persisted composite application " + app.getAlias()); +// } +// } +// // sending application created event to restore in Toplogy +// for (ConfigCompositeApplication app : apps) { +// log.debug("restoring composite application " + app.getAlias()); +// ApplicationUtils.publishApplicationCreatedEvent(app); +// } +// +// } catch (PersistenceManagerException e) { +// String errorMsg = "Error restoring composite application "; +// log.error(errorMsg); +// throw new ADCException(errorMsg, e); +// } +// } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java new file mode 100644 index 0000000000..710c5f5d11 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class CompositeAppSubscriptionException extends Exception { + + private String message; + + public CompositeAppSubscriptionException() { + super(); + } + + public CompositeAppSubscriptionException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public CompositeAppSubscriptionException(String message) { + super(message); + this.message = message; + } + + public CompositeAppSubscriptionException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/GroupSubscriptionException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/GroupSubscriptionException.java new file mode 100644 index 0000000000..de24a455c3 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/GroupSubscriptionException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.manager.exception; + +public class GroupSubscriptionException extends Exception { + + private String message; + + public GroupSubscriptionException () { + super(); + } + + public GroupSubscriptionException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public GroupSubscriptionException (String message) { + super(message); + this.message = message; + } + + public GroupSubscriptionException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} 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 index f778760a0e..a86c379706 100644 --- 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 @@ -31,9 +31,7 @@ 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.CartridgeSubscription; -import org.apache.stratos.manager.subscription.PersistenceContext; -import org.apache.stratos.manager.subscription.SubscriptionData; +import org.apache.stratos.manager.subscription.*; import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory; import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour; import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour; @@ -60,6 +58,54 @@ public class CartridgeSubscriptionManager { private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class); //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); + public GroupSubscription createGroupSubscription (String groupName, String groupAlias, String tenantAdminUsername, + String tenantDomain, 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 + " ]"); + } + + groupSubscription = new GroupSubscription(groupName, groupAlias); + Subscriber subscriber = new Subscriber(tenantAdminUsername, tenantId, tenantDomain); + groupSubscription.setSubscriber(subscriber); + return groupSubscription; + } + + public CompositeAppSubscription createCompositeAppSubscription (String appId, String tenantAdminUsername, + String tenantDomain, int tenantId) throws CompositeAppSubscriptionException { + + DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); + CompositeAppSubscription compositeAppSubscription; + + try { + compositeAppSubscription = dataInsertionAndRetrievalMgr.getCompositeAppSubscription(tenantId, appId); + + } catch (PersistenceManagerException e) { + throw new CompositeAppSubscriptionException(e); + } + + if (compositeAppSubscription != null) { + // Composite App Subscription already exists with same app id + throw new CompositeAppSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); + } + + compositeAppSubscription = new CompositeAppSubscription(appId); + Subscriber subscriber = new Subscriber(tenantAdminUsername, tenantId, tenantDomain); + compositeAppSubscription.setSubscriber(subscriber); + return compositeAppSubscription; + } + public CartridgeSubscription createCartridgeSubscription (SubscriptionData subscriptionData) throws ADCException, InvalidCartridgeAliasException, DuplicateCartridgeAliasException, PolicyException, UnregisteredCartridgeException, RepositoryRequiredException, RepositoryCredentialsRequiredException, RepositoryTransportException, 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 index c0203eba6c..9fba1a0b68 100644 --- 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 @@ -19,12 +19,12 @@ package org.apache.stratos.manager.persistence; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; 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.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.manager.subscription.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.GroupSubscription; import java.util.Collection; @@ -33,6 +33,15 @@ 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; @@ -42,6 +51,15 @@ public abstract Collection getCartridgeSubscriptions() public abstract Collection getCartridgeSubscriptions(int tenantId) throws PersistenceManagerException; + public abstract void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) + throws PersistenceManagerException; + + public abstract CompositeAppSubscription 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 getServices () throws PersistenceManagerException; @@ -55,14 +73,4 @@ public abstract Collection getCartridgeSubscriptions(int public abstract ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException; public abstract void removeServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException; - - //Grouping - public abstract void persistDeployedCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException; - public abstract void persistCompositeApplication(CompositeAppDefinition compositeApplication) throws PersistenceManagerException; - - //Grouping - public abstract void removeDeployedCompositeApplication(String configCompositeApplicationAlias) throws PersistenceManagerException; - - public abstract Collection getDeployedCompositeApplications () throws PersistenceManagerException; - } 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 index 2ef26802fc..239f8156eb 100644 --- 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 @@ -27,6 +27,8 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.manager.utils.Deserializer; import org.apache.stratos.manager.utils.Serializer; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; @@ -136,6 +138,22 @@ private void removeSubscription (int tenantId, String type, String alias) throws } } + + @Override + public void persistGroupSubscription(GroupSubscription groupSubscription) throws PersistenceManagerException { + //TODO + } + + public GroupSubscription getGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException { + //TODO + return null; + } + + @Override + public void removeGroupSubscription(int tenantId, String groupName, String groupAlias) throws PersistenceManagerException { + //TODO + } + @Override public Collection getCartridgeSubscriptions () throws PersistenceManagerException { @@ -222,244 +240,23 @@ public Collection getCartridgeSubscriptions (int tenantId return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + "/" + Integer.toString(tenantId)); } - - - //Grouping - public void persistDeployedCompositeApplication (ConfigCompositeApplication configCompositeAapplication) - throws PersistenceManagerException { - - if (log.isDebugEnabled()) { - log.debug(String.format("trying to persist ConfigCompositeApplication [ %s ]", configCompositeAapplication.getAlias())); - } - 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); - - persistCompApplication(configCompositeAapplication); - - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - - } else { - persistCompApplication(configCompositeAapplication); - } - } - - public void persistCompositeApplication (CompositeAppDefinition configCompositeApplication) - throws PersistenceManagerException { - - if (log.isDebugEnabled()) { - log.debug(String.format("trying to persist ConfigCompositeApplication [ %s ]", configCompositeApplication.getAlias())); - } - 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); - - persistCompApplication(configCompositeApplication); - - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - - } else { - persistCompApplication(configCompositeApplication); - } - } - - // Grouping - private void persistCompApplication (ConfigCompositeApplication configCompositeAapplication) throws PersistenceManagerException { - - // persist Service - try { - //RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + configCompositeAapplication.getAlias(), - RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + "compositeApplicationAlias", - Serializer.serializeServiceToByteArray(configCompositeAapplication), null); - - if (log.isDebugEnabled()) { - log.debug("Persisted ConfigCompositeApplication successfully: hardcoded [ " + configCompositeAapplication.getAlias() + " ]"); - } - - } catch (RegistryException e) { - throw new PersistenceManagerException(e); - - } catch (IOException e) { - throw new PersistenceManagerException(e); - } - } - - // Grouping - private void persistCompApplication (CompositeAppDefinition configCompositeAapplication) throws PersistenceManagerException { - - // persist Service - try { - //RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + configCompositeAapplication.getAlias(), - RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION + "/" + "compositeApplicationAlias", - Serializer.serializeServiceToByteArray(configCompositeAapplication), null); - if (log.isDebugEnabled()) { - log.debug("Persisted ConfigCompositeApplication successfully: hardcoded [ " + configCompositeAapplication.getAlias() + " ]"); - } - - } catch (RegistryException e) { - throw new PersistenceManagerException(e); - - } catch (IOException e) { - throw new PersistenceManagerException(e); - } - } - - public void removeDeployedCompositeApplication(String configCompositeApplicationAlias) 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); - - if (log.isDebugEnabled()) { - log.debug("removing persisted ConfigCompositeApplication : [ " + configCompositeApplicationAlias + " ]"); - } - removeCompApplication(configCompositeApplicationAlias); - - if (log.isDebugEnabled()) { - log.debug("successfully removed persisted ConfigCompositeApplication : [ " + configCompositeApplicationAlias + " ]"); - } - - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - - } else { - if (log.isDebugEnabled()) { - log.debug("removing persisted ConfigCompositeApplication 1 : [ " + configCompositeApplicationAlias + " ]"); - } - removeCompApplication(configCompositeApplicationAlias); - - if (log.isDebugEnabled()) { - log.debug("successfully removed persisted ConfigCompositeApplication 1 : [ " + configCompositeApplicationAlias + " ]"); - } - } + @Override + public void persistCompositeAppSubscription(CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { + //TODO } - - public Collection getDeployedCompositeApplications () throws PersistenceManagerException {; - if (log.isDebugEnabled()) { - log.debug("retrieving persisted ConfigCompositeApplication "); - } - - 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); - if (log.isDebugEnabled()) { - log.debug("traversing ConfigCompositeApplications "); - } - return traverseAndGetDeloyedCompositeApplication(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION); - - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - - } else { - return traverseAndGetDeloyedCompositeApplication(STRATOS_MANAGER_REOSURCE + COMPOSITE_APPLICATION); - } - + @Override + public CompositeAppSubscription getCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException { + //TODO + return null; } - - public Collection traverseAndGetDeloyedCompositeApplication (String resourcePath) throws PersistenceManagerException { - - if (log.isDebugEnabled()) { - log.debug("traverseAndGetDeloyedCompositeApplication: Root resource path: " + resourcePath); - } - - Object resourceObj; - - try { - resourceObj = RegistryManager.getInstance().retrieve(resourcePath); - if (log.isDebugEnabled()) { - log.debug("traversing com apps , retrieving resource: " + resourceObj); - } - - } catch (RegistryException e) { - throw new PersistenceManagerException(e); - } - - Collection comApps = new ArrayList(); - - 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[] compAppResourcePaths = (String[]) resourceObj; - if (log.isDebugEnabled()) { - for (String retrievedResourcePath : compAppResourcePaths) { - log.debug("Retrieved resource sub-path " + retrievedResourcePath); - } - } - - // traverse the paths recursively - for (String compAppResourcePath : compAppResourcePaths) { - - if (log.isDebugEnabled()) { - log.debug("Traversing resource path " + compAppResourcePath); - } - - comApps.addAll(traverseAndGetDeloyedCompositeApplication(compAppResourcePath)); - } - - } else { - // De-serialize - Object compAppObj; - - try { - compAppObj = 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 (compAppObj != null && compAppObj instanceof ConfigCompositeApplication) { - - ConfigCompositeApplication deserilizedCompApp = (ConfigCompositeApplication) compAppObj; - if (log.isDebugEnabled()) { - log.debug("Successfully de-serialized ConfigCompositeApplication: " + deserilizedCompApp.toString()); - } - - comApps.add(deserilizedCompApp); - - } - } - - // remove any nulls - comApps.removeAll(Collections.singleton(null)); - return comApps; + @Override + public void removeCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException { + //TODO } - @Override public void persistService(Service service) throws PersistenceManagerException { 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 index 4f88f2c9b9..c9b92aa80a 100644 --- 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 @@ -29,6 +29,8 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import java.util.Collection; @@ -337,114 +339,49 @@ public CartridgeSubscription getCartridgeSubscriptionForAlias (String subscripti LookupDataHolder.getInstance().releaseReadLock(); } } - - // Grouping - public void persistCompositeApplication (ConfigCompositeApplication configCompositeApplication) throws PersistenceManagerException { - // get the write lock - //LookupDataHolder.getInstance().acquireWriteLock(); - - try { - // store in LookupDataHolder - //ToDo ... add to data holder - // LookupDataHolder.getInstance().putSubscription(cartridgeSubscription); - - try { - // store in Persistence Manager - persistenceManager.persistDeployedCompositeApplication(configCompositeApplication); - - } 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 - /* TODO - LookupDataHolder.getInstance().removeSubscription(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getType(), - cartridgeSubscription.getAlias(), cartridgeSubscription.getClusterDomain(), - cartridgeSubscription.getRepository() != null ? cartridgeSubscription.getRepository().getUrl() : null); - */ - throw e; - } + public void peristServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException { - } finally { - // release the write lock - //LookupDataHolder.getInstance().releaseWriteLock(); - } + persistenceManager.persistServiceGroupDefinition(serviceGroupDefinition); } - public void persistCompositeApplication (CompositeAppDefinition compositeApplication) throws PersistenceManagerException { - - // get the write lock - //LookupDataHolder.getInstance().acquireWriteLock(); - - try { - // store in LookupDataHolder - //ToDo ... add to data holder - // LookupDataHolder.getInstance().putSubscription(cartridgeSubscription); + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException { - try { - // store in Persistence Manager - persistenceManager.persistCompositeApplication(compositeApplication); + return persistenceManager.getServiceGroupDefinition(serviceGroupDefinitionName); + } - } 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 - /* TODO - LookupDataHolder.getInstance().removeSubscription(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getType(), - cartridgeSubscription.getAlias(), cartridgeSubscription.getClusterDomain(), - cartridgeSubscription.getRepository() != null ? cartridgeSubscription.getRepository().getUrl() : null); - */ - throw e; - } + public void removeServiceGroupDefinition (String serviceGroupName) throws PersistenceManagerException { - } finally { - // release the write lock - //LookupDataHolder.getInstance().releaseWriteLock(); - } + persistenceManager.removeServiceGroupDefinition(serviceGroupName); } - // Grouping - - public void removeCompositeApplication (String configCompositeApplicationAlias) throws PersistenceManagerException { - LookupDataHolder.getInstance().acquireWriteLock(); + public void persistGroupSubscription (GroupSubscription groupSubscription) throws PersistenceManagerException { - try { - // remove from persistence manager - try { - persistenceManager.removeDeployedCompositeApplication(configCompositeApplicationAlias); + persistenceManager.persistGroupSubscription(groupSubscription); + } - } catch (PersistenceManagerException e) { - String errorMsg = "Error in removing Composite application from Persistence Manager"; - log.error(errorMsg, e); - throw e; - } + public GroupSubscription getGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException { - } finally { - LookupDataHolder.getInstance().releaseWriteLock(); - } + return persistenceManager.getGroupSubscription(tenantId, groupName, groupAlias); } - - // Grouping - - - public Collection getCompositeApplications() throws PersistenceManagerException { + public void removeGroupSubscription (int tenantId, String groupName, String groupAlias) throws PersistenceManagerException { - return persistenceManager.getDeployedCompositeApplications(); + persistenceManager.removeGroupSubscription(tenantId, groupName, groupAlias); } - public void peristServiceGroupDefinition (ServiceGroupDefinition serviceGroupDefinition) throws PersistenceManagerException { + public void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { - persistenceManager.persistServiceGroupDefinition(serviceGroupDefinition); + persistenceManager.persistCompositeAppSubscription(compositeAppSubscription); } - public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws PersistenceManagerException { + public CompositeAppSubscription getCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { - return persistenceManager.getServiceGroupDefinition(serviceGroupDefinitionName); + return persistenceManager.getCompositeAppSubscription(tenantId, appId); } - public void removeServiceGroupDefinition (String serviceGroupName) throws PersistenceManagerException { + public void removeCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { - persistenceManager.removeServiceGroupDefinition(serviceGroupName); + persistenceManager.removeCompositeAppSubscription(tenantId, appId); } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java index 86fb0cd2df..018d1c4ed0 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -21,6 +21,7 @@ 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; @@ -39,6 +40,8 @@ public class CompositeAppSubscription implements Serializable { private Set groupSubscriptionAliases; + private Subscriber subscriber; + public CompositeAppSubscription (String appId) { this.appId = appId; @@ -65,4 +68,16 @@ public void addGroupSubscriptionAlias (String groupSubscriptionAlias) { public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { cartridgeSubscriptionAliases.addAll(groupSubscriptionAliases); } + + public String getAppId() { + return appId; + } + + public Subscriber getSubscriber() { + return subscriber; + } + + public void setSubscriber(Subscriber subscriber) { + this.subscriber = subscriber; + } } 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 index 31fcb731b4..ef327f5653 100644 --- 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 @@ -19,20 +19,27 @@ 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 cartridgeSubscriptionAliases; private Set groupSubscriptionAliases; - public GroupSubscription (String groupAlias) { + private Subscriber subscriber; + + public GroupSubscription (String name, String groupAlias) { + this.name = name; this.groupAlias = groupAlias; cartridgeSubscriptionAliases = new HashSet(); groupSubscriptionAliases = new HashSet(); @@ -61,4 +68,16 @@ public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { public String getGroupAlias() { return groupAlias; } + + public String getName() { + return name; + } + + public Subscriber getSubscriber() { + return subscriber; + } + + public void setSubscriber(Subscriber subscriber) { + this.subscriber = subscriber; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 8e10fda356..e02ea113d1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -321,29 +321,29 @@ static StratosAdminResponse unDeployApplication(String configCompositeApplicatio } - static StratosAdminResponse unDeployApplicationOld(String configCompositeApplicationAlias, ConfigurationContext ctxt, - String userName, String tenantDomain) throws RestAPIException { - - log.info("Starting to undeploy a composite application " + configCompositeApplicationAlias); - - CompositeApplicationManager manager = new CompositeApplicationManager(); - - try { - manager.unDeployCompositeApplication(configCompositeApplicationAlias); - } catch (ADCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = e.getMessage(); - log.error(message, e); - throw new RestAPIException(message, e); - } - - log.info("l [type] " + configCompositeApplicationAlias); - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); - return stratosAdminResponse; - } +// static StratosAdminResponse unDeployApplicationOld(String configCompositeApplicationAlias, ConfigurationContext ctxt, +// String userName, String tenantDomain) throws RestAPIException { +// +// log.info("Starting to undeploy a composite application " + configCompositeApplicationAlias); +// +// CompositeApplicationManager manager = new CompositeApplicationManager(); +// +// try { +// manager.unDeployCompositeApplication(configCompositeApplicationAlias); +// } catch (ADCException e) { +// // TODO Auto-generated catch block +// e.printStackTrace(); +// String message = e.getMessage(); +// log.error(message, e); +// throw new RestAPIException(message, e); +// } +// +// log.info("l [type] " + configCompositeApplicationAlias); +// +// StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); +// stratosAdminResponse.setMessage("Successfully un-deployed application with alias " + configCompositeApplicationAlias); +// return stratosAdminResponse; +// } @SuppressWarnings("unused") private static DeploymentPolicy[] intersection( From 51ec31c50a0cd559345ca00371adb7491b2785cc Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 17 Jul 2014 15:18:11 +0530 Subject: [PATCH 016/436] alias validation and a minor bug --- .../parser/DefaultCompositeApplicationParser.java | 12 +++++++----- .../application/utils/ApplicationUtils.java | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 9bfc864239..fdd0138d69 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -29,6 +29,7 @@ import org.apache.stratos.manager.composite.application.structure.GroupContext; import org.apache.stratos.manager.composite.application.structure.StartupOrder; import org.apache.stratos.manager.composite.application.structure.SubscribableContext; +import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -111,13 +112,13 @@ private Map getDefinedGroups (CompositeAppDefinition co } // check if group is deployed - if(isGroupDeployed(group.getName())) { + if(!isGroupDeployed(group.getName())) { throw new CompositeApplicationDefinitionException("Group with name " + group.getName() + " not deployed"); } // check validity of group alias - if (group.getAlias() == null || group.getAlias().isEmpty()) { - throw new CompositeApplicationDefinitionException("Invalid Group alias specified"); + if (group.getAlias() == null || group.getAlias().isEmpty() || ApplicationUtils.isAliasValid(group.getAlias())) { + throw new CompositeApplicationDefinitionException("Invalid Group alias specified: [ " + group.getAlias() + " ]"); } // check if a group is already defined under the same alias @@ -148,8 +149,9 @@ private Map getSubscribableInformation (CompositeAppDe for (SubscribableInfo subscribableInfo : compositeAppDefinition.getSubscribableInfo()) { - if (subscribableInfo.getAlias() == null || subscribableInfo.getAlias().isEmpty()) { - throw new CompositeApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj"); + if (subscribableInfo.getAlias() == null || subscribableInfo.getAlias().isEmpty() || + ApplicationUtils.isAliasValid(subscribableInfo.getAlias())) { + throw new CompositeApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfo.getAlias() + " ]"); } // check if a group is already defined under the same alias diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java index 8b7cdbbd46..7dde85c9d2 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java @@ -1,9 +1,11 @@ package org.apache.stratos.manager.composite.application.utils; import java.util.concurrent.Executor; +import java.util.regex.Pattern; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.exception.InvalidCartridgeAliasException; import org.apache.stratos.messaging.broker.publish.EventPublisher; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; @@ -98,5 +100,17 @@ public void execute(Runnable command) { exec.execute(new ApplicationRemovedEventPublisher(configApplicationAlias)); } + public static boolean isAliasValid (String alias) { + + String patternString = "([a-z0-9]+([-][a-z0-9])*)+"; + Pattern pattern = Pattern.compile(patternString); + + if (!pattern.matcher(alias).matches()) { + return false; + } + + return true; + } + } From 3d5e9a105c218753958be348ce0c980f86e394b9 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 17 Jul 2014 17:19:45 +0530 Subject: [PATCH 017/436] remove duplicate alias validations --- .../composite/application/utils/ApplicationUtils.java | 8 ++------ .../subscription/utils/CartridgeSubscriptionUtils.java | 7 +++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java index 7dde85c9d2..e208562316 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java @@ -104,12 +104,8 @@ public static boolean isAliasValid (String alias) { String patternString = "([a-z0-9]+([-][a-z0-9])*)+"; Pattern pattern = Pattern.compile(patternString); - - if (!pattern.matcher(alias).matches()) { - return false; - } - - return true; + + return pattern.matcher(alias).matches(); } 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 index a5c55178b1..deb9475701 100644 --- 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 @@ -27,6 +27,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; +import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; @@ -208,10 +209,8 @@ public static void publishTenantUnSubscribedEvent(int tenantId, String serviceNa 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()) { + boolean validAlias = ApplicationUtils.isAliasValid(alias); + if (!validAlias) { 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); From 4b30f2385d28fbfca8ff6a83709956455dffe052 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 17 Jul 2014 18:29:03 +0530 Subject: [PATCH 018/436] removing Subscriber from App Subscriptions and Group Subscriptions --- .../CompositeApplicationManager.java | 14 +++++--------- .../manager/CartridgeSubscriptionManager.java | 17 +++++------------ .../RegistryBasedPersistenceManager.java | 2 +- .../subscription/CompositeAppSubscription.java | 10 ---------- .../manager/subscription/GroupSubscription.java | 10 ---------- 5 files changed, 11 insertions(+), 42 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index fafcdcfe19..9448438a09 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -41,8 +41,7 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin // create the CompositeAppSubscription CompositeAppSubscription compositeAppSubscription; try { - compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(compositeAppContext.getAppId(), - tenantAdminUsername, tenantDomain, tenantId); + compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(compositeAppContext.getAppId(), tenantId); } catch (CompositeAppSubscriptionException e) { throw new CompositeApplicationDefinitionException(e); @@ -89,8 +88,7 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin } // create Group Subscriptions and collect them - for (GroupSubscription groupSubscription : getGroupSubscriptions(compositeAppContext.getGroupContexts(), - tenantAdminUsername, tenantDomain, tenantId)) { + for (GroupSubscription groupSubscription : getGroupSubscriptions(compositeAppContext.getGroupContexts(), tenantId)) { // check if a Group Subscription already exists with this alias for this Composite App if (groupSubscriptionExistsForAlias(groupAliasToGroupSubscription, groupSubscription.getGroupAlias())) { @@ -116,16 +114,14 @@ private Set getCartrigdeSubscriptionAliases (Set su return cartridgeSubscriptionAliases; } - private Set getGroupSubscriptions (Set groupContexts, String tenantAdminUsername, - String tenantDomain, int tenantID) throws CompositeApplicationException { + private Set getGroupSubscriptions (Set groupContexts, int tenantID) throws CompositeApplicationException { Set groupSubscriptions = new HashSet(); for (GroupContext groupContext : groupContexts) { // create Group Subscriptions for this Group GroupSubscription groupSubscription; try { - groupSubscription = cartridgeSubscriptionManager.createGroupSubscription(groupContext.getName(), - groupContext.getAlias(), tenantAdminUsername, tenantDomain, tenantID); + groupSubscription = cartridgeSubscriptionManager.createGroupSubscription(groupContext.getName(), groupContext.getAlias(), tenantID); } catch (GroupSubscriptionException e) { throw new CompositeApplicationException(e); @@ -138,7 +134,7 @@ private Set getGroupSubscriptions (Set groupCon if (groupContext.getGroupContexts() != null) { groupSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(groupContext.getGroupContexts())); // need to recurse to get other nested groups, if any - getGroupSubscriptions(groupContext.getGroupContexts(),tenantAdminUsername, tenantDomain, tenantID); + getGroupSubscriptions(groupContext.getGroupContexts(), tenantID); } groupSubscriptions.add(groupSubscription); 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 index a86c379706..cbf0b01374 100644 --- 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 @@ -58,8 +58,8 @@ public class CartridgeSubscriptionManager { private static Log log = LogFactory.getLog(CartridgeSubscriptionManager.class); //private static DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); - public GroupSubscription createGroupSubscription (String groupName, String groupAlias, String tenantAdminUsername, - String tenantDomain, int tenantId) throws GroupSubscriptionException { + public GroupSubscription createGroupSubscription (String groupName, String groupAlias, int tenantId) + throws GroupSubscriptionException { DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); GroupSubscription groupSubscription; @@ -76,14 +76,10 @@ public GroupSubscription createGroupSubscription (String groupName, String group throw new GroupSubscriptionException("Group Subscription already exists with name [ " + groupName + " ], alias [ " + groupAlias + " ]"); } - groupSubscription = new GroupSubscription(groupName, groupAlias); - Subscriber subscriber = new Subscriber(tenantAdminUsername, tenantId, tenantDomain); - groupSubscription.setSubscriber(subscriber); - return groupSubscription; + return new GroupSubscription(groupName, groupAlias); } - public CompositeAppSubscription createCompositeAppSubscription (String appId, String tenantAdminUsername, - String tenantDomain, int tenantId) throws CompositeAppSubscriptionException { + public CompositeAppSubscription createCompositeAppSubscription (String appId, int tenantId) throws CompositeAppSubscriptionException { DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); CompositeAppSubscription compositeAppSubscription; @@ -100,10 +96,7 @@ public CompositeAppSubscription createCompositeAppSubscription (String appId, St throw new CompositeAppSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); } - compositeAppSubscription = new CompositeAppSubscription(appId); - Subscriber subscriber = new Subscriber(tenantAdminUsername, tenantId, tenantDomain); - compositeAppSubscription.setSubscriber(subscriber); - return compositeAppSubscription; + return new CompositeAppSubscription(appId); } public CartridgeSubscription createCartridgeSubscription (SubscriptionData subscriptionData) throws ADCException, 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 index 239f8156eb..390c7c6e3d 100644 --- 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 @@ -501,7 +501,7 @@ private void removeCompApplication(String alias) throws PersistenceManagerExcept if (log.isDebugEnabled()) { log.debug("Deleted composite application on path " + resourcePath + " successfully"); } - + if (log.isDebugEnabled()) { obj = RegistryManager.getInstance().retrieve(resourcePath); if (obj == null) { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java index 018d1c4ed0..074dc38f07 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -40,8 +40,6 @@ public class CompositeAppSubscription implements Serializable { private Set groupSubscriptionAliases; - private Subscriber subscriber; - public CompositeAppSubscription (String appId) { this.appId = appId; @@ -72,12 +70,4 @@ public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { public String getAppId() { return appId; } - - public Subscriber getSubscriber() { - return subscriber; - } - - public void setSubscriber(Subscriber subscriber) { - this.subscriber = subscriber; - } } 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 index ef327f5653..7b0f382e3e 100644 --- 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 @@ -35,8 +35,6 @@ public class GroupSubscription implements Serializable { private Set groupSubscriptionAliases; - private Subscriber subscriber; - public GroupSubscription (String name, String groupAlias) { this.name = name; @@ -72,12 +70,4 @@ public String getGroupAlias() { public String getName() { return name; } - - public Subscriber getSubscriber() { - return subscriber; - } - - public void setSubscriber(Subscriber subscriber) { - this.subscriber = subscriber; - } } From e997fc5db71a25012496253254e70ea9e7e20a3b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 17 Jul 2014 19:48:09 +0530 Subject: [PATCH 019/436] persisting Group Subscriptions and Composite App Subscriptions --- .../CompositeApplicationManager.java | 149 +++----- .../manager/CartridgeSubscriptionManager.java | 39 ++ .../RegistryBasedPersistenceManager.java | 334 +++++++++++++++--- .../stratos/manager/utils/Serializer.java | 42 +-- 4 files changed, 387 insertions(+), 177 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 9448438a09..b4db5dec56 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -102,6 +102,12 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin // set top level group aliases to Composite App Subscription compositeAppSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(compositeAppContext.getGroupContexts())); } + + // TODO: send the Composite App structure to CC + + persistCartridgeSubscriptions(aliasToCartridgeSubscription.values()); + persistGroupSubscriptions(groupAliasToGroupSubscription.values()); + persistCompositeAppSubscription(compositeAppSubscription); } private Set getCartrigdeSubscriptionAliases (Set subscribableContexts) throws CompositeApplicationException { @@ -250,104 +256,49 @@ private boolean groupSubscriptionExistsForAlias (Map return groupAliasToGroupSubscription.get(newGroupSubscriptionAlias) != null; } - -// public void unDeployCompositeApplication(String configApplicationAlias) throws ADCException { -// if (log.isDebugEnabled()) { -// log.debug("undeploying composite application " + configApplicationAlias); -// } -// // unregister application -// unRegisterCompositeApplication(configApplicationAlias); -// if (log.isDebugEnabled()) { -// log.debug("publishing composite application removed event" + configApplicationAlias); -// } -// ApplicationUtils.publishApplicationUnDeployEvent(configApplicationAlias); -// if (log.isDebugEnabled()) { -// log.debug("composite application successfully removed " + configApplicationAlias); -// } -// } - -// private void registerCompositeApplication(ConfigCompositeApplication configCompositeApplication) throws ADCException { -// -// try { -// if (log.isDebugEnabled()) { -// log.debug("registering composite application " + configCompositeApplication.getAlias()); -// } -// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); -// mgr.persistCompositeApplication ( configCompositeApplication); -// -// if (log.isDebugEnabled()) { -// log.debug("testing to retrieve persisted composite application "); -// Collection apps = mgr.getCompositeApplications(); -// log.debug("retrieved persisted composite application " + apps.size()); -// for (ConfigCompositeApplication app : apps) { -// log.debug("retrieved persisted composite application " + app.getAlias()); -// } -// } -// -// } catch (PersistenceManagerException e) { -// String errorMsg = "Error saving composite application " + configCompositeApplication.getAlias(); -// log.error(errorMsg); -// throw new ADCException(errorMsg, e); -// } -// -// log.info("Successfully registered composite application " + configCompositeApplication.getAlias()); -// -// } - -// private void unRegisterCompositeApplication(String configApplicationAlias) throws ADCException { -// -// try { -// if (log.isDebugEnabled()) { -// log.debug("unregistering composite application " + configApplicationAlias); -// } -// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); -// mgr.removeCompositeApplication(configApplicationAlias); -// -// if (log.isDebugEnabled()) { -// log.debug("removed persisted composite application successfully"); -// } -// -// } catch (PersistenceManagerException e) { -// String errorMsg = "Error undeploying composite application " + configApplicationAlias; -// log.error(errorMsg); -// throw new ADCException(errorMsg, e); -// } -// -// log.info("Successfully undeployed composite application " + configApplicationAlias); -// -// } - -// public void restoreCompositeApplications () throws ADCException { -// try { -// if (log.isDebugEnabled()) { -// log.debug("restoring composite applications " ); -// } -// DataInsertionAndRetrievalManager mgr = new DataInsertionAndRetrievalManager(); -// Collection apps = mgr.getCompositeApplications(); -// -// if (apps == null) { -// if (log.isDebugEnabled()) { -// log.debug("no composite application configured"); -// } -// return; -// } -// if (log.isDebugEnabled()) { -// log.debug("retrieved persisted composite application " + apps.size()); -// for (ConfigCompositeApplication app : apps) { -// log.debug("retrieved persisted composite application " + app.getAlias()); -// } -// } -// // sending application created event to restore in Toplogy -// for (ConfigCompositeApplication app : apps) { -// log.debug("restoring composite application " + app.getAlias()); -// ApplicationUtils.publishApplicationCreatedEvent(app); -// } -// -// } catch (PersistenceManagerException e) { -// String errorMsg = "Error restoring composite application "; -// log.error(errorMsg); -// throw new ADCException(errorMsg, e); -// } -// } + + private void persistCartridgeSubscriptions (Collection cartridgeSubscriptions) throws CompositeApplicationException { + + if (cartridgeSubscriptions == null) { + return; + } + + for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) { + try { + cartridgeSubscriptionManager.persistCartridgeSubscription(cartridgeSubscription); + + } catch (ADCException e) { + throw new CompositeApplicationException(e); + } + } + } + + private void persistGroupSubscriptions (Collection groupSubscriptions) throws CompositeApplicationException { + + if (groupSubscriptions == null) { + return; + } + + for (GroupSubscription groupSubscription : groupSubscriptions) { + try { + cartridgeSubscriptionManager.persistGroupSubscription(groupSubscription); + + } catch (ADCException e) { + throw new CompositeApplicationException(e); + } + } + } + + private void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws CompositeApplicationException { + + if (compositeAppSubscription != null) { + try { + cartridgeSubscriptionManager.persistCompositeAppSubscription(compositeAppSubscription); + + } catch (ADCException e) { + throw new CompositeApplicationException(e); + } + } + } } 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 index cbf0b01374..7d6be7cf7f 100644 --- 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 @@ -127,6 +127,45 @@ public CartridgeSubscription createCartridgeSubscription (SubscriptionData subsc 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 + CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), + cartridgeSubscription.getCartridgeInfo().getType()); + } + + public void persistGroupSubscription (GroupSubscription groupSubscription) throws ADCException { + + try { + new DataInsertionAndRetrievalManager().persistGroupSubscription(groupSubscription); + + } catch (PersistenceManagerException e) { + throw new ADCException(e); + } + } + + public void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws ADCException { + + try { + new DataInsertionAndRetrievalManager().persistCompositeAppSubscription(compositeAppSubscription); + + } catch (PersistenceManagerException e) { + throw new ADCException(e); + } + } public SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws ADCException, InvalidCartridgeAliasException, 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 index 390c7c6e3d..6a829bb911 100644 --- 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 @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; @@ -31,7 +30,6 @@ import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.manager.utils.Deserializer; import org.apache.stratos.manager.utils.Serializer; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.exceptions.RegistryException; @@ -50,7 +48,9 @@ public class RegistryBasedPersistenceManager extends PersistenceManager { 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 COMPOSITE_APPLICATION = "/composite_applications"; + private static final String CARTRIDGES = "/cartridges"; + private static final String GROUPS = "/groups"; + private static final String COMPOSITE_APPLICATIONS = "/composite_applications"; private static final String SERVICE_GROUPING = "/service.grouping"; private static final String SERVICE_GROUPING_DEFINITIONS = SERVICE_GROUPING + "/definitions"; @@ -81,7 +81,7 @@ private void persistSubscription (CartridgeSubscription cartridgeSubscription) t // persist try { - RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + "/" + + RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + CARTRIDGES + ACTIVE_SUBSCRIPTIONS + "/" + Integer.toString(cartridgeSubscription.getSubscriber().getTenantId()) + "/" + cartridgeSubscription.getType() + "/" + cartridgeSubscription.getAlias(), Serializer.serializeSubscriptionSontextToByteArray(cartridgeSubscription), cartridgeSubscription.getClusterDomain()); @@ -124,8 +124,8 @@ public void removeCartridgeSubscription (int tenantId, String type, String 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 + "/" + Integer.toString(tenantId) + "/" + type + "/" + alias; - String targetPath = STRATOS_MANAGER_REOSURCE + INACTIVE_SUBSCRIPTIONS + "/" + Integer.toString(tenantId) + "/" + type + "/" + alias; + 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); @@ -138,26 +138,149 @@ private void removeSubscription (int tenantId, String type, String alias) throws } } - @Override public void persistGroupSubscription(GroupSubscription groupSubscription) throws PersistenceManagerException { - //TODO + + 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 { - //TODO + + 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 { - //TODO + + 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 getCartridgeSubscriptions () throws PersistenceManagerException { - return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS); + return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES); } private Collection traverseAndGetCartridgeSubscriptions (String resourcePath) throws PersistenceManagerException { @@ -238,23 +361,146 @@ private Collection traverseAndGetCartridgeSubscriptions ( @Override public Collection getCartridgeSubscriptions (int tenantId) throws PersistenceManagerException { - return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + "/" + Integer.toString(tenantId)); + return traverseAndGetCartridgeSubscriptions(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" + Integer.toString(tenantId)); } @Override public void persistCompositeAppSubscription(CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { - //TODO + + 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, CompositeAppSubscription 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 CompositeAppSubscription getCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException { - //TODO + + 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 CompositeAppSubscription 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 CompositeAppSubscription) { + return (CompositeAppSubscription) compositeAppSubscriptionObj; + } + return null; } @Override public void removeCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException { - //TODO + + 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 @@ -485,36 +731,36 @@ private void removeDeployedService (String cartridgeType) throws PersistenceMana 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); - } - } +// 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 { 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 index 6597499c91..743be4825c 100644 --- 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 @@ -24,6 +24,8 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import java.io.ByteArrayOutputStream; @@ -59,20 +61,14 @@ public static byte[] serializeSubscriptionSontextToByteArray(CartridgeSubscripti } - /** - * Serialize a ClusterIdToSubscription instance to a byte array. - * @param clusterIdToSubscription - * @return byte[] - * @throws java.io.IOException - */ - public static byte[] serializeClusterIdToSubscriptionToByteArray(ClusterIdToSubscription clusterIdToSubscription) + public static byte[] serializeGroupSubscriptionToByteArray (GroupSubscription groupSubscription) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); - out.writeObject(clusterIdToSubscription); + out.writeObject(groupSubscription); return bos.toByteArray(); @@ -85,14 +81,14 @@ public static byte[] serializeClusterIdToSubscriptionToByteArray(ClusterIdToSubs } - public static byte[] serializeServiceToByteArray(Service service) + public static byte[] serializeCompositeAppSubscriptionToByteArray (CompositeAppSubscription compositeAppSubscription) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); - out.writeObject(service); + out.writeObject(compositeAppSubscription); return bos.toByteArray(); @@ -104,37 +100,15 @@ public static byte[] serializeServiceToByteArray(Service service) } } - - // Grouping - public static byte[] serializeServiceToByteArray(ConfigCompositeApplication configCompositeApplication) - throws IOException { - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutput out = null; - try { - out = new ObjectOutputStream(bos); - out.writeObject(configCompositeApplication); - - return bos.toByteArray(); - - } finally { - if (out != null) { - out.close(); - } - bos.close(); - } - - } - - // Grouping - public static byte[] serializeServiceToByteArray(CompositeAppDefinition configCompositeApplication) + public static byte[] serializeServiceToByteArray(Service service) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = null; try { out = new ObjectOutputStream(bos); - out.writeObject(configCompositeApplication); + out.writeObject(service); return bos.toByteArray(); From 744386833c3f30899975ab8d077099a39861e73a Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 18 Jul 2014 19:02:10 +0530 Subject: [PATCH 020/436] filterng out duplicated top level Groups from ApplicationContext --- .../CompositeApplicationManager.java | 2 + .../DefaultCompositeApplicationParser.java | 60 +++++++++++++++++-- 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index b4db5dec56..75434d07b8 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -35,6 +35,8 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); + Set topLevelGroupsContexts = compositeAppContext.getGroupContexts(); + log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ] deployed successfully"); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index a2b36bde37..436e647317 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -224,9 +224,53 @@ private Set getGroupContexts (List groupDefinitio groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); } + //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); + Set nestedGroupContexts = new HashSet(); + getNestedGroupContexts(nestedGroupContexts, groupContexts); + filterDuplicatedGroupContexts(groupContexts, nestedGroupContexts); + return groupContexts; } +// private Set getTopLevelGroupContexts (Set groupContexts) { +// +// Set topLevelGroupContexts = new HashSet(); +// for (GroupContext groupContext : groupContexts) { +// topLevelGroupContexts.add(groupContext); +// } +// +// return topLevelGroupContexts; +// } + + private void getNestedGroupContexts (Set nestedGroupContexts, Set groupContexts) { + + if (groupContexts != null) { + for (GroupContext groupContext : groupContexts) { + if (groupContext.getGroupContexts() != null) { + nestedGroupContexts.addAll(groupContext.getGroupContexts()); + getNestedGroupContexts(nestedGroupContexts, groupContext.getGroupContexts()); + } + } + } + } + + private void filterDuplicatedGroupContexts (Set topLevelGroupContexts, Set nestedGroupContexts) { + + Iterator parentIterator = topLevelGroupContexts.iterator(); + Iterator nestedIterator = nestedGroupContexts.iterator(); + + while (parentIterator.hasNext()) { + GroupContext parentGroupCtxt = parentIterator.next(); + while (nestedIterator.hasNext()) { + GroupContext nestedGroupCtxt = nestedIterator.next(); + if (parentGroupCtxt.getName().equals(nestedGroupCtxt.getName()) && + parentGroupCtxt.getAlias().equals(nestedGroupCtxt.getAlias())) { + parentIterator.remove(); + } + } + } + } + private GroupContext getGroupContext (GroupDefinition group, Map subscribableInformation, Map definedGroups) throws CompositeApplicationDefinitionException { @@ -238,21 +282,25 @@ private GroupContext getGroupContext (GroupDefinition group, Map nestedGroupContexts = new HashSet(); // check sub groups for (GroupDefinition subGroup : group.getSubGroups()) { + // get the complete Group Definition + subGroup = definedGroups.get(subGroup.getAlias()); nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); } From b097cbc48fae7e56d0b2d22d9b0d6c4c69d2699f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 20 Jul 2014 22:17:33 +0530 Subject: [PATCH 021/436] removing duplicated groups from top level --- .../CompositeApplicationManager.java | 2 -- .../DefaultCompositeApplicationParser.java | 4 ++-- .../structure/CompositeAppContext.java | 22 +++++++++++++++++++ .../application/structure/GroupContext.java | 19 +++++++++++++++- .../application/structure/StartupOrder.java | 18 +++++++++++++++ .../structure/SubscribableContext.java | 18 +++++++++++++++ .../deployer/DefaultServiceGroupDeployer.java | 2 +- .../RegistryBasedPersistenceManager.java | 2 +- 8 files changed, 80 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 75434d07b8..b4db5dec56 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -35,8 +35,6 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); - Set topLevelGroupsContexts = compositeAppContext.getGroupContexts(); - log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " + compositeAppDefinition.getAlias() + " ] deployed successfully"); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 436e647317..ef6814baac 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -186,10 +186,10 @@ private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition c Map subscribableInformation) throws CompositeApplicationDefinitionException { - CompositeAppContext compositeAppContext = new CompositeAppContext(); + CompositeAppContext compositeAppContext = new CompositeAppContext(compositeAppDefinition.getApplicationId()); - // get top level Subscribables if (compositeAppDefinition.getComponents() != null) { + // get top level Subscribables if (compositeAppDefinition.getComponents().getSubscribables() != null) { compositeAppContext.setSubscribableContexts(getSubsribableContexts(compositeAppDefinition.getComponents().getSubscribables(), subscribableInformation)); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java index 6a589e7841..4cb7073368 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java @@ -33,6 +33,10 @@ public class CompositeAppContext { private String killBehaviour; + public CompositeAppContext (String appId) { + this.appId = appId; + } + public String getAppId() { return appId; } @@ -72,4 +76,22 @@ public String getKillBehaviour() { public void setKillBehaviour(String killBehaviour) { this.killBehaviour = killBehaviour; } + + public boolean equals(Object other) { + + if(this == other) { + return true; + } + if(!(other instanceof CompositeAppContext)) { + return false; + } + + CompositeAppContext that = (CompositeAppContext)other; + return this.appId.equals(that.appId); + } + + public int hashCode () { + + return appId.hashCode(); + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java index e7736ea6ca..b235c1b859 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java @@ -19,7 +19,6 @@ package org.apache.stratos.manager.composite.application.structure; -import java.util.List; import java.util.Set; public class GroupContext { @@ -104,4 +103,22 @@ public Set getSubscribableContexts() { public void setSubscribableContexts(Set subscribableContexts) { this.subscribableContexts = subscribableContexts; } + + public boolean equals(Object other) { + + if(this == other) { + return true; + } + if(!(other instanceof GroupContext)) { + return false; + } + + GroupContext that = (GroupContext)other; + return this.name.equals(that.name) && this.alias.equals(that.alias); + } + + public int hashCode () { + + return name.hashCode() + alias.hashCode(); + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java index 4553a9f04e..4617090a12 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/StartupOrder.java @@ -45,4 +45,22 @@ public String getAfter() { public void setAfter(String after) { this.after = after; } + + public boolean equals(Object other) { + + if(this == other) { + return true; + } + if(!(other instanceof StartupOrder)) { + return false; + } + + StartupOrder that = (StartupOrder)other; + return this.start.equals(that.start) && this.after.equals(that.after); + } + + public int hashCode () { + + return start.hashCode() + after.hashCode(); + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java index 2e30c1bff9..a336a6233c 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/SubscribableContext.java @@ -105,4 +105,22 @@ public String getPassword() { public void setPassword(String password) { this.password = password; } + + public boolean equals(Object other) { + + if(this == other) { + return true; + } + if(!(other instanceof SubscribableContext)) { + return false; + } + + SubscribableContext that = (SubscribableContext)other; + return this.cartridgeType.equals(that.cartridgeType) && this.alias.equals(that.alias); + } + + public int hashCode () { + + return cartridgeType.hashCode() + alias.hashCode(); + } } 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 index 4744f9fd0f..2fd3eee01c 100644 --- 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 @@ -59,7 +59,7 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro throw new InvalidServiceGroupException("Service Group definition not found"); } - // if any cartridges are specified in the group, they should be already deployed +// if any cartridges are specified in the group, they should be already deployed if (serviceGroupDefinition.getCartridges() != null) { List cartridgeTypes = serviceGroupDefinition.getCartridges(); 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 index 6a829bb911..9bab469d88 100644 --- 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 @@ -81,7 +81,7 @@ private void persistSubscription (CartridgeSubscription cartridgeSubscription) t // persist try { - RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + CARTRIDGES + ACTIVE_SUBSCRIPTIONS + "/" + + RegistryManager.getInstance().persist(STRATOS_MANAGER_REOSURCE + ACTIVE_SUBSCRIPTIONS + CARTRIDGES + "/" + Integer.toString(cartridgeSubscription.getSubscriber().getTenantId()) + "/" + cartridgeSubscription.getType() + "/" + cartridgeSubscription.getAlias(), Serializer.serializeSubscriptionSontextToByteArray(cartridgeSubscription), cartridgeSubscription.getClusterDomain()); From f2e841002bee7ffafe0b1fcc51c9bbbd04a89c12 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 21 Jul 2014 00:09:34 +0530 Subject: [PATCH 022/436] adding a validation in top level Subscribables --- .../DefaultCompositeApplicationParser.java | 49 +++++++++++++++++-- .../application/parser/ParserUtils.java | 4 -- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index ef6814baac..c8b699888a 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -19,8 +19,11 @@ package org.apache.stratos.manager.composite.application.parser; +import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; @@ -36,6 +39,7 @@ import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; +import java.rmi.RemoteException; import java.util.*; public class DefaultCompositeApplicationParser implements CompositeApplicationParser { @@ -58,7 +62,7 @@ public CompositeAppContext parse(Object obj) throws CompositeApplicationDefiniti } if (compositeAppDefinition == null) { - throw new CompositeApplicationDefinitionException("Invlaid Composite Application Defintion"); + throw new CompositeApplicationDefinitionException("Invalid Composite Application Definition"); } if (compositeAppDefinition.getAlias() == null || compositeAppDefinition.getAlias().isEmpty()) { @@ -91,6 +95,10 @@ public CompositeAppContext parse(Object obj) throws CompositeApplicationDefiniti log.debug(" ]"); } + if (subscribablesInfo == null) { + throw new CompositeApplicationDefinitionException("Invalid Composite Application Definition, no Subscribable Information specified"); + } + return buildCompositeAppStructure (compositeAppDefinition, definedGroups, subscribablesInfo); } @@ -263,8 +271,9 @@ private void filterDuplicatedGroupContexts (Set topLevelGroupConte GroupContext parentGroupCtxt = parentIterator.next(); while (nestedIterator.hasNext()) { GroupContext nestedGroupCtxt = nestedIterator.next(); - if (parentGroupCtxt.getName().equals(nestedGroupCtxt.getName()) && - parentGroupCtxt.getAlias().equals(nestedGroupCtxt.getAlias())) { + // if there is an exactly similar nested Group Context and a top level Group Context + // it implies that they are duplicates. Should be removed from top level. + if (parentGroupCtxt.equals(nestedGroupCtxt)) { parentIterator.remove(); } } @@ -387,10 +396,44 @@ private Set getSubsribableContexts (List Date: Mon, 21 Jul 2014 11:47:16 +0530 Subject: [PATCH 023/436] fixing only one group subscription is stored in registry --- .../application/CompositeApplicationManager.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index b4db5dec56..5b0eea8853 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -88,7 +88,9 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin } // create Group Subscriptions and collect them - for (GroupSubscription groupSubscription : getGroupSubscriptions(compositeAppContext.getGroupContexts(), tenantId)) { + List groupSubscriptions = new LinkedList(); + getGroupSubscriptions(compositeAppContext.getGroupContexts(), tenantId, groupSubscriptions); + for (GroupSubscription groupSubscription : groupSubscriptions) { // check if a Group Subscription already exists with this alias for this Composite App if (groupSubscriptionExistsForAlias(groupAliasToGroupSubscription, groupSubscription.getGroupAlias())) { @@ -120,9 +122,8 @@ private Set getCartrigdeSubscriptionAliases (Set su return cartridgeSubscriptionAliases; } - private Set getGroupSubscriptions (Set groupContexts, int tenantID) throws CompositeApplicationException { + private void getGroupSubscriptions(Set groupContexts, int tenantID, List groupSubscriptions) throws CompositeApplicationException { - Set groupSubscriptions = new HashSet(); for (GroupContext groupContext : groupContexts) { // create Group Subscriptions for this Group GroupSubscription groupSubscription; @@ -140,13 +141,11 @@ private Set getGroupSubscriptions (Set groupCon if (groupContext.getGroupContexts() != null) { groupSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(groupContext.getGroupContexts())); // need to recurse to get other nested groups, if any - getGroupSubscriptions(groupContext.getGroupContexts(), tenantID); + getGroupSubscriptions(groupContext.getGroupContexts(), tenantID, groupSubscriptions); } groupSubscriptions.add(groupSubscription); } - - return groupSubscriptions; } private Set getGroupSubscriptionAliases (Set groupContexts) throws CompositeApplicationException { From 4a14d93ed529ad57ad5dbf1530139c8a0679a8cc Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 21 Jul 2014 12:27:20 +0530 Subject: [PATCH 024/436] persisting subscriptions in a synchronized block --- .../application/CompositeApplicationManager.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index b4db5dec56..e764de26a0 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -105,9 +105,8 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin // TODO: send the Composite App structure to CC - persistCartridgeSubscriptions(aliasToCartridgeSubscription.values()); - persistGroupSubscriptions(groupAliasToGroupSubscription.values()); - persistCompositeAppSubscription(compositeAppSubscription); + // persist + persistSubscriptions(aliasToCartridgeSubscription.values(), groupAliasToGroupSubscription.values(), compositeAppSubscription); } private Set getCartrigdeSubscriptionAliases (Set subscribableContexts) throws CompositeApplicationException { @@ -257,6 +256,16 @@ private boolean groupSubscriptionExistsForAlias (Map return groupAliasToGroupSubscription.get(newGroupSubscriptionAlias) != null; } + private synchronized void persistSubscriptions(Collection cartridgeSubscriptions, + Collection groupSubscriptions, + CompositeAppSubscription compositeAppSubscription) + throws CompositeApplicationException { + + persistCartridgeSubscriptions(cartridgeSubscriptions); + persistGroupSubscriptions(groupSubscriptions); + persistCompositeAppSubscription(compositeAppSubscription); + } + private void persistCartridgeSubscriptions (Collection cartridgeSubscriptions) throws CompositeApplicationException { if (cartridgeSubscriptions == null) { From 110584a322904fbea5108a5913af109b97c167f1 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 21 Jul 2014 19:35:54 +0530 Subject: [PATCH 025/436] fixing some naming issues in beans --- .../CompositeApplicationManager.java | 2 +- .../application/beans/SubscribableInfo.java | 20 +++++++++---------- .../application/parser/ParserUtils.java | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index c5c2284d91..c8bfd30e4f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -36,7 +36,7 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " - + compositeAppDefinition.getAlias() + " ] deployed successfully"); + + compositeAppDefinition.getAlias() + " ] parsed successfully"); // create the CompositeAppSubscription CompositeAppSubscription compositeAppSubscription; 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 index 09130c3394..3e0ba547c6 100644 --- 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 @@ -34,9 +34,9 @@ public class SubscribableInfo { private boolean privateRepo; - private String username; + private String repoUsername; - private String password; + private String repoPassword; public String getAlias() { return alias; @@ -78,19 +78,19 @@ public void setPrivateRepo(boolean privateRepo) { this.privateRepo = privateRepo; } - public String getUsername() { - return username; + public String getRepoUsername() { + return repoUsername; } - public void setUsername(String username) { - this.username = username; + public void setRepoUsername(String repoUsername) { + this.repoUsername = repoUsername; } - public String getPassword() { - return password; + public String getRepoPassword() { + return repoPassword; } - public void setPassword(String password) { - this.password = password; + public void setRepoPassword(String repoPassword) { + this.repoPassword = repoPassword; } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java index 6b4b883ccb..765c4c41f5 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/ParserUtils.java @@ -40,8 +40,8 @@ public static SubscribableContext convert (SubscribableDefinition subscribable, if (subscribableInfo.getRepoUrl() != null && !subscribableInfo.getRepoUrl().isEmpty()) { subscribableContext.setRepoUrl(subscribableInfo.getRepoUrl()); subscribableContext.setPrivateRepo(subscribableInfo.isPrivateRepo()); - subscribableContext.setUsername(subscribableInfo.getUsername()); - subscribableContext.setPassword(subscribableInfo.getPassword()); + subscribableContext.setUsername(subscribableInfo.getRepoUsername()); + subscribableContext.setPassword(subscribableInfo.getRepoPassword()); } return subscribableContext; From 78bf6dac9d7421b838553c5e42f88e7b8bf80cb8 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 21 Jul 2014 20:27:15 +0530 Subject: [PATCH 026/436] fixing a bug in building composite app structure --- .../DefaultCompositeApplicationParser.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index c8b699888a..0f24708d0c 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -264,18 +264,20 @@ private void getNestedGroupContexts (Set nestedGroupContexts, Set< private void filterDuplicatedGroupContexts (Set topLevelGroupContexts, Set nestedGroupContexts) { - Iterator parentIterator = topLevelGroupContexts.iterator(); - Iterator nestedIterator = nestedGroupContexts.iterator(); + for (GroupContext nestedGropCtxt : nestedGroupContexts) { + filterNestedGroupFromTopLevel(topLevelGroupContexts, nestedGropCtxt); + } + } + private void filterNestedGroupFromTopLevel (Set topLevelGroupContexts, GroupContext nestedGroupCtxt) { + + Iterator parentIterator = topLevelGroupContexts.iterator(); while (parentIterator.hasNext()) { GroupContext parentGroupCtxt = parentIterator.next(); - while (nestedIterator.hasNext()) { - GroupContext nestedGroupCtxt = nestedIterator.next(); - // if there is an exactly similar nested Group Context and a top level Group Context - // it implies that they are duplicates. Should be removed from top level. - if (parentGroupCtxt.equals(nestedGroupCtxt)) { - parentIterator.remove(); - } + // if there is an exactly similar nested Group Context and a top level Group Context + // it implies that they are duplicates. Should be removed from top level. + if (parentGroupCtxt.equals(nestedGroupCtxt)) { + parentIterator.remove(); } } } From c9e3e7273499dbbe4cc2f198b4aaf60233a0c845 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 26 Aug 2014 11:30:08 -0700 Subject: [PATCH 027/436] replacing cartridgeSubscriptionAliases with groupSubscriptionAliases in addGroupSubscriptionAliases --- .../stratos/manager/subscription/CompositeAppSubscription.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java index 074dc38f07..2a99842840 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java @@ -64,7 +64,7 @@ public void addGroupSubscriptionAlias (String groupSubscriptionAlias) { } public void addGroupSubscriptionAliases (Set groupSubscriptionAliases) { - cartridgeSubscriptionAliases.addAll(groupSubscriptionAliases); + groupSubscriptionAliases.addAll(groupSubscriptionAliases); } public String getAppId() { From 8c14177f4f625c1f16c1b20a455f67dccbeb1f18 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 14:30:23 +0530 Subject: [PATCH 028/436] merging messaging component --- .../manager/CartridgeSubscriptionManager.java | 242 ++++++++++-- .../manager/payload/BasicPayloadData.java | 17 +- .../manager/repository/Repository.java | 9 + .../subscription/CartridgeSubscription.java | 34 +- .../subscription/LBCartridgeSubscription.java | 37 +- .../subscription/SubscriptionData.java | 39 +- .../utils/CartridgeSubscriptionUtils.java | 34 +- .../manager/utils/CartridgeConstants.java | 1 + .../messaging/domain/tenant/Subscription.java | 77 ++++ .../domain/tenant/SubscriptionDomain.java | 41 ++ .../messaging/domain/tenant/Tenant.java | 29 +- .../messaging/domain/topology/Cluster.java | 10 + .../domain/topology/ClusterStatus.java | 36 ++ .../tenant/SubscriptionDomainAddedEvent.java | 67 ++++ .../SubscriptionDomainRemovedEvent.java | 60 +++ .../tenant/SubscriptionDomainsAddedEvent.java | 60 +++ .../SubscriptionDomainsRemovedEvent.java | 60 +++ .../event/tenant/TenantSubscribedEvent.java | 9 +- .../topology/ClusterMaintenanceModeEvent.java | 58 +++ .../event/topology/MemberActivatedEvent.java | 49 ++- .../event/topology/MemberTerminatedEvent.java | 10 + ...SubscriptionDomainsAddedEventListener.java | 28 ++ ...bscriptionDomainsRemovedEventListener.java | 28 ++ .../ClusterMaintenanceModeEventListener.java | 25 ++ ...bscriptionDomainAddedMessageProcessor.java | 100 +++++ ...criptionDomainRemovedMessageProcessor.java | 97 +++++ .../TenantSubscribedMessageProcessor.java | 5 +- .../TenantUnSubscribedMessageProcessor.java | 2 +- ...lusterMaintenanceModeMessageProcessor.java | 115 ++++++ .../rest/endpoint/services/StratosAdmin.java | 363 ++++++++++++------ 30 files changed, 1520 insertions(+), 222 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Subscription.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/SubscriptionDomain.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainAddedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainRemovedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsAddedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsRemovedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsAddedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsRemovedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainAddedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainRemovedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.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 index 7d6be7cf7f..989fed48fc 100644 --- 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 @@ -23,10 +23,13 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; 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; @@ -41,14 +44,17 @@ 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.Constants; import org.wso2.carbon.context.CarbonContext; import org.apache.stratos.manager.publisher.CartridgeSubscriptionDataPublisher; -import java.util.Collection; -import java.util.Random; +import java.util.*; /** * Manager class for the purpose of managing CartridgeSubscriptionInfo subscriptions, groupings, etc. @@ -143,8 +149,10 @@ public void persistCartridgeSubscription (CartridgeSubscription cartridgeSubscri log.info("Successful Subscription: " + cartridgeSubscription.toString()); // Publish tenant subscribed event to message broker + Set clusterIds = new HashSet(); + clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain()); CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), - cartridgeSubscription.getCartridgeInfo().getType()); + cartridgeSubscription.getCartridgeInfo().getType(), clusterIds); } public void persistGroupSubscription (GroupSubscription groupSubscription) throws ADCException { @@ -280,14 +288,17 @@ private boolean activeInstancesAvailable(SubscriptionData subscriptionData) { Collection members = cluster.getMembers(); for (Member member : members) { if(member.isActive()) { - activeMemberCount++; + if(log.isDebugEnabled()) { + log.debug("Active member found for cluster [" + cluster +"]"); + } + return true; } } } if(log.isDebugEnabled()) { - log.debug("Active member count for cluster [" + cluster +"] is : "+ activeMemberCount); + log.debug("Active member not found for cluster [" + cluster +"]"); } - return activeMemberCount > 0; + return false; } private CartridgeSubscription subscribeToLB (SubscriptionData subscriptionData, LBDataContext lbDataContext, @@ -299,7 +310,7 @@ private CartridgeSubscription subscribeToLB (SubscriptionData subscriptionData, if (lbDataContext.getLbCategory() == null || lbDataContext.getLbCategory().equals(Constants.NO_LOAD_BALANCER)) { - // no load balancer subscription requiredgenerateSubscriptionKey + // 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; @@ -394,25 +405,64 @@ private CartridgeSubscription subscribe (SubscriptionData subscriptionData, Cart // Create the CartridgeSubscription instance CartridgeSubscription cartridgeSubscription = CartridgeSubscriptionFactory.getCartridgeSubscriptionInstance(cartridgeInfo, tenancyBehaviour); - // Generate and set the key - String subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey(); - cartridgeSubscription.setSubscriptionKey(subscriptionKey); - String encryptedRepoPassword; - String repositoryPassword = subscriptionData.getRepositoryPassword(); - if(repositoryPassword != null && !repositoryPassword.isEmpty()) { - encryptedRepoPassword = RepoPasswordMgtUtil.encryptPassword(repositoryPassword, subscriptionKey); - } else { - encryptedRepoPassword = ""; + // 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(), - encryptedRepoPassword, + subscriptionData.getRepositoryPassword(), subscriptionData.isPrivateRepository()); - // Create subscriber - Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain()); + // 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); @@ -488,13 +538,155 @@ private SubscriptionInfo registerCartridgeSubscription(CartridgeSubscription car log.info("Successful Subscription: " + cartridgeSubscription.toString()); // Publish tenant subscribed event to message broker - CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), - cartridgeSubscription.getCartridgeInfo().getType()); + Set clusterIds = new HashSet(); + clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain()); + CartridgeSubscriptionUtils.publishTenantSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), cartridgeSubscription.getCartridgeInfo().getType(), clusterIds); return ApplicationManagementUtil. createSubscriptionResponse(cartridgeSubscriptionInfo, cartridgeSubscription.getRepository()); } + public 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); + + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC); + + Set clusterIds = new HashSet(); + clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain()); + SubscriptionDomainAddedEvent event = new SubscriptionDomainAddedEvent(tenantId, cartridgeSubscription.getType(), + clusterIds, domainName, applicationContext); + + eventPublisher.publish(event); + } + + public 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); + + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC); + + Set clusterIds = new HashSet(); + clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain()); + SubscriptionDomainRemovedEvent event = new SubscriptionDomainRemovedEvent(tenantId, cartridgeSubscription.getType(), + clusterIds, domainName); + eventPublisher.publish(event); + } + + public List 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) cartridgeSubscription.getSubscriptionDomains(); + return new ArrayList(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 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 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 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 Collection getCartridgeSubscriptions (int tenantId, String type) throws ADCException { if (type == null || type.isEmpty()) { @@ -543,8 +735,12 @@ public void unsubscribeFromCartridge (String tenantDomain, String alias) } // Publish tenant un-subscribed event to message broker - CartridgeSubscriptionUtils.publishTenantUnSubscribedEvent(cartridgeSubscription.getSubscriber().getTenantId(), - cartridgeSubscription.getCartridgeInfo().getType()); + + Set clusterIds = new HashSet(); + 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 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 index 0d27b1b878..234dac14be 100644 --- 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 @@ -47,6 +47,7 @@ public class BasicPayloadData implements Serializable { private String gitRepositoryUrl; private String portMappings; private String multitenant; + private String provider; protected StringBuilder payloadBuilder; @@ -74,13 +75,15 @@ public void populatePayload () { payloadBuilder.append(","); payloadBuilder.append("CARTRIDGE_KEY=" + getSubscriptionKey()); payloadBuilder.append(","); - payloadBuilder.append("DEPLOYMENT=" + getDeployment()); - 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(","); @@ -88,6 +91,8 @@ public void populatePayload () { 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)); } @@ -216,4 +221,12 @@ public String getPuppetEnvironment() { public void setPuppetEnvironment(String puppetEnvironment) { this.puppetEnvironment = puppetEnvironment; } + + public String getProvider() { + return provider; + } + + public void setProvider(String provider) { + this.provider = provider; + } } 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 index 16cc2c49de..ab95ae3303 100644 --- 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 @@ -29,6 +29,7 @@ public class Repository implements Serializable { private String userName; private String password; private boolean isPrivateRepository; + private boolean commitEnabled; public String getUserName() { return userName; @@ -75,4 +76,12 @@ 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; + } } 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 index b974f54128..a5d901d959 100644 --- 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 @@ -35,7 +35,7 @@ import org.apache.stratos.manager.utils.CartridgeConstants; import java.io.Serializable; -import java.util.Map; +import java.util.*; public abstract class CartridgeSubscription implements Serializable { @@ -59,7 +59,7 @@ public abstract class CartridgeSubscription implements Serializable { //private List connectedSubscriptionAliases; private String subscriptionKey; private SubscriptionTenancyBehaviour subscriptionTenancyBehaviour; - + private Map subscriptionDomainMap; /** * Constructor @@ -80,6 +80,7 @@ public CartridgeSubscription(CartridgeInfo cartridgeInfo, SubscriptionTenancyBeh //this.setSubscriptionStatus(CartridgeConstants.SUBSCRIBED); //this.connectedSubscriptionAliases = new ArrayList(); this.setSubscriptionTenancyBehaviour(subscriptionTenancyBehaviour); + this.subscriptionDomainMap = new HashMap(); } /** @@ -118,6 +119,33 @@ public void createSubscription (Subscriber subscriber, String alias, String auto 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 getSubscriptionDomains() { + return Collections.unmodifiableCollection(subscriptionDomainMap.values()); + } + /** * Unsubscribe from this cartridge subscription * @@ -389,7 +417,7 @@ public String toString() { ", alias=" + alias + ", autoscalingPolicyName=" + autoscalingPolicyName + ", deploymentPolicyName=" + deploymentPolicyName + ", subscriber=" + subscriber + ", repository=" + repository + ", cartridgeInfo=" + cartridgeInfo + ", payload=" + - payloadData + ", cluster=" + cluster + "]"; + payloadData + ", cluster=" + cluster + "]" + ", subscriptionDomainMap=" + subscriptionDomainMap.toString(); } public String getLbClusterId() { 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 index f6555f8689..c0bd321ce3 100644 --- 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 @@ -25,23 +25,15 @@ import org.apache.stratos.cloud.controller.stub.pojo.Persistence; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; -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.NotSubscribedException; -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.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; +import java.util.Set; + public class LBCartridgeSubscription extends CartridgeSubscription { private LoadBalancerCategory loadBalancerCategory; @@ -72,24 +64,25 @@ public void createSubscription (Subscriber subscriber, String alias, String auto 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())); - } +// 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."); - } + //if(!loadBalancerCategory.isLoadBalancedServiceMultiTenant()) { + //if(log.isDebugEnabled()) { + //log.debug("Loadbalanced service is single tenant."); + //} getLoadBalancerCategory().register (getCartridgeInfo(), getCluster(), getPayloadData(), getAutoscalingPolicyName(), - getDeploymentPolicyName(), properties, persistence); - } - + getDeploymentPolicyName(), properties, null); + //} return ApplicationManagementUtil.createCartridgeSubscription(getCartridgeInfo(), getAutoscalingPolicyName(), getType(), getAlias(), getSubscriber().getTenantId(), getSubscriber().getTenantDomain(), 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 index 0b257d5e7b..56829e0fad 100644 --- 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 @@ -22,12 +22,15 @@ import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; +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; @@ -43,8 +46,14 @@ public class SubscriptionData { private PersistenceContext persistanceCtxt; private boolean isCommitsEnabled; private String serviceGroup; + private Set domains; private Persistence persistence; private Properties properties; + private String serviceName; + + public SubscriptionData() { + this.domains = new HashSet(); + } public String getCartridgeType() { return cartridgeType; @@ -166,13 +175,29 @@ public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } + public void addDomains(Set domains) { + domains.addAll(domains); + } + + public void removeDomain(String domain) { + domains.remove(domain); + } + + public void removeDomains(Set domains) { + domains.removeAll(domains); + } + + public Set getDomains() { + return Collections.unmodifiableSet(domains); + } + public Persistence getPersistence() { return persistence; } - public void setPersistence(Persistence persistence) { + public void setPersistence(Persistence persistence) { this.persistence = persistence; - } + } public Properties getProperties() { return properties; @@ -181,4 +206,12 @@ public Properties getProperties() { public void setProperties(Properties properties) { this.properties = properties; } + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + } 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 index deb9475701..4e54f21122 100644 --- 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 @@ -45,6 +45,7 @@ import org.apache.stratos.messaging.event.tenant.TenantUnSubscribedEvent; import org.apache.stratos.messaging.util.Constants; +import java.util.Set; import java.util.concurrent.Executor; import java.util.regex.Pattern; @@ -58,10 +59,11 @@ public static BasicPayloadData createBasicPayload (CartridgeInfo cartridgeInfo, BasicPayloadData basicPayloadData = new BasicPayloadData(); basicPayloadData.setApplicationPath(cartridgeInfo.getBaseDir()); basicPayloadData.setSubscriptionKey(subscriptionKey); - basicPayloadData.setDeployment("default");//currently hard coded to default + //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()); @@ -96,7 +98,7 @@ public static BasicPayloadData createBasicPayload (Service service) { basicPayloadData.setApplicationPath(service.getCartridgeInfo().getBaseDir()); basicPayloadData.setSubscriptionKey(service.getSubscriptionKey()); basicPayloadData.setClusterId(service.getClusterId()); - basicPayloadData.setDeployment("default");//currently hard coded to default + //basicPayloadData.setDeployment("default");//currently hard coded to default basicPayloadData.setHostName(service.getHostName()); basicPayloadData.setMultitenant(String.valueOf(service.getCartridgeInfo().getMultiTenant())); basicPayloadData.setPortMappings(createPortMappingPayloadString(service.getCartridgeInfo())); @@ -147,19 +149,19 @@ private static String createPortMappingPayloadString (CartridgeInfo cartridgeInf } public static String generateSubscriptionKey() { - String key = RandomStringUtils.randomAlphanumeric(16); - log.info("Generated key : " + key); // TODO -- remove the log - return key; + return RandomStringUtils.randomAlphanumeric(16); } static class TenantSubscribedEventPublisher implements Runnable { - int tenantId; - String serviceName; + private int tenantId; + private String serviceName; + private Set clusterIds; - public TenantSubscribedEventPublisher(int tenantId, String service) { + public TenantSubscribedEventPublisher(int tenantId, String service, Set clusterIds) { this.tenantId = tenantId; this.serviceName = service; + this.clusterIds = clusterIds; } @Override public void run() { @@ -167,7 +169,7 @@ public void run() { if(log.isInfoEnabled()) { log.info(String.format("Publishing tenant subscribed event: [tenant-id] %d [service] %s", tenantId, serviceName)); } - TenantSubscribedEvent subscribedEvent = new TenantSubscribedEvent(tenantId, serviceName); + TenantSubscribedEvent subscribedEvent = new TenantSubscribedEvent(tenantId, serviceName, clusterIds); EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC); eventPublisher.publish(subscribedEvent); } catch (Exception e) { @@ -179,7 +181,7 @@ public void run() { } } - public static void publishTenantSubscribedEvent(int tenantId, String serviceName) { + public static void publishTenantSubscribedEvent(int tenantId, String serviceName, Set clusterIds) { Executor exec = new Executor() { @@ -189,15 +191,15 @@ public void execute(Runnable command) { } }; - exec.execute(new TenantSubscribedEventPublisher(tenantId, serviceName)); + exec.execute(new TenantSubscribedEventPublisher(tenantId, serviceName, clusterIds)); } - public static void publishTenantUnSubscribedEvent(int tenantId, String serviceName) { + public static void publishTenantUnSubscribedEvent(int tenantId, String serviceName, Set 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); + TenantUnSubscribedEvent event = new TenantUnSubscribedEvent(tenantId, serviceName, clusterIds); EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TENANT_TOPIC); eventPublisher.publish(event); } catch (Exception e) { @@ -209,8 +211,10 @@ public static void publishTenantUnSubscribedEvent(int tenantId, String serviceNa public static void validateCartridgeAlias (int tenantId, String cartridgeType, String alias) throws InvalidCartridgeAliasException, DuplicateCartridgeAliasException, ADCException { - boolean validAlias = ApplicationUtils.isAliasValid(alias); - if (!validAlias) { + 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); 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 6ed5564874..ab78bd6db4 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 @@ -33,6 +33,7 @@ public class CartridgeConstants { 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"; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Subscription.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Subscription.java new file mode 100644 index 0000000000..caab4235b6 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Subscription.java @@ -0,0 +1,77 @@ +/* + * 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.messaging.domain.tenant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.*; + +/** + * Tenant's service subscription. + */ +public class Subscription { + private static final Log log = LogFactory.getLog(Subscription.class); + + private final String serviceName; + private final Set clusterIds; + private final Map subscriptionDomainMap; + + public Subscription(String serviceName, Set clusterIds) { + this.serviceName = serviceName; + this.clusterIds = clusterIds; + this.subscriptionDomainMap = new HashMap(); + } + + public String getServiceName() { + return serviceName; + } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } + + public void addSubscriptionDomain(SubscriptionDomain subscriptionDomain) { + subscriptionDomainMap.put(subscriptionDomain.getDomainName(), subscriptionDomain); + } + + public void addSubscriptionDomain(String domainName, String applicationContext) { + addSubscriptionDomain(new SubscriptionDomain(domainName, applicationContext)); + } + + 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 Collection getSubscriptionDomains() { + return Collections.unmodifiableCollection(subscriptionDomainMap.values()); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/SubscriptionDomain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/SubscriptionDomain.java new file mode 100644 index 0000000000..84df4c818e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/SubscriptionDomain.java @@ -0,0 +1,41 @@ +/* + * 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.messaging.domain.tenant; + +/** + * Subscription domain definition. + */ +public class SubscriptionDomain { + 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; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Tenant.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Tenant.java index bc4244a5c2..ed20bd0172 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Tenant.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/tenant/Tenant.java @@ -32,13 +32,13 @@ public class Tenant implements Serializable{ private int tenantId; private String tenantDomain; - // Map - private Map serviceNameMap; + // Map + private Map serviceNameSubscriptionMap; public Tenant(int tenantId, String tenantDomain) { this.tenantId = tenantId; this.tenantDomain = tenantDomain; - this.serviceNameMap = new HashMap(); + this.serviceNameSubscriptionMap = new HashMap(); } public int getTenantId() { @@ -53,19 +53,26 @@ public void setTenantDomain(String tenantDomain) { this.tenantDomain = tenantDomain; } - public Collection getServiceSubscriptions() { - return serviceNameMap.keySet(); + public Subscription getSubscription(String serviceName) { + if(serviceNameSubscriptionMap.containsKey(serviceName)) { + return serviceNameSubscriptionMap.get(serviceName); + } + return null; } - public boolean isServiceSubscribed(String serviceName) { - return serviceNameMap.containsKey(serviceName); + public Collection getSubscriptions() { + return serviceNameSubscriptionMap.values(); } - public void addServiceSubscription(String serviceName) { - serviceNameMap.put(serviceName, true); + public boolean isSubscribed(String serviceName) { + return serviceNameSubscriptionMap.containsKey(serviceName); } - public void removeServiceSubscription(String serviceName) { - serviceNameMap.remove(serviceName); + public void addSubscription(Subscription subscription) { + serviceNameSubscriptionMap.put(subscription.getServiceName(), subscription); + } + + public void removeSubscription(String serviceName) { + serviceNameSubscriptionMap.remove(serviceName); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index dddb869422..08bd2621f0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -49,6 +49,8 @@ public class Cluster implements Serializable { @XmlJavaTypeAdapter(MapAdapter.class) private Map memberMap; + private ClusterStatus status; + private String loadBalanceAlgorithmName; @XmlJavaTypeAdapter(MapAdapter.class) private Properties properties; @@ -200,5 +202,13 @@ public Collection findPartitionIds() { } return partitionIds.keySet(); } + + public ClusterStatus getStatus() { + return status; + } + + public void setStatus(ClusterStatus status) { + this.status = status; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java new file mode 100644 index 0000000000..b3301c88d1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -0,0 +1,36 @@ +/* + * 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.messaging.domain.topology; +public enum ClusterStatus { + Created(1), + In_Maintenance(2), + Removed(3); + + private int code; + + private ClusterStatus(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainAddedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainAddedEvent.java new file mode 100644 index 0000000000..e2b87d4f70 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainAddedEvent.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.messaging.event.tenant; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; +import java.util.*; + +/** + * This event is fired when domains are added to a tenant subscription. + */ +public class SubscriptionDomainAddedEvent extends Event implements Serializable { + private static final long serialVersionUID = 3457484382856403382L; + + private final int tenantId; + private final String serviceName; + private final Set clusterIds; + private final String domainName; + private final String applicationContext; + + public SubscriptionDomainAddedEvent(int tenantId, String serviceName, Set clusterIds, String domainName, + String applicationContext) { + this.tenantId = tenantId; + this.serviceName = serviceName; + this.clusterIds = clusterIds; + this.domainName = domainName; + this.applicationContext = applicationContext; + } + + public int getTenantId() { + return tenantId; + } + + public String getServiceName() { + return serviceName; + } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } + + public String getDomainName() { + return domainName; + } + + public String getApplicationContext() { + return applicationContext; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainRemovedEvent.java new file mode 100644 index 0000000000..b3d9578a48 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainRemovedEvent.java @@ -0,0 +1,60 @@ +/* + * 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.messaging.event.tenant; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; +import java.util.*; + +/** + * This event is fired when domains are removed from a tenant subscription. + */ +public class SubscriptionDomainRemovedEvent extends Event implements Serializable { + private static final long serialVersionUID = -8837521344795740210L; + + private final int tenantId; + private final String serviceName; + private final Set clusterIds; + private final String domainName; + + public SubscriptionDomainRemovedEvent(int tenantId, String serviceName, Set clusterIds, String domainName) { + this.tenantId = tenantId; + this.serviceName = serviceName; + this.clusterIds = clusterIds; + this.domainName = domainName; + } + + public int getTenantId() { + return tenantId; + } + + public String getServiceName() { + return serviceName; + } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } + + public String getDomainName() { + return domainName; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsAddedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsAddedEvent.java new file mode 100644 index 0000000000..312571a9c4 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsAddedEvent.java @@ -0,0 +1,60 @@ +/* + * 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.messaging.event.tenant; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; +import java.util.*; + +/** + * This event is fired when domains are added to a tenant subscription. + */ +public class SubscriptionDomainsAddedEvent extends Event implements Serializable { + private static final long serialVersionUID = 3457484382856403382L; + + private final int tenantId; + private final String serviceName; + private final Set clusterIds; + private final Set domains; + + public SubscriptionDomainsAddedEvent(int tenantId, String serviceName, Set clusterIds, Set domains) { + this.tenantId = tenantId; + this.serviceName = serviceName; + this.clusterIds = clusterIds; + this.domains = (domains != null) ? domains : new HashSet(); + } + + public int getTenantId() { + return tenantId; + } + + public String getServiceName() { + return serviceName; + } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } + + public Set getDomains() { + return Collections.unmodifiableSet(domains); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsRemovedEvent.java new file mode 100644 index 0000000000..3cc566426b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/SubscriptionDomainsRemovedEvent.java @@ -0,0 +1,60 @@ +/* + * 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.messaging.event.tenant; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; +import java.util.*; + +/** + * This event is fired when domains are removed from a tenant subscription. + */ +public class SubscriptionDomainsRemovedEvent extends Event implements Serializable { + private static final long serialVersionUID = -8837521344795740210L; + + private final int tenantId; + private final String serviceName; + private final Set clusterIds; + private Set domains; + + public SubscriptionDomainsRemovedEvent(int tenantId, String serviceName, Set clusterIds, Set domains) { + this.tenantId = tenantId; + this.serviceName = serviceName; + this.clusterIds = clusterIds; + this.domains = (domains != null) ? domains : new HashSet(); + } + + public int getTenantId() { + return tenantId; + } + + public String getServiceName() { + return serviceName; + } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } + + public Set getDomains() { + return Collections.unmodifiableSet(domains); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantSubscribedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantSubscribedEvent.java index 2be1ad3a35..d89de122cb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantSubscribedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantSubscribedEvent.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.event.tenant; import java.io.Serializable; +import java.util.*; /** * This event is fired when a tenant is subscribed to a service. @@ -29,10 +30,12 @@ public class TenantSubscribedEvent extends TenantEvent implements Serializable { private final int tenantId; private final String serviceName; + private final Set clusterIds; - public TenantSubscribedEvent(int tenantId, String serviceName) { + public TenantSubscribedEvent(int tenantId, String serviceName, Set clusterIds) { this.tenantId = tenantId; this.serviceName = serviceName; + this.clusterIds = clusterIds; } public int getTenantId() { @@ -42,4 +45,8 @@ public int getTenantId() { public String getServiceName() { return serviceName; } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java new file mode 100644 index 0000000000..76e58208e2 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java @@ -0,0 +1,58 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.ClusterStatus; + +import java.io.Serializable; + +public class ClusterMaintenanceModeEvent extends TopologyEvent implements Serializable { + + private final String serviceName; + private final String clusterId; + private ClusterStatus status; + + public ClusterMaintenanceModeEvent(String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterMaintenanceModeEvent [serviceName=" + serviceName + ", clusterStatus=" + + status.toString() + "]"; + } + + public String getClusterId() { + return clusterId; + } + + public ClusterStatus getStatus() { + return status; + } + + public void setStatus(ClusterStatus status) { + this.status = status; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java index 38d4f92731..3e0d355953 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java @@ -19,6 +19,9 @@ package org.apache.stratos.messaging.event.topology; +import java.io.Serializable; +import java.util.*; + import org.apache.stratos.messaging.domain.topology.Port; import java.io.Serializable; @@ -38,8 +41,8 @@ public class MemberActivatedEvent extends TopologyEvent implements Serializable private final String networkPartitionId; private final String partitionId; private final String memberId; - private Map portMap; - private String memberPublicIp; + // Key: Port.proxy + private Map portMap; private String memberIp; private String groupId; private String applicationId; @@ -50,7 +53,7 @@ public MemberActivatedEvent(String serviceName, String clusterId, String network this.networkPartitionId = networkPartitionId; this.partitionId = partitionId; this.memberId = memberId; - this.portMap = new HashMap(); + this.portMap = new HashMap(); } public String getServiceName() { @@ -72,32 +75,37 @@ public String getPartitionId(){ public String getMemberId() { return memberId; } - + public Collection getPorts() { - return portMap.values(); + return Collections.unmodifiableCollection(portMap.values()); } - public void addPort(Port port) { - this.portMap.put(port.getProtocol(), port); + public Port getPort(int proxy) { + if(portMap.containsKey(proxy)) { + return portMap.get(proxy); + } + return null; } - public void removePort(Port port) { - this.portMap.remove(port.getProtocol()); + public void addPort(Port port) { + this.portMap.put(port.getProxy(), port); } - public void removePort(String portName) { - this.portMap.remove(portName); + public void addPorts(Collection ports) { + for(Port port : ports) { + addPort(port); + } } - public boolean portExists(Port port) { - return this.portMap.containsKey(port.getProtocol()); + public void removePort(Port port) { + this.portMap.remove(port.getProxy()); } - public Port getPort(String portName) { - return this.portMap.get(portName); + public boolean portExists(Port port) { + return this.portMap.containsKey(port.getProxy()); } - public String getMemberIp() { + public String getMemberIp() { return memberIp; } @@ -105,15 +113,6 @@ public void setMemberIp(String memberIp) { this.memberIp = memberIp; } - public String getMemberPublicIp() { - return memberPublicIp; - } - - public void setMemberPublicIp(String memberPublicIp) { - this.memberPublicIp = memberPublicIp; - } - - public String getGroupId() { return groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java index c35f80c562..d8fd990193 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.event.topology; import java.io.Serializable; +import java.util.Properties; /** * This event is fired by Cloud Controller when a member is terminated. @@ -34,6 +35,8 @@ private final String partitionId; private final String memberId; private String groupId; + private Properties properties; + public MemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -70,4 +73,11 @@ public String getGroupId() { public void setGroupId(String groupId) { this.groupId = groupId; } + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsAddedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsAddedEventListener.java new file mode 100644 index 0000000000..3f169b7abf --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsAddedEventListener.java @@ -0,0 +1,28 @@ +/* + * 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.messaging.listener.tenant; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Tenant subscription domains added event listener. + */ +public abstract class SubscriptionDomainsAddedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsRemovedEventListener.java new file mode 100644 index 0000000000..5c81ad6b7f --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/tenant/SubscriptionDomainsRemovedEventListener.java @@ -0,0 +1,28 @@ +/* + * 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.messaging.listener.tenant; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Tenant subscription domains removed event listener. + */ +public abstract class SubscriptionDomainsRemovedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java new file mode 100644 index 0000000000..3bd2a192ef --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java @@ -0,0 +1,25 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterMaintenanceModeEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainAddedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainAddedMessageProcessor.java new file mode 100644 index 0000000000..a185cd2779 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainAddedMessageProcessor.java @@ -0,0 +1,100 @@ +/* + * 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.messaging.message.processor.tenant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.SubscriptionDomain; +import org.apache.stratos.messaging.domain.tenant.Tenant; +import org.apache.stratos.messaging.event.tenant.SubscriptionDomainAddedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.tenant.TenantManager; +import org.apache.stratos.messaging.util.Util; + +/** + * Subscription domain added message processor for adding domains to tenant subscriptions. + */ +public class SubscriptionDomainAddedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(SubscriptionDomainAddedMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (SubscriptionDomainAddedEvent.class.getName().equals(type)) { + // Return if tenant manager has not initialized + + if (!TenantManager.getInstance().isInitialized()) { + return false; + } + + // Parse complete message and build event + SubscriptionDomainAddedEvent event = (SubscriptionDomainAddedEvent) Util.jsonToObject(message, SubscriptionDomainAddedEvent.class); + + try { + TenantManager.acquireWriteLock(); + Tenant tenant = TenantManager.getInstance().getTenant(event.getTenantId()); + + if (tenant == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Tenant not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + Subscription subscription = tenant.getSubscription(event.getServiceName()); + if (subscription == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Subscription not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + subscription.addSubscriptionDomain(new SubscriptionDomain(event.getDomainName(), event.getApplicationContext())); + + if (log.isInfoEnabled()) { + log.info(String.format("Domain added to tenant subscription: [tenant-id] %d [tenant-domain] %s " + + "[service] %s [domain-name] %s [application-context] %s", tenant.getTenantId(), + tenant.getTenantDomain(), event.getServiceName(), event.getDomainName(), event.getApplicationContext() + )); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + finally { + TenantManager.releaseWriteLock(); + } + } + else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process tenant message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainRemovedMessageProcessor.java new file mode 100644 index 0000000000..88b3690252 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/SubscriptionDomainRemovedMessageProcessor.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.messaging.message.processor.tenant; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.Tenant; +import org.apache.stratos.messaging.event.tenant.SubscriptionDomainRemovedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.tenant.TenantManager; +import org.apache.stratos.messaging.util.Util; + +/** + * Subscription domain removed message processor for removing domains from tenant subscriptions. + */ +public class SubscriptionDomainRemovedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(SubscriptionDomainRemovedMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (SubscriptionDomainRemovedEvent.class.getName().equals(type)) { + // Return if tenant manager has not initialized + if (!TenantManager.getInstance().isInitialized()) { + return false; + } + + // Parse complete message and build event + SubscriptionDomainRemovedEvent event = (SubscriptionDomainRemovedEvent) Util.jsonToObject(message, SubscriptionDomainRemovedEvent.class); + + try { + TenantManager.acquireWriteLock(); + Tenant tenant = TenantManager.getInstance().getTenant(event.getTenantId()); + if(tenant == null) { + if(log.isWarnEnabled()) { + log.warn(String.format("Tenant not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + Subscription subscription = tenant.getSubscription(event.getServiceName()); + + if (subscription == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Subscription not found: [tenant-id] %d", event.getTenantId())); + } + return false; + } + subscription.removeSubscriptionDomain(event.getDomainName()); + if(log.isInfoEnabled()) { + log.info(String.format("Domain removed from tenant subscription: [tenant-id] %d [tenant-domain] %s " + + "[service] %s [domain-name] %s", tenant.getTenantId(), tenant.getTenantDomain(), + event.getServiceName(), event.getDomainName())); + + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + finally { + TenantManager.releaseWriteLock(); + } + } + else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process tenant message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java index aae074b14d..196bc22cab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantSubscribedMessageProcessor.java @@ -21,6 +21,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.tenant.Subscription; +import org.apache.stratos.messaging.domain.tenant.SubscriptionDomain; import org.apache.stratos.messaging.domain.tenant.Tenant; import org.apache.stratos.messaging.event.tenant.TenantSubscribedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -62,7 +64,8 @@ public boolean process(String type, String message, Object object) { } return false; } - tenant.addServiceSubscription(event.getServiceName()); + Subscription subscription = new Subscription(event.getServiceName(), event.getClusterIds()); + tenant.addSubscription(subscription); if(log.isInfoEnabled()) { log.info(String.format("Tenant subscribed to service: [tenant-id] %d [tenant-domain] %s [service] %s", tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java index 6c4157cefc..ee929a38ce 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/tenant/TenantUnSubscribedMessageProcessor.java @@ -62,7 +62,7 @@ public boolean process(String type, String message, Object object) { } return false; } - tenant.removeServiceSubscription(event.getServiceName()); + tenant.removeSubscription(event.getServiceName()); if(log.isInfoEnabled()) { log.info(String.format("Tenant un-subscribed from service: [tenant-id] %d [tenant-domain] %s [service] %s", tenant.getTenantId(), tenant.getTenantDomain(), event.getServiceName())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java new file mode 100644 index 0000000000..0300b24641 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -0,0 +1,115 @@ +/* + * 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.messaging.message.processor.topology; + +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.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ClusterMaintenanceModeMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterMaintenanceModeMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (ClusterMaintenanceModeEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util. + jsonToObject(message, ClusterMaintenanceModeEvent.class); + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + // Apply changes to the topology + cluster.setStatus(ClusterStatus.In_Maintenance); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster updated as maintenance mode: %s", + cluster.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 98b3725989..8303bee1e9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.rest.endpoint.services; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.common.beans.TenantInfoBean; @@ -27,14 +28,18 @@ import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; +import org.apache.stratos.manager.exception.DomainMappingExistsException; +import org.apache.stratos.manager.exception.ServiceDoesNotExistException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.subscription.CartridgeSubscription; +import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.rest.endpoint.ServiceHolder; import org.apache.stratos.rest.endpoint.Utils; import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; import org.apache.stratos.rest.endpoint.bean.StratosAdminResponse; +import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.AutoscalePolicy; @@ -42,8 +47,11 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; +import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository; +import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; +import org.apache.stratos.rest.endpoint.exception.TenantNotFoundException; import org.apache.stratos.tenant.mgt.core.TenantPersistor; import org.apache.stratos.tenant.mgt.util.TenantMgtUtil; import org.wso2.carbon.context.PrivilegedCarbonContext; @@ -70,6 +78,8 @@ import java.util.List; import java.util.UUID; +import static javax.ws.rs.core.Response.ResponseBuilder; + @Path("/admin/") public class StratosAdmin extends AbstractAdmin { private static Log log = LogFactory.getLog(StratosAdmin.class); @@ -78,12 +88,14 @@ public class StratosAdmin extends AbstractAdmin { @Context UriInfo uriInfo; + @POST @Path("/init") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public StratosAdminResponse initialize () throws RestAPIException { + StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); stratosAdminResponse.setMessage("Successfully logged in"); return stratosAdminResponse; @@ -229,9 +241,10 @@ public StratosAdminResponse deployCartridgeDefinition(CartridgeDefinitionBean ca @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse unDeployCartridgeDefinition (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { + public Response unDeployCartridgeDefinition (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - return ServiceUtils.undeployCartridge(cartridgeType); + ServiceUtils.undeployCartridge(cartridgeType); + return Response.noContent().build(); } @POST @@ -278,10 +291,12 @@ public Response undeployServiceGroupDefinition (@PathParam("groupDefinitionName" @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deployPartition (Partition partition) + public Response deployPartition (Partition partition) throws RestAPIException { - return ServiceUtils.deployPartition(partition); + ServiceUtils.deployPartition(partition); + URI url = uriInfo.getAbsolutePathBuilder().path(partition.id).build(); + return Response.created(url).build(); } @POST @@ -290,10 +305,12 @@ public StratosAdminResponse deployPartition (Partition partition) @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deployAutoscalingPolicyDefintion (AutoscalePolicy autoscalePolicy) + public Response deployAutoscalingPolicyDefintion (AutoscalePolicy autoscalePolicy) throws RestAPIException { - return ServiceUtils.deployAutoscalingPolicy(autoscalePolicy); + ServiceUtils.deployAutoscalingPolicy(autoscalePolicy); + URI url = uriInfo.getAbsolutePathBuilder().path(autoscalePolicy.getId()).build(); + return Response.created(url).build(); } @POST @@ -302,10 +319,12 @@ public StratosAdminResponse deployAutoscalingPolicyDefintion (AutoscalePolicy au @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deployDeploymentPolicyDefinition (DeploymentPolicy deploymentPolicy) + public Response deployDeploymentPolicyDefinition (DeploymentPolicy deploymentPolicy) throws RestAPIException { - return ServiceUtils.deployDeploymentPolicy(deploymentPolicy); + ServiceUtils.deployDeploymentPolicy(deploymentPolicy); + URI url = uriInfo.getAbsolutePathBuilder().path(deploymentPolicy.id).build(); + return Response.created(url).build(); } @GET @@ -313,9 +332,8 @@ public StratosAdminResponse deployDeploymentPolicyDefinition (DeploymentPolicy d @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Partition[] getPartitions () throws RestAPIException { - - return ServiceUtils.getAvailablePartitions(); + public Response getPartitions () throws RestAPIException { + return Response.ok().entity(ServiceUtils.getAvailablePartitions()).build(); } @GET @@ -323,9 +341,8 @@ public Partition[] getPartitions () throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Partition getPartition (@PathParam("partitionId") String partitionId) throws RestAPIException { - - return ServiceUtils.getPartition(partitionId); + public Response getPartition (@PathParam("partitionId") String partitionId) throws RestAPIException { + return Response.ok().entity(ServiceUtils.getPartition(partitionId)).build(); } @GET @@ -333,10 +350,9 @@ public Partition getPartition (@PathParam("partitionId") String partitionId) thr @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public PartitionGroup[] getPartitionGroups (@PathParam("deploymentPolicyId") String deploymentPolicyId) + public Response getPartitionGroups (@PathParam("deploymentPolicyId") String deploymentPolicyId) throws RestAPIException { - - return ServiceUtils.getPartitionGroups(deploymentPolicyId); + return Response.ok().entity(ServiceUtils.getPartitionGroups(deploymentPolicyId)).build(); } @GET @@ -344,10 +360,9 @@ public PartitionGroup[] getPartitionGroups (@PathParam("deploymentPolicyId") Str @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Partition [] getPartitions (@PathParam("deploymentPolicyId") String deploymentPolicyId, + public Response getPartitions (@PathParam("deploymentPolicyId") String deploymentPolicyId, @PathParam("partitionGroupId") String partitionGroupId) throws RestAPIException { - - return ServiceUtils.getPartitionsOfGroup(deploymentPolicyId, partitionGroupId); + return Response.ok().entity(ServiceUtils.getPartitionsOfGroup(deploymentPolicyId, partitionGroupId)).build(); } @GET @@ -355,10 +370,10 @@ public PartitionGroup[] getPartitionGroups (@PathParam("deploymentPolicyId") Str @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Partition [] getPartitionsOfPolicy (@PathParam("deploymentPolicyId") String deploymentPolicyId) + public Response getPartitionsOfPolicy (@PathParam("deploymentPolicyId") String deploymentPolicyId) throws RestAPIException { - return ServiceUtils.getPartitionsOfDeploymentPolicy(deploymentPolicyId); + return Response.ok().entity(ServiceUtils.getPartitionsOfDeploymentPolicy(deploymentPolicyId)).build(); } @GET @@ -366,9 +381,8 @@ public PartitionGroup[] getPartitionGroups (@PathParam("deploymentPolicyId") Str @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public AutoscalePolicy[] getAutoscalePolicies () throws RestAPIException { - - return ServiceUtils.getAutoScalePolicies(); + public Response getAutoscalePolicies () throws RestAPIException { + return Response.ok().entity(ServiceUtils.getAutoScalePolicies()).build(); } @GET @@ -376,10 +390,9 @@ public AutoscalePolicy[] getAutoscalePolicies () throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public AutoscalePolicy getAutoscalePolicies (@PathParam("autoscalePolicyId") String autoscalePolicyId) + public Response getAutoscalePolicies (@PathParam("autoscalePolicyId") String autoscalePolicyId) throws RestAPIException { - - return ServiceUtils.getAutoScalePolicy(autoscalePolicyId); + return Response.ok().entity(ServiceUtils.getAutoScalePolicy(autoscalePolicyId)).build(); } @GET @@ -387,9 +400,8 @@ public AutoscalePolicy getAutoscalePolicies (@PathParam("autoscalePolicyId") Str @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public DeploymentPolicy[] getDeploymentPolicies () throws RestAPIException { - - return ServiceUtils.getDeploymentPolicies(); + public Response getDeploymentPolicies () throws RestAPIException { + return Response.ok().entity(ServiceUtils.getDeploymentPolicies()).build(); } @GET @@ -397,10 +409,9 @@ public DeploymentPolicy[] getDeploymentPolicies () throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public DeploymentPolicy getDeploymentPolicies (@PathParam("deploymentPolicyId") String deploymentPolicyId) + public Response getDeploymentPolicies (@PathParam("deploymentPolicyId") String deploymentPolicyId) throws RestAPIException { - - return ServiceUtils.getDeploymentPolicy(deploymentPolicyId); + return Response.ok().entity(ServiceUtils.getDeploymentPolicy(deploymentPolicyId)).build(); } @GET @@ -408,10 +419,9 @@ public DeploymentPolicy getDeploymentPolicies (@PathParam("deploymentPolicyId") @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public DeploymentPolicy[] getValidDeploymentPolicies (@PathParam("cartridgeType") String cartridgeType) + public Response getValidDeploymentPolicies (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - - return ServiceUtils.getDeploymentPolicies(cartridgeType); + return Response.ok().entity(ServiceUtils.getDeploymentPolicies(cartridgeType)).build(); } @GET @@ -419,9 +429,11 @@ public DeploymentPolicy[] getValidDeploymentPolicies (@PathParam("cartridgeType" @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge[] getAvailableMultiTenantCartridges() throws RestAPIException { + public Response getAvailableMultiTenantCartridges() throws RestAPIException { List cartridges = ServiceUtils.getAvailableCartridges(null, true, getConfigContext()); - return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]); + ResponseBuilder rb = Response.ok(); + rb.entity(cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()])); + return rb.build(); } @GET @@ -429,9 +441,11 @@ public Cartridge[] getAvailableMultiTenantCartridges() throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge[] getAvailableSingleTenantCartridges() throws RestAPIException { + public Response getAvailableSingleTenantCartridges() throws RestAPIException { List cartridges = ServiceUtils.getAvailableCartridges(null, false, getConfigContext()); - return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]); + ResponseBuilder rb = Response.ok(); + rb.entity(cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()])); + return rb.build(); } @GET @@ -439,9 +453,11 @@ public Cartridge[] getAvailableSingleTenantCartridges() throws RestAPIException @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge[] getAvailableCartridges() throws RestAPIException { + public Response getAvailableCartridges() throws RestAPIException { List cartridges = ServiceUtils.getAvailableCartridges(null, null, getConfigContext()); - return cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()]); + ResponseBuilder rb = Response.ok(); + rb.entity(cartridges.isEmpty() ? new Cartridge[0] : cartridges.toArray(new Cartridge[cartridges.size()])); + return rb.build(); } @GET @@ -449,10 +465,25 @@ public Cartridge[] getAvailableCartridges() throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge[] getSubscribedCartridges() throws RestAPIException { - List cartridgeList = ServiceUtils.getSubscriptions(null, getConfigContext()); + public Response getSubscribedCartridges() throws RestAPIException { + List cartridgeList = ServiceUtils.getSubscriptions(null,null, 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(); + } + + @GET + @Path("/cartridge/list/subscribed/group/{serviceGroup}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getSubscribedCartridgesForServiceGroup(@PathParam("serviceGroup") String serviceGroup) throws RestAPIException { + List cartridgeList = ServiceUtils.getSubscriptions(null, serviceGroup, getConfigContext()); // Following is very important when working with axis2 - return cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()]); + ResponseBuilder rb = Response.ok(); + rb.entity(cartridgeList.isEmpty() ? new Cartridge[0] : cartridgeList.toArray(new Cartridge[cartridgeList.size()])); + return rb.build(); } @GET @@ -460,8 +491,10 @@ public Cartridge[] getSubscribedCartridges() throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge getCartridgeInfo(@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException { - return ServiceUtils.getSubscription(subscriptionAlias, getConfigContext()); + public Response getCartridgeInfo(@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException { + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getSubscription(subscriptionAlias, getConfigContext())); + return rb.build(); } @GET @@ -469,9 +502,11 @@ public Cartridge getCartridgeInfo(@PathParam("subscriptionAlias") String subscri @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cartridge getAvailableSingleTenantCartridgeInfo(@PathParam("cartridgeType") String cartridgeType) + public Response getAvailableSingleTenantCartridgeInfo(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - return ServiceUtils.getAvailableCartridgeInfo(cartridgeType, null, getConfigContext()); + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getAvailableCartridgeInfo(cartridgeType, null, getConfigContext())); + return rb.build(); } @GET @@ -479,9 +514,8 @@ public Cartridge getAvailableSingleTenantCartridgeInfo(@PathParam("cartridgeType @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public List getAvailableLbCartridges() - throws RestAPIException { - return ServiceUtils.getAvailableLbCartridges(false, getConfigContext()); + public Response getAvailableLbCartridges() throws RestAPIException { + return Response.ok().entity(ServiceUtils.getAvailableLbCartridges(false, getConfigContext())).build(); } @GET @@ -489,9 +523,11 @@ public List getAvailableLbCartridges() @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public int getActiveInstances(@PathParam("cartridgeType") String cartridgeType, + public Response getActiveInstances(@PathParam("cartridgeType") String cartridgeType, @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException { - return ServiceUtils.getActiveInstances(cartridgeType, subscriptionAlias, getConfigContext()); + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getActiveInstances(cartridgeType, subscriptionAlias, getConfigContext())); + return rb.build(); } @POST @@ -499,12 +535,13 @@ public int getActiveInstances(@PathParam("cartridgeType") String cartridgeType, @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean) throws RestAPIException { + public Response subscribe(CartridgeInfoBean cartridgeInfoBean) throws RestAPIException { - return ServiceUtils.subscribeToCartridge(cartridgeInfoBean, + SubscriptionInfo subscriptionInfo= ServiceUtils.subscribe(cartridgeInfoBean, getConfigContext(), getUsername(), getTenantDomain()); + return Response.ok(subscriptionInfo).build(); } @GET @@ -512,9 +549,8 @@ public SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean) throws Re @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cluster[] getClustersForTenant() throws RestAPIException { - - return ServiceUtils.getClustersForTenant(getConfigContext()); + public Response getClustersForTenant() throws RestAPIException { + return Response.ok().entity(ServiceUtils.getClustersForTenant(getConfigContext())).build(); } @GET @@ -522,9 +558,22 @@ public Cluster[] getClustersForTenant() throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cluster[] getClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { + public Response getClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - return ServiceUtils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType); + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType)); + return rb.build(); + } + + @GET + @Path("/cluster/service/{cartridgeType}/") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getServiceClusters(@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getClustersForTenantAndCartridgeType(getConfigContext(), cartridgeType)); + return rb.build(); } @GET @@ -532,10 +581,11 @@ public Cluster[] getClusters(@PathParam("cartridgeType") String cartridgeType) t @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cluster getCluster(@PathParam("cartridgeType") String cartridgeType, + public Response getCluster(@PathParam("cartridgeType") String cartridgeType, @PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException, RestAPIException { - - return ServiceUtils.getCluster(cartridgeType, subscriptionAlias, getConfigContext()); + ResponseBuilder rb = Response.ok(); + rb.entity(ServiceUtils.getCluster(cartridgeType, subscriptionAlias, getConfigContext())); + return rb.build(); } @GET @@ -543,10 +593,10 @@ public Cluster getCluster(@PathParam("cartridgeType") String cartridgeType, @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Cluster getCluster(@PathParam("clusterId") String clusterId) throws RestAPIException { + public Response getCluster(@PathParam("clusterId") String clusterId) throws RestAPIException { Cluster cluster = null; if(log.isDebugEnabled()) { - log.debug("Finding the Cluster for [id]: "+clusterId); + log.debug("Finding cluster for [id]: "+clusterId); } Cluster[] clusters = ServiceUtils.getClustersForTenant(getConfigContext()); if(log.isDebugEnabled()) { @@ -561,17 +611,16 @@ public Cluster getCluster(@PathParam("clusterId") String clusterId) throws RestA break; } } - return cluster; + return Response.ok().entity(cluster).build(); } @POST @Path("/cartridge/unsubscribe") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public StratosAdminResponse unsubscribe(String alias) throws RestAPIException { - - return ServiceUtils.unsubscribe(alias, getTenantDomain()); - + public Response unsubscribe(String alias) throws RestAPIException { + ServiceUtils.unsubscribe(alias, getTenantDomain()); + return Response.noContent().build(); } @POST @@ -580,7 +629,7 @@ public StratosAdminResponse unsubscribe(String alias) throws RestAPIException { @Produces("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse addTenant(TenantInfoBean tenantInfoBean) throws RestAPIException { + public Response addTenant(TenantInfoBean tenantInfoBean) throws RestAPIException { try { CommonUtil.validateEmail(tenantInfoBean.getEmail()); } catch (Exception e) { @@ -655,9 +704,8 @@ public StratosAdminResponse addTenant(TenantInfoBean tenantInfoBean) throws Rest throw new RestAPIException(msg); } - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully added new tenant with domain " + tenantInfoBean.getTenantDomain()); - return stratosAdminResponse; + URI url = uriInfo.getAbsolutePathBuilder().path(tenant.getDomain()).build(); + return Response.created(url).build(); } @PUT @@ -665,18 +713,23 @@ public StratosAdminResponse addTenant(TenantInfoBean tenantInfoBean) throws Rest @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse updateTenant(TenantInfoBean tenantInfoBean) throws RestAPIException { + public Response updateTenant(TenantInfoBean tenantInfoBean) throws RestAPIException { try { - return updateExistingTenant(tenantInfoBean); - } catch (Exception e) { + updateExistingTenant(tenantInfoBean); + + } catch(TenantNotFoundException ex){ + Response.status(Response.Status.NOT_FOUND).build(); + }catch (Exception e) { String msg = "Error in updating tenant " + tenantInfoBean.getTenantDomain(); log.error(msg, e); throw new RestAPIException(msg); } + + return Response.noContent().build(); } - private StratosAdminResponse updateExistingTenant(TenantInfoBean tenantInfoBean) throws Exception { + private void updateExistingTenant(TenantInfoBean tenantInfoBean) throws Exception { TenantManager tenantManager = ServiceHolder.getTenantManager(); UserStoreManager userStoreManager; @@ -704,7 +757,7 @@ private StratosAdminResponse updateExistingTenant(TenantInfoBean tenantInfoBean) String msg = "Error in retrieving the tenant id for the tenant domain: " + tenantDomain + "."; log.error(msg, e); - throw new Exception(msg, e); + throw new TenantNotFoundException(msg,e); } // filling the first and last name values @@ -795,10 +848,6 @@ private StratosAdminResponse updateExistingTenant(TenantInfoBean tenantInfoBean) log.error(msg, e); throw new Exception(msg, e); } - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully updated the tenant " + tenantDomain); - return stratosAdminResponse; } @GET @@ -867,7 +916,7 @@ private TenantInfoBean getTenantForDomain (String tenantDomain) throws Exception @Produces("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deleteTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { + public Response deleteTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); int tenantId = 0; try { @@ -875,7 +924,8 @@ public StratosAdminResponse deleteTenant(@PathParam("tenantDomain") String tenan } catch (org.wso2.carbon.user.api.UserStoreException e) { String msg = "Error in deleting tenant " + tenantDomain; log.error(msg, e); - throw new RestAPIException(msg); + //throw new RestAPIException(msg); + return Response.status(Response.Status.NOT_FOUND).build(); } try { //TODO: billing related info cleanup @@ -891,9 +941,7 @@ public StratosAdminResponse deleteTenant(@PathParam("tenantDomain") String tenan throw new RestAPIException(msg); } - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deleted tenant " + tenantDomain); - return stratosAdminResponse; + return Response.noContent().build(); } @GET @@ -936,7 +984,7 @@ public TenantInfoBean[] retrievePartialSearchTenants(@PathParam("domain")String @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse activateTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { + public Response activateTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); int tenantId; try { @@ -952,8 +1000,6 @@ public StratosAdminResponse activateTenant(@PathParam("tenantDomain") String ten throw new RestAPIException( e); } - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - try { TenantMgtUtil.activateTenant(tenantDomain, tenantManager, tenantId); @@ -970,8 +1016,7 @@ public StratosAdminResponse activateTenant(@PathParam("tenantDomain") String ten throw new RestAPIException(msg, e); } - stratosAdminResponse.setMessage("Successfully activated tenant " + tenantDomain); - return stratosAdminResponse; + return Response.noContent().build(); } @POST @@ -979,15 +1024,16 @@ public StratosAdminResponse activateTenant(@PathParam("tenantDomain") String ten @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public boolean isDomainAvailable(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { + public Response isDomainAvailable(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { + boolean available; try { - return CommonUtil.isDomainNameAvailable(tenantDomain); + available = CommonUtil.isDomainNameAvailable(tenantDomain); } catch (Exception e) { String msg = "Error in checking domain " + tenantDomain + " is available"; log.error(msg, e); throw new RestAPIException(msg); } - + return Response.ok(available).build(); } @POST @@ -995,7 +1041,7 @@ public boolean isDomainAvailable(@PathParam("tenantDomain") String tenantDomain) @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse deactivateTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { + public Response deactivateTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException { TenantManager tenantManager = ServiceHolder.getTenantManager(); int tenantId; @@ -1013,8 +1059,6 @@ public StratosAdminResponse deactivateTenant(@PathParam("tenantDomain") String t throw new RestAPIException( e); } - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - try { TenantMgtUtil.deactivateTenant(tenantDomain, tenantManager, tenantId); } catch (Exception e) { @@ -1030,8 +1074,7 @@ public StratosAdminResponse deactivateTenant(@PathParam("tenantDomain") String t throw new RestAPIException(msg, e); } - stratosAdminResponse.setMessage("Successfully deactivated tenant " + tenantDomain); - return stratosAdminResponse; + return Response.noContent().build(); } @POST @@ -1040,16 +1083,19 @@ public StratosAdminResponse deactivateTenant(@PathParam("tenantDomain") String t @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse 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 ServiceUtils.deployService(serviceDefinitionBean.getCartridgeType(), UUID.randomUUID().toString(), serviceDefinitionBean.getAutoscalingPolicyName(), + ServiceUtils.deployService(serviceDefinitionBean.getCartridgeType(), UUID.randomUUID().toString(), serviceDefinitionBean.getAutoscalingPolicyName(), serviceDefinitionBean.getDeploymentPolicyName(), getTenantDomain(), getUsername(), getTenantId(), serviceDefinitionBean.getClusterDomain(), serviceDefinitionBean.getClusterSubDomain(), serviceDefinitionBean.getTenantRange()); + + URI url = uriInfo.getAbsolutePathBuilder().path(serviceDefinitionBean.getServiceName()).build(); + return Response.created(url).build(); } @GET @@ -1068,9 +1114,15 @@ public ServiceDefinitionBean[] getServices() throws RestAPIException { @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public ServiceDefinitionBean getService(@PathParam("serviceType") String serviceType)throws RestAPIException { - - return ServiceUtils.getDeployedServiceInformation(serviceType); + public Response getService(@PathParam("serviceType") String serviceType)throws RestAPIException { + ResponseBuilder rb; + ServiceDefinitionBean serviceDefinitionBean = ServiceUtils.getDeployedServiceInformation(serviceType); + if(serviceDefinitionBean == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok(serviceDefinitionBean); + } + return rb.build(); } @GET @@ -1089,10 +1141,13 @@ public List getActiveService()throws RestAPIException { @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) - public StratosAdminResponse unDeployService (@PathParam("serviceType") String serviceType) - throws RestAPIException { - - return ServiceUtils.undeployService(serviceType); + public Response unDeployService (@PathParam("serviceType") String serviceType) throws RestAPIException { + try { + ServiceUtils.undeployService(serviceType); + } catch (ServiceDoesNotExistException e) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.noContent().build(); } @POST @@ -1100,16 +1155,17 @@ public StratosAdminResponse unDeployService (@PathParam("serviceType") String se @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public void getRepoNotification(Payload payload) throws RestAPIException { + public Response getRepoNotification(Payload payload) throws RestAPIException { ServiceUtils.getGitRepositoryNotification(payload); + return Response.noContent().build(); } @POST @Path("/cartridge/sync") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public StratosAdminResponse synchronizeRepository(String alias) throws RestAPIException { + public Response synchronizeRepository(String alias) throws RestAPIException { if (log.isDebugEnabled()) { log.debug(String.format("Synchronizing Git repository for alias '%s'", alias)); } @@ -1118,7 +1174,8 @@ public StratosAdminResponse synchronizeRepository(String alias) throws RestAPIEx log.debug(String.format("Found subscription for '%s'. Git repository: %s", alias, cartridgeSubscription .getRepository().getUrl())); } - return ServiceUtils.synchronizeRepository(cartridgeSubscription); + ServiceUtils.synchronizeRepository(cartridgeSubscription); + return Response.noContent().build(); } private List getAllTenants() throws RestAPIException { @@ -1159,4 +1216,80 @@ private List searchPartialTenantsDomains(String domain) throws R } return tenantList; } + + @POST + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domains") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType, + + @PathParam("subscriptionAlias") String subscriptionAlias, + SubscriptionDomainRequest request) throws RestAPIException { + ServiceUtils.addSubscriptionDomains(getConfigContext(), cartridgeType, subscriptionAlias, request); + return Response.noContent().build(); + } + + @GET + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domains") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getSubscriptionDomains(@PathParam("cartridgeType") String cartridgeType,@PathParam("subscriptionAlias") String subscriptionAlias) throws RestAPIException { + + SubscriptionDomainBean[] subscriptionDomainBean = ServiceUtils.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(); + } + } + + @GET + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domains/{domainName}") + @Consumes("application/json") + @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 = ServiceUtils.getSubscriptionDomain(getConfigContext(), cartridgeType, subscriptionAlias, domainName); + if(subscriptionDomainBean.domainName == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + }else{ + return Response.ok().entity(subscriptionDomainBean).build(); + } + } + + @DELETE + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/domains/{domainName}") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response removeSubscriptionDomain(@PathParam("cartridgeType") String cartridgeType, + @PathParam("subscriptionAlias") String subscriptionAlias, + @PathParam("domainName") String domainName) throws RestAPIException { + try { + ServiceUtils.removeSubscriptionDomain(getConfigContext(), cartridgeType, subscriptionAlias, domainName); + } catch (DomainMappingExistsException e) { + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.noContent().build(); + } + + @GET + @Path("/cartridge/{cartridgeType}/subscription/{subscriptionAlias}/load-balancer-cluster") + @Consumes("application/json") + @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 = ServiceUtils.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)) { + Response.fromResponse(getCluster(lbClusterId)); + } + return Response.status(Response.Status.NOT_FOUND).build(); + } } From bc7f7b249d2f40543c127d6f564ce2d5dd3a9d3d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 14:53:51 +0530 Subject: [PATCH 029/436] merging manager component --- components/org.apache.stratos.manager/pom.xml | 6 +++ .../DomainSubscriptionDoesNotExist.java | 48 +++++++++++++++++++ .../publisher/TenantSynzhronizerTask.java | 35 +++++++++++--- .../subscription/SubscriptionDomain.java | 48 +++++++++++++++++++ .../event/tenant/TenantUnSubscribedEvent.java | 10 +++- 5 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.java diff --git a/components/org.apache.stratos.manager/pom.xml b/components/org.apache.stratos.manager/pom.xml index 3c24303021..7481745676 100644 --- a/components/org.apache.stratos.manager/pom.xml +++ b/components/org.apache.stratos.manager/pom.xml @@ -114,6 +114,12 @@ org.apache.stratos.messaging ${project.version} + + org.apache.stratos + org.apache.stratos.tenant.mgt + ${project.version} + provided + diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java new file mode 100644 index 0000000000..fbef4a852f --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.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.exception; + +public class DomainSubscriptionDoesNotExist extends Exception { + + private static final long serialVersionUID = 1L; + + private final String message; + + private final String subscriptionDomain; + + public DomainSubscriptionDoesNotExist(String message, String subscriptionDomain, Throwable cause) { + super(message, cause); + this.message = message; + this.subscriptionDomain = subscriptionDomain; + } + + public DomainSubscriptionDoesNotExist(String message, String subscriptionDomain) { + super(message); + this.message = message; + this.subscriptionDomain = subscriptionDomain; + } + + public String getMessage() { + return message; + } + + public String getSubscriptionDomain() { + return subscriptionDomain; + } +} 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 index 3eac3f5a75..81ec432568 100644 --- 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 @@ -21,21 +21,22 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.TenantInfoBean; 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.Constants; +import org.apache.stratos.tenant.mgt.util.TenantMgtUtil; import org.wso2.carbon.ntask.core.Task; import org.wso2.carbon.user.core.tenant.TenantManager; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; +import java.util.*; /** * Tenant synchronizer task for publishing complete tenant event periodically @@ -65,18 +66,38 @@ public void execute() { 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 cartridgeSubscriptions = PersistenceManager.getSubscriptionsForTenant(tenant.getTenantId()); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Collection cartridgeSubscriptions = new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenant.getTenantId()); if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) { - for (CartridgeSubscription subscription : cartridgeSubscriptions) { + 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(), subscription.getType())); + carbonTenant.getId(), carbonTenant.getDomain(), cartridgeSubscription.getType())); + } + HashSet clusterIds = new HashSet(); + clusterIds.add(cartridgeSubscription.getCluster().getClusterDomain()); + Subscription subscription = new Subscription(cartridgeSubscription.getType(), clusterIds); + for(SubscriptionDomain subscriptionDomain : cartridgeSubscription.getSubscriptionDomains()) { + subscription.addSubscriptionDomain(subscriptionDomain.getDomainName(), subscriptionDomain.getApplicationContext()); } - tenant.addServiceSubscription(subscription.getType()); + tenant.addSubscription(subscription); } } tenants.add(tenant); 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 new file mode 100644 index 0000000000..9fed0b023c --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/SubscriptionDomain.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.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()); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantUnSubscribedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantUnSubscribedEvent.java index 2262cd4dc6..5cfcfdf577 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantUnSubscribedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/tenant/TenantUnSubscribedEvent.java @@ -20,6 +20,8 @@ package org.apache.stratos.messaging.event.tenant; import java.io.Serializable; +import java.util.Collections; +import java.util.Set; /** * This event is fired when a tenant is un-subscribed from a service. @@ -29,10 +31,12 @@ public class TenantUnSubscribedEvent extends TenantEvent implements Serializable private final int tenantId; private final String serviceName; + private final Set clusterIds; - public TenantUnSubscribedEvent(int tenantId, String serviceName) { + public TenantUnSubscribedEvent(int tenantId, String serviceName, Set clusterIds) { this.tenantId = tenantId; this.serviceName = serviceName; + this.clusterIds = clusterIds; } public int getTenantId() { @@ -42,4 +46,8 @@ public int getTenantId() { public String getServiceName() { return serviceName; } + + public Set getClusterIds() { + return Collections.unmodifiableSet(clusterIds); + } } From 92f26acbc976d03a4c328b7b8181036f877092bb Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 16:26:52 +0530 Subject: [PATCH 030/436] messaging component merging --- .../event/topology/MemberActivatedEvent.java | 7 +------ .../event/topology/MemberTerminatedEvent.java | 8 +------- .../bean/util/converter/PojoConverter.java | 8 +------- .../rest/endpoint/services/ServiceUtils.java | 14 -------------- .../rest/endpoint/services/StratosAdmin.java | 9 --------- 5 files changed, 3 insertions(+), 43 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java index 23ef560c03..20d1273f94 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java @@ -21,16 +21,11 @@ import java.io.Serializable; import java.util.*; -<<<<<<< HEAD - import org.apache.stratos.messaging.domain.topology.Port; - -import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.Map; -======= ->>>>>>> master + /** * This event is fired by Cloud Controller when a member has started it's server and diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java index e0c050307c..42f6d5f885 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberTerminatedEvent.java @@ -34,10 +34,7 @@ private final String networkPartitionId; private final String partitionId; private final String memberId; -<<<<<<< HEAD private String groupId; -======= ->>>>>>> master private Properties properties; @@ -68,8 +65,6 @@ public String getMemberId() { public String getNetworkPartitionId() { return networkPartitionId; } - -<<<<<<< HEAD public String getGroupId() { return groupId; } @@ -77,8 +72,7 @@ public String getGroupId() { public void setGroupId(String groupId) { this.groupId = groupId; } -======= ->>>>>>> master + public Properties getProperties() { return properties; } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 68dec871d7..974c34d113 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -19,10 +19,7 @@ package org.apache.stratos.rest.endpoint.bean.util.converter; -<<<<<<< HEAD import org.apache.commons.logging.LogFactory; -======= ->>>>>>> master import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.deploy.service.Service; @@ -153,11 +150,8 @@ private static IaasConfig[] getIaasConfigsAsArray (List iaasPr return iaasConfigsArray; } -<<<<<<< HEAD - public static Persistence getPersistence(PersistenceBean persistenceBean) { -======= public static Persistence getPersistence(PersistenceBean persistenceBean) { ->>>>>>> master + Persistence persistence = new Persistence(); persistence.setPersistanceRequired(persistenceBean.isRequired); VolumeBean[] volumeBean = new VolumeBean[persistenceBean.volume.size()]; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 0654c35fdb..a2c2491fab 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -24,28 +24,22 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -<<<<<<< HEAD import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; import org.apache.stratos.cloud.controller.stub.pojo.Property; -======= ->>>>>>> master import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; -<<<<<<< HEAD import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.composite.application.CompositeApplicationManager; -======= import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Property; ->>>>>>> master import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.service.Service; @@ -1170,10 +1164,6 @@ static SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean, Configura subscriptionData.setRepositoryPassword(cartridgeInfoBean.getRepoPassword()); subscriptionData.setCommitsEnabled(cartridgeInfoBean.isCommitsEnabled()); subscriptionData.setServiceGroup(cartridgeInfoBean.getServiceGroup()); -<<<<<<< HEAD - -======= ->>>>>>> master PersistenceBean persistenceBean = cartridgeInfoBean.getPersistence(); if(persistenceBean != null) { @@ -1202,10 +1192,6 @@ static SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean, Configura subscriptionData.setPersistanceCtxt(persistenceContext); } */ -<<<<<<< HEAD - -======= ->>>>>>> master //subscribe SubscriptionInfo subscriptionInfo = null; try{ diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index e50214ede9..2759ad476b 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -30,10 +30,7 @@ import org.apache.stratos.manager.dto.SubscriptionInfo; import org.apache.stratos.manager.exception.DomainMappingExistsException; import org.apache.stratos.manager.exception.ServiceDoesNotExistException; -<<<<<<< HEAD import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; -======= ->>>>>>> master import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.rest.endpoint.ServiceHolder; @@ -74,10 +71,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; -<<<<<<< HEAD -======= ->>>>>>> master import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -252,7 +246,6 @@ public Response unDeployCartridgeDefinition (@PathParam("cartridgeType") String ServiceUtils.undeployCartridge(cartridgeType); return Response.noContent().build(); -<<<<<<< HEAD } @POST @@ -291,8 +284,6 @@ public Response undeployServiceGroupDefinition (@PathParam("groupDefinitionName" ServiceUtils.undeployServiceGroupDefinition(groupDefinitionName); return Response.noContent().build(); -======= ->>>>>>> master } @POST From 7a2dc588c98ab738ce73fb24f545e2ce0faf3f9f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 17:06:06 +0530 Subject: [PATCH 031/436] merging DomainSubscriptionDoesNotExist and CartridgeInfoBean classes --- .../DomainSubscriptionDoesNotExist.java | 27 ------------------- .../manager/CartridgeSubscriptionManager.java | 21 +-------------- .../rest/endpoint/bean/CartridgeInfoBean.java | 21 --------------- 3 files changed, 1 insertion(+), 68 deletions(-) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java index 69ab506944..2e4e366fed 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/DomainSubscriptionDoesNotExist.java @@ -20,7 +20,6 @@ public class DomainSubscriptionDoesNotExist extends Exception { -<<<<<<< HEAD private static final long serialVersionUID = 1L; private final String message; @@ -46,31 +45,5 @@ public String getMessage() { public String getSubscriptionDomain() { return subscriptionDomain; } -======= - private static final long serialVersionUID = 1L; - private final String message; - - private final String subscriptionDomain; - - public DomainSubscriptionDoesNotExist(String message, String subscriptionDomain, Throwable cause) { - super(message, cause); - this.message = message; - this.subscriptionDomain = subscriptionDomain; - } - - public DomainSubscriptionDoesNotExist(String message, String subscriptionDomain) { - super(message); - this.message = message; - this.subscriptionDomain = subscriptionDomain; - } - - public String getMessage() { - return message; - } - - public String getSubscriptionDomain() { - return subscriptionDomain; - } ->>>>>>> master } 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 index 391aec6eee..86206fe7f2 100644 --- 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 @@ -21,10 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.openjpa.util.java$util$ArrayList$proxy; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.deploy.service.Service; @@ -35,14 +31,11 @@ import org.apache.stratos.manager.repository.Repository; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import org.apache.stratos.manager.subscriber.Subscriber; -<<<<<<< HEAD import org.apache.stratos.manager.subscription.*; -======= import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.subscription.PersistenceContext; import org.apache.stratos.manager.subscription.SubscriptionData; import org.apache.stratos.manager.subscription.SubscriptionDomain; ->>>>>>> master import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory; import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour; import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour; @@ -434,18 +427,7 @@ private CartridgeSubscription subscribe (SubscriptionData subscriptionData, Cart }else { // Generate and set the key subscriptionKey = CartridgeSubscriptionUtils.generateSubscriptionKey(); -<<<<<<< HEAD - } - - cartridgeSubscription.setSubscriptionKey(subscriptionKey); - if(log.isDebugEnabled()) { - log.debug("Repository with url: " + subscriptionData.getRepositoryURL() + - " username: " + subscriptionData.getRepositoryUsername() + - " Type: " + subscriptionData.getRepositoryType()); - } - -======= } cartridgeSubscription.setSubscriptionKey(subscriptionKey); @@ -455,8 +437,7 @@ private CartridgeSubscription subscribe (SubscriptionData subscriptionData, Cart " username: " + subscriptionData.getRepositoryUsername() + " Type: " + subscriptionData.getRepositoryType()); } - ->>>>>>> master + // Create subscriber Subscriber subscriber = new Subscriber(subscriptionData.getTenantAdminUsername(), subscriptionData.getTenantId(), subscriptionData.getTenantDomain()); cartridgeSubscription.setSubscriber(subscriber); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java index 52973c0329..6d67fe1716 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/CartridgeInfoBean.java @@ -20,10 +20,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PersistenceBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.PropertyBean; -<<<<<<< HEAD - -======= ->>>>>>> master import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; @@ -41,24 +37,17 @@ public class CartridgeInfoBean { String dataCartridgeType; String dataCartridgeAlias; boolean commitsEnabled; -<<<<<<< HEAD -======= ->>>>>>> master private String serviceGroup; private PersistenceBean persistence; private List property; -<<<<<<< HEAD - public CartridgeInfoBean() { -======= private List domains; public CartridgeInfoBean() { this.domains = new ArrayList(); ->>>>>>> master } public String getCartridgeType() { @@ -161,13 +150,8 @@ public PersistenceBean getPersistence() { return persistence; } -<<<<<<< HEAD - public void setPersistence(PersistenceBean persistenceBean) { - this.persistence = persistenceBean; -======= public void setPersistence(PersistenceBean persistence) { this.persistence = persistence; ->>>>>>> master } public List getProperty() { @@ -177,12 +161,7 @@ public List getProperty() { public void setProperty(List property) { this.property = property; } -<<<<<<< HEAD -======= - public List getDomains() { return domains; } public void setDomains(List domains) { this.domains = domains; } - ->>>>>>> master } From 317858007f6fb12970db29ec5ef39bcf0ea99a81 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 17:18:03 +0530 Subject: [PATCH 032/436] merging HealthStatisticsReader and CartridgeAgent --- .../cartridge/agent/CartridgeAgent.java | 54 +-------- .../publisher/HealthStatisticsReader.java | 112 ++++++++---------- 2 files changed, 51 insertions(+), 115 deletions(-) diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java index b73db36aa9..a69aa7a932 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/CartridgeAgent.java @@ -154,14 +154,11 @@ public void run() { if (log.isInfoEnabled()) { log.info("No artifact repository found"); } -<<<<<<< HEAD -======= // Execute instance activated shell script extensionHandler.onInstanceActivatedEvent(); // Publish instance activated event CartridgeAgentEventPublisher.publishInstanceActivatedEvent(); ->>>>>>> master } else { //Start periodical file checker task /*if (CartridgeAgentConfiguration.getInstance().isCommitsEnabled()) { @@ -620,59 +617,10 @@ private static void publishLogs(LogPublisherManager logPublisherManager) { } } -<<<<<<< HEAD - private void onArtifactUpdateEvent(ArtifactUpdatedEvent event) { - ArtifactUpdatedEvent artifactUpdatedEvent = event; - if(log.isInfoEnabled()) { - log.info(String.format("Artifact update event received: %s", artifactUpdatedEvent.toString())); - } - - String clusterIdInPayload = CartridgeAgentConfiguration.getInstance().getClusterId(); - String localRepoPath = CartridgeAgentConfiguration.getInstance().getAppPath(); - String clusterIdInMessage = artifactUpdatedEvent.getClusterId(); - String repoURL = artifactUpdatedEvent.getRepoURL(); - String repoPassword = CartridgeAgentUtils.decryptPassword(artifactUpdatedEvent.getRepoPassword()); - String repoUsername = artifactUpdatedEvent.getRepoUserName(); - String tenantId = artifactUpdatedEvent.getTenantId(); - boolean isMultitenant = CartridgeAgentConfiguration.getInstance().isMultitenant(); - - if(StringUtils.isNotEmpty(repoURL) && (clusterIdInPayload != null) && clusterIdInPayload.equals(clusterIdInMessage)) { - if(log.isInfoEnabled()) { - log.info("Executing git checkout"); - } - RepositoryInformation repoInformation = new RepositoryInformation(); - repoInformation.setRepoUsername(repoUsername); - if(repoPassword == null) { - repoInformation.setRepoPassword(""); - }else { - repoInformation.setRepoPassword(repoPassword); - } - repoInformation.setRepoUrl(repoURL); - repoInformation.setRepoPath(localRepoPath); - repoInformation.setTenantId(tenantId); - repoInformation.setMultitenant(isMultitenant); - boolean cloneExists = GitBasedArtifactRepository.getInstance().cloneExists(repoInformation); - GitBasedArtifactRepository.getInstance().checkout(repoInformation); - - ExtensionUtils.executeArtifactsUpdatedExtension(); - - if (!cloneExists && portsActivated) { - // Executed git clone, publish instance activated event - CartridgeAgentEventPublisher.publishInstanceActivatedEvent(); - } - - // Start the artifact update task - boolean artifactUpdateEnabled = Boolean.parseBoolean(System.getProperty(CartridgeAgentConstants.ENABLE_ARTIFACT_UPDATE)); - if (artifactUpdateEnabled) { - - long artifactUpdateInterval = 10; - // get update interval - String artifactUpdateIntervalStr = System.getProperty(CartridgeAgentConstants.ARTIFACT_UPDATE_INTERVAL); -======= public static ExtensionHandler getExtensionHandler() { return extensionHandler; } ->>>>>>> master + public void terminate() { terminated = true; diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java index f934d0a4de..87a0e5ac3b 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java @@ -29,44 +29,27 @@ import java.io.FileInputStream; import java.io.IOException; import java.lang.management.ManagementFactory; -<<<<<<< HEAD import java.io.IOException; -======= import java.util.Scanner; ->>>>>>> master /** * Health statistics reader. */ -public class HealthStatisticsReader implements IHealthStatisticsReader { - +public class HealthStatisticsReader { private static final int MB = 1024 * 1024; private static final Log log = LogFactory.getLog(HealthStatisticsReader.class); -<<<<<<< HEAD - public boolean init() { - return true; - } - - public CartridgeStatistics getCartridgeStatistics() throws IOException { - OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); - double totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); - double usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); - double loadAvg = (double)osBean.getSystemLoadAverage(); - // assume system cores = available cores to JVM - int cores = osBean.getAvailableProcessors(); -======= public static double getMemoryConsumption() { - double totalMemory = 0, usedMemory = 0; - - if (isWindows()) { - OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); - totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); - usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); - } else { - String fName = "/proc/meminfo"; - try { - FileInputStream f = new FileInputStream(fName); + double totalMemory = 0, usedMemory = 0; + + if (isWindows()) { + OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); + usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); + } else { + String fName = "/proc/meminfo"; + try { + FileInputStream f = new FileInputStream(fName); /* $ cat /proc/meminfo * MemTotal: 2056964 kB @@ -74,54 +57,59 @@ public static double getMemoryConsumption() { * Buffers: 9776 kB * Cached: 127220 kB */ - Scanner scanner = new Scanner(f).useDelimiter("\\D+"); - try { - long memTotal = scanner.nextLong(); - long memFree = scanner.nextLong(); - long buffers = scanner.nextLong(); - long cached = scanner.nextLong(); - - totalMemory = memTotal; - usedMemory = memTotal - (memFree + buffers + cached); - } catch (Exception ex) { - log.error("Could not calculate memory usage.", ex); - } finally { - scanner.close(); - } - } catch (IOException ex) { - log.error("Could not calculate memory usage.", ex); - } - } - + Scanner scanner = new Scanner(f).useDelimiter("\\D+"); + try { + long memTotal = scanner.nextLong(); + long memFree = scanner.nextLong(); + long buffers = scanner.nextLong(); + long cached = scanner.nextLong(); + + totalMemory = memTotal; + usedMemory = memTotal - (memFree + buffers + cached); + } catch (Exception ex) { + log.error("Could not calculate memory usage.", ex); + } finally { + scanner.close(); + } + } catch (IOException ex) { + log.error("Could not calculate memory usage.", ex); + } + } + if(log.isDebugEnabled()) { - log.debug("Calculating memory consumption: [totalMemory] "+totalMemory+" [usedMemory] "+usedMemory); + log.debug("Calculating memory consumption: [totalMemory] "+totalMemory+" [usedMemory] "+usedMemory); } ->>>>>>> master double memoryConsumption = (usedMemory / totalMemory) * 100; - double loadAvgPercentage = (loadAvg/cores) * 100; + if(log.isDebugEnabled()) { + log.debug("Calculating memory consumption: [percentage] "+memoryConsumption); + } + return memoryConsumption; + } + + public static double getLoadAverage() { + double loadAvg = (double)ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); + // assume system cores = available cores to JVM + int cores = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); + + if(log.isDebugEnabled()) { + log.debug("Calculating load average consumption: [loadAverage] "+loadAvg+" [cores] "+cores); + } + double loadAvgPercentage = (loadAvg/cores) * 100; if(log.isDebugEnabled()) { - log.debug("Memory consumption: [totalMemory] "+totalMemory+"Mb [usedMemory] "+usedMemory+"Mb: "+memoryConsumption+"%"); - log.debug("Processor consumption: [loadAverage] "+loadAvg+" [cores] "+cores+": "+loadAvgPercentage+"%"); + log.debug("Calculating load average consumption: [percentage] "+loadAvgPercentage); } - - return (new CartridgeStatistics(memoryConsumption, loadAvgPercentage)); + return loadAvgPercentage; } public static boolean allPortsActive() { return CartridgeAgentUtils.checkPortsActive(CartridgeAgentConfiguration.getInstance().getListenAddress(), - CartridgeAgentConfiguration.getInstance().getPorts()); + CartridgeAgentConfiguration.getInstance().getPorts()); } -<<<<<<< HEAD - public void delete() { - } -} -======= - private static boolean isWindows() { String os = System.getProperty("os.name").toLowerCase(); return os.indexOf("win") >= 0; } } ->>>>>>> master + From 671165d805a2f05d8e3d856717340fd83d761d73 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 17:31:48 +0530 Subject: [PATCH 033/436] merging AbstractMonitor --- .../autoscaler/monitor/AbstractMonitor.java | 67 +++---------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java index d19694aeab..3d5ab2fe8e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java @@ -18,12 +18,11 @@ */ package org.apache.stratos.autoscaler.monitor; -<<<<<<< HEAD -======= +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; + import java.util.Map; import org.apache.commons.configuration.XMLConfiguration; ->>>>>>> master import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; @@ -46,14 +45,13 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ -<<<<<<< HEAD -abstract public class AbstractMonitor implements Runnable { + abstract public class AbstractMonitor implements Runnable{ - private static final Log log = LogFactory.getLog(AbstractMonitor.class); - // Map - protected Map networkPartitionCtxts; - protected DeploymentPolicy deploymentPolicy; - protected AutoscalePolicy autoscalePolicy; + private static final Log log = LogFactory.getLog(AbstractMonitor.class); + // Map + protected Map networkPartitionCtxts; + protected DeploymentPolicy deploymentPolicy; + protected AutoscalePolicy autoscalePolicy; protected FactHandle minCheckFactHandle; @@ -63,50 +61,6 @@ abstract public class AbstractMonitor implements Runnable { protected StatefulKnowledgeSession minCheckKnowledgeSession; protected StatefulKnowledgeSession scaleCheckKnowledgeSession; protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; - protected boolean isDestroyed; - - protected String clusterId; - protected String serviceId; - - protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; - - @Override - public void run() { - // TODO Auto-generated method stub - - } - - - public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { - log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); - String networkPartitionId = member.getNetworkPartitionId(); - if (networkPartitionCtxts.containsKey(networkPartitionId)) { - log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); - return networkPartitionCtxts.get(networkPartitionId); - } - log.info("returning null getNetworkPartitionCtxt"); - return null; - } - - public String getPartitionOfMember(String memberId) { - for (Service service : TopologyManager.getTopology().getServices()) { - for (Cluster cluster : service.getClusters()) { - if (cluster.memberExists(memberId)) { -======= - abstract public class AbstractMonitor implements Runnable{ - - private static final Log log = LogFactory.getLog(AbstractMonitor.class); - // Map - protected Map networkPartitionCtxts; - protected DeploymentPolicy deploymentPolicy; - protected AutoscalePolicy autoscalePolicy; - - - protected FactHandle minCheckFactHandle; - protected FactHandle scaleCheckFactHandle; - - protected StatefulKnowledgeSession minCheckKnowledgeSession; - protected StatefulKnowledgeSession scaleCheckKnowledgeSession; protected boolean isDestroyed; protected String clusterId; @@ -152,7 +106,6 @@ public String getPartitionOfMember(String memberId){ for(Service service: TopologyManager.getTopology().getServices()){ for(Cluster cluster: service.getClusters()){ if(cluster.memberExists(memberId)){ ->>>>>>> master return cluster.getMember(memberId).getPartitionId(); } } @@ -250,7 +203,6 @@ public void setMinCheckFactHandle(FactHandle minCheckFactHandle) { this.minCheckFactHandle = minCheckFactHandle; } -<<<<<<< HEAD public StatefulKnowledgeSession getTerminateDependencyKnowledgeSession() { return terminateDependencyKnowledgeSession; } @@ -269,10 +221,7 @@ public void setTerminateDependencyFactHandle( this.terminateDependencyFactHandle = terminateDependencyFactHandle; } - -======= public int getMonitorInterval() { return monitorInterval; } ->>>>>>> master } \ No newline at end of file From a29b2cd45e67cd15cca9a426ba38505451361633 Mon Sep 17 00:00:00 2001 From: Reka Date: Thu, 28 Aug 2014 18:05:13 +0530 Subject: [PATCH 034/436] merging master with messaging --- .../event/topology/MemberActivatedEvent.java | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java index 20d1273f94..94e04b08be 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/MemberActivatedEvent.java @@ -44,6 +44,7 @@ public class MemberActivatedEvent extends TopologyEvent implements Serializable private String memberIp; private String groupId; private String applicationId; + private String memberPublicIp; public MemberActivatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -51,9 +52,9 @@ public MemberActivatedEvent(String serviceName, String clusterId, String network this.networkPartitionId = networkPartitionId; this.partitionId = partitionId; this.memberId = memberId; - this.portMap = new HashMap(); + this.portMap = new HashMap(); } - + public String getServiceName() { return serviceName; } @@ -104,20 +105,20 @@ public boolean portExists(Port port) { } public String getMemberIp() { - return memberIp; + return memberIp; } - public void setMemberIp(String memberIp) { - this.memberIp = memberIp; + public void setMemberIp(String memberIp) { + this.memberIp = memberIp; } - public String getGroupId() { - return groupId; - } + public String getGroupId() { + return groupId; + } - public void setGroupId(String groupId) { - this.groupId = groupId; - } + public void setGroupId(String groupId) { + this.groupId = groupId; + } public String getApplicationId() { return applicationId; @@ -126,4 +127,12 @@ public String getApplicationId() { public void setApplicationId(String applicationId) { this.applicationId = applicationId; } + + public String getMemberPublicIp() { + return memberPublicIp; + } + + public void setMemberPublicIp(String memberPublicIp) { + this.memberPublicIp = memberPublicIp; + } } From 9f6c02e87f2f68ba21b9b1104dac23057e8fd886 Mon Sep 17 00:00:00 2001 From: Reka Date: Thu, 28 Aug 2014 18:08:52 +0530 Subject: [PATCH 035/436] merging cloud controller from master --- .../controller/iaases/OpenstackNovaIaas.java | 3 - .../impl/CloudControllerServiceImpl.java | 1289 ++++++++--------- .../controller/topology/TopologyBuilder.java | 438 +++--- .../topology/TopologyEventPublisher.java | 90 +- 4 files changed, 894 insertions(+), 926 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java index a9cf0dc90a..722b4b28b8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java @@ -583,10 +583,7 @@ private boolean waitForStatus(String volumeId, Volume.Status expectedStatus, int ComputeServiceContext context = iaasInfo.getComputeService().getContext();; RestContext nova = context.unwrap(); VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); -<<<<<<< HEAD VolumeAttachmentApi volumeAttachmentApi = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); -======= ->>>>>>> master Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); while(volumeStatus != expectedStatus){ diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index bb7dce7df8..151234cd62 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1,18 +1,18 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one + * 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 + * "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. */ @@ -61,95 +61,94 @@ /** * Cloud Controller Service is responsible for starting up new server instances, * terminating already started instances, providing pending instance count etc. - * + * */ public class CloudControllerServiceImpl implements CloudControllerService { - private static final Log log = LogFactory - .getLog(CloudControllerServiceImpl.class); - private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder - .getInstance(); - - public CloudControllerServiceImpl() { - // acquire serialized data from registry - acquireData(); - } - - private void acquireData() { - - Object obj = RegistryManager.getInstance().retrieve(); - if (obj != null) { - try { - Object dataObj = Deserializer - .deserializeFromByteArray((byte[]) obj); - if (dataObj instanceof FasterLookUpDataHolder) { - FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj; - FasterLookUpDataHolder currentData = FasterLookUpDataHolder - .getInstance(); - - // assign necessary data - currentData.setClusterIdToContext(serializedObj.getClusterIdToContext()); - currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); - currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); - currentData.setCartridges(serializedObj.getCartridges()); - currentData.setConfigCompositeApplication(serializedObj.getConfigCompositeApplication()); - - if(log.isDebugEnabled()) { - - log.debug("Cloud Controller Data is retrieved from registry."); - } - } else { - if(log.isDebugEnabled()) { - - log.debug("Cloud Controller Data cannot be found in registry."); - } - } - } catch (Exception e) { + private static final Log log = LogFactory + .getLog(CloudControllerServiceImpl.class); + private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder + .getInstance(); + + public CloudControllerServiceImpl() { + // acquire serialized data from registry + acquireData(); + } + + private void acquireData() { + + Object obj = RegistryManager.getInstance().retrieve(); + if (obj != null) { + try { + Object dataObj = Deserializer + .deserializeFromByteArray((byte[]) obj); + if (dataObj instanceof FasterLookUpDataHolder) { + FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj; + FasterLookUpDataHolder currentData = FasterLookUpDataHolder + .getInstance(); + + // assign necessary data + currentData.setClusterIdToContext(serializedObj.getClusterIdToContext()); + currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); + currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); + currentData.setCartridges(serializedObj.getCartridges()); + currentData.setConfigCompositeApplication(serializedObj.getConfigCompositeApplication()); + + if(log.isDebugEnabled()) { + + log.debug("Cloud Controller Data is retrieved from registry."); + } + } else { + if(log.isDebugEnabled()) { + + log.debug("Cloud Controller Data cannot be found in registry."); + } + } + } catch (Exception e) { + + String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected."; + log.warn(msg, e); + } - String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected."; - log.warn(msg, e); - } + } + // restore compostie application + List apps = restoreConfigCompositeApplication(); + if (apps == null) { + this.dataHolder.setConfigCompositeApplication(new ArrayList()); - } - // restore compostie application - List apps = restoreConfigCompositeApplication(); - if (apps == null) { - this.dataHolder.setConfigCompositeApplication(new ArrayList()); + } + } - } - } + public void deployCompositeApplicationDefinition(CompositeApplicationDefinition compositeApplicationDefinition) throws InvalidCompositeApplicationDefinitionException, + InvalidIaasProviderException { - public void deployCompositeApplicationDefinition(CompositeApplicationDefinition compositeApplicationDefinition) throws InvalidCompositeApplicationDefinitionException, - InvalidIaasProviderException { - - String alias = compositeApplicationDefinition.getAlias(); - if(log.isDebugEnabled()){ + String alias = compositeApplicationDefinition.getAlias(); + if(log.isDebugEnabled()){ log.debug("composite application alias : " + alias); - } - - ConfigCompositeApplication messConfigApp = TopologyBuilder.convertCompositeApplication(compositeApplicationDefinition); + } + + ConfigCompositeApplication messConfigApp = null;//TopologyBuilder.convertCompositeApplication(compositeApplicationDefinition); String key = "compositeApplicationAlias"; //app.getAlias() - - - List data = new ArrayList(); - data.add(messConfigApp); - dataHolder.setConfigCompositeApplication(data); - + + + List data = new ArrayList(); + data.add(messConfigApp); + dataHolder.setConfigCompositeApplication(data); + // persist persist(); - - if(log.isDebugEnabled()){ + + if(log.isDebugEnabled()){ log.debug("deploying composite application in cloud controller: " + compositeApplicationDefinition); } - - TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); + + TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); } - - public void unDeployCompositeApplicationDefinition(String appAlias) throws InvalidCompositeApplicationDefinitionException, - InvalidIaasProviderException { -<<<<<<< HEAD - if(log.isDebugEnabled()){ + + public void unDeployCompositeApplicationDefinition(String appAlias) throws InvalidCompositeApplicationDefinitionException, + InvalidIaasProviderException { + if(log.isDebugEnabled()){ log.debug("undeploying composite application in cloud controller, removing all composite apps "); dataHolder.removeAllConfigCompositeApplications(); persist(); @@ -157,10 +156,8 @@ public void unDeployCompositeApplicationDefinition(String appAlias) throws Inval } } - public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, - InvalidIaasProviderException { -======= ->>>>>>> master + public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, + InvalidIaasProviderException { if (cartridgeConfig == null) { String msg = "Invalid Cartridge Definition: Definition is null."; log.error(msg); @@ -177,43 +174,43 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In cartridge = CloudControllerUtil.toCartridge(cartridgeConfig); } catch (Exception e) { String msg = - "Invalid Cartridge Definition: Cartridge Type: " + - cartridgeConfig.getType()+ - ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage(); + "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType()+ + ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage(); log.error(msg, e); throw new InvalidCartridgeDefinitionException(msg, e); } List iaases = cartridge.getIaases(); - + if (iaases == null || iaases.isEmpty()) { String msg = - "Invalid Cartridge Definition: Cartridge Type: " + - cartridgeConfig.getType()+ - ". Cause: Iaases of this Cartridge is null or empty."; + "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType()+ + ". Cause: Iaases of this Cartridge is null or empty."; log.error(msg); throw new InvalidCartridgeDefinitionException(msg); } - + for (IaasProvider iaasProvider : iaases) { CloudControllerUtil.getIaas(iaasProvider); } - + // TODO transaction begins String cartridgeType = cartridge.getType(); if(dataHolder.getCartridge(cartridgeType) != null) { - Cartridge cartridgeToBeRemoved = dataHolder.getCartridge(cartridgeType); - // undeploy + Cartridge cartridgeToBeRemoved = dataHolder.getCartridge(cartridgeType); + // undeploy try { - undeployCartridgeDefinition(cartridgeToBeRemoved.getType()); - } catch (InvalidCartridgeTypeException e) { - //ignore - } + undeployCartridgeDefinition(cartridgeToBeRemoved.getType()); + } catch (InvalidCartridgeTypeException e) { + //ignore + } populateNewCartridge(cartridge, cartridgeToBeRemoved); } - + dataHolder.addCartridge(cartridge); - + // persist persist(); @@ -222,48 +219,48 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In TopologyBuilder.handleServiceCreated(cartridgeList); // transaction ends - + log.info("Successfully deployed the Cartridge definition: " + cartridgeType); } private void populateNewCartridge(Cartridge cartridge, - Cartridge cartridgeToBeRemoved) { - - List newIaasProviders = cartridge.getIaases(); - Map oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider(); - - for (String partitionId : oldPartitionToIaasMap.keySet()) { - IaasProvider oldIaasProvider = oldPartitionToIaasMap.get(partitionId); - if (newIaasProviders.contains(oldIaasProvider)) { - if (log.isDebugEnabled()) { - log.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " - + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() ); - } - cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider))); - } - } - - } + Cartridge cartridgeToBeRemoved) { + + List newIaasProviders = cartridge.getIaases(); + Map oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider(); + + for (String partitionId : oldPartitionToIaasMap.keySet()) { + IaasProvider oldIaasProvider = oldPartitionToIaasMap.get(partitionId); + if (newIaasProviders.contains(oldIaasProvider)) { + if (log.isDebugEnabled()) { + log.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " + + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() ); + } + cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider))); + } + } + + } - public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException { + public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException { Cartridge cartridge = null; if((cartridge = dataHolder.getCartridge(cartridgeType)) != null) { if (dataHolder.getCartridges().remove(cartridge)) { - // invalidate partition validation cache - dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType); - - if (log.isDebugEnabled()) { - log.debug("Partition cache invalidated for cartridge "+cartridgeType); - } - + // invalidate partition validation cache + dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType); + + if (log.isDebugEnabled()) { + log.debug("Partition cache invalidated for cartridge "+cartridgeType); + } + persist(); - + // sends the service removed event List cartridgeList = new ArrayList(); cartridgeList.add(cartridge); TopologyBuilder.handleServiceRemoved(cartridgeList); - + if(log.isInfoEnabled()) { log.info("Successfully undeployed the Cartridge definition: " + cartridgeType); } @@ -274,14 +271,14 @@ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCart log.error(msg); throw new InvalidCartridgeTypeException(msg); } - + @Override public MemberContext startInstance(MemberContext memberContext) throws - UnregisteredCartridgeException, InvalidIaasProviderException { + UnregisteredCartridgeException, InvalidIaasProviderException { - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:startInstance"); - } + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:startInstance"); + } if (memberContext == null) { String msg = "Instance start-up failed. Member is null."; @@ -293,7 +290,7 @@ public MemberContext startInstance(MemberContext memberContext) throws Partition partition = memberContext.getPartition(); if(log.isDebugEnabled()) { - log.debug("Received an instance spawn request : " + memberContext.toString()); + log.debug("Received an instance spawn request : " + memberContext.toString()); } ComputeService computeService = null; @@ -301,8 +298,8 @@ public MemberContext startInstance(MemberContext memberContext) throws if (partition == null) { String msg = - "Instance start-up failed. Specified Partition is null. " + - memberContext.toString(); + "Instance start-up failed. Specified Partition is null. " + + memberContext.toString(); log.error(msg); throw new IllegalArgumentException(msg); } @@ -322,8 +319,8 @@ public MemberContext startInstance(MemberContext memberContext) throws if (cartridge == null) { String msg = - "Instance start-up failed. No matching Cartridge found [type] "+cartridgeType +". "+ - memberContext.toString(); + "Instance start-up failed. No matching Cartridge found [type] "+cartridgeType +". "+ + memberContext.toString(); log.error(msg); throw new UnregisteredCartridgeException(msg); } @@ -333,20 +330,20 @@ public MemberContext startInstance(MemberContext memberContext) throws IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partitionId); if (iaasProvider == null) { - if (log.isDebugEnabled()) { - log.debug("IaasToPartitionMap "+cartridge.hashCode() - + " for cartridge "+cartridgeType+ " and for partition: "+partitionId); - } - String msg = "Instance start-up failed. " - + "There's no IaaS provided for the partition: " - + partitionId - + " and for the Cartridge type: " - + cartridgeType - + ". Only following " - + "partitions can be found in this Cartridge: " - + cartridge.getPartitionToIaasProvider().keySet() - .toString() + ". " + memberContext.toString() - + ". "; + if (log.isDebugEnabled()) { + log.debug("IaasToPartitionMap "+cartridge.hashCode() + + " for cartridge "+cartridgeType+ " and for partition: "+partitionId); + } + String msg = "Instance start-up failed. " + + "There's no IaaS provided for the partition: " + + partitionId + + " and for the Cartridge type: " + + cartridgeType + + ". Only following " + + "partitions can be found in this Cartridge: " + + cartridge.getPartitionToIaasProvider().keySet() + .toString() + ". " + memberContext.toString() + + ". "; log.fatal(msg); throw new InvalidIaasProviderException(msg); } @@ -362,7 +359,7 @@ public MemberContext startInstance(MemberContext memberContext) throws addToPayload(payload, "NETWORK_PARTITION_ID", memberContext.getNetworkPartitionId()); addToPayload(payload, "PARTITION_ID", partitionId); if(memberContext.getProperties() != null) { - org.apache.stratos.cloud.controller.pojo.Properties props1 = memberContext.getProperties(); + org.apache.stratos.cloud.controller.pojo.Properties props1 = memberContext.getProperties(); if (props1 != null) { for (Property prop : props1.getProperties()) { addToPayload(payload, prop.getName(), prop.getValue()); @@ -371,11 +368,11 @@ public MemberContext startInstance(MemberContext memberContext) throws } Iaas iaas = iaasProvider.getIaas(); - + if (log.isDebugEnabled()) { log.debug("Payload: " + payload.toString()); } - + if (iaas == null) { if(log.isDebugEnabled()) { log.debug("Iaas is null of Iaas Provider: "+type+". Trying to build IaaS..."); @@ -388,7 +385,7 @@ public MemberContext startInstance(MemberContext memberContext) throws log.error(msg, e); throw new InvalidIaasProviderException(msg, e); } - + } if(ctxt.isVolumeRequired()) { @@ -412,12 +409,12 @@ public MemberContext startInstance(MemberContext memberContext) throws // get the pre built ComputeService from provider or region or zone or host computeService = iaasProvider.getComputeService(); template = iaasProvider.getTemplate(); - + if (template == null) { String msg = - "Failed to start an instance. " + - memberContext.toString() + - ". Reason : Jclouds Template is null for iaas provider [type]: "+iaasProvider.getType(); + "Failed to start an instance. " + + memberContext.toString() + + ". Reason : Jclouds Template is null for iaas provider [type]: "+iaasProvider.getType(); log.error(msg); throw new InvalidIaasProviderException(msg); } @@ -430,31 +427,31 @@ public MemberContext startInstance(MemberContext memberContext) throws String group = str.replaceAll("[^a-z0-9-]", ""); NodeMetadata node; - - if (log.isDebugEnabled()) { - log.debug("Cloud Controller is delegating request to start an instance for " - + memberContext + " to Jclouds layer."); - } + + if (log.isDebugEnabled()) { + log.debug("Cloud Controller is delegating request to start an instance for " + + memberContext + " to Jclouds layer."); + } // create and start a node Set nodes = - computeService.createNodesInGroup(group, 1, - template); + computeService.createNodesInGroup(group, 1, + template); node = nodes.iterator().next(); - + if (log.isDebugEnabled()) { - log.debug("Cloud Controller received a response for the request to start " - + memberContext + " from Jclouds layer."); - } - - + log.debug("Cloud Controller received a response for the request to start " + + memberContext + " from Jclouds layer."); + } + + //Start allocating ip as a new job ThreadExecutor exec = ThreadExecutor.getInstance(); if (log.isDebugEnabled()) { - log.debug("Cloud Controller is starting the IP Allocator thread."); - } + log.debug("Cloud Controller is starting the IP Allocator thread."); + } exec.execute(new IpAllocator(memberContext, iaasProvider, cartridgeType, node)); @@ -465,40 +462,32 @@ public MemberContext startInstance(MemberContext memberContext) throws log.fatal(msg); throw new IllegalStateException(msg); } -<<<<<<< HEAD - memberContext.setNodeId(nodeId); - if(log.isDebugEnabled()) { - log.debug("Node id was set. "+memberContext.toString()); + + memberContext.setNodeId(nodeId); + if (log.isDebugEnabled()) { + log.debug("Node id was set. " + memberContext.toString()); + } + // attach volumes + if (ctxt.isVolumeRequired()) { + // remove region prefix + String instanceId = nodeId.indexOf('/') != -1 ? nodeId + .substring(nodeId.indexOf('/') + 1, nodeId.length()) + : nodeId; + memberContext.setInstanceId(instanceId); + if (ctxt.getVolumes() != null) { + for (Volume volume : ctxt.getVolumes()) { + try { + iaas.attachVolume(instanceId, volume.getId(), + volume.getDevice()); + } catch (Exception e) { + // continue without throwing an exception, since + // there is an instance already running + log.error("Attaching Volume " + volume.getId() + " to Instance [ " + + instanceId + " ] failed!", e); + } + } } -======= - - memberContext.setNodeId(nodeId); - if (log.isDebugEnabled()) { - log.debug("Node id was set. " + memberContext.toString()); - } ->>>>>>> master - - // attach volumes - if (ctxt.isVolumeRequired()) { - // remove region prefix - String instanceId = nodeId.indexOf('/') != -1 ? nodeId - .substring(nodeId.indexOf('/') + 1, nodeId.length()) - : nodeId; - memberContext.setInstanceId(instanceId); - if (ctxt.getVolumes() != null) { - for (Volume volume : ctxt.getVolumes()) { - try { - iaas.attachVolume(instanceId, volume.getId(), - volume.getDevice()); - } catch (Exception e) { - // continue without throwing an exception, since - // there is an instance already running - log.error("Attaching Volume " + volume.getId() + " to Instance [ " - + instanceId + " ] failed!", e); - } - } - } - } + } log.info("Instance is successfully starting up. "+memberContext.toString()); @@ -512,12 +501,12 @@ public MemberContext startInstance(MemberContext memberContext) throws } - private void createVolumeAndSetInClusterContext(Volume volume, - IaasProvider iaasProvider) { - // iaas cannot be null at this state #startInstance method - Iaas iaas = iaasProvider.getIaas(); - int sizeGB = volume.getSize(); - String snapshotId = volume.getSnapshotId(); + private void createVolumeAndSetInClusterContext(Volume volume, + IaasProvider iaasProvider) { + // iaas cannot be null at this state #startInstance method + Iaas iaas = iaasProvider.getIaas(); + int sizeGB = volume.getSize(); + String snapshotId = volume.getSnapshotId(); if(StringUtils.isNotEmpty(volume.getVolumeId())){ // volumeID is specified, so not creating additional volumes if(log.isDebugEnabled()){ @@ -528,67 +517,67 @@ private void createVolumeAndSetInClusterContext(Volume volume, String volumeId = iaas.createVolume(sizeGB, snapshotId); volume.setId(volumeId); } - - volume.setIaasType(iaasProvider.getType()); - } + + volume.setIaasType(iaasProvider.getType()); + } private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) { - StringBuilder persistencePayload = new StringBuilder(); - if(isPersistenceMappingAvailable(ctx)){ - for(Volume volume : ctx.getVolumes()){ - if(log.isDebugEnabled()){ - log.debug("Adding persistence mapping " + volume.toString()); - } + StringBuilder persistencePayload = new StringBuilder(); + if(isPersistenceMappingAvailable(ctx)){ + for(Volume volume : ctx.getVolumes()){ + if(log.isDebugEnabled()){ + log.debug("Adding persistence mapping " + volume.toString()); + } if(persistencePayload.length() != 0) { - persistencePayload.append("|"); + persistencePayload.append("|"); } - - persistencePayload.append(iaas.getIaasDevice(volume.getDevice())); - persistencePayload.append("|"); + + persistencePayload.append(iaas.getIaasDevice(volume.getDevice())); + persistencePayload.append("|"); persistencePayload.append(volume.getId()); persistencePayload.append("|"); persistencePayload.append(volume.getMappingPath()); - } - } + } + } if(log.isDebugEnabled()){ log.debug("Persistence payload is" + persistencePayload.toString()); } System.out.println("****** " + persistencePayload); - return persistencePayload; - } + return persistencePayload; + } - private boolean isPersistenceMappingAvailable(ClusterContext ctx) { - return ctx.getVolumes() != null && ctx.isVolumeRequired(); - } + private boolean isPersistenceMappingAvailable(ClusterContext ctx) { + return ctx.getVolumes() != null && ctx.isVolumeRequired(); + } - private void addToPayload(StringBuilder payload, String name, String value) { - payload.append(","); + private void addToPayload(StringBuilder payload, String name, String value) { + payload.append(","); payload.append(name+"=" + value); } /** - * Persist data in registry. - */ - private void persist() { - try { - RegistryManager.getInstance().persist( - dataHolder); - } catch (RegistryException e) { - - String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; - log.fatal(msg); - throw new CloudControllerException(msg, e); - } - } + * Persist data in registry. + */ + private void persist() { + try { + RegistryManager.getInstance().persist( + dataHolder); + } catch (RegistryException e) { + + String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; + log.fatal(msg); + throw new CloudControllerException(msg, e); + } + } private String generateMemberId(String clusterId) { UUID memberId = UUID.randomUUID(); - return clusterId + memberId.toString(); + return clusterId + memberId.toString(); } @Override - public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException + public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException { if(memberId == null) { @@ -596,20 +585,20 @@ public void terminateInstance(String memberId) throws InvalidMemberException, In log.error(msg); throw new IllegalArgumentException(msg); } - + MemberContext ctxt = dataHolder.getMemberContextOfMemberId(memberId); - + if(ctxt == null) { String msg = "Termination failed. Invalid Member Id: "+memberId; log.error(msg); throw new InvalidMemberException(msg); } - + ThreadExecutor exec = ThreadExecutor.getInstance(); exec.execute(new InstanceTerminator(ctxt)); - } - + } + private class InstanceTerminator implements Runnable { private MemberContext ctxt; @@ -632,14 +621,14 @@ public void run() { Cartridge cartridge = dataHolder.getCartridge(cartridgeType); log.info("Starting to terminate an instance with member id : " + memberId + - " in partition id: " + partitionId + " of cluster id: " + clusterId + - " and of cartridge type: " + cartridgeType); + " in partition id: " + partitionId + " of cluster id: " + clusterId + + " and of cartridge type: " + cartridgeType); if (cartridge == null) { String msg = - "Termination of Member Id: " + memberId + " failed. " + - "Cannot find a matching Cartridge for type: " + - cartridgeType; + "Termination of Member Id: " + memberId + " failed. " + + "Cannot find a matching Cartridge for type: " + + cartridgeType; log.error(msg); throw new InvalidCartridgeTypeException(msg); } @@ -648,8 +637,8 @@ public void run() { if (nodeId == null) { String msg = - "Termination failed. Cannot find a node id for Member Id: " + - memberId; + "Termination failed. Cannot find a node id for Member Id: " + + memberId; log.error(msg); throw new InvalidMemberException(msg); } @@ -664,7 +653,7 @@ public void run() { } catch (Exception e) { String msg = - "Instance termination failed. "+ctxt.toString(); + "Instance termination failed. "+ctxt.toString(); log.error(msg, e); throw new CloudControllerException(msg, e); } @@ -679,8 +668,8 @@ private class IpAllocator implements Runnable { private String cartridgeType; NodeMetadata node; - public IpAllocator(MemberContext memberContext, IaasProvider iaasProvider, - String cartridgeType, NodeMetadata node) { + public IpAllocator(MemberContext memberContext, IaasProvider iaasProvider, + String cartridgeType, NodeMetadata node) { this.memberContext = memberContext; this.iaasProvider = iaasProvider; this.cartridgeType = cartridgeType; @@ -696,263 +685,263 @@ public void run() { String publicIp = null; try{ - if (log.isDebugEnabled()) { - log.debug("IP allocation process started for "+memberContext); - } + if (log.isDebugEnabled()) { + log.debug("IP allocation process started for "+memberContext); + } String autoAssignIpProp = - iaasProvider.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY); - + iaasProvider.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY); + String pre_defined_ip = iaasProvider.getProperty(CloudControllerConstants.FLOATING_IP_PROPERTY); - - // reset ip - String ip = ""; - - // default behavior is autoIpAssign=false - if (autoAssignIpProp == null || + + // reset ip + String ip = ""; + + // default behavior is autoIpAssign=false + if (autoAssignIpProp == null || (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) { - - // check if floating ip is well defined in cartridge definition - if (pre_defined_ip != null) { - if (isValidIpAddress(pre_defined_ip)) { - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:IpAllocator:pre_defined_ip: invoking associatePredefinedAddress" + pre_defined_ip); - } - Iaas iaas = iaasProvider.getIaas(); - ip = iaas.associatePredefinedAddress(node, pre_defined_ip); - - if (ip == null || "".equals(ip) || !pre_defined_ip.equals(ip)) { - // throw exception and stop instance creation - String msg = "Error occurred while allocating predefined floating ip address: " + pre_defined_ip + - " / allocated ip:" + ip + - " - terminating node:" + memberContext.toString(); - log.error(msg); - // terminate instance - terminate(iaasProvider, - node.getId(), memberContext); - throw new CloudControllerException(msg); - } - } else { - String msg = "Invalid floating ip address configured: " + pre_defined_ip + - " - terminating node:" + memberContext.toString(); - log.error(msg); - // terminate instance - terminate(iaasProvider, - node.getId(), memberContext); - throw new CloudControllerException(msg); - } - + + // check if floating ip is well defined in cartridge definition + if (pre_defined_ip != null) { + if (isValidIpAddress(pre_defined_ip)) { + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:IpAllocator:pre_defined_ip: invoking associatePredefinedAddress" + pre_defined_ip); + } + Iaas iaas = iaasProvider.getIaas(); + ip = iaas.associatePredefinedAddress(node, pre_defined_ip); + + if (ip == null || "".equals(ip) || !pre_defined_ip.equals(ip)) { + // throw exception and stop instance creation + String msg = "Error occurred while allocating predefined floating ip address: " + pre_defined_ip + + " / allocated ip:" + ip + + " - terminating node:" + memberContext.toString(); + log.error(msg); + // terminate instance + terminate(iaasProvider, + node.getId(), memberContext); + throw new CloudControllerException(msg); + } } else { - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:IpAllocator:no (valid) predefined floating ip configured, " + pre_defined_ip - + ", selecting available one from pool"); - } - Iaas iaas = iaasProvider.getIaas(); - // allocate an IP address - manual IP assigning mode - ip = iaas.associateAddress(node); - - if (ip != null) { - memberContext.setAllocatedIpAddress(ip); - log.info("Allocated an ip address: " - + memberContext.toString()); - } - } - - // build the node with the new ip - node = NodeMetadataBuilder.fromNodeMetadata(node) - .publicAddresses(ImmutableSet.of(ip)).build(); - } - - - // public ip - if (node.getPublicAddresses() != null && - node.getPublicAddresses().iterator().hasNext()) { - ip = node.getPublicAddresses().iterator().next(); - publicIp = ip; - memberContext.setPublicIpAddress(ip); - log.info("Retrieving Public IP Address : " + memberContext.toString()); + String msg = "Invalid floating ip address configured: " + pre_defined_ip + + " - terminating node:" + memberContext.toString(); + log.error(msg); + // terminate instance + terminate(iaasProvider, + node.getId(), memberContext); + throw new CloudControllerException(msg); + } + + } else { + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:IpAllocator:no (valid) predefined floating ip configured, " + pre_defined_ip + + ", selecting available one from pool"); + } + Iaas iaas = iaasProvider.getIaas(); + // allocate an IP address - manual IP assigning mode + ip = iaas.associateAddress(node); + + if (ip != null) { + memberContext.setAllocatedIpAddress(ip); + log.info("Allocated an ip address: " + + memberContext.toString()); + } } - // private IP - if (node.getPrivateAddresses() != null && + // build the node with the new ip + node = NodeMetadataBuilder.fromNodeMetadata(node) + .publicAddresses(ImmutableSet.of(ip)).build(); + } + + + // public ip + if (node.getPublicAddresses() != null && + node.getPublicAddresses().iterator().hasNext()) { + ip = node.getPublicAddresses().iterator().next(); + publicIp = ip; + memberContext.setPublicIpAddress(ip); + log.info("Retrieving Public IP Address : " + memberContext.toString()); + } + + // private IP + if (node.getPrivateAddresses() != null && node.getPrivateAddresses().iterator().hasNext()) { - ip = node.getPrivateAddresses().iterator().next(); - memberContext.setPrivateIpAddress(ip); - log.info("Retrieving Private IP Address. " + memberContext.toString()); - } + ip = node.getPrivateAddresses().iterator().next(); + memberContext.setPrivateIpAddress(ip); + log.info("Retrieving Private IP Address. " + memberContext.toString()); + } + + dataHolder.addMemberContext(memberContext); + + // persist in registry + persist(); - dataHolder.addMemberContext(memberContext); - - // persist in registry - persist(); - - - // trigger topology - TopologyBuilder.handleMemberSpawned(cartridgeType, clusterId, - partition.getId(), ip, publicIp, memberContext); - - String memberID = memberContext.getMemberId(); - - // update the topology with the newly spawned member - // publish data - CartridgeInstanceDataPublisher.publish(memberID, - memberContext.getPartition().getId(), - memberContext.getNetworkPartitionId(), - memberContext.getClusterId(), - cartridgeType, - MemberStatus.Created.toString(), - node); - if (log.isDebugEnabled()) { - log.debug("Node details: " + node.toString()); - } - - if (log.isDebugEnabled()) { - log.debug("IP allocation process ended for "+memberContext); - } + + // trigger topology + TopologyBuilder.handleMemberSpawned(cartridgeType, clusterId, + partition.getId(), ip, publicIp, memberContext); + + String memberID = memberContext.getMemberId(); + + // update the topology with the newly spawned member + // publish data + CartridgeInstanceDataPublisher.publish(memberID, + memberContext.getPartition().getId(), + memberContext.getNetworkPartitionId(), + memberContext.getClusterId(), + cartridgeType, + MemberStatus.Created.toString(), + node); + if (log.isDebugEnabled()) { + log.debug("Node details: " + node.toString()); + } + + if (log.isDebugEnabled()) { + log.debug("IP allocation process ended for "+memberContext); + } } catch (Exception e) { String msg = "Error occurred while allocating an ip address. " + memberContext.toString(); log.error(msg, e); throw new CloudControllerException(msg, e); - } + } } } - + private boolean isValidIpAddress (String ip) { - boolean isValid = InetAddresses.isInetAddress(ip); - return isValid; + boolean isValid = InetAddresses.isInetAddress(ip); + return isValid; } - @Override - public void terminateAllInstances(String clusterId) throws InvalidClusterException { - - log.info("Starting to terminate all instances of cluster : " - + clusterId); - - if(clusterId == null) { - String msg = "Instance termination failed. Cluster id is null."; - log.error(msg); - throw new IllegalArgumentException(msg); - } - - List ctxts = dataHolder.getMemberContextsOfClusterId(clusterId); - - if(ctxts == null) { - String msg = "Instance termination failed. No members found for cluster id: "+clusterId; - log.warn(msg); + @Override + public void terminateAllInstances(String clusterId) throws InvalidClusterException { + + log.info("Starting to terminate all instances of cluster : " + + clusterId); + + if(clusterId == null) { + String msg = "Instance termination failed. Cluster id is null."; + log.error(msg); + throw new IllegalArgumentException(msg); + } + + List ctxts = dataHolder.getMemberContextsOfClusterId(clusterId); + + if(ctxts == null) { + String msg = "Instance termination failed. No members found for cluster id: "+clusterId; + log.warn(msg); return; - } - - ThreadExecutor exec = ThreadExecutor.getInstance(); - for (MemberContext memberContext : ctxts) { + } + + ThreadExecutor exec = ThreadExecutor.getInstance(); + for (MemberContext memberContext : ctxts) { exec.execute(new InstanceTerminator(memberContext)); } - } + } - /** - * A helper method to terminate an instance. + /** + * A helper method to terminate an instance. * @param iaasProvider * @param ctxt * @param nodeId * @return will return the IaaSProvider */ - private IaasProvider terminate(IaasProvider iaasProvider, - String nodeId, MemberContext ctxt) { - Iaas iaas = iaasProvider.getIaas(); - if (iaas == null) { - - try { - iaas = CloudControllerUtil.getIaas(iaasProvider); - } catch (InvalidIaasProviderException e) { - String msg = - "Instance termination failed. " +ctxt.toString() + - ". Cause: Unable to build Iaas of this " + iaasProvider.toString(); - log.error(msg, e); - throw new CloudControllerException(msg, e); - } - - } - - //detach volumes if any - detachVolume(iaasProvider, ctxt); - - // destroy the node - iaasProvider.getComputeService().destroyNode(nodeId); - - // release allocated IP address - if (ctxt.getAllocatedIpAddress() != null) { + private IaasProvider terminate(IaasProvider iaasProvider, + String nodeId, MemberContext ctxt) { + Iaas iaas = iaasProvider.getIaas(); + if (iaas == null) { + + try { + iaas = CloudControllerUtil.getIaas(iaasProvider); + } catch (InvalidIaasProviderException e) { + String msg = + "Instance termination failed. " +ctxt.toString() + + ". Cause: Unable to build Iaas of this " + iaasProvider.toString(); + log.error(msg, e); + throw new CloudControllerException(msg, e); + } + + } + + //detach volumes if any + detachVolume(iaasProvider, ctxt); + + // destroy the node + iaasProvider.getComputeService().destroyNode(nodeId); + + // release allocated IP address + if (ctxt.getAllocatedIpAddress() != null) { iaas.releaseAddress(ctxt.getAllocatedIpAddress()); - } - - log.info("Member is terminated: "+ctxt.toString()); - return iaasProvider; - } - - private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { - String clusterId = ctxt.getClusterId(); - ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId); - if (clusterCtxt.getVolumes() != null) { - for (Volume volume : clusterCtxt.getVolumes()) { - try { - String volumeId = volume.getId(); - if (volumeId == null) { - return; - } - Iaas iaas = iaasProvider.getIaas(); - iaas.detachVolume(ctxt.getInstanceId(), volumeId); - } catch (ResourceNotFoundException ignore) { - if(log.isDebugEnabled()) { - log.debug(ignore); - } - } - } - } - } + } + + log.info("Member is terminated: "+ctxt.toString()); + return iaasProvider; + } + + private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { + String clusterId = ctxt.getClusterId(); + ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId); + if (clusterCtxt.getVolumes() != null) { + for (Volume volume : clusterCtxt.getVolumes()) { + try { + String volumeId = volume.getId(); + if (volumeId == null) { + return; + } + Iaas iaas = iaasProvider.getIaas(); + iaas.detachVolume(ctxt.getInstanceId(), volumeId); + } catch (ResourceNotFoundException ignore) { + if(log.isDebugEnabled()) { + log.debug(ignore); + } + } + } + } + } - private void logTermination(MemberContext memberContext) { + private void logTermination(MemberContext memberContext) { //updating the topology - TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), - memberContext.getClusterId(), memberContext.getNetworkPartitionId(), - memberContext.getPartition().getId(), memberContext.getMemberId()); + TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), + memberContext.getClusterId(), memberContext.getNetworkPartitionId(), + memberContext.getPartition().getId(), memberContext.getMemberId()); //publishing data CartridgeInstanceDataPublisher.publish(memberContext.getMemberId(), - memberContext.getPartition().getId(), - memberContext.getNetworkPartitionId(), - memberContext.getClusterId(), - memberContext.getCartridgeType(), - MemberStatus.Terminated.toString(), - null); + memberContext.getPartition().getId(), + memberContext.getNetworkPartitionId(), + memberContext.getClusterId(), + memberContext.getCartridgeType(), + MemberStatus.Terminated.toString(), + null); // update data holders dataHolder.removeMemberContext(memberContext.getMemberId(), memberContext.getClusterId()); - - // persist - persist(); - } + // persist + persist(); - @Override - public boolean registerService(Registrant registrant) - throws UnregisteredCartridgeException { + } - String cartridgeType = registrant.getCartridgeType(); - String clusterId = registrant.getClusterId(); + @Override + public boolean registerService(Registrant registrant) + throws UnregisteredCartridgeException { + + String cartridgeType = registrant.getCartridgeType(); + String clusterId = registrant.getClusterId(); String payload = registrant.getPayload(); String hostName = registrant.getHostName(); - + if(cartridgeType == null || clusterId == null || payload == null || hostName == null) { - String msg = "Null Argument/s detected: Cartridge type: "+cartridgeType+", " + - "Cluster Id: "+clusterId+", Payload: "+payload+", Host name: "+hostName; - log.error(msg); - throw new IllegalArgumentException(msg); - } - + String msg = "Null Argument/s detected: Cartridge type: "+cartridgeType+", " + + "Cluster Id: "+clusterId+", Payload: "+payload+", Host name: "+hostName; + log.error(msg); + throw new IllegalArgumentException(msg); + } + Cartridge cartridge = null; if ((cartridge = dataHolder.getCartridge(cartridgeType)) == null) { @@ -961,41 +950,41 @@ public boolean registerService(Registrant registrant) log.error(msg); throw new UnregisteredCartridgeException(msg); } - + Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; ClusterContext ctxt = buildClusterContext(cartridge, clusterId, - payload, hostName, props, isLb, registrant.getPersistence()); + payload, hostName, props, isLb, registrant.getPersistence()); - dataHolder.addClusterContext(ctxt); - TopologyBuilder.handleClusterCreated(registrant, isLb); - - persist(); - - log.info("Successfully registered: "+registrant); - - return true; - } + dataHolder.addClusterContext(ctxt); + TopologyBuilder.handleClusterCreated(registrant, isLb); - private ClusterContext buildClusterContext(Cartridge cartridge, + persist(); + + log.info("Successfully registered: "+registrant); + + return true; + } + + private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, Properties props, boolean isLb, Persistence persistence) { - // initialize ClusterContext - ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, - hostName, isLb); - - String property; - property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); - long timeout = property != null ? Long.parseLong(property) : 30000; + // initialize ClusterContext + ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, + hostName, isLb); + + String property; + property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); + long timeout = property != null ? Long.parseLong(property) : 30000; boolean persistanceRequired = false; if(persistence != null){ - persistanceRequired = persistence.isPersistanceRequired(); + persistanceRequired = persistence.isPersistanceRequired(); } if(persistanceRequired){ @@ -1037,7 +1026,7 @@ private ClusterContext buildClusterContext(Cartridge cartridge, ctxt.setVolumes(persistence.getVolumes()); ctxt.setVolumeRequired(true); } else { - // if we cannot find necessary data, we would not consider + // if we cannot find necessary data, we would not consider // this as a volume required instance. //isVolumeRequired = false; ctxt.setVolumeRequired(false); @@ -1046,51 +1035,51 @@ private ClusterContext buildClusterContext(Cartridge cartridge, //ctxt.setVolumeRequired(isVolumeRequired); } */ - ctxt.setTimeoutInMillis(timeout); - return ctxt; - } + ctxt.setTimeoutInMillis(timeout); + return ctxt; + } @Override - public String[] getRegisteredCartridges() { - // get the list of cartridges registered - List cartridges = dataHolder - .getCartridges(); + public String[] getRegisteredCartridges() { + // get the list of cartridges registered + List cartridges = dataHolder + .getCartridges(); - if (cartridges == null) { - return new String[0]; - } + if (cartridges == null) { + return new String[0]; + } - String[] cartridgeTypes = new String[cartridges.size()]; - int i = 0; + String[] cartridgeTypes = new String[cartridges.size()]; + int i = 0; - for (Cartridge cartridge : cartridges) { - cartridgeTypes[i] = cartridge.getType(); - i++; - } + for (Cartridge cartridge : cartridges) { + cartridgeTypes[i] = cartridge.getType(); + i++; + } - return cartridgeTypes; - } + return cartridgeTypes; + } - @Override - public CartridgeInfo getCartridgeInfo(String cartridgeType) - throws UnregisteredCartridgeException { - Cartridge cartridge = dataHolder - .getCartridge(cartridgeType); + @Override + public CartridgeInfo getCartridgeInfo(String cartridgeType) + throws UnregisteredCartridgeException { + Cartridge cartridge = dataHolder + .getCartridge(cartridgeType); - if (cartridge != null) { + if (cartridge != null) { - return CloudControllerUtil.toCartridgeInfo(cartridge); + return CloudControllerUtil.toCartridgeInfo(cartridge); - } + } - String msg = "Cannot find a Cartridge having a type of " - + cartridgeType + ". Hence unable to find information."; - log.error(msg); - throw new UnregisteredCartridgeException(msg); - } + String msg = "Cannot find a Cartridge having a type of " + + cartridgeType + ". Hence unable to find information."; + log.error(msg); + throw new UnregisteredCartridgeException(msg); + } @Override - public void unregisterService(String clusterId) throws UnregisteredClusterException { + public void unregisterService(String clusterId) throws UnregisteredClusterException { final String clusterId_ = clusterId; TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); @@ -1098,13 +1087,13 @@ public void unregisterService(String clusterId) throws UnregisteredClusterExcept @Override public void run() { ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); - if(ctxt == null) { - String msg = "Unregistration of service cluster failed. Cluster not found: " + clusterId_; - log.error(msg); - } - Collection members = TopologyManager.getTopology(). - getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); - //finding the responding members from the existing members in the topology. + if(ctxt == null) { + String msg = "Unregistration of service cluster failed. Cluster not found: " + clusterId_; + log.error(msg); + } + Collection members = TopologyManager.getTopology(). + getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); + //finding the responding members from the existing members in the topology. int sizeOfRespondingMembers = 0; for(Member member : members) { if(member.getStatus().getCode() >= MemberStatus.Activated.getCode()) { @@ -1118,63 +1107,63 @@ public void run() { } - // if there're still alive members - if(members.size() > 0) { - //forcefully terminate them - for (Member member : members) { + // if there're still alive members + if(members.size() > 0) { + //forcefully terminate them + for (Member member : members) { - try { + try { terminateInstance(member.getMemberId()); } catch (Exception e) { // we are not gonna stop the execution due to errors. log.warn("Instance termination failed of member [id] " + member.getMemberId(), e); } } - } + } } }; Runnable unregister = new Runnable() { - public void run() { - ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); - if(ctxt == null) { - String msg = "Unregistration of service cluster failed. Cluster not found: " + clusterId_; - log.error(msg); - } - Collection members = TopologyManager.getTopology(). - getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); - // TODO why end time is needed? - // long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size(); - - while(members.size() > 0) { + public void run() { + ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); + if(ctxt == null) { + String msg = "Unregistration of service cluster failed. Cluster not found: " + clusterId_; + log.error(msg); + } + Collection members = TopologyManager.getTopology(). + getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); + // TODO why end time is needed? + // long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size(); + + while(members.size() > 0) { //waiting until all the members got removed from the Topology/ timed out CloudControllerUtil.sleep(1000); - } + } - log.info("Unregistration of service cluster: " + clusterId_); - deleteVolumes(ctxt); - TopologyBuilder.handleClusterRemoved(ctxt); - dataHolder.removeClusterContext(clusterId_); - dataHolder.removeMemberContextsOfCluster(clusterId_); - persist(); - } + log.info("Unregistration of service cluster: " + clusterId_); + deleteVolumes(ctxt); + TopologyBuilder.handleClusterRemoved(ctxt); + dataHolder.removeClusterContext(clusterId_); + dataHolder.removeMemberContextsOfCluster(clusterId_); + persist(); + } private void deleteVolumes(ClusterContext ctxt) { if(ctxt.isVolumeRequired()) { - Cartridge cartridge = dataHolder.getCartridge(ctxt.getCartridgeType()); - if(cartridge != null && cartridge.getIaases() != null && ctxt.getVolumes() != null) { - for (Volume volume : ctxt.getVolumes()) { + Cartridge cartridge = dataHolder.getCartridge(ctxt.getCartridgeType()); + if(cartridge != null && cartridge.getIaases() != null && ctxt.getVolumes() != null) { + for (Volume volume : ctxt.getVolumes()) { if(volume.getId() != null) { String iaasType = volume.getIaasType(); //Iaas iaas = dataHolder.getIaasProvider(iaasType).getIaas(); Iaas iaas = cartridge.getIaasProvider(iaasType).getIaas(); if(iaas != null) { try { - // delete the volumes if remove on unsubscription is true. - if(volume.isRemoveOntermination()) - { - iaas.deleteVolume(volume.getId()); - volume.setId(null); - } + // delete the volumes if remove on unsubscription is true. + if(volume.isRemoveOntermination()) + { + iaas.deleteVolume(volume.getId()); + volume.setId(null); + } } catch(Exception ignore) { if(log.isErrorEnabled()) { log.error("Error while deleting volume [id] "+ volume.getId(), ignore); @@ -1184,39 +1173,39 @@ private void deleteVolumes(ClusterContext ctxt) { } } - } - } + } + } } }; new Thread(terminateInTimeout).start(); new Thread(unregister).start(); - - } + + } @Override - public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) + public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) throws InvalidPartitionException, InvalidCartridgeTypeException { - Map> validatedCache = dataHolder.getCartridgeTypeToPartitionIds(); - List validatedPartitions = new ArrayList(); - - if (validatedCache.containsKey(cartridgeType)) { - // cache hit for this cartridge - // get list of partitions - validatedPartitions = validatedCache.get(cartridgeType); - if (log.isDebugEnabled()) { - log.debug("Partition validation cache hit for cartridge type: "+cartridgeType); - } - - } - + Map> validatedCache = dataHolder.getCartridgeTypeToPartitionIds(); + List validatedPartitions = new ArrayList(); + + if (validatedCache.containsKey(cartridgeType)) { + // cache hit for this cartridge + // get list of partitions + validatedPartitions = validatedCache.get(cartridgeType); + if (log.isDebugEnabled()) { + log.debug("Partition validation cache hit for cartridge type: "+cartridgeType); + } + + } + Map partitionToIaasProviders = - new ConcurrentHashMap(); - + new ConcurrentHashMap(); + if (log.isDebugEnabled()) { - log.debug("Deployment policy validation started for cartridge type: "+cartridgeType); - } + log.debug("Deployment policy validation started for cartridge type: "+cartridgeType); + } Cartridge cartridge = dataHolder.getCartridge(cartridgeType); @@ -1225,89 +1214,89 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit log.error(msg); throw new InvalidCartridgeTypeException(msg); } - + Map> jobList = new HashMap>(); - for (Partition partition : partitions) { - - if (validatedPartitions.contains(partition.getId())) { - // partition cache hit - continue; - } - - Callable worker = new PartitionValidatorCallable( - partition, cartridge); - Future job = FasterLookUpDataHolder.getInstance() - .getExecutor().submit(worker); - jobList.put(partition.getId(), job); - } - + for (Partition partition : partitions) { + + if (validatedPartitions.contains(partition.getId())) { + // partition cache hit + continue; + } + + Callable worker = new PartitionValidatorCallable( + partition, cartridge); + Future job = FasterLookUpDataHolder.getInstance() + .getExecutor().submit(worker); + jobList.put(partition.getId(), job); + } + // Retrieve the results of the concurrently performed sanity checks. for (String partitionId : jobList.keySet()) { - Future job = jobList.get(partitionId); + Future job = jobList.get(partitionId); try { - // add to a temporary Map - partitionToIaasProviders.put(partitionId, job.get()); - - // add to cache - this.dataHolder.addToCartridgeTypeToPartitionIdMap(cartridgeType, partitionId); - - if (log.isDebugEnabled()) { - log.debug("Partition "+partitionId+" added to the cache against cartridge type: "+cartridgeType); - } + // add to a temporary Map + partitionToIaasProviders.put(partitionId, job.get()); + + // add to cache + this.dataHolder.addToCartridgeTypeToPartitionIdMap(cartridgeType, partitionId); + + if (log.isDebugEnabled()) { + log.debug("Partition "+partitionId+" added to the cache against cartridge type: "+cartridgeType); + } } catch (Exception e) { log.error(e.getMessage(), e); throw new InvalidPartitionException(e.getMessage(), e); - } + } } // if and only if the deployment policy valid cartridge.addIaasProviders(partitionToIaasProviders); - + // persist data persist(); - + log.info("All partitions "+CloudControllerUtil.getPartitionIds(partitions)+ - " were validated successfully, against the Cartridge: "+cartridgeType); - + " were validated successfully, against the Cartridge: "+cartridgeType); + return true; } @Override public boolean validatePartition(Partition partition) throws InvalidPartitionException { - //FIXME add logs + //FIXME add logs String provider = partition.getProvider(); IaasProvider iaasProvider = dataHolder.getIaasProvider(provider); if (iaasProvider == null) { String msg = - "Invalid Partition - " + partition.toString()+". Cause: Iaas Provider " + - "is null for Partition Provider: "+provider; + "Invalid Partition - " + partition.toString()+". Cause: Iaas Provider " + + "is null for Partition Provider: "+provider; log.error(msg); throw new InvalidPartitionException(msg); } - + Iaas iaas = iaasProvider.getIaas(); - + if (iaas == null) { - - try { + + try { iaas = CloudControllerUtil.getIaas(iaasProvider); } catch (InvalidIaasProviderException e) { String msg = "Invalid Partition - " + partition.toString() + - ". Cause: Unable to build Iaas of this IaasProvider [Provider] : " + provider+". "+e.getMessage(); + ". Cause: Unable to build Iaas of this IaasProvider [Provider] : " + provider+". "+e.getMessage(); log.error(msg, e); throw new InvalidPartitionException(msg, e); } - + } PartitionValidator validator = iaas.getPartitionValidator(); validator.setIaasProvider(iaasProvider); validator.validate(partition.getId(), - CloudControllerUtil.toJavaUtilProperties(partition.getProperties())); - + CloudControllerUtil.toJavaUtilProperties(partition.getProperties())); + return true; } @@ -1317,24 +1306,24 @@ public ClusterContext getClusterContext (String clusterId) { } private List restoreConfigCompositeApplication () { - List apps = this.dataHolder.getConfigCompositeApplication(); - if (apps == null) { - if (log.isDebugEnabled()) { - log.debug("composite applications for cloud controller is null while restoring "); - } - return apps; - } - if (log.isDebugEnabled()) { - log.debug("trying to restore composite applications for cloud controller " + apps.size()); - } - for (ConfigCompositeApplication messConfigApp : apps) { - if (log.isDebugEnabled()) { - log.debug(" restoring composite application for cloud controller " + messConfigApp.getAlias()); - } - TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); - } - - return apps; + List apps = this.dataHolder.getConfigCompositeApplication(); + if (apps == null) { + if (log.isDebugEnabled()) { + log.debug("composite applications for cloud controller is null while restoring "); + } + return apps; + } + if (log.isDebugEnabled()) { + log.debug("trying to restore composite applications for cloud controller " + apps.size()); + } + for (ConfigCompositeApplication messConfigApp : apps) { + if (log.isDebugEnabled()) { + log.debug(" restoring composite application for cloud controller " + messConfigApp.getAlias()); + } + TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); + } + + return apps; } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 2af179a423..a051cf41df 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -22,16 +22,13 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -<<<<<<< HEAD import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.ClusterContext; import org.apache.stratos.cloud.controller.pojo.CompositeApplicationDefinition; import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.Registrant; -======= import org.apache.stratos.cloud.controller.pojo.*; ->>>>>>> master import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; @@ -44,11 +41,8 @@ import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; -<<<<<<< HEAD import org.apache.stratos.messaging.util.Util; -======= import org.apache.stratos.messaging.util.Constants; ->>>>>>> master import java.util.ArrayList; import java.util.List; @@ -67,8 +61,8 @@ public static void handleServiceCreated(List cartridgeList) { Service service; Topology topology = TopologyManager.getTopology(); if (cartridgeList == null) { - log.warn(String.format("Cartridge list is empty")); - return; + log.warn(String.format("Cartridge list is empty")); + return; } try { @@ -116,7 +110,7 @@ public static void handleServiceRemoved(List cartridgeList) { } TopologyEventPublisher.sendServiceRemovedEvent(cartridgeList); } else { - log.warn(String.format("Service %s does not exist..", cartridge.getType())); + log.warn(String.format("Service %s does not exist..", cartridge.getType())); } } else { log.warn("Subscription already exists. Hence not removing the service:" + cartridge.getType() @@ -133,7 +127,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { String cartridgeType = registrant.getCartridgeType(); service = topology.getService(cartridgeType); Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); - + Cluster cluster; String clusterId = registrant.getClusterId(); if (service.clusterExists(clusterId)) { @@ -150,7 +144,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { cluster.setLbCluster(isLb); } else { cluster = new Cluster(cartridgeType, clusterId, - registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName()); + registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName()); cluster.addHostName(registrant.getHostName()); if(service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); @@ -176,16 +170,16 @@ public static void handleClusterRemoved(ClusterContext ctxt) { Service service = topology.getService(ctxt.getCartridgeType()); String deploymentPolicy; if (service == null) { - log.warn(String.format("Service %s does not exist", + log.warn(String.format("Service %s does not exist", ctxt.getCartridgeType())); - return; + return; } if (!service.clusterExists(ctxt.getClusterId())) { - log.warn(String.format("Cluster %s does not exist for service %s", + log.warn(String.format("Cluster %s does not exist for service %s", ctxt.getClusterId(), ctxt.getCartridgeType())); - return; + return; } try { @@ -228,87 +222,87 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { } - public static void handleMemberSpawned(String serviceName, - String clusterId, String partitionId, - String privateIp, String publicIp, MemberContext context) { - // adding the new member to the cluster after it is successfully started - // in IaaS. - Topology topology = TopologyManager.getTopology(); - Service service = topology.getService(serviceName); - Cluster cluster = service.getCluster(clusterId); - String memberId = context.getMemberId(); - String networkPartitionId = context.getNetworkPartitionId(); - String lbClusterId = context.getLbClusterId(); - - if (cluster.memberExists(memberId)) { - log.warn(String.format("Member %s already exists", memberId)); - return; - } - - try { - TopologyManager.acquireWriteLock(); - Member member = new Member(serviceName, clusterId, - networkPartitionId, partitionId, memberId); - member.setStatus(MemberStatus.Created); - member.setMemberIp(privateIp); - member.setLbClusterId(lbClusterId); - member.setMemberPublicIp(publicIp); - member.setProperties(CloudControllerUtil.toJavaUtilProperties(context.getProperties())); - cluster.addMember(member); - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendInstanceSpawnedEvent(serviceName, clusterId, - networkPartitionId, partitionId, memberId, lbClusterId, - publicIp, privateIp, context); - } - + public static void handleMemberSpawned(String serviceName, + String clusterId, String partitionId, + String privateIp, String publicIp, MemberContext context) { + // adding the new member to the cluster after it is successfully started + // in IaaS. + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(serviceName); + Cluster cluster = service.getCluster(clusterId); + String memberId = context.getMemberId(); + String networkPartitionId = context.getNetworkPartitionId(); + String lbClusterId = context.getLbClusterId(); + + if (cluster.memberExists(memberId)) { + log.warn(String.format("Member %s already exists", memberId)); + return; + } + + try { + TopologyManager.acquireWriteLock(); + Member member = new Member(serviceName, clusterId, + networkPartitionId, partitionId, memberId); + member.setStatus(MemberStatus.Created); + member.setMemberIp(privateIp); + member.setLbClusterId(lbClusterId); + member.setMemberPublicIp(publicIp); + member.setProperties(CloudControllerUtil.toJavaUtilProperties(context.getProperties())); + cluster.addMember(member); + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendInstanceSpawnedEvent(serviceName, clusterId, + networkPartitionId, partitionId, memberId, lbClusterId, + publicIp, privateIp, context); + } + public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceStartedEvent.getServiceName()); if (service == null) { - log.warn(String.format("Service %s does not exist", + log.warn(String.format("Service %s does not exist", instanceStartedEvent.getServiceName())); - return; + return; } if (!service.clusterExists(instanceStartedEvent.getClusterId())) { - log.warn(String.format("Cluster %s does not exist in service %s", + log.warn(String.format("Cluster %s does not exist in service %s", instanceStartedEvent.getClusterId(), instanceStartedEvent.getServiceName())); - return; + return; } Member member = service.getCluster(instanceStartedEvent.getClusterId()). getMember(instanceStartedEvent.getMemberId()); if (member == null) { - log.warn(String.format("Member %s does not exist", + log.warn(String.format("Member %s does not exist", instanceStartedEvent.getMemberId())); - return; + return; } - - //grouping - + + //grouping + if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - + log.debug("checking group id in ToplogyBuilder for member started event"); + } + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceStartedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceStartedEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); - } + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceStartedEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceStartedEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); + } } - + try { TopologyManager.acquireWriteLock(); member.setStatus(MemberStatus.Starting); @@ -322,12 +316,12 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent TopologyEventPublisher.sendMemberStartedEvent(instanceStartedEvent); //publishing data CartridgeInstanceDataPublisher.publish(instanceStartedEvent.getMemberId(), - instanceStartedEvent.getPartitionId(), - instanceStartedEvent.getNetworkPartitionId(), - instanceStartedEvent.getClusterId(), - instanceStartedEvent.getServiceName(), - MemberStatus.Starting.toString(), - null); + instanceStartedEvent.getPartitionId(), + instanceStartedEvent.getNetworkPartitionId(), + instanceStartedEvent.getClusterId(), + instanceStartedEvent.getServiceName(), + MemberStatus.Starting.toString(), + null); } public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) { @@ -335,46 +329,46 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate Service service = topology.getService(instanceActivatedEvent.getServiceName()); if (service == null) { log.warn(String.format("Service %s does not exist", - instanceActivatedEvent.getServiceName())); + instanceActivatedEvent.getServiceName())); return; } - + Cluster cluster = service.getCluster(instanceActivatedEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceActivatedEvent.getClusterId())); + instanceActivatedEvent.getClusterId())); return; } - + // grouping - + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for member activated " + appAlias); - } - String clusterId = instanceActivatedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceActivatedEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); - } + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for member activated " + appAlias); + } + String clusterId = instanceActivatedEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceActivatedEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); + } } - - - + + + Member member = cluster.getMember(instanceActivatedEvent.getMemberId()); if (member == null) { - log.warn(String.format("Member %s does not exist", + log.warn(String.format("Member %s does not exist", instanceActivatedEvent.getMemberId())); - return; + return; } MemberActivatedEvent memberActivatedEvent = new MemberActivatedEvent(instanceActivatedEvent.getServiceName(), - instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); + instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); // grouping - set grouid memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId()); @@ -406,53 +400,53 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate TopologyEventPublisher.sendMemberActivatedEvent(memberActivatedEvent); //publishing data CartridgeInstanceDataPublisher.publish(memberActivatedEvent.getMemberId(), - memberActivatedEvent.getPartitionId(), - memberActivatedEvent.getNetworkPartitionId(), - memberActivatedEvent.getClusterId(), - memberActivatedEvent.getServiceName(), - MemberStatus.Activated.toString(), - null); + memberActivatedEvent.getPartitionId(), + memberActivatedEvent.getNetworkPartitionId(), + memberActivatedEvent.getClusterId(), + memberActivatedEvent.getServiceName(), + MemberStatus.Activated.toString(), + null); } public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent instanceReadyToShutdownEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceReadyToShutdownEvent.getServiceName()); //update the status of the member if (service == null) { - log.warn(String.format("Service %s does not exist", - instanceReadyToShutdownEvent.getServiceName())); - return; + log.warn(String.format("Service %s does not exist", + instanceReadyToShutdownEvent.getServiceName())); + return; } Cluster cluster = service.getCluster(instanceReadyToShutdownEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceReadyToShutdownEvent.getClusterId())); + instanceReadyToShutdownEvent.getClusterId())); return; } - - //grouping - + + //grouping + if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - + log.debug("checking group id in ToplogyBuilder for member started event"); + } + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceReadyToShutdownEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceReadyToShutdownEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); - } + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceReadyToShutdownEvent.getClusterId(); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceReadyToShutdownEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + } } - + Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", @@ -460,11 +454,11 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst return; } MemberReadyToShutdownEvent memberReadyToShutdownEvent = new MemberReadyToShutdownEvent( - instanceReadyToShutdownEvent.getServiceName(), - instanceReadyToShutdownEvent.getClusterId(), - instanceReadyToShutdownEvent.getNetworkPartitionId(), - instanceReadyToShutdownEvent.getPartitionId(), - instanceReadyToShutdownEvent.getMemberId()); + instanceReadyToShutdownEvent.getServiceName(), + instanceReadyToShutdownEvent.getClusterId(), + instanceReadyToShutdownEvent.getNetworkPartitionId(), + instanceReadyToShutdownEvent.getPartitionId(), + instanceReadyToShutdownEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); member.setStatus(MemberStatus.ReadyToShutDown); @@ -477,69 +471,69 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst TopologyEventPublisher.sendMemberReadyToShutdownEvent(memberReadyToShutdownEvent); //publishing data CartridgeInstanceDataPublisher.publish(instanceReadyToShutdownEvent.getMemberId(), - instanceReadyToShutdownEvent.getPartitionId(), - instanceReadyToShutdownEvent.getNetworkPartitionId(), - instanceReadyToShutdownEvent.getClusterId(), - instanceReadyToShutdownEvent.getServiceName(), - MemberStatus.ReadyToShutDown.toString(), - null); + instanceReadyToShutdownEvent.getPartitionId(), + instanceReadyToShutdownEvent.getNetworkPartitionId(), + instanceReadyToShutdownEvent.getClusterId(), + instanceReadyToShutdownEvent.getServiceName(), + MemberStatus.ReadyToShutDown.toString(), + null); //termination of particular instance will be handled by autoscaler } - public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceMaintenanceModeEvent.getServiceName()); //update the status of the member if (service == null) { log.warn(String.format("Service %s does not exist", - instanceMaintenanceModeEvent.getServiceName())); + instanceMaintenanceModeEvent.getServiceName())); return; } Cluster cluster = service.getCluster(instanceMaintenanceModeEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceMaintenanceModeEvent.getClusterId())); + instanceMaintenanceModeEvent.getClusterId())); return; } - + Member member = cluster.getMember(instanceMaintenanceModeEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", instanceMaintenanceModeEvent.getMemberId())); return; } - - - //grouping - + + + //grouping + if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - + log.debug("checking group id in ToplogyBuilder for member started event"); + } + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceMaintenanceModeEvent.getClusterId(); - - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceMaintenanceModeEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); - } + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + String clusterId = instanceMaintenanceModeEvent.getClusterId(); + + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + instanceMaintenanceModeEvent.setGroupId(groupAlias); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + } } - + MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent( - instanceMaintenanceModeEvent.getServiceName(), - instanceMaintenanceModeEvent.getClusterId(), - instanceMaintenanceModeEvent.getNetworkPartitionId(), - instanceMaintenanceModeEvent.getPartitionId(), - instanceMaintenanceModeEvent.getMemberId()); + instanceMaintenanceModeEvent.getServiceName(), + instanceMaintenanceModeEvent.getClusterId(), + instanceMaintenanceModeEvent.getNetworkPartitionId(), + instanceMaintenanceModeEvent.getPartitionId(), + instanceMaintenanceModeEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); member.setStatus(MemberStatus.In_Maintenance); @@ -560,43 +554,43 @@ public static void handleMemberTerminated(String serviceName, String clusterId, Properties properties; if (service == null) { log.warn(String.format("Service %s does not exist", - serviceName)); + serviceName)); return; } Cluster cluster = service.getCluster(clusterId); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - clusterId)); + clusterId)); return; } - + Member member = cluster.getMember(memberId); - if (member == null) { - log.warn(String.format("Member with nodeID %s does not exist", - memberId)); - return; - } - - //grouping - + if (member == null) { + log.warn(String.format("Member with nodeID %s does not exist", + memberId)); + return; + } + + //grouping + if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - + log.debug("checking group id in ToplogyBuilder for member started event"); + } + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); String groupAlias = null; if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - groupAlias = app.extractClusterGroupFromClusterId(clusterId); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); - } + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder found composite app for " + appAlias); + } + groupAlias = app.extractClusterGroupFromClusterId(clusterId); + if (log.isDebugEnabled()) { + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); + } } try { @@ -607,11 +601,7 @@ public static void handleMemberTerminated(String serviceName, String clusterId, } finally { TopologyManager.releaseWriteLock(); } -<<<<<<< HEAD - TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, groupAlias); -======= - TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, properties); ->>>>>>> master + TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, properties, groupAlias); } public static void handleMemberSuspended() { @@ -622,33 +612,33 @@ public static void handleMemberSuspended() { TopologyManager.releaseWriteLock(); } } - + public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { Topology topology = TopologyManager.getTopology(); - + //ConfigCompositeApplication messConfigApp; try { TopologyManager.acquireWriteLock(); String key = "compositeApplicationAlias"; //app.getAlias() topology.addConfigCompositeApplication(key ,messConfigApp); - TopologyManager.updateTopology(topology); - } + TopologyManager.updateTopology(topology); + } finally { TopologyManager.releaseWriteLock(); } - TopologyEventPublisher.sendConfigApplicationCreatedEventEvent(messConfigApp); + TopologyEventPublisher.sendConfigApplicationCreatedEventEvent(messConfigApp); log.info("TopolgyBuilder: sending sendConfigApplicationCreatedEventEvent "); } - + public static void handleCompositeApplicationRemoved(String alias) { - log.info("TopolgyBuilder: sending sendConfigApplicationRemovedEventEvent "); - TopologyEventPublisher.sendConfigApplicationRemovedEventEvent(alias); + log.info("TopolgyBuilder: sending sendConfigApplicationRemovedEventEvent "); + TopologyEventPublisher.sendConfigApplicationRemovedEventEvent(alias); } - - - public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { + + + /*public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { ConfigCompositeApplication messApp = new ConfigCompositeApplication(); String alias = compositeApplicationDefinition.getAlias(); messApp.setAlias(alias); @@ -656,15 +646,15 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA messApp.setApplicationId(applicationId); org.apache.stratos.cloud.controller.pojo.ConfigCartridge[] arrayMessCartridges = compositeApplicationDefinition.getCartridges(); org.apache.stratos.cloud.controller.pojo.ConfigGroup [] messConfigGroup = compositeApplicationDefinition.getComponents(); - + List cartridges = new ArrayList(); List messGroups = new ArrayList(); List messDependencies= new ArrayList(); - + for (org.apache.stratos.cloud.controller.pojo.ConfigCartridge cfg : arrayMessCartridges) { ConfigCartridge cartridge = new ConfigCartridge(); cartridge.setAlias(cfg.getAlias()); - + cartridges.add(cartridge); } messApp.setCartridges(cartridges); @@ -673,7 +663,7 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA } for (org.apache.stratos.cloud.controller.pojo.ConfigGroup gr : messConfigGroup) { ConfigGroup group = new ConfigGroup(); - + // alias group.setAlias(gr.getAlias()); if (log.isDebugEnabled()) { @@ -697,7 +687,7 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA } } if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: adding subscribables to group: " + group.getAlias() + + log.debug("TopolgyBuilder: adding subscribables to group: " + group.getAlias() + " and nr of subscribables " + subscribables.size()); } group.setSubscribables(subscribables); @@ -716,7 +706,7 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA ConfigDependencies.Pair messPair = new ConfigDependencies.Pair(pair.getKey(), pair.getValue()); startup_order.add(messPair); if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: adding dep pairs to group: " + pair.getKey() + " / " + + log.debug("TopolgyBuilder: adding dep pairs to group: " + pair.getKey() + " / " + pair.getValue() + " at " + i); } } else { @@ -731,14 +721,14 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA } startup_order = new ArrayList(0); } - + messDep.setStartup_order(startup_order); messDep.setKill_behavior(dep.getKill_behavior()); if (log.isDebugEnabled()) { log.debug("TopolgyBuilder: added kill behavior " + dep.getKill_behavior()); } group.setDependencies(messDep); - + messGroups.add(group); if (log.isDebugEnabled()) { log.debug("TopolgyBuilder: number of groups " + messGroups.size()); @@ -754,7 +744,7 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA } } - + /* test ConfigGroup grX = new ConfigGroup(); grX.setAlias("hug"); @@ -776,34 +766,34 @@ public static ConfigCompositeApplication convertCompositeApplication(CompositeA log.debug("verifying messApp object serialization : " + Util.ObjectToJson(messApp)); // test end */ - + /* return messApp; - } - + }*/ + /* public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - + if (log.isDebugEnabled()) { - log.debug("processing application event of type " + type + + log.debug("processing application event of type " + type + " / topology:" + topology + " msg: " + message); } if (CompositeApplicationCreatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) { - + if (log.isDebugEnabled()) { log.debug("topology is not initialized .... need to add check ... Grouping"); } - + //return false; } // Parse complete message and build event - CompositeApplicationCreatedEvent event = + CompositeApplicationCreatedEvent event = (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class); - + if (log.isDebugEnabled()) { log.debug("processing application created event with application id: " + event.getApplicationAlias()); } @@ -814,7 +804,7 @@ public boolean process(String type, String message, Object object) { log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias())); } } else { - + ConfigCompositeApplication configApp = event.getCompositeApplication(); CompositeApplicationBuilder builder = new CompositeApplicationBuilder(configApp); CompositeApplication app = new CompositeApplication(); @@ -822,7 +812,7 @@ public boolean process(String type, String message, Object object) { app.setTop_level(builder.buildApplication()); String key = "compositeApplicationAlias"; //app.getAlias() topology.addCompositeApplication(key ,app); - + if (log.isInfoEnabled()) { log.info("CompositeApplication created with alias" +app.getAlias() + " and saved with key " + "compositeApplicationAlias" ); log.info(String.format("CompositeApplication created: [app] %s", app.getTop_level())); @@ -831,7 +821,7 @@ public boolean process(String type, String message, Object object) { } } } - + // Notify event listeners notifyEventListeners(event); return true; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 6151b8346f..0ffc0ffdd5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -26,15 +26,12 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.broker.publish.EventPublisher; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; -<<<<<<< HEAD import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.stratos.messaging.domain.topology.Port; import org.apache.stratos.messaging.domain.topology.ServiceType; import org.apache.stratos.messaging.domain.topology.Topology; -======= import org.apache.stratos.messaging.domain.topology.*; ->>>>>>> master import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; @@ -60,8 +57,8 @@ public static void sendServiceCreateEvent(List cartridgeList) { List portMappings = cartridge.getPortMappings(); for(PortMapping portMapping : portMappings) { port = new Port(portMapping.getProtocol(), - Integer.parseInt(portMapping.getPort()), - Integer.parseInt(portMapping.getProxyPort())); + Integer.parseInt(portMapping.getPort()), + Integer.parseInt(portMapping.getProxyPort())); serviceCreatedEvent.addPort(port); } @@ -117,7 +114,7 @@ public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) { } public static void sendInstanceSpawnedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, - String lbClusterId, String publicIp, String privateIp, MemberContext context) { + String lbClusterId, String publicIp, String privateIp, MemberContext context) { InstanceSpawnedEvent instanceSpawnedEvent = new InstanceSpawnedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); instanceSpawnedEvent.setLbClusterId(lbClusterId); instanceSpawnedEvent.setMemberIp(privateIp); @@ -132,69 +129,64 @@ public static void sendInstanceSpawnedEvent(String serviceName, String clusterId public static void sendMemberStartedEvent(InstanceStartedEvent instanceStartedEvent) { MemberStartedEvent memberStartedEventTopology = new MemberStartedEvent(instanceStartedEvent.getServiceName(), - instanceStartedEvent.getClusterId(), instanceStartedEvent.getNetworkPartitionId(), instanceStartedEvent.getPartitionId(), instanceStartedEvent.getMemberId()); + instanceStartedEvent.getClusterId(), instanceStartedEvent.getNetworkPartitionId(), instanceStartedEvent.getPartitionId(), instanceStartedEvent.getMemberId()); - // grouping + // grouping memberStartedEventTopology.setGroupId(instanceStartedEvent.getGroupId()); if(log.isInfoEnabled()) { log.info(" Grouping member started event - adding groupID " + instanceStartedEvent.getGroupId() + " for cluster " + - instanceStartedEvent.getClusterId()); + instanceStartedEvent.getClusterId()); } - + if(log.isInfoEnabled()) { log.info(String.format("Publishing member started event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", - memberStartedEventTopology.getServiceName(), memberStartedEventTopology.getClusterId(), memberStartedEventTopology.getNetworkPartitionId(), - memberStartedEventTopology.getPartitionId(), memberStartedEventTopology.getMemberId(), memberStartedEventTopology.getGroupId())); + memberStartedEventTopology.getServiceName(), memberStartedEventTopology.getClusterId(), memberStartedEventTopology.getNetworkPartitionId(), + memberStartedEventTopology.getPartitionId(), memberStartedEventTopology.getMemberId(), memberStartedEventTopology.getGroupId())); } - + publishEvent(memberStartedEventTopology); } - public static void sendMemberActivatedEvent(MemberActivatedEvent memberActivatedEvent) { - if(log.isInfoEnabled()) { + public static void sendMemberActivatedEvent(MemberActivatedEvent memberActivatedEvent) { + if(log.isInfoEnabled()) { log.info(String.format("Publishing member activated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", - memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId(), memberActivatedEvent.getNetworkPartitionId(), + memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId(), memberActivatedEvent.getNetworkPartitionId(), memberActivatedEvent.getPartitionId(), memberActivatedEvent.getMemberId(), memberActivatedEvent.getGroupId())); - } - publishEvent(memberActivatedEvent); + } + publishEvent(memberActivatedEvent); } public static void sendMemberReadyToShutdownEvent(MemberReadyToShutdownEvent memberReadyToShutdownEvent) { - if(log.isInfoEnabled()) { + if(log.isInfoEnabled()) { log.info(String.format("Publishing member Ready to shut down event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", - memberReadyToShutdownEvent.getServiceName(), memberReadyToShutdownEvent.getClusterId(), memberReadyToShutdownEvent.getNetworkPartitionId(), + memberReadyToShutdownEvent.getServiceName(), memberReadyToShutdownEvent.getClusterId(), memberReadyToShutdownEvent.getNetworkPartitionId(), memberReadyToShutdownEvent.getPartitionId(), memberReadyToShutdownEvent.getMemberId(), memberReadyToShutdownEvent.getGroupId())); - } - // grouping - memberReadyToShutdownEvent.setGroupId(memberReadyToShutdownEvent.getGroupId()); - publishEvent(memberReadyToShutdownEvent); + } + // grouping + memberReadyToShutdownEvent.setGroupId(memberReadyToShutdownEvent.getGroupId()); + publishEvent(memberReadyToShutdownEvent); } public static void sendMemberMaintenanceModeEvent(MemberMaintenanceModeEvent memberMaintenanceModeEvent) { - if(log.isInfoEnabled()) { - log.info(String.format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", - memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getNetworkPartitionId(), - memberMaintenanceModeEvent.getPartitionId(), memberMaintenanceModeEvent.getMemberId(), memberMaintenanceModeEvent.getGroupId())); - } + if(log.isInfoEnabled()) { + log.info(String.format("Publishing Maintenance mode event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", + memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getNetworkPartitionId(), + memberMaintenanceModeEvent.getPartitionId(), memberMaintenanceModeEvent.getMemberId(), memberMaintenanceModeEvent.getGroupId())); + } - publishEvent(memberMaintenanceModeEvent); - } + publishEvent(memberMaintenanceModeEvent); + } -<<<<<<< HEAD - public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, String groupId) { - MemberTerminatedEvent memberTerminatedEvent = new MemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); - // grouping - memberTerminatedEvent.setGroupId(groupId); -======= public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, - String partitionId, String memberId, Properties properties) { + String partitionId, String memberId, Properties properties, String groupId) { MemberTerminatedEvent memberTerminatedEvent = new MemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); memberTerminatedEvent.setProperties(properties); ->>>>>>> master + memberTerminatedEvent.setGroupId(groupId); + if(log.isInfoEnabled()) { - log.info(String.format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", serviceName, clusterId, networkPartitionId, - partitionId, memberId, groupId)); + log.info(String.format("Publishing member terminated event: [service] %s [cluster] %s [network-partition] %s [partition] %s [member] %s [groupId] %s", serviceName, clusterId, networkPartitionId, + partitionId, memberId, groupId)); } publishEvent(memberTerminatedEvent); @@ -208,27 +200,27 @@ public static void sendCompleteTopologyEvent(Topology topology) { } publishEvent(completeTopologyEvent); } - + // Grouping public static void sendConfigApplicationCreatedEventEvent(ConfigCompositeApplication configCompositeApplication) { - - CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = new CompositeApplicationCreatedEvent(configCompositeApplication); + + CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = new CompositeApplicationCreatedEvent(configCompositeApplication); if(log.isDebugEnabled()) { log.debug(String.format("Publishing compositeApplicationCreatedEvent: " + compositeApplicationCreatedEvent)); } publishEvent(compositeApplicationCreatedEvent); } - - public static void sendConfigApplicationRemovedEventEvent(String alias) { - - CompositeApplicationRemovedEvent compositeApplicationCreatedEvent = new CompositeApplicationRemovedEvent(alias); + + public static void sendConfigApplicationRemovedEventEvent(String alias) { + + CompositeApplicationRemovedEvent compositeApplicationCreatedEvent = new CompositeApplicationRemovedEvent(alias); if(log.isDebugEnabled()) { log.debug(String.format("Publishing compositeApplicationRemovedEvent: " + compositeApplicationCreatedEvent)); } publishEvent(compositeApplicationCreatedEvent); - } + } public static void publishEvent(Event event) { EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); From 33314ee0ad6eef476bb43519862fa4b4217767b7 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 18:36:02 +0530 Subject: [PATCH 036/436] merging CloudControllerService.wsdl --- .../resources/CloudControllerService.wsdl | 628 +++++------------- 1 file changed, 176 insertions(+), 452 deletions(-) diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index c898b3fe90..88d247cdd3 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,21 +1,13 @@ -<<<<<<< HEAD - -======= ->>>>>>> master CloudControllerService - + -<<<<<<< HEAD - -======= ->>>>>>> master @@ -25,284 +17,186 @@ -<<<<<<< HEAD -======= - ->>>>>>> master -<<<<<<< HEAD - -======= - ->>>>>>> master + - + - + - + - + -<<<<<<< HEAD - - + - -======= - - - - + ->>>>>>> master - + - - - - - - - - + - + -<<<<<<< HEAD - + - + - - - - -======= - + - - ->>>>>>> master + + -<<<<<<< HEAD - -======= - ->>>>>>> master + -<<<<<<< HEAD - -======= - ->>>>>>> master + -<<<<<<< HEAD - + - + - + - + - + - + - -======= - + - + - + - + - ->>>>>>> master + -<<<<<<< HEAD - -======= - ->>>>>>> master + -<<<<<<< HEAD - - -======= - ->>>>>>> master + -<<<<<<< HEAD - - - - - - - - -======= - ->>>>>>> master - - - - - - -<<<<<<< HEAD - -======= - ->>>>>>> master + - + - + -<<<<<<< HEAD - - - - - - - - - - - - - - - - - - -======= - ->>>>>>> master + -<<<<<<< HEAD - -======= - ->>>>>>> master + @@ -318,101 +212,103 @@ - - - - - - - - + - + - + - + - + - + -<<<<<<< HEAD - -======= - ->>>>>>> master + - + -<<<<<<< HEAD - -======= - + - + - ->>>>>>> master + -<<<<<<< HEAD - - - + + + - - - - - + - - - - -======= - - - ->>>>>>> master + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + @@ -427,9 +323,21 @@ -<<<<<<< HEAD - + + + + + + + + + + + + + + @@ -437,163 +345,70 @@ - - + - - - + + + -======= - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ->>>>>>> master - - - + - - - - - + - - - - - - + - + + - + - - - + + + - + - + + + + - + - - + - + - - + + + -<<<<<<< HEAD - + - - + + - + - - - + + - -======= - ->>>>>>> master + - @@ -601,88 +416,55 @@ - + + - - - + + + + - + - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - -<<<<<<< HEAD - - - - - - - + - - + - + - - - - - - - - - - - - + + + - -======= - + ->>>>>>> master - - - - - - - - - + + + + + @@ -875,21 +657,6 @@ -<<<<<<< HEAD - - - - - - - - - - - - -======= ->>>>>>> master @@ -903,15 +670,15 @@ - + - + - + - + @@ -1052,21 +819,6 @@ -<<<<<<< HEAD - - - - - - - - - - - - -======= ->>>>>>> master @@ -1080,15 +832,15 @@ - + - + - + - + @@ -1220,15 +972,6 @@ -<<<<<<< HEAD - - - - - - -======= ->>>>>>> master @@ -1239,9 +982,9 @@ - + - + @@ -1319,41 +1062,22 @@ -<<<<<<< HEAD - - - - - - - - - - - - - - - - -======= - + - + - + - + - + - ->>>>>>> master + \ No newline at end of file From e3da9aa8c0d73203dfc97114788dc996b7b19fb1 Mon Sep 17 00:00:00 2001 From: Reka Date: Thu, 28 Aug 2014 18:39:05 +0530 Subject: [PATCH 037/436] meging autoscaler conflicts with master --- .../AutoscalerTopologyEventReceiver.java | 201 ++++++++---------- .../autoscaler/monitor/AbstractMonitor.java | 60 +++--- .../autoscaler/monitor/ClusterMonitor.java | 35 +-- 3 files changed, 128 insertions(+), 168 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 8669441b91..2ac006b05c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -24,19 +24,18 @@ import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -<<<<<<< HEAD -======= import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.exception.TerminationException; ->>>>>>> master import org.apache.stratos.autoscaler.monitor.AbstractMonitor; import org.apache.stratos.autoscaler.monitor.CompositeApplicationMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.CompositeApplication; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; +import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; @@ -109,36 +108,36 @@ protected void onEvent(Event event) { }); -<<<<<<< HEAD + topologyEventReceiver.addEventListener(new CompositeApplicationCreatedEventListener() { - @Override - protected void onEvent(Event event) { + @Override + protected void onEvent(Event event) { - log.info("[ClusterCreatedEventListener] Received: " + event.getClass()); + log.info("[ClusterCreatedEventListener] Received: " + event.getClass()); - CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = (CompositeApplicationCreatedEvent) event; + CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = (CompositeApplicationCreatedEvent) event; - ConfigCompositeApplication configCompositeApplication = - compositeApplicationCreatedEvent.getCompositeApplication(); + ConfigCompositeApplication configCompositeApplication = + compositeApplicationCreatedEvent.getCompositeApplication(); - //acquire read lock - TopologyManager.acquireReadLock(); + //acquire read lock + TopologyManager.acquireReadLock(); - try { - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - CompositeApplication compositeApplication = - builder.buildCompositeApplication(TopologyManager.getTopology(), - configCompositeApplication.getAlias()); - //start the app monitor + try { + CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); + CompositeApplication compositeApplication = + builder.buildCompositeApplication(TopologyManager.getTopology(), + configCompositeApplication.getAlias()); + //start the app monitor - } finally { - //release read lock - TopologyManager.releaseReadLock(); - } + } finally { + //release read lock + TopologyManager.releaseReadLock(); + } - } - }); + } + }); // topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { // @Override @@ -158,7 +157,7 @@ protected void onEvent(Event event) { // } // // }); -======= + topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { @Override protected void onEvent(Event event) { @@ -197,7 +196,7 @@ protected void onEvent(Event event) { if (log.isInfoEnabled()) { log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); + memberId, partitionId, clusterId)); } } catch (TerminationException e) { log.error(e); @@ -206,24 +205,6 @@ protected void onEvent(Event event) { }); - topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - log.info("Event received: " + event); - ClusterCreatedEvent e = (ClusterCreatedEvent) event; - TopologyManager.acquireReadLock(); - Service service = TopologyManager.getTopology().getService(e.getServiceName()); - Cluster cluster = service.getCluster(e.getClusterId()); - startClusterMonitor(cluster); - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - TopologyManager.releaseReadLock(); - } - } - - }); topologyEventReceiver.addEventListener(new ClusterMaintenanceModeEventListener() { @Override @@ -248,8 +229,8 @@ protected void onEvent(Event event) { } } - }); ->>>>>>> master + }); + topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override @@ -424,51 +405,51 @@ else if(appMonitor.lbMonitorExists(clusterId)) { }); topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent)event; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - String memberId = memberReadyToShutdownEvent.getMemberId(); - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } - - NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); - - // start a new member in the same Partition - String partitionId = monitor.getPartitionOfMember(memberId); - PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); - - - // terminate the shutdown ready member - CloudControllerClient ccClient = CloudControllerClient.getInstance(); - ccClient.terminate(memberId); - - // remove from active member list - partitionCtxt.removeActiveMemberById(memberId); - - if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); - } - } catch (TerminationException e) { - log.error(e); - } - } - - }); + @Override + protected void onEvent(Event event) { + try { + MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent)event; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractMonitor monitor; + String clusterId = memberReadyToShutdownEvent.getClusterId(); + String memberId = memberReadyToShutdownEvent.getMemberId(); + + if(asCtx.monitorExist(clusterId)){ + monitor = asCtx.getMonitor(clusterId); + }else if(asCtx.lbMonitorExist(clusterId)){ + monitor = asCtx.getLBMonitor(clusterId); + }else{ + if(log.isDebugEnabled()){ + log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + } + return; + } + + NetworkPartitionContext nwPartitionCtxt; + nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); + + // start a new member in the same Partition + String partitionId = monitor.getPartitionOfMember(memberId); + PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); + + + // terminate the shutdown ready member + CloudControllerClient ccClient = CloudControllerClient.getInstance(); + ccClient.terminate(memberId); + + // remove from active member list + partitionCtxt.removeActiveMemberById(memberId); + + if (log.isInfoEnabled()) { + log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", + memberId, partitionId, clusterId)); + } + } catch (TerminationException e) { + log.error(e); + } + } + + }); topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { @@ -532,7 +513,7 @@ protected void onEvent(Event event) { - + } // private class LBClusterMonitorAdder implements Runnable { @@ -675,7 +656,7 @@ public void run() { // } @SuppressWarnings("unused") - private void runTerminateAllRule(AbstractMonitor monitor) { + private void runTerminateAllRule(AbstractMonitor monitor) { FactHandle terminateAllFactHandle = null; @@ -725,25 +706,25 @@ public void terminate() { // } protected synchronized void startAppMonitor(CompositeApplication compositeApplication) { - Thread th = null; - if (AutoscalerContext.getInstance() - .appMonitorExist( - compositeApplication.getAlias())) { - th = new Thread(new AppMonitorAdder( - compositeApplication)); + Thread th = null; + if (AutoscalerContext.getInstance() + .appMonitorExist( + compositeApplication.getAlias())) { + th = new Thread(new AppMonitorAdder( + compositeApplication)); + } + if (th != null) { + th.start(); + try { + th.join(); + } catch (InterruptedException ignore) { } - if (th != null) { - th.start(); - try { - th.join(); - } catch (InterruptedException ignore) { - } - if (log.isDebugEnabled()) { - log.debug(String - .format("Composite Application monitor thread has been started successfully: [Composite Application] %s ", - compositeApplication.getAlias())); - } + if (log.isDebugEnabled()) { + log.debug(String + .format("Composite Application monitor thread has been started successfully: [Composite Application] %s ", + compositeApplication.getAlias())); } } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java index 3d5ab2fe8e..3c95c9100d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java @@ -45,13 +45,13 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ - abstract public class AbstractMonitor implements Runnable{ +abstract public class AbstractMonitor implements Runnable{ - private static final Log log = LogFactory.getLog(AbstractMonitor.class); - // Map - protected Map networkPartitionCtxts; - protected DeploymentPolicy deploymentPolicy; - protected AutoscalePolicy autoscalePolicy; + private static final Log log = LogFactory.getLog(AbstractMonitor.class); + // Map + protected Map networkPartitionCtxts; + protected DeploymentPolicy deploymentPolicy; + protected AutoscalePolicy autoscalePolicy; protected FactHandle minCheckFactHandle; @@ -61,12 +61,12 @@ abstract public class AbstractMonitor implements Runnable{ protected StatefulKnowledgeSession minCheckKnowledgeSession; protected StatefulKnowledgeSession scaleCheckKnowledgeSession; protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; - protected boolean isDestroyed; - - protected String clusterId; - protected String serviceId; - - protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; + protected boolean isDestroyed; + + protected String clusterId; + protected String serviceId; + + protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; // time intereval between two runs of the Monitor. Default is 90000ms. protected int monitorInterval; @@ -84,24 +84,24 @@ private void readConfigurations () { } } - @Override - public void run() { - // TODO Auto-generated method stub - - } - - - public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { - log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); - String networkPartitionId = member.getNetworkPartitionId(); - if(networkPartitionCtxts.containsKey(networkPartitionId)) { - log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); - return networkPartitionCtxts.get(networkPartitionId); - } - log.info("returning null getNetworkPartitionCtxt"); - return null; - } - + @Override + public void run() { + // TODO Auto-generated method stub + + } + + + public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { + log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); + String networkPartitionId = member.getNetworkPartitionId(); + if(networkPartitionCtxts.containsKey(networkPartitionId)) { + log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); + return networkPartitionCtxts.get(networkPartitionId); + } + log.info("returning null getNetworkPartitionCtxt"); + return null; + } + public String getPartitionOfMember(String memberId){ for(Service service: TopologyManager.getTopology().getServices()){ for(Cluster cluster: service.getClusters()){ diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java index 2428c6fd98..a17bf55948 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java @@ -1,18 +1,18 @@ /* - * Licensed to the Apache Software Foundation (ASF) under one + * 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 + * "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. */ @@ -85,7 +85,7 @@ public void run() { } else { if (log.isDebugEnabled()) { log.debug("Cluster monitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + ClusterStatus.In_Maintenance + " mode......"); } } } catch (Exception e) { @@ -98,10 +98,6 @@ public void run() { } } -<<<<<<< HEAD - private void monitor() { -// if(clusterCtxt != null ) { -======= private boolean isPrimaryMember(MemberContext memberContext){ Properties props = memberContext.getProperties(); if (log.isDebugEnabled()) { @@ -122,8 +118,6 @@ private boolean isPrimaryMember(MemberContext memberContext){ } private void monitor() { - ->>>>>>> master //TODO make this concurrent for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { // store primary members in the network partition context @@ -131,13 +125,6 @@ private void monitor() { //minimum check per partition for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { -<<<<<<< HEAD - - minCheckKnowledgeSession.setGlobal("clusterId", clusterId); - minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); - minCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); - minCheckKnowledgeSession.setGlobal("serviceId", serviceId); -======= // store primary members in the partition context List primaryMemberListInPartition = new ArrayList(); // get active primary members in this partition context @@ -156,8 +143,7 @@ private void monitor() { minCheckKnowledgeSession.setGlobal("clusterId", clusterId); minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); minCheckKnowledgeSession.setGlobal("isPrimary", hasPrimary); - minCheckKnowledgeSession.setGlobal("primaryMemberCount", primaryMemberListInPartition.size()); ->>>>>>> master + if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); @@ -189,16 +175,13 @@ private void monitor() { boolean rifReset = networkPartitionContext.isRifReset(); boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); -<<<<<<< HEAD - if (rifReset || memoryConsumptionReset || loadAverageReset) { -======= if (log.isDebugEnabled()) { log.debug("flag of rifReset: " + rifReset + " flag of memoryConsumptionReset" + memoryConsumptionReset + " flag of loadAverageReset" + loadAverageReset); } if (rifReset || memoryConsumptionReset || loadAverageReset) { ->>>>>>> master + scaleCheckKnowledgeSession.setGlobal("clusterId", clusterId); //scaleCheckKnowledgeSession.setGlobal("deploymentPolicy", deploymentPolicy); scaleCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); @@ -231,12 +214,8 @@ private void monitor() { public String toString() { return "ClusterMonitor [clusterId=" + clusterId + ", serviceId=" + serviceId + ", deploymentPolicy=" + deploymentPolicy + ", autoscalePolicy=" + autoscalePolicy + -<<<<<<< HEAD - ", lbReferenceType=" + lbReferenceType + "]"; -======= ", lbReferenceType=" + lbReferenceType + ", hasPrimary=" + hasPrimary + " ]"; ->>>>>>> master } public String getLbReferenceType() { From 2ce45977d1914209688500907923dc7f5d76198d Mon Sep 17 00:00:00 2001 From: Reka Date: Thu, 28 Aug 2014 18:42:22 +0530 Subject: [PATCH 038/436] fixing min rule merging issue --- .../stratos/modules/distribution/src/main/conf/mincheck.drl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/products/stratos/modules/distribution/src/main/conf/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/mincheck.drl index 833293cebf..e1f377053f 100755 --- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl +++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl @@ -48,15 +48,12 @@ global org.apache.stratos.messaging.domain.topology.Topology $topology; global java.util.Map partitionCtxts; global java.lang.String clusterId; global java.lang.String lbRef; -<<<<<<< HEAD global java.lang.String serviceId; global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy; -======= global java.lang.Boolean isPrimary; global Integer primaryMemberCount; ->>>>>>> master rule "Minimum Rule" dialect "mvel" @@ -65,15 +62,12 @@ dialect "mvel" eval(log.debug("Running minimum rule: [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount())) -<<<<<<< HEAD eval($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount()) eval(log.debug("Grouping ... checking startup dependencies for " + clusterId)) eval($ctxt.checkStartupDependencies(serviceId, clusterId)) eval(log.debug("startup dependencies successfully checked for" + clusterId)) -======= eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) ) ->>>>>>> master then if (isPrimary){ log.debug("[min-check] true [primary] true [primary member count] " + primaryMemberCount); From 73830e226c731bd718ced9f8ebd747787c4772e4 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 28 Aug 2014 18:52:20 +0530 Subject: [PATCH 039/436] merging CartridgeSubscriptionManager --- .../manager/CartridgeSubscriptionManager.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 index 86206fe7f2..bdf5b377f4 100644 --- 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 @@ -21,6 +21,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; +import org.apache.stratos.cloud.controller.stub.pojo.Persistence; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.deploy.service.Service; @@ -57,6 +63,7 @@ import java.util.*; + /** * Manager class for the purpose of managing CartridgeSubscriptionInfo subscriptions, groupings, etc. */ @@ -562,11 +569,8 @@ public void addSubscriptionDomain(int tenantId, String subscriptionAlias, String } cartridgeSubscription.addSubscriptionDomain(new SubscriptionDomain(domainName, applicationContext)); -<<<<<<< HEAD new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription); -======= - new DataInsertionAndRetrievalManager().cacheAndUpdateSubscription(cartridgeSubscription); ->>>>>>> master + } catch (PersistenceManagerException e) { String errorMsg = "Could not add domain to cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias + " [domain-name] " + domainName + " [application-context] " + applicationContext; @@ -596,11 +600,8 @@ public void removeSubscriptionDomain(int tenantId, String subscriptionAlias, Str throw new DomainSubscriptionDoesNotExist("Cartridge subscription not found", domainName); } cartridgeSubscription.removeSubscriptionDomain(domainName); -<<<<<<< HEAD new DataInsertionAndRetrievalManager().cacheAndPersistSubcription(cartridgeSubscription); -======= - new DataInsertionAndRetrievalManager().cacheAndUpdateSubscription(cartridgeSubscription); ->>>>>>> master + } catch (PersistenceManagerException e) { String errorMsg = "Could not remove domain from cartridge subscription: [tenant-id] " + tenantId + " [subscription-alias] " + subscriptionAlias + " [domain-name] " + domainName; From feeca27a82fbc82be22a02ab4540b7b62d75436a Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 28 Aug 2014 13:23:54 -0700 Subject: [PATCH 040/436] continuation of Merging Merge branch '4.0.0-grouping' of https://git-wip-us.apache.org/repos/asf/stratos into 4.0.0-grouping --- .../git/impl/GitBasedArtifactRepository.java | 47 -- .../publisher/HealthStatisticsReader.java | 113 +++-- .../stratos/cli/RestCommandLineService.java | 18 +- .../cli/commands/SubscribeCommand.java | 116 +---- .../rest/endpoint/services/ServiceUtils.java | 20 +- .../distribution/src/main/bin/stratos.sh | 4 - .../conf/templates/jndi.properties.template | 3 +- .../distribution/src/main/conf/mincheck.drl | 8 +- .../resources/CloudControllerService.wsdl | 438 +++++++++--------- 9 files changed, 307 insertions(+), 460 deletions(-) diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/artifact/deployment/synchronizer/git/impl/GitBasedArtifactRepository.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/artifact/deployment/synchronizer/git/impl/GitBasedArtifactRepository.java index 49338a6e50..839a34b983 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/artifact/deployment/synchronizer/git/impl/GitBasedArtifactRepository.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/artifact/deployment/synchronizer/git/impl/GitBasedArtifactRepository.java @@ -438,54 +438,7 @@ private void pushToRemoteRepo(RepositoryContext gitRepoCtx) { } } - /* public boolean checkout(RepositoryInformation repositoryInformation) { - - if (log.isDebugEnabled()) { -<<<<<<< HEAD - log.debug("Artifact checkout will be done by thread " + Thread.currentThread().getName() + " - " + - Thread.currentThread().getId()); - } - - int tenantId = Integer.parseInt(repositoryInformation.getTenantId()); - - // if context for tenant is not initialized - if(tenantToRepoContextMap.get(tenantId) == null) { - initGitContext(repositoryInformation); - } - - RepositoryContext gitRepoCtx = retrieveCachedGitContext(tenantId); - - if (gitRepoCtx == null) { // to handle super tenant scenario - log.info("No git repository context information found for deployment synchronizer"); -======= - log.debug("Artifact checkout done by thread " + Thread.currentThread().getName() + " - " + - Thread.currentThread().getId()); - } - - int tenantId = Integer.parseInt(repositoryInformation.getTenantId()); - - // if context for tenant is not initialized - if (tenantToRepoContextMap.get(tenantId) == null) - initGitContext(repositoryInformation); - - - RepositoryContext gitRepoCtx = retrieveCachedGitContext(tenantId); - if (gitRepoCtx == null) { //to handle super tenant scenario - // if(log.isDebugEnabled()) - log.info("No git repository context information found for deployment synchronizer"); ->>>>>>> 400 - - return true; - } - - synchronized (gitRepoCtx) { - if (!gitRepoCtx.cloneExists()) - cloneRepository(gitRepoCtx); - - return pullArtifacts(gitRepoCtx); - } - } */ public boolean checkout (RepositoryInformation repositoryInformation) throws Exception { int tenantId = Integer.parseInt(repositoryInformation.getTenantId()); diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java index 87a0e5ac3b..c7c7e523c7 100644 --- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java +++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/statistics/publisher/HealthStatisticsReader.java @@ -29,27 +29,31 @@ import java.io.FileInputStream; import java.io.IOException; import java.lang.management.ManagementFactory; -import java.io.IOException; import java.util.Scanner; /** * Health statistics reader. */ -public class HealthStatisticsReader { +public class HealthStatisticsReader implements IHealthStatisticsReader { + private static final int MB = 1024 * 1024; private static final Log log = LogFactory.getLog(HealthStatisticsReader.class); + + public boolean init() { + return true; + } public static double getMemoryConsumption() { - double totalMemory = 0, usedMemory = 0; - - if (isWindows()) { - OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); - totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); - usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); - } else { - String fName = "/proc/meminfo"; - try { - FileInputStream f = new FileInputStream(fName); + double totalMemory = 0, usedMemory = 0; + + if (isWindows()) { + OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); + usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); + } else { + String fName = "/proc/meminfo"; + try { + FileInputStream f = new FileInputStream(fName); /* $ cat /proc/meminfo * MemTotal: 2056964 kB @@ -57,59 +61,80 @@ public static double getMemoryConsumption() { * Buffers: 9776 kB * Cached: 127220 kB */ - Scanner scanner = new Scanner(f).useDelimiter("\\D+"); - try { - long memTotal = scanner.nextLong(); - long memFree = scanner.nextLong(); - long buffers = scanner.nextLong(); - long cached = scanner.nextLong(); - - totalMemory = memTotal; - usedMemory = memTotal - (memFree + buffers + cached); - } catch (Exception ex) { - log.error("Could not calculate memory usage.", ex); - } finally { - scanner.close(); - } - } catch (IOException ex) { - log.error("Could not calculate memory usage.", ex); - } - } - + Scanner scanner = new Scanner(f).useDelimiter("\\D+"); + try { + long memTotal = scanner.nextLong(); + long memFree = scanner.nextLong(); + long buffers = scanner.nextLong(); + long cached = scanner.nextLong(); + + totalMemory = memTotal; + usedMemory = memTotal - (memFree + buffers + cached); + } catch (Exception ex) { + log.error("Could not calculate memory usage.", ex); + } finally { + scanner.close(); + } + } catch (IOException ex) { + log.error("Could not calculate memory usage.", ex); + } + } + if(log.isDebugEnabled()) { - log.debug("Calculating memory consumption: [totalMemory] "+totalMemory+" [usedMemory] "+usedMemory); + log.debug("Calculating memory consumption: [totalMemory] "+totalMemory+" [usedMemory] "+usedMemory); } double memoryConsumption = (usedMemory / totalMemory) * 100; if(log.isDebugEnabled()) { - log.debug("Calculating memory consumption: [percentage] "+memoryConsumption); + log.debug("Calculating memory consumption: [percentage] "+memoryConsumption); } return memoryConsumption; } public static double getLoadAverage() { - double loadAvg = (double)ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); - // assume system cores = available cores to JVM - int cores = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); - + double loadAvg = (double)ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); + // assume system cores = available cores to JVM + int cores = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors(); + + if(log.isDebugEnabled()) { + log.debug("Calculating load average consumption: [loadAverage] "+loadAvg+" [cores] "+cores); + } + + double loadAvgPercentage = (loadAvg/cores) * 100; if(log.isDebugEnabled()) { - log.debug("Calculating load average consumption: [loadAverage] "+loadAvg+" [cores] "+cores); + log.debug("Calculating load average consumption: [percentage] "+loadAvgPercentage); } - + return loadAvgPercentage; + } + + public CartridgeStatistics getCartridgeStatistics() throws IOException { + OperatingSystemMXBean osBean = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean(); + double totalMemory = (double)(osBean.getTotalPhysicalMemorySize()/ MB); + double usedMemory = (double)((totalMemory - (osBean.getFreePhysicalMemorySize() / MB) )); + double loadAvg = (double)osBean.getSystemLoadAverage(); + // assume system cores = available cores to JVM + int cores = osBean.getAvailableProcessors(); + double memoryConsumption = (usedMemory / totalMemory) * 100; double loadAvgPercentage = (loadAvg/cores) * 100; + if(log.isDebugEnabled()) { - log.debug("Calculating load average consumption: [percentage] "+loadAvgPercentage); + log.debug("Memory consumption: [totalMemory] "+totalMemory+"Mb [usedMemory] "+usedMemory+"Mb: "+memoryConsumption+"%"); + log.debug("Processor consumption: [loadAverage] "+loadAvg+" [cores] "+cores+": "+loadAvgPercentage+"%"); } - return loadAvgPercentage; + + return (new CartridgeStatistics(memoryConsumption, loadAvgPercentage)); } + public static boolean allPortsActive() { return CartridgeAgentUtils.checkPortsActive(CartridgeAgentConfiguration.getInstance().getListenAddress(), - CartridgeAgentConfiguration.getInstance().getPorts()); + CartridgeAgentConfiguration.getInstance().getPorts()); } - + private static boolean isWindows() { String os = System.getProperty("os.name").toLowerCase(); return os.indexOf("win") >= 0; } -} + public void delete() { + } +} 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 f10f8607d7..89d623b15b 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 @@ -904,23 +904,7 @@ public void subscribe(String cartridgeType, String alias, String externalRepoURL DefaultHttpClient httpClient = new DefaultHttpClient(); CartridgeInfoBean cartridgeInfoBean = new CartridgeInfoBean(); -<<<<<<< HEAD - cartridgeInfoBean.setCartridgeType(null); - cartridgeInfoBean.setAlias(null); - cartridgeInfoBean.setRepoURL(null); - cartridgeInfoBean.setPrivateRepo(false); - cartridgeInfoBean.setRepoUsername(null); - cartridgeInfoBean.setRepoPassword(null); - cartridgeInfoBean.setAutoscalePolicy(null); - cartridgeInfoBean.setDeploymentPolicy(null); - cartridgeInfoBean.setSize(size); - - cartridgeInfoBean.setRemoveOnTermination(remoOnTermination); - cartridgeInfoBean.setPersistanceRequired(persistanceMapping); - cartridgeInfoBean.setCommitsEnabled(enableCommits); - -======= ->>>>>>> master + GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java index dab2685768..2825e309b3 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SubscribeCommand.java @@ -34,11 +34,8 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; -<<<<<<< HEAD -import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; -======= import java.util.ArrayList; ->>>>>>> master +import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; public class SubscribeCommand implements Command { @@ -116,17 +113,6 @@ private Options constructOptions() { upstreamCommitsEnabledOption.setOptionalArg(true); options.addOption(upstreamCommitsEnabledOption); -<<<<<<< HEAD - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { - if (logger.isDebugEnabled()) { - logger.debug("Executing {} command...", getName()); - } - if (args != null && args.length > 0) { - String[] remainingArgs = null; - String type = null; - String alias = null; - String policy = null; -======= return options; } @@ -142,7 +128,7 @@ public String getArgumentSyntax() { return "[Cartridge type] [Cartridge alias]"; } - public int execute(StratosCommandContext context, String[] args) throws CommandException { + public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -151,7 +137,6 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE String type = null; String alias = null; String policy = null; ->>>>>>> master String asPolicy = null; String depPolicy = null; String repoURL = null, username = "", password = ""; @@ -169,6 +154,8 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE try { commandLine = parser.parse(options, args); remainingArgs = commandLine.getArgs(); + //merge newly discovered options with previously discovered ones. + Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (remainingArgs != null && remainingArgs.length == 2) { // Get type type = remainingArgs[0]; @@ -178,43 +165,13 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE return CliConstants.BAD_ARGS_CODE; } -<<<<<<< HEAD - final CommandLineParser parser = new GnuParser(); - CommandLine commandLine; - try { - commandLine = parser.parse(options, args); - remainingArgs = commandLine.getArgs(); - //merge newly discovered options with previously discovered ones. - Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); - if (remainingArgs != null && remainingArgs.length == 2) { - // Get type - type = remainingArgs[0]; - alias = remainingArgs[1]; - } else { - context.getStratosApplication().printUsage(getName()); - return CliConstants.BAD_ARGS_CODE; - } - - if (logger.isDebugEnabled()) { - logger.debug("Subscribing to {} cartridge with alias {}", type, alias); - } - - //if (opts.hasOption(CliConstants.POLICY_OPTION)) { - // if (logger.isTraceEnabled()) { - // logger.trace("Policy option is passed"); - // } - // policy = opts.getOptionValue(CliConstants.POLICY_OPTION); - //} - if (opts.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { -======= // This will check the subscribe cartridge type is multi tenant or single tenant isMultiTenant = RestCommandLineService.getInstance().isMultiTenant(type); if (logger.isDebugEnabled()) { logger.debug("Subscribing to {} cartridge with alias {}", type, alias); } - if (commandLine.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { ->>>>>>> master + if (opts.hasOption(CliConstants.AUTOSCALING_POLICY_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Autoscaling policy option is passed"); } @@ -226,29 +183,13 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE } depPolicy = opts.getOption(CliConstants.DEPLOYMENT_POLICY_OPTION).getValue(); } -<<<<<<< HEAD if (opts.hasOption(CliConstants.REPO_URL_OPTION)) { - if (logger.isTraceEnabled()) { - logger.trace("RepoURL option is passed"); - } - repoURL = opts.getOption(CliConstants.REPO_URL_OPTION).getValue(); - } - //if (opts.hasOption(CliConstants.PRIVATE_REPO_OPTION)) { - // if (logger.isTraceEnabled()) { - // logger.trace("privateRepo option is passed"); - // } - // privateRepo = true; - //} - if (opts.hasOption(CliConstants.VOLUME_SIZE_OPTION)) { -======= - if (commandLine.hasOption(CliConstants.REPO_URL_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("RepoURL option is passed"); } - repoURL = commandLine.getOptionValue(CliConstants.REPO_URL_OPTION); + repoURL = opts.getOption(CliConstants.REPO_URL_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.VOLUME_SIZE_OPTION)) { ->>>>>>> master + if (opts.hasOption(CliConstants.VOLUME_SIZE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Volume size option is passed"); @@ -256,28 +197,16 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE size = opts.getOption(CliConstants.VOLUME_SIZE_OPTION).getValue(); } -<<<<<<< HEAD if (opts.hasOption(CliConstants.VOLUME_ID_OPTION)) { -======= - if (commandLine.hasOption(CliConstants.VOLUME_ID_OPTION)) { ->>>>>>> master if (logger.isTraceEnabled()) { logger.trace("Volume id option is passed"); } -<<<<<<< HEAD volumeID = opts.getOption(CliConstants.VOLUME_ID_OPTION).getValue(); } if (opts.hasOption(CliConstants.REMOVE_ON_TERMINATION_OPTION)) { -======= - volumeID = commandLine.getOptionValue(CliConstants.VOLUME_ID_OPTION); - } - - - if (commandLine.hasOption(CliConstants.REMOVE_ON_TERMINATION_OPTION)) { ->>>>>>> master if (logger.isTraceEnabled()) { logger.trace("Remove on termination option is passed"); @@ -318,45 +247,24 @@ public int execute(StratosCommandContext context, String[] args) throws CommandE } } - if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) { + if (opts.hasOption(CliConstants.USERNAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Username option is passed"); } - username = commandLine.getOptionValue(CliConstants.USERNAME_OPTION); + username = opts.getOption(CliConstants.USERNAME_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) { + if (opts.hasOption(CliConstants.PASSWORD_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Password option is passed"); } - password = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION); + password = opts.getOption(CliConstants.PASSWORD_OPTION).getValue(); } - if (commandLine.hasOption(CliConstants.ENABLE_COMMITS_OPTION)) { + if (opts.hasOption(CliConstants.ENABLE_COMMITS_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Upstream git commits are enabled"); } commitsEnabled = true; } -<<<<<<< HEAD - if (opts.hasOption(CliConstants.USERNAME_OPTION)) { - if (logger.isTraceEnabled()) { - logger.trace("Username option is passed"); - } - username = opts.getOption(CliConstants.USERNAME_OPTION).getValue(); - } - if (opts.hasOption(CliConstants.PASSWORD_OPTION)) { - if (logger.isTraceEnabled()) { - logger.trace("Password option is passed"); - } - password = opts.getOption(CliConstants.PASSWORD_OPTION).getValue(); - } - if (opts.hasOption(CliConstants.ENABLE_COMMITS_OPTION)) { - if (logger.isTraceEnabled()) { - logger.trace("Upstream git commits are enabled"); - } - commitsEnabled = true; - } -======= ->>>>>>> master if ( ! isMultiTenant && depPolicy == null) { System.out.println("Deployment policy is required."); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index a2c2491fab..5f6f7f5dbb 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -25,20 +25,17 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; -import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; -import org.apache.stratos.manager.composite.application.CompositeApplicationManager; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.CompositeApplicationManager; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; @@ -1174,11 +1171,6 @@ static SubscriptionInfo subscribe(CartridgeInfoBean cartridgeInfoBean, Configura } /* -<<<<<<< HEAD - if (cartridgeInfoBean.getPersistence() != null) { - -======= ->>>>>>> master if (cartridgeInfoBean.isPersistanceRequired()) { if (cartridgeInfoBean.getPersistence() != null) { // Add persistence related properties to PersistenceContext @@ -1285,10 +1277,6 @@ public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getCluste subscriptionData.setTenantAdminUsername(userName); subscriptionData.setRepositoryType("git"); //subscriptionData.setPayloadProperties(props); -<<<<<<< HEAD - //subscriptionData.setProperties(props); -======= ->>>>>>> master subscriptionData.setPrivateRepository(false); cartridgeSubscription = @@ -1299,10 +1287,6 @@ public static org.apache.stratos.rest.endpoint.bean.topology.Cluster[] getCluste Properties lbProperties = new Properties(); lbProperties.setPayloadProperties(props); -<<<<<<< HEAD - lbProperties.setProperties(props); -======= ->>>>>>> master cartridgeSubsciptionManager.registerCartridgeSubscription(cartridgeSubscription, lbProperties); if(log.isDebugEnabled()) { diff --git a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh index 491d52ee68..2636e74c77 100644 --- a/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh +++ b/products/cartridge-agent/modules/distribution/src/main/bin/stratos.sh @@ -49,9 +49,6 @@ properties="-Dmb.ip=MB-IP -Dmonitoring.server.secure.port=MONITORING-SERVER-SECURE-PORT -Dmonitoring.server.admin.username=MONITORING-SERVER-ADMIN-USERNAME -Dmonitoring.server.admin.password=MONITORING-SERVER-ADMIN-PASSWORD -<<<<<<< HEAD - -DAPP_PATH=APP-PATH" -======= -Dlog.file.paths=LOG_FILE_PATHS -DAPP_PATH=APP_PATH -Dsuper.tenant.repository.path=/repository/deployment/server/ @@ -73,7 +70,6 @@ properties="-Dmb.ip=MB-IP -Dextension.artifacts.copy=artifacts-copy.sh -Dextension.tenant.subscribed=tenant-subscribed.sh -Dextension.tenant.unsubscribed=tenant-unsubscribed.sh" ->>>>>>> master # Uncomment below line to enable remote debugging #debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" diff --git a/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template b/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template index 1ff5b1f289..588d47aeab 100644 --- a/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template +++ b/products/cartridge-agent/modules/distribution/src/main/conf/templates/jndi.properties.template @@ -24,5 +24,4 @@ connectionfactoryName=TopicConnectionFactory connectionfactory.topicConnectionfactory=tcp://$mb_ip:$mb_port java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory -======= ->>>>>>> master + diff --git a/products/stratos/modules/distribution/src/main/conf/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/mincheck.drl index e1f377053f..ed331cf6de 100755 --- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl +++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl @@ -48,12 +48,12 @@ global org.apache.stratos.messaging.domain.topology.Topology $topology; global java.util.Map partitionCtxts; global java.lang.String clusterId; global java.lang.String lbRef; +global java.lang.Boolean isPrimary; +global Integer primaryMemberCount; global java.lang.String serviceId; global org.apache.stratos.autoscaler.policy.model.AutoscalePolicy autoscalePolicy; -global java.lang.Boolean isPrimary; -global Integer primaryMemberCount; rule "Minimum Rule" dialect "mvel" @@ -62,12 +62,10 @@ dialect "mvel" eval(log.debug("Running minimum rule: [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount())) - eval($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount()) + eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) ) eval(log.debug("Grouping ... checking startup dependencies for " + clusterId)) eval($ctxt.checkStartupDependencies(serviceId, clusterId)) eval(log.debug("startup dependencies successfully checked for" + clusterId)) - - eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) ) then if (isPrimary){ log.debug("[min-check] true [primary] true [primary member count] " + primaryMemberCount); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 88d247cdd3..758e5a12d0 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,18 +1,18 @@ - + CloudControllerService - + - + - + @@ -22,97 +22,89 @@ - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - - - - - - - - - + - + - + - + - + @@ -123,192 +115,236 @@ - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + - + + + + + + - + + + + + - + - - - - - - - - - - - - - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + @@ -323,21 +359,16 @@ - + - - - - - - - - + + + - + @@ -345,11 +376,11 @@ - + - - - + + + @@ -362,25 +393,24 @@ - - - - - - - + - - - + + + + + + + + - - + + @@ -391,14 +421,14 @@ - + - + @@ -407,64 +437,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + + + + + + + + + + + + + - - - - + - - - - - + + + + + + + + + @@ -657,18 +657,6 @@ - - - - - - - - - - - - @@ -681,6 +669,18 @@ + + + + + + + + + + + + @@ -819,18 +819,6 @@ - - - - - - - - - - - - @@ -843,6 +831,18 @@ + + + + + + + + + + + + @@ -972,6 +972,12 @@ + + + + + + @@ -981,12 +987,6 @@ - - - - - - @@ -1062,22 +1062,22 @@ - + - + - + - + - + - + \ No newline at end of file From 397d99264525e6f91bca4b6e4bad449dba6e058a Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sat, 6 Sep 2014 21:23:43 +0530 Subject: [PATCH 041/436] merging master branch to 4.0.0-grouping - 6th Sept --- .../pom.xml | 340 ++++++------ .../controller/iaases/OpenstackNovaIaas.java | 66 ++- .../console/cartridge_info.jag | 18 +- .../console/cartridge_info_sg.jag | 29 +- .../console/cartridges.jag | 5 + .../console/configure_stratos.jag | 33 +- .../console/configure_stratos_wizard.jag | 38 +- .../console/index.jag | 6 +- .../console/subscribe_cartridge.jag | 24 +- .../console/tenant_management.jag | 5 + .../theme1/renderers/configure_stratos.js | 6 +- .../renderers/configure_stratos_wizard.js | 8 +- .../console/themes/theme1/renderers/index.js | 3 + .../theme1/renderers/subscribe_cartridge.js | 18 +- .../theme1/renderers/tenant_management.js | 6 +- .../console/util/utility.jag | 140 ++--- .../rest/endpoint/services/StratosAdmin.java | 3 +- .../stratos-test/WEB-INF/schemas/schema.xsd | 9 +- .../webapp/stratos/WEB-INF/schemas/schema.xsd | 9 +- .../extensions/DockerImageExtension.java | 120 ----- .../compute/features/internal/Archives.java | 96 ---- .../src/main/resources/ubuntu/Dockerfile | 30 -- .../compute/DockerExperimentLiveTest.java | 144 ----- .../docker/config/DockerParserModuleTest.java | 102 ---- .../src/test/resources/Dockerfile | 29 - .../src/test/resources/container.json | 87 --- .../README.md | 0 .../{1.7.1-stratos => 1.8.0-stratos}/pom.xml | 6 +- .../java/org/jclouds/docker/DockerApi.java | 5 +- .../org/jclouds/docker/DockerApiMetadata.java | 22 +- .../binders/BindInputStreamToRequest.java | 32 +- .../DockerComputeServiceContextModule.java | 16 +- .../functions/ContainerToNodeMetadata.java | 51 +- .../compute/functions/ImageToImage.java | 16 +- .../compute/functions/StateToStatus.java | 10 +- .../options/DockerTemplateOptions.java | 158 +++++- .../strategy/DockerComputeServiceAdapter.java | 115 ++-- .../docker/config/DockerHttpApiModule.java | 2 - .../docker/config/DockerParserModule.java | 39 -- .../docker/config/DockerProperties.java | 3 - .../org/jclouds/docker/domain/Config.java | 55 +- .../org/jclouds/docker/domain/Container.java | 125 +++-- .../jclouds/docker/domain/ExposedPorts.java | 17 +- .../org/jclouds/docker/domain/HostConfig.java | 118 +++- .../java/org/jclouds/docker/domain/Image.java | 19 +- .../docker/domain/NetworkSettings.java | 27 +- .../java/org/jclouds/docker/domain/Port.java | 7 +- .../java/org/jclouds/docker/domain/State.java | 5 +- .../org/jclouds/docker/domain/Version.java | 5 +- .../jclouds/docker}/features/RemoteApi.java | 7 +- .../docker/features/internal/Archives.java | 60 +++ .../docker/handlers/DockerErrorHandler.java | 20 +- .../jclouds/docker/options/BuildOptions.java | 2 - .../jclouds/docker/options/CommitOptions.java | 2 - .../docker/options/CreateImageOptions.java | 34 -- .../docker/options/DeleteImageOptions.java | 2 - .../docker/options/ListContainerOptions.java | 2 +- .../docker/options/ListImageOptions.java | 2 +- .../options/RemoveContainerOptions.java | 2 - .../services/org.jclouds.apis.ApiMetadata | 0 .../jclouds/docker/DockerApiMetadataTest.java | 10 +- .../binders/BindInputStreamToRequestTest.java | 66 +++ .../docker/compute/BaseDockerApiLiveTest.java | 13 +- .../DockerComputeServiceAdapterLiveTest.java | 67 +-- .../compute/DockerComputeServiceLiveTest.java | 142 +++++ .../ContainerToNodeMetadataTest.java | 61 ++- .../compute/functions/ImageToImageTest.java | 14 +- .../compute/functions/StateToStatusTest.java | 16 +- .../options/DockerTemplateOptionsTest.java | 62 +++ .../docker/config/DockerParserModuleTest.java | 52 ++ .../docker}/features/RemoteApiLiveTest.java | 43 +- .../docker}/features/RemoteApiMockTest.java | 114 ++-- .../features/internal/ArchivesTest.java | 112 ++++ .../docker/internal/BaseDockerMockTest.java | 33 +- .../src/test/resources}/Dockerfile | 0 .../test/resources/container-creation.json | 0 .../src/test/resources/container.json | 81 +++ .../src/test/resources/containers.json | 0 .../src/test/resources/logback.xml | 66 +-- .../compute/EC2ComputeServiceExpectTest.java | 148 ------ .../describe_instances_running-named.xml | 74 --- .../README.txt | 0 .../{1.7.1-stratos => 1.8.0-stratos}/pom.xml | 6 +- .../src/main/clojure/org/jclouds/ec2/ami2.clj | 0 .../src/main/clojure/org/jclouds/ec2/ebs2.clj | 0 .../clojure/org/jclouds/ec2/elastic_ip2.clj | 0 .../org/jclouds/ec2/security_group2.clj | 0 .../src/main/java/org/jclouds/ec2/EC2Api.java | 2 - .../java/org/jclouds/ec2/EC2ApiMetadata.java | 0 .../java/org/jclouds/ec2/EC2Fallbacks.java | 0 ...BlockDeviceMappingToIndexedFormParams.java | 4 - .../BindBundleIdsToIndexedFormParams.java | 2 - .../BindFiltersToIndexedFormParams.java | 2 - .../BindGroupIdsToIndexedFormParams.java | 2 - .../BindGroupNamesToIndexedFormParams.java | 2 - .../BindInstanceIdsToIndexedFormParams.java | 2 - .../BindIpPermissionToIndexedFormParams.java | 3 - .../BindIpPermissionsToIndexedFormParams.java | 3 - .../BindKeyNamesToIndexedFormParams.java | 2 - .../BindProductCodesToIndexedFormParams.java | 2 - .../BindPublicIpsToIndexedFormParams.java | 2 - .../BindResourceIdsToIndexedFormParams.java | 2 - .../BindS3UploadPolicyAndSignature.java | 4 - .../BindTagKeysToIndexedFormParams.java | 2 - .../binders/BindTagsToIndexedFormParams.java | 3 - .../BindUserGroupsToIndexedFormParams.java | 2 - ...upPairToSourceSecurityGroupFormParams.java | 2 - .../BindUserIdsToIndexedFormParams.java | 2 - .../BindVolumeIdsToIndexedFormParams.java | 2 - ...otNullBindAvailabilityZoneToFormParam.java | 2 - .../ec2/compute/EC2ComputeService.java | 49 +- .../ec2/compute/EC2ComputeServiceContext.java | 3 - .../EC2BindComputeStrategiesByClass.java | 3 - .../EC2BindComputeSuppliersByClass.java | 3 - .../EC2ComputeServiceContextModule.java | 2 - .../EC2ComputeServiceDependenciesModule.java | 4 - .../config/EC2ResolveImagesModule.java | 3 - .../compute/domain/EC2HardwareBuilder.java | 17 +- .../domain/PasswordDataAndPrivateKey.java | 2 - .../ec2/compute/domain/RegionAndName.java | 4 - .../domain/RegionNameAndIngressRules.java | 4 - .../compute/extensions/EC2ImageExtension.java | 3 - .../extensions/EC2SecurityGroupExtension.java | 2 - .../AddElasticIpsToNodemetadata.java | 2 - .../functions/CreateUniqueKeyPair.java | 4 - .../functions/CredentialsForInstance.java | 4 - .../ec2/compute/functions/EC2ImageParser.java | 3 - .../functions/EC2SecurityGroupIdFromName.java | 3 - .../EC2SecurityGroupToSecurityGroup.java | 2 - .../functions/ImagesToRegionAndIdMap.java | 3 - ...asswordCredentialsFromWindowsInstance.java | 3 - .../compute/functions/PresentInstances.java | 2 - .../RunningInstanceToNodeMetadata.java | 3 - ...dowsLoginCredentialsFromEncryptedData.java | 2 - .../EC2ComputeServiceContextImpl.java | 3 - .../internal/EC2TemplateBuilderImpl.java | 13 +- .../loaders/CreateSecurityGroupIfNeeded.java | 4 - .../LoadPublicIpForInstanceOrNull.java | 3 - .../compute/loaders/RegionAndIdToImage.java | 4 - .../compute/options/EC2TemplateOptions.java | 96 +++- .../predicates/EC2ImagePredicates.java | 2 - .../predicates/SecurityGroupPresent.java | 4 - ...rityGroupsAsNeededAndReturnRunOptions.java | 65 ++- .../strategy/DescribeImagesParallel.java | 4 - .../EC2CreateNodesInGroupThenAddToSet.java | 52 +- .../strategy/EC2DestroyNodeStrategy.java | 4 - .../compute/strategy/EC2GetImageStrategy.java | 4 - .../strategy/EC2GetNodeMetadataStrategy.java | 4 - .../strategy/EC2ListNodesStrategy.java | 8 +- ...faultLoginCredentialsForImageStrategy.java | 3 - .../strategy/EC2RebootNodeStrategy.java | 4 - .../strategy/EC2ResumeNodeStrategy.java | 4 - .../strategy/EC2SuspendNodeStrategy.java | 4 - .../compute/strategy/ReviseParsedImage.java | 4 - .../suppliers/EC2HardwareSupplier.java | 4 - .../compute/suppliers/EC2ImageSupplier.java | 4 - .../RegionAndNameToImageSupplier.java | 4 - .../ec2/compute/util/EC2ComputeUtils.java | 4 - .../ec2/config/BaseEC2HttpApiModule.java | 2 - .../jclouds/ec2/config/EC2HttpApiModule.java | 2 - .../org/jclouds/ec2/domain/Attachment.java | 1 - .../ec2/domain/AvailabilityZoneInfo.java | 1 - .../org/jclouds/ec2/domain/BlockDevice.java | 1 - .../ec2/domain/BlockDeviceMapping.java | 86 ++- .../ec2/domain/BundleInstanceS3Storage.java | 1 - .../org/jclouds/ec2/domain/BundleTask.java | 2 - .../org/jclouds/ec2/domain/Hypervisor.java | 2 - .../java/org/jclouds/ec2/domain/Image.java | 40 +- .../jclouds/ec2/domain/ImageAttribute.java | 2 - .../org/jclouds/ec2/domain/InstanceState.java | 2 - .../ec2/domain/InstanceStateChange.java | 1 - .../org/jclouds/ec2/domain/InstanceType.java | 2 - .../java/org/jclouds/ec2/domain/KeyPair.java | 1 - .../org/jclouds/ec2/domain/PasswordData.java | 2 - .../org/jclouds/ec2/domain/Permission.java | 1 - .../ec2/domain/PublicIpInstanceIdPair.java | 1 - .../org/jclouds/ec2/domain/Reservation.java | 1 - .../ec2/domain/ReservedInstancesOffering.java | 1 - .../jclouds/ec2/domain/RootDeviceType.java | 2 - .../jclouds/ec2/domain/RunningInstance.java | 1 - .../org/jclouds/ec2/domain/SecurityGroup.java | 1 - .../java/org/jclouds/ec2/domain/Snapshot.java | 1 - .../java/org/jclouds/ec2/domain/Subnet.java | 3 - .../main/java/org/jclouds/ec2/domain/Tag.java | 2 - .../jclouds/ec2/domain/UserIdGroupPair.java | 5 +- .../ec2/domain/VirtualizationType.java | 2 - .../java/org/jclouds/ec2/domain/Volume.java | 74 ++- .../java/org/jclouds/ec2/features/AMIApi.java | 2 - .../AvailabilityZoneAndRegionApi.java | 2 - .../ec2/features/ElasticBlockStoreApi.java | 33 +- .../ec2/features/ElasticIPAddressApi.java | 2 - .../org/jclouds/ec2/features/InstanceApi.java | 2 - .../org/jclouds/ec2/features/KeyPairApi.java | 2 - .../ec2/features/SecurityGroupApi.java | 2 - .../org/jclouds/ec2/features/SubnetApi.java | 2 - .../java/org/jclouds/ec2/features/TagApi.java | 1 - .../org/jclouds/ec2/features/WindowsApi.java | 1 - ...rtUnencodedBytesToBase64EncodedString.java | 2 - .../EncodedRSAPublicKeyToBase64.java | 1 - .../BundleInstanceS3StorageOptions.java | 1 - .../ec2/options/CreateImageOptions.java | 1 - .../ec2/options/CreateSnapshotOptions.java | 1 - .../ec2/options/CreateVolumeOptions.java | 146 +++++ .../DescribeAvailabilityZonesOptions.java | 1 - .../ec2/options/DescribeImagesOptions.java | 1 - .../ec2/options/DescribeRegionsOptions.java | 1 - .../ec2/options/DescribeSnapshotsOptions.java | 1 - .../ec2/options/DetachVolumeOptions.java | 1 - .../RegisterImageBackedByEbsOptions.java | 116 +++- .../ec2/options/RegisterImageOptions.java | 1 - .../ec2/options/RunInstancesOptions.java | 27 +- .../internal/BaseEC2RequestOptions.java | 4 - .../ec2/predicates/InstanceHasIpAddress.java | 2 - .../ec2/predicates/InstanceStateRunning.java | 2 - .../ec2/predicates/InstanceStateStopped.java | 2 - .../predicates/InstanceStateTerminated.java | 2 - .../ec2/predicates/SnapshotCompleted.java | 2 - .../ec2/predicates/VolumeAttached.java | 2 - .../ec2/predicates/VolumeAvailable.java | 2 - .../ec2/predicates/VolumeDetached.java | 2 - .../jclouds/ec2/reference/EC2Constants.java | 7 +- .../DescribeAvailabilityZonesInRegion.java | 0 .../DescribeRegionsForRegionURIs.java | 0 .../org/jclouds/ec2/util/IpPermissions.java | 2 - .../jclouds/ec2/util/SubnetFilterBuilder.java | 2 - .../jclouds/ec2/util/TagFilterBuilder.java | 1 - .../main/java/org/jclouds/ec2/util/Tags.java | 4 - .../xml/AllocateAddressResponseHandler.java | 3 - .../jclouds/ec2/xml/AttachmentHandler.java | 4 - .../ec2/xml/BaseReservationHandler.java | 4 - .../ec2/xml/BlockDeviceMappingHandler.java | 4 - .../jclouds/ec2/xml/BooleanValueHandler.java | 1 - .../jclouds/ec2/xml/BundleTaskHandler.java | 4 - .../ec2/xml/CreateVolumeResponseHandler.java | 33 +- .../xml/DescribeAddressesResponseHandler.java | 4 - ...cribeAvailabilityZonesResponseHandler.java | 4 - .../DescribeBundleTasksResponseHandler.java | 3 - .../xml/DescribeImagesResponseHandler.java | 33 +- .../xml/DescribeInstancesResponseHandler.java | 1 - .../xml/DescribeKeyPairsResponseHandler.java | 1 - .../xml/DescribeRegionsResponseHandler.java | 4 - ...DescribeSecurityGroupsResponseHandler.java | 1 - .../xml/DescribeSnapshotsResponseHandler.java | 3 - .../xml/DescribeSubnetsResponseHandler.java | 3 - .../ec2/xml/DescribeTagsResponseHandler.java | 2 - .../xml/DescribeVolumesResponseHandler.java | 3 - .../xml/GetConsoleOutputResponseHandler.java | 1 - .../xml/GetPasswordDataResponseHandler.java | 3 - .../org/jclouds/ec2/xml/ImageIdHandler.java | 1 - ...tanceInitiatedShutdownBehaviorHandler.java | 1 - .../ec2/xml/InstanceStateChangeHandler.java | 1 - .../jclouds/ec2/xml/InstanceTypeHandler.java | 1 - .../jclouds/ec2/xml/IpPermissionHandler.java | 4 - .../ec2/xml/KeyPairResponseHandler.java | 1 - .../jclouds/ec2/xml/PermissionHandler.java | 1 - .../ec2/xml/RunInstancesResponseHandler.java | 1 - .../jclouds/ec2/xml/SecurityGroupHandler.java | 3 - .../org/jclouds/ec2/xml/SnapshotHandler.java | 4 - .../jclouds/ec2/xml/StringValueHandler.java | 1 - .../org/jclouds/ec2/xml/SubnetHandler.java | 3 - .../java/org/jclouds/ec2/xml/TagHandler.java | 2 - .../org/jclouds/ec2/xml/TagSetHandler.java | 3 - .../ec2/xml/UnencodeStringValueHandler.java | 1 - .../services/org.jclouds.apis.ApiMetadata | 0 ...pplicationArchitecturesEC2ApiLiveTest.java | 4 +- .../jclouds/ec2/EBSBootEC2ApiLiveTest.java | 4 +- .../org/jclouds/ec2/EC2ApiMetadataTest.java | 4 - .../jclouds/ec2/EC2ContextBuilderText.java | 3 - ...kDeviceMappingToIndexedFormParamsTest.java | 2 - .../BindBundleIdsToIndexedFormParamsTest.java | 2 - .../BindFiltersToIndexedFormParamsTest.java | 2 - ...BindGroupNamesToIndexedFormParamsTest.java | 2 - ...indInstanceIdsToIndexedFormParamsTest.java | 2 - .../BindKeyNamesToIndexedFormParamsTest.java | 2 - ...ndProductCodesToIndexedFormParamsTest.java | 2 - .../BindPublicIpsToIndexedFormParamsTest.java | 2 - ...indResourceIdsToIndexedFormParamsTest.java | 2 - .../BindS3UploadPolicyAndSignatureTest.java | 2 - .../BindTagKeysToIndexedFormParamsTest.java | 2 - .../BindTagsToIndexedFormParamsTest.java | 2 - ...BindUserGroupsToIndexedFormParamsTest.java | 2 - ...irToSourceSecurityGroupFormParamsTest.java | 2 - .../BindUserIdsToIndexedFormParamsTest.java | 2 - .../BindVolumeIdsToIndexedFormParamsTest.java | 2 - ...llBindAvailabilityZoneToFormParamTest.java | 2 - .../compute/EC2ComputeServiceExpectTest.java | 319 +++++++++++ .../compute/EC2ComputeServiceLiveTest.java | 11 +- .../compute/EC2TemplateBuilderLiveTest.java | 0 .../ec2/compute/EC2TemplateBuilderTest.java | 20 +- .../compute/TestCanRecreateGroupLiveTest.java | 6 +- .../EC2ComputeServiceContextModuleTest.java | 3 - .../EC2ImageExtensionExpectTest.java | 4 - .../extensions/EC2ImageExtensionLiveTest.java | 3 - .../EC2SecurityGroupExtensionExpectTest.java | 4 - .../EC2SecurityGroupExtensionLiveTest.java | 3 - .../AddElasticIpsToNodemetadataTest.java | 3 - .../functions/CreateUniqueKeyPairTest.java | 7 +- .../compute/functions/EC2ImageParserTest.java | 3 - .../EC2SecurityGroupToSecurityGroupTest.java | 3 - .../functions/PresentInstancesTest.java | 3 - .../RunningInstanceToNodeMetadataTest.java | 5 +- ...LoginCredentialsFromEncryptedDataTest.java | 5 +- ...aseEC2ComputeServiceContextExpectTest.java | 0 .../BaseEC2ComputeServiceExpectTest.java | 68 ++- .../internal/EC2TemplateBuilderImplTest.java | 71 ++- .../CreateSecurityGroupIfNeededTest.java | 3 - .../LoadPublicIpForInstanceOrNullTest.java | 3 - .../loaders/RegionAndIdToImageTest.java | 3 - .../options/EC2TemplateOptionsTest.java | 45 +- ...GroupsAsNeededAndReturnRunOptionsTest.java | 34 +- ...EC2CreateNodesInGroupThenAddToSetTest.java | 23 +- .../strategy/EC2DestroyNodeStrategyTest.java | 3 - .../config/EC2HttpApiModuleExpectTest.java | 3 - .../ec2/features/AMIApiExpectTest.java | 3 - .../jclouds/ec2/features/AMIApiLiveTest.java | 37 +- .../org/jclouds/ec2/features/AMIApiTest.java | 2 - .../AvailabilityZoneAndRegionApiLiveTest.java | 2 - .../AvailabilityZoneAndRegionApiTest.java | 2 - .../jclouds/ec2/features/BaseEC2ApiTest.java | 3 - .../EC2ElasticBlockStoreApiExpectTest.java | 76 ++- .../ElasticBlockStoreApiLiveTest.java | 74 ++- .../features/ElasticBlockStoreApiTest.java | 2 - .../ElasticIPAddressApiExpectTest.java | 1 - .../features/ElasticIPAddressApiLiveTest.java | 2 - .../ec2/features/ElasticIPAddressApiTest.java | 2 - .../ec2/features/InstanceApiExpectTest.java | 1 - .../ec2/features/InstanceApiLiveTest.java | 2 - .../jclouds/ec2/features/InstanceApiTest.java | 2 - .../ec2/features/KeyPairApiExpectTest.java | 3 - .../ec2/features/KeyPairApiLiveTest.java | 2 - .../jclouds/ec2/features/KeyPairApiTest.java | 2 - .../features/SecurityGroupApiExpectTest.java | 3 - .../features/SecurityGroupApiLiveTest.java | 2 - .../ec2/features/SecurityGroupApiTest.java | 2 - .../ec2/features/SubnetApiExpectTest.java | 3 - .../ec2/features/SubnetApiLiveTest.java | 3 - .../ec2/features/TagApiExpectTest.java | 3 - .../ec2/features/WindowsApiExpectTest.java | 3 - .../ec2/features/WindowsApiLiveTest.java | 3 - .../jclouds/ec2/features/WindowsApiTest.java | 4 +- .../features/internal/BaseTagApiLiveTest.java | 2 - ...encodedBytesToBase64EncodedStringTest.java | 2 - .../EncodedRSAPublicKeyToBase64Test.java | 2 - .../ec2/internal/BaseEC2ApiExpectTest.java | 0 .../ec2/internal/BaseEC2ApiLiveTest.java | 4 - .../ec2/internal/BaseEC2ExpectTest.java | 0 .../BundleInstanceS3StorageOptionsTest.java | 2 - .../ec2/options/CreateImageOptionsTest.java | 2 - .../options/CreateSnapshotOptionsTest.java | 2 - .../ec2/options/CreateVolumeOptionsTest.java | 156 ++++++ .../options/DescribeImagesOptionsTest.java | 2 - .../options/DescribeSnapshotsOptionsTest.java | 2 - .../ec2/options/DetachVolumeOptionsTest.java | 2 - .../RegisterImageBackedByEbsOptionsTest.java | 77 ++- .../ec2/options/RegisterImageOptionsTest.java | 2 - .../ec2/options/RunInstancesOptionsTest.java | 31 +- .../parse/DescribeSubnetsResponseTest.java | 4 - .../ec2/parse/DescribeTagsResponseTest.java | 3 - .../parse/GetPasswordDataResponseTest.java | 3 - .../ec2/predicates/VolumeDetachedTest.java | 3 - ...DescribeAvailabilityZonesInRegionTest.java | 2 - .../jclouds/ec2/util/IpPermissionsTest.java | 2 - .../java/org/jclouds/ec2/util/TagsTest.java | 3 - .../AllocateAddressResponseHandlerTest.java | 2 - .../ec2/xml/AttachmentHandlerTest.java | 2 - .../jclouds/ec2/xml/BaseEC2HandlerTest.java | 4 - .../xml/BlockDeviceMappingHandlerTest.java | 2 - .../ec2/xml/BundleTaskHandlerTest.java | 2 - .../xml/CreateVolumeResponseHandlerTest.java | 8 +- .../DescribeAddressesResponseHandlerTest.java | 2 - ...eAvailabilityZonesResponseHandlerTest.java | 2 - ...escribeBundleTasksResponseHandlerTest.java | 2 - .../DescribeImagesResponseHandlerTest.java | 18 +- .../xml/DescribeInstanceAttributeTest.java | 2 - .../DescribeInstancesResponseHandlerTest.java | 4 +- .../DescribeKeyPairsResponseHandlerTest.java | 2 - .../DescribeRegionsResponseHandlerTest.java | 2 - ...ribeSecurityGroupsResponseHandlerTest.java | 2 - .../DescribeSnapshotsResponseHandlerTest.java | 2 - .../DescribeVolumesResponseHandlerTest.java | 15 +- .../GetConsoleOutputResponseHandlerTest.java | 2 - .../xml/InstanceStateChangeHandlerTest.java | 2 - .../ec2/xml/KeyPairResponseHandlerTest.java | 2 - .../ec2/xml/PermissionHandlerTest.java | 2 - .../xml/RunInstancesResponseHandlerTest.java | 2 - .../jclouds/ec2/xml/SnapshotHandlerTest.java | 2 - .../src/test/resources/allocate_address.xml | 0 .../src/test/resources/amzn_images.xml | 0 .../src/test/resources/attach.xml | 0 ...thorize_securitygroup_ingress_response.xml | 0 .../availabilityZones-ap-northeast-1.xml | 0 .../availabilityZones-ap-southeast-1.xml | 0 .../resources/availabilityZones-eu-west-1.xml | 0 .../resources/availabilityZones-sa-east-1.xml | 0 .../resources/availabilityZones-us-east-1.xml | 0 .../resources/availabilityZones-us-west-1.xml | 0 .../resources/availabilityZones-us-west-2.xml | 0 .../src/test/resources/availabilityZones.xml | 0 .../src/test/resources/bundle_instance.xml | 0 .../src/test/resources/cancel_bundle_task.xml | 0 .../src/test/resources/create_keypair.xml | 0 .../test/resources/created_securitygroup.xml | 0 .../src/test/resources/created_snapshot.xml | 0 .../src/test/resources/created_volume.xml | 3 + .../test/resources/delete_securitygroup.xml | 0 .../src/test/resources/describe_addresses.xml | 0 .../resources/describe_addresses_single.xml | 0 .../test/resources/describe_bundle_tasks.xml | 0 ...ibe_image_attribute_blockDeviceMapping.xml | 0 ...cribe_image_attribute_launchPermission.xml | 0 .../src/test/resources/describe_images.xml | 0 .../test/resources/describe_images_ebs.xml | 4 + .../describe_images_imageextension0.xml | 0 .../describe_images_imageextension1.xml | 0 .../describe_images_imageextension2.xml | 0 .../test/resources/describe_images_nova.xml | 0 .../test/resources/describe_images_tags.xml | 0 .../resources/describe_images_windows.xml | 0 .../src/test/resources/describe_instances.xml | 0 .../test/resources/describe_instances_ebs.xml | 0 .../resources/describe_instances_multiple.xml | 0 .../describe_instances_running-1.xml | 0 .../describe_instances_running-named.xml | 186 +++++++ .../resources/describe_instances_running.xml | 0 ...cribe_instances_running_securitygroups.xml | 0 .../describe_instances_three_ids.xml | 74 +++ .../src/test/resources/describe_keypairs.xml | 0 .../resources/describe_securitygroups.xml | 0 .../describe_securitygroups_empty.xml | 0 ...describe_securitygroups_extension_cidr.xml | 0 ...escribe_securitygroups_extension_group.xml | 0 .../describe_securitygroups_extension_new.xml | 0 ...scribe_securitygroups_extension_single.xml | 0 .../src/test/resources/describe_snapshots.xml | 0 .../src/test/resources/describe_subnets.xml | 0 .../src/test/resources/describe_tags.xml | 0 .../src/test/resources/describe_volumes.xml | 6 + .../resources/describe_volumes_single.xml | 3 + .../test/resources/disableApiTermination.xml | 0 .../resources/get_console_output_response.xml | 0 .../src/test/resources/get_passworddata.xml | 0 .../instanceInitiatedShutdownBehavior.xml | 0 .../src/test/resources/instanceType.xml | 0 .../src/test/resources/log4j.xml | 0 .../src/test/resources/new_instance.xml | 0 .../src/test/resources/new_securitygroup.xml | 0 .../src/test/resources/ramdisk.xml | 0 .../resources/regionEndpoints-additional.xml | 0 .../test/resources/regionEndpoints-all.xml | 0 .../src/test/resources/regionEndpoints.xml | 0 .../src/test/resources/run_instances.xml | 0 .../resources/run_instances_cloudbridge.xml | 0 .../test/resources/run_instances_three.xml | 74 +++ .../src/test/resources/start_instances.xml | 0 .../src/test/resources/stop_instances.xml | 0 .../test/resources/terminate_instances.xml | 0 .../src/test/resources/userData.xml | 0 .../openstack/nova/v2_0/NovaAsyncApi.java | 214 -------- .../nova/v2_0/domain/QuotaClass.java | 62 --- .../v2_0/extensions/AvailabilityZoneAPI.java | 40 -- .../extensions/AvailabilityZoneAsyncApi.java | 58 -- .../v2_0/extensions/FlavorExtraSpecsApi.java | 77 --- .../nova/v2_0/extensions/FloatingIPApi.java | 98 ---- .../extensions/HostAdministrationApi.java | 103 ---- .../v2_0/extensions/HostAggregateApi.java | 87 --- .../nova/v2_0/extensions/KeyPairApi.java | 65 --- .../nova/v2_0/extensions/QuotaApi.java | 57 -- .../nova/v2_0/extensions/QuotaClassApi.java | 51 -- .../v2_0/extensions/SecurityGroupApi.java | 89 ---- .../nova/v2_0/extensions/ServerAdminApi.java | 120 ----- .../ServerWithSecurityGroupsApi.java | 49 -- .../v2_0/extensions/VirtualInterfaceApi.java | 43 -- .../nova/v2_0/extensions/VolumeApi.java | 147 ----- .../extensions/VolumeAttachmentAsyncApi.java | 107 ---- .../nova/v2_0/extensions/VolumeTypeApi.java | 101 ---- .../nova/v2_0/features/FlavorApi.java | 78 --- .../nova/v2_0/features/ImageApi.java | 142 ----- .../nova/v2_0/features/ServerApi.java | 276 ---------- .../nova/v2_0/features/ServerAsyncApi.java | 356 ------------- .../AvailabilityZonesApiLiveTest.java | 45 -- .../extensions/QuotaClassApiExpectTest.java | 105 ---- .../extensions/QuotaClassApiLiveTest.java | 73 --- .../test/resources/attachment_details.json | 1 - .../src/test/resources/attachment_list.json | 1 - .../src/test/resources/extension_details.json | 21 - .../test/resources/extension_list_full.json | 281 ---------- .../test/resources/extension_list_normal.json | 31 -- .../resources/extension_list_openstack.json | 115 ---- .../src/test/resources/flavor_details.json | 19 - .../test/resources/flavor_list_detail.json | 1 - .../flavor_list_detail_openstack.json | 83 --- .../src/test/resources/flavor_new.json | 10 - .../test/resources/floatingip_details.json | 9 - .../src/test/resources/floatingip_list.json | 16 - .../src/test/resources/host.json | 1 - .../resources/host_aggregate_details.json | 1 - .../test/resources/host_aggregate_list.json | 1 - .../host_aggregate_with_host_details.json | 1 - .../src/test/resources/hosts_list.json | 1 - .../src/test/resources/image_active.json | 41 -- .../src/test/resources/image_details.json | 41 -- .../src/test/resources/image_list_detail.json | 1 - .../image_list_detail_imageextension.json | 121 ----- .../image_list_detail_openstack.json | 81 --- .../src/test/resources/quota_class.json | 15 - .../src/test/resources/quotas.json | 15 - .../test/resources/securitygroup_details.json | 34 -- ...ygroup_details_computeservice_typical.json | 51 -- .../securitygroup_details_extension.json | 34 -- ...curitygroup_details_extension_norules.json | 10 - .../securitygroup_details_port22.json | 19 - .../test/resources/securitygroup_list.json | 51 -- ...p_list_details_computeservice_typical.json | 53 -- .../securitygroup_list_extension.json | 51 -- .../resources/server_details_devstack.json | 44 -- .../test/resources/server_diagnostics.json | 17 - .../resources/server_list_details_essex.json | 152 ------ .../server_with_security_groups.json | 1 - ...server_with_security_groups_extension.json | 1 - .../test/resources/simple_tenant_usage.json | 1 - .../test/resources/simple_tenant_usages.json | 1 - .../src/test/resources/snapshot_details.json | 1 - .../src/test/resources/snapshot_list.json | 1 - .../test/resources/snapshot_list_detail.json | 1 - .../resources/virtual_interfaces_list.json | 1 - .../src/test/resources/volume_details.json | 1 - .../src/test/resources/volume_list.json | 1 - .../test/resources/volume_list_detail.json | 1 - .../src/test/resources/volume_type.json | 9 - .../resources/volume_type_extra_specs.json | 1 - .../src/test/resources/volume_type_list.json | 1 - .../README.txt | 0 .../{1.7.1-stratos => 1.8.0-stratos}/pom.xml | 18 +- .../jclouds/openstack/nova/v2_0/NovaApi.java | 70 ++- .../openstack/nova/v2_0/NovaApiMetadata.java | 38 +- .../binders/BindConsoleToJsonPayload.java | 63 +++ .../binders/BindKeyPairToJsonPayload.java | 4 - .../binders/BindMetadataToJsonPayload.java | 4 - .../BindSecurityGroupRuleToJsonPayload.java | 5 - .../nova/v2_0/compute/NovaComputeService.java | 3 - .../compute/NovaComputeServiceAdapter.java | 13 +- .../NovaComputeServiceContextModule.java | 41 +- .../extensions/NovaImageExtension.java | 3 - .../NovaSecurityGroupExtension.java | 4 +- .../AllocateAndAddFloatingIpToNode.java | 95 +++- .../CreateSecurityGroupIfNeeded.java | 4 - .../functions/FlavorInZoneToHardware.java | 2 - .../compute/functions/ImageInZoneToImage.java | 2 - .../functions/ImageToOperatingSystem.java | 2 - ...ovaSecurityGroupInZoneToSecurityGroup.java | 2 - .../NovaSecurityGroupToSecurityGroup.java | 6 +- .../functions/OrphanedGroupsByZoneId.java | 4 - ...RemoveFloatingIpFromNodeAndDeallocate.java | 2 - .../SecurityGroupRuleToIpPermission.java | 2 - .../functions/ServerInZoneToNodeMetadata.java | 22 +- .../compute/loaders/CreateUniqueKeyPair.java | 3 - .../loaders/FindSecurityGroupOrCreate.java | 4 - .../loaders/LoadFloatingIpsForInstance.java | 2 - .../options/NodeAndNovaTemplateOptions.java | 54 ++ .../compute/options/NovaTemplateOptions.java | 111 ++-- .../predicates/AllNodesInGroupTerminated.java | 3 - ...sWithGroupEncodedIntoNameThenAddToSet.java | 23 +- .../nova/v2_0/config/NovaHttpApiModule.java} | 89 +--- .../nova/v2_0/config/NovaParserModule.java | 29 +- .../nova/v2_0/config/NovaProperties.java | 2 - .../openstack/nova/v2_0/domain/Address.java | 1 - .../nova/v2_0/domain/BackupType.java | 3 - .../openstack/nova/v2_0/domain/Console.java | 161 ++++++ .../openstack/nova/v2_0/domain/Flavor.java | 1 - .../nova/v2_0/domain/FloatingIP.java | 49 +- .../openstack/nova/v2_0/domain/Host.java | 0 .../nova/v2_0/domain/HostAggregate.java | 2 +- .../nova/v2_0/domain/HostResourceUsage.java | 0 .../openstack/nova/v2_0/domain/Image.java | 2 - .../openstack/nova/v2_0/domain/Ingress.java | 1 - .../openstack/nova/v2_0/domain/KeyPair.java | 0 .../openstack/nova/v2_0/domain/Network.java | 1 - .../openstack/nova/v2_0/domain/Quota.java | 0 .../nova/v2_0/domain/RebootType.java | 4 - .../nova/v2_0/domain/SecurityGroup.java | 0 .../nova/v2_0/domain/SecurityGroupRule.java | 0 .../openstack/nova/v2_0/domain/Server.java | 16 +- .../nova/v2_0/domain/ServerCreated.java | 1 - .../v2_0/domain/ServerExtendedAttributes.java | 1 - .../v2_0/domain/ServerExtendedStatus.java | 1 - .../v2_0/domain/ServerWithSecurityGroups.java | 1 - .../nova/v2_0/domain/SimpleServerUsage.java | 1 - .../nova/v2_0/domain/SimpleTenantUsage.java | 1 - .../nova/v2_0/domain/TenantIdAndName.java | 1 - .../nova/v2_0/domain/VirtualInterface.java | 1 - .../openstack/nova/v2_0/domain/Volume.java | 0 .../nova/v2_0/domain/VolumeAttachment.java | 0 .../nova/v2_0/domain/VolumeSnapshot.java | 0 .../nova/v2_0/domain/VolumeType.java | 0 .../domain/zonescoped/AvailabilityZone.java | 31 +- .../v2_0/domain/zonescoped/FlavorInZone.java | 3 - .../v2_0/domain/zonescoped/ImageInZone.java | 3 - .../zonescoped/SecurityGroupInZone.java | 3 - .../v2_0/domain/zonescoped/ServerInZone.java | 3 - .../v2_0/domain/zonescoped/ZoneAndId.java | 3 - .../v2_0/domain/zonescoped/ZoneAndName.java | 2 - .../ZoneSecurityGroupNameAndPorts.java | 3 - .../v2_0/domain/zonescoped/ZoneState.java | 31 +- .../v2_0/extensions/AvailabilityZoneApi.java} | 44 +- .../nova/v2_0/extensions/ConsolesApi.java} | 54 +- .../v2_0/extensions/ExtensionNamespaces.java | 15 +- .../v2_0/extensions/FlavorExtraSpecsApi.java} | 78 +-- .../nova/v2_0/extensions/FloatingIPApi.java} | 109 ++-- .../extensions/HostAdministrationApi.java} | 97 ++-- .../v2_0/extensions/HostAggregateApi.java} | 88 ++- .../nova/v2_0/extensions/KeyPairApi.java} | 79 ++- .../nova/v2_0/extensions/QuotaApi.java} | 46 +- .../v2_0/extensions/SecurityGroupApi.java} | 104 ++-- .../nova/v2_0/extensions/ServerAdminApi.java} | 124 +++-- .../ServerWithSecurityGroupsApi.java} | 32 +- .../extensions/SimpleTenantUsageApi.java} | 39 +- .../v2_0/extensions/VirtualInterfaceApi.java} | 20 +- .../nova/v2_0/extensions/VolumeApi.java} | 109 ++-- .../v2_0/extensions/VolumeAttachmentApi.java | 85 ++- .../nova/v2_0/extensions/VolumeTypeApi.java} | 101 ++-- .../nova/v2_0/features/FlavorApi.java} | 86 ++- .../nova/v2_0/features/ImageApi.java} | 175 +++--- .../nova/v2_0/features/ServerApi.java | 433 +++++++++++++++ .../functions/FieldValueResponseParsers.java | 0 .../nova/v2_0/functions/OverLimitParser.java | 3 - .../ParseImageIdFromLocationHeader.java | 4 +- .../internal/OnlyMetadataValueOrNull.java | 4 - .../functions/internal/ParseDiagnostics.java | 11 +- .../internal/ParseFlavorDetails.java | 2 - .../v2_0/functions/internal/ParseFlavors.java | 2 - .../functions/internal/ParseImageDetails.java | 2 - .../v2_0/functions/internal/ParseImages.java | 2 - .../functions/internal/ParseKeyPairs.java | 4 - .../internal/ParseServerDetails.java | 2 - .../v2_0/functions/internal/ParseServers.java | 2 - .../nova/v2_0/handlers/NovaErrorHandler.java | 3 - .../options/CreateBackupOfServerOptions.java | 3 - .../v2_0/options/CreateServerOptions.java | 30 +- .../v2_0/options/CreateVolumeOptions.java | 3 - .../options/CreateVolumeSnapshotOptions.java | 3 - .../v2_0/options/CreateVolumeTypeOptions.java | 3 - .../nova/v2_0/options/ListOptions.java | 1 - .../v2_0/options/RebuildServerOptions.java | 4 - ...indSecurityGroupWithNameAndReturnTrue.java | 2 - .../nova/v2_0/predicates/ImagePredicates.java | 2 - .../v2_0/predicates/KeyPairPredicates.java | 2 - .../predicates/SecurityGroupPredicates.java | 2 - .../v2_0/predicates/ServerPredicates.java | 117 ++++ .../services/org.jclouds.apis.ApiMetadata | 0 ...eyAndTenantIdAuthenticationExpectTest.java | 3 +- ...tNamePropertyAuthenticationExpectTest.java | 3 +- ...yAndSecretKeyAuthenticationExpectTest.java | 3 +- .../v2_0/EndpointIdIsRandomExpectTest.java | 2 - .../nova/v2_0/NovaApiMetadataTest.java | 4 - .../PasswordAuthenticationExpectTest.java | 3 +- ...uthenticationWithTenantNameExpectTest.java | 3 +- .../NovaComputeServiceAdapterExpectTest.java | 175 ++++-- .../compute/NovaComputeServiceExpectTest.java | 39 +- .../compute/NovaComputeServiceLiveTest.java | 4 - .../NovaImageExtensionExpectTest.java | 12 +- .../NovaImageExtensionLiveTest.java | 3 - .../NovaSecurityGroupExtensionExpectTest.java | 40 +- .../NovaSecurityGroupExtensionLiveTest.java | 3 - ...ocateAndAddFloatingIpToNodeExpectTest.java | 64 ++- .../functions/FlavorInZoneToHardwareTest.java | 2 - .../functions/ImageInZoneToImageTest.java | 2 - .../functions/ImageToOperatingSystemTest.java | 2 - ...ecurityGroupInZoneToSecurityGroupTest.java | 3 - .../NovaSecurityGroupToSecurityGroupTest.java | 5 +- .../functions/OrphanedGroupsByZoneIdTest.java | 5 - .../SecurityGroupRuleToIpPermissionTest.java | 6 +- .../ServerInZoneToNodeMetadataTest.java | 44 +- .../loaders/CreateUniqueKeyPairTest.java | 3 - .../FindSecurityGroupOrCreateTest.java | 3 - .../LoadFloatingIpsForInstanceTest.java | 3 - .../options/NovaTemplateOptionsTest.java | 4 +- .../extensions/AdminActionsApiExpectTest.java | 51 +- .../extensions/AdminActionsApiLiveTest.java | 2 - .../AvailabilityZoneApiExpectTest.java | 41 +- .../AvailabilityZonesApiLiveTest.java | 43 ++ .../v2_0/extensions/ConsolesApiLiveTest.java | 64 +++ .../v2_0/extensions/ConsolesApiMockTest.java | 144 +++++ .../FlavorExtraSpecsApiExpectTest.java | 18 +- .../FlavorExtraSpecsApiLiveTest.java | 2 - .../extensions/FloatingIPApiExpectTest.java | 18 +- .../extensions/FloatingIPApiLiveTest.java | 6 +- .../HostAdministrationApiExpectTest.java | 28 +- .../HostAdministrationApiLiveTest.java | 2 - .../HostAggregateApiExpectTest.java | 24 +- .../extensions/HostAggregateApiLiveTest.java | 2 - .../v2_0/extensions/KeyPairApiExpectTest.java | 55 +- .../v2_0/extensions/KeyPairApiLiveTest.java | 40 +- .../v2_0/extensions/QuotaApiExpectTest.java | 16 +- .../v2_0/extensions/QuotaApiLiveTest.java | 2 - .../SecurityGroupApiExpectTest.java | 24 +- .../extensions/SecurityGroupApiLiveTest.java | 2 - ...ServerWithSecurityGroupsApiExpectTest.java | 6 +- .../ServerWithSecurityGroupsApiLiveTest.java | 2 - .../SimpleTenantUsageApiExpectTest.java | 6 +- .../SimpleTenantUsageApiLiveTest.java | 2 - .../VirtualInterfaceApiExpectTest.java | 6 +- .../VirtualInterfaceApiLiveTest.java | 2 - .../v2_0/extensions/VolumeApiExpectTest.java | 60 +-- .../v2_0/extensions/VolumeApiLiveTest.java | 18 +- .../VolumeAttachmentApiExpectTest.java | 20 +- .../VolumeAttachmentApiLiveTest.java | 2 - .../extensions/VolumeTypeApiExpectTest.java | 34 +- .../extensions/VolumeTypeApiLiveTest.java | 2 - .../v2_0/features/ExtensionApiExpectTest.java | 39 +- .../v2_0/features/ExtensionApiLiveTest.java | 2 - .../v2_0/features/FlavorApiExpectTest.java | 64 +-- .../nova/v2_0/features/FlavorApiLiveTest.java | 2 - .../v2_0/features/ImageApiExpectTest.java | 153 +++--- .../nova/v2_0/features/ImageApiLiveTest.java | 2 - .../v2_0/features/ServerApiExpectTest.java | 357 ++++++------- .../nova/v2_0/features/ServerApiLiveTest.java | 66 ++- .../CreateSecurityGroupIfNeededTest.java | 16 +- ...yGroupWithNameAndReturnTrueExpectTest.java | 8 +- .../v2_0/functions/InternalURLLiveTest.java | 1 - .../v2_0/handlers/NovaErrorHandlerTest.java | 12 +- .../v2_0/internal/BaseNovaApiExpectTest.java | 2 - .../v2_0/internal/BaseNovaApiLiveTest.java | 38 +- ...seNovaComputeServiceContextExpectTest.java | 18 +- .../BaseNovaComputeServiceExpectTest.java | 2 - .../v2_0/internal/BaseNovaExpectTest.java | 4 +- ...omputeServiceTypicalSecurityGroupTest.java | 4 - .../v2_0/parse/ParseCreateFlavorTest.java | 33 +- .../v2_0/parse/ParseCreatedServerTest.java | 7 +- .../parse/ParseExtensionListNormalTest.java | 4 - .../v2_0/parse/ParseExtensionListTest.java | 4 - .../nova/v2_0/parse/ParseExtensionTest.java | 3 - .../nova/v2_0/parse/ParseFlavorListTest.java | 8 +- .../nova/v2_0/parse/ParseFlavorTest.java | 5 +- .../v2_0/parse/ParseFloatingIPListTest.java | 10 +- .../nova/v2_0/parse/ParseFloatingIPTest.java | 4 +- .../nova/v2_0/parse/ParseImageListTest.java | 8 +- .../nova/v2_0/parse/ParseImageTest.java | 7 +- .../nova/v2_0/parse/ParseKeyPairListTest.java | 4 - .../nova/v2_0/parse/ParseKeyPairTest.java | 5 +- .../v2_0/parse/ParseMetadataItemTest.java | 4 - .../v2_0/parse/ParseMetadataListTest.java | 4 - .../v2_0/parse/ParseMetadataUpdateTest.java | 4 - .../v2_0/parse/ParseNOVNCConsoleTest.java | 69 +++ .../nova/v2_0/parse/ParseRDPConsoleTest.java | 70 +++ .../v2_0/parse/ParseSPICEConsoleTest.java | 70 +++ .../parse/ParseSecurityGroupListTest.java | 4 - .../v2_0/parse/ParseSecurityGroupTest.java | 4 - .../parse/ParseServerDetailsEssexTest.java | 9 +- .../parse/ParseServerDetailsStatesTest.java | 252 +++++++++ .../v2_0/parse/ParseServerDiagnostics.java | 40 +- .../nova/v2_0/parse/ParseServerListTest.java | 8 +- .../nova/v2_0/parse/ParseServerTest.java | 13 +- .../ParseServerWithAllExtensionsTest.java | 3 - .../ParseServerWithInternetAddressesTest.java | 5 +- .../parse/ParseServerWithoutImageTest.java | 99 ++++ .../v2_0/parse/ParseXVPVNCConsoleTest.java | 68 +++ ...licIpsInPrivateAddressBlockExpectTest.java | 5 +- .../v2_0/predicates/ImagePredicatesTest.java | 4 - .../SecurityGroupPredicatesTest.java | 4 - .../predicates/ServerPredicatesMockTest.java | 105 ++++ .../src/test/resources/access.json | 228 ++++++++ .../test/resources/attachment_details.json | 8 + .../src/test/resources/attachment_list.json | 10 + .../src/test/resources/extension_details.json | 21 + .../src/test/resources/extension_list.json | 2 +- .../test/resources/extension_list_full.json | 284 ++++++++++ .../test/resources/extension_list_normal.json | 36 ++ .../resources/extension_list_openstack.json | 140 +++++ .../src/test/resources/flavor_details.json | 19 + .../src/test/resources/flavor_list.json | 6 +- .../test/resources/flavor_list_detail.json | 124 +++++ .../flavor_list_detail_openstack.json | 104 ++++ .../src/test/resources/flavor_new.json | 10 + .../test/resources/floatingip_details.json | 9 + .../src/test/resources/floatingip_list.json | 30 ++ .../src/test/resources/host.json | 40 ++ .../resources/host_aggregate_details.json | 17 + .../test/resources/host_aggregate_list.json | 19 + .../host_aggregate_with_host_details.json | 19 + .../src/test/resources/hosts_list.json | 8 + .../src/test/resources/image_active.json | 41 ++ .../src/test/resources/image_details.json | 41 ++ .../src/test/resources/image_list.json | 20 +- .../src/test/resources/image_list_detail.json | 503 ++++++++++++++++++ .../image_list_detail_imageextension.json | 146 +++++ .../image_list_detail_openstack.json | 98 ++++ .../keypair_created_computeservice.json | 2 +- .../src/test/resources/keypair_details.json} | 2 +- .../src/test/resources/keypair_list.json | 2 +- .../test/resources/listAvailabilityZones.json | 0 .../src/test/resources/metadata_item.json | 4 +- .../src/test/resources/metadata_list.json | 4 +- .../src/test/resources/metadata_updated.json | 4 +- .../src/test/resources/new_server.json | 39 +- .../resources/new_server_config_drive.json} | 4 +- .../new_server_disk_config_auto.json | 49 ++ .../new_server_disk_config_manual.json | 39 +- .../test/resources/new_server_in_zone.json | 39 +- .../new_server_networks_response.json | 2 +- .../resources/new_server_no_adminpass.json | 2 +- .../resources/new_server_nova_networks.json | 0 .../src/test/resources/novnc_console.json | 7 + .../src/test/resources/quotas.json | 17 + .../src/test/resources/rdp_console.json | 7 + .../test/resources/securitygroup_created.json | 4 +- .../test/resources/securitygroup_details.json | 33 ++ ...ygroup_details_computeservice_typical.json | 56 ++ .../securitygroup_details_extension.json | 33 ++ ...curitygroup_details_extension_norules.json | 9 + .../securitygroup_details_port22.json | 21 + .../test/resources/securitygroup_list.json | 45 ++ ...p_list_details_computeservice_typical.json | 58 ++ .../securitygroup_list_extension.json | 45 ++ .../resources/securitygrouprule_created.json | 5 +- .../securitygrouprule_created_cidr.json | 2 +- .../securitygrouprule_created_group.json | 2 +- .../src/test/resources/server_details.json} | 41 +- .../resources/server_details_devstack.json | 60 +++ .../resources/server_details_openstack.json | 49 +- .../server_details_without_image.json} | 22 +- .../test/resources/server_diagnostics.json | 17 + .../src/test/resources/server_list.json | 4 +- .../test/resources/server_list_details.json | 78 +++ .../resources/server_list_details_essex.json | 188 +++++++ .../resources/server_list_details_states.json | 342 ++++++++++++ .../server_public_ip_in_private.json | 56 +- .../server_with_security_groups.json | 62 +++ ...server_with_security_groups_extension.json | 59 ++ .../test/resources/simple_tenant_usage.json | 39 ++ .../test/resources/simple_tenant_usages.json | 13 + .../src/test/resources/snapshot_details.json | 11 + .../src/test/resources/snapshot_list.json | 13 + .../test/resources/snapshot_list_detail.json | 13 + .../src/test/resources/spice_console.json | 7 + .../resources/virtual_interfaces_list.json | 8 + .../src/test/resources/volume_details.json | 22 + .../src/test/resources/volume_list.json | 24 + .../test/resources/volume_list_detail.json | 24 + .../src/test/resources/volume_type.json | 14 + .../resources/volume_type_extra_specs.json | 5 + .../src/test/resources/volume_type_list.json | 16 + .../src/test/resources/xvpvnc_console.json | 7 + .../README.txt | 0 .../{1.7.1-stratos => 1.8.0-stratos}/pom.xml | 6 +- .../vcloud/TaskInErrorStateException.java | 5 - .../vcloud/TaskStillRunningException.java | 5 - .../java/org/jclouds/vcloud/VCloudApi.java | 1 - .../org/jclouds/vcloud/VCloudApiMetadata.java | 2 - .../org/jclouds/vcloud/VCloudMediaType.java | 2 +- .../vcloud/VCloudResponseException.java | 3 - .../java/org/jclouds/vcloud/VCloudToken.java | 3 - .../org/jclouds/vcloud/VCloudVersionsApi.java | 4 +- .../binders/BindCPUCountToXmlPayload.java | 5 - .../BindCaptureVAppParamsToXmlPayload.java | 5 - .../binders/BindCatalogItemToXmlPayload.java | 5 - .../binders/BindCloneParamsToXmlPayload.java | 5 - .../BindCloneVAppParamsToXmlPayload.java | 5 - ...ndCloneVAppTemplateParamsToXmlPayload.java | 5 - .../BindDeployVAppParamsToXmlPayload.java | 5 - ...GuestCustomizationSectionToXmlPayload.java | 5 - ...antiateVAppTemplateParamsToXmlPayload.java | 5 - .../binders/BindMemoryToXmlPayload.java | 5 - ...dNetworkConnectionSectionToXmlPayload.java | 5 - .../binders/BindParamsToXmlPayload.java | 5 - .../BindUndeployVAppParamsToXmlPayload.java | 5 - .../OrgNameAndCatalogNameToEndpoint.java | 4 - .../binders/OrgNameAndVDCNameToEndpoint.java | 4 - .../OrgNameCatalogNameItemNameToEndpoint.java | 4 - ...CatalogNameVAppTemplateNameToEndpoint.java | 4 - .../OrgNameVDCNameNetworkNameToEndpoint.java | 4 - ...meVDCNameResourceEntityNameToEndpoint.java | 4 - .../OrgNameVDCNameResourceNameToEndpoint.java | 4 - .../VCloudComputeServiceContextModule.java | 2 - ...CloudComputeServiceDependenciesModule.java | 4 - .../functions/FindLocationForResource.java | 3 - .../compute/functions/HardwareForVApp.java | 3 - .../functions/HardwareForVAppTemplate.java | 3 - .../functions/ImageForVAppTemplate.java | 3 - .../compute/functions/VAppToNodeMetadata.java | 1 - ...ardwareBuilderFromResourceAllocations.java | 3 - ...velopeOrThrowIllegalArgumentException.java | 3 - .../internal/VCloudTemplateBuilderImpl.java | 13 +- .../options/VCloudTemplateOptions.java | 2 - ...IntoNameThenCustomizeDeployAndPowerOn.java | 3 - ...workConfigurationForNetworkAndOptions.java | 4 - .../strategy/VCloudComputeServiceAdapter.java | 1 - .../compute/util/VCloudComputeUtils.java | 4 - .../vcloud/config/DefaultCatalogForOrg.java | 4 - .../vcloud/config/DefaultNetworkForVDC.java | 4 - .../vcloud/config/DefaultOrgForUser.java | 4 - .../vcloud/config/DefaultTasksListForOrg.java | 4 - .../config/DefaultVCloudReferencesModule.java | 4 - .../vcloud/config/DefaultVDCForOrg.java | 4 - .../vcloud/config/VCloudHttpApiModule.java | 2 - .../vcloud/domain/AllocationModel.java | 0 .../org/jclouds/vcloud/domain/Capacity.java | 2 - .../org/jclouds/vcloud/domain/Catalog.java | 3 - .../jclouds/vcloud/domain/CatalogItem.java | 3 - .../domain/GuestCustomizationSection.java | 0 .../domain/InstantiateVAppTemplateParams.java | 0 .../vcloud/domain/NetworkConnection.java | 2 - .../domain/NetworkConnectionSection.java | 0 .../java/org/jclouds/vcloud/domain/Org.java | 2 - .../jclouds/vcloud/domain/ReferenceType.java | 5 +- .../org/jclouds/vcloud/domain/Status.java | 2 - .../java/org/jclouds/vcloud/domain/Task.java | 0 .../org/jclouds/vcloud/domain/TaskStatus.java | 3 - .../org/jclouds/vcloud/domain/TasksList.java | 3 - .../java/org/jclouds/vcloud/domain/VApp.java | 2 - .../jclouds/vcloud/domain/VAppTemplate.java | 2 - .../jclouds/vcloud/domain/VCloudError.java | 5 - .../jclouds/vcloud/domain/VCloudSession.java | 4 - .../java/org/jclouds/vcloud/domain/VDC.java | 2 - .../org/jclouds/vcloud/domain/VDCStatus.java | 0 .../java/org/jclouds/vcloud/domain/Vm.java | 2 - .../vcloud/domain/internal/CatalogImpl.java | 6 +- .../domain/internal/CatalogItemImpl.java | 5 - .../vcloud/domain/internal/ErrorImpl.java | 5 - .../vcloud/domain/internal/OrgImpl.java | 3 - .../domain/internal/ReferenceTypeImpl.java | 16 +- .../vcloud/domain/internal/TaskImpl.java | 5 - .../vcloud/domain/internal/TasksListImpl.java | 3 - .../vcloud/domain/internal/VAppImpl.java | 3 - .../domain/internal/VAppTemplateImpl.java | 3 - .../vcloud/domain/internal/VDCImpl.java | 3 - .../vcloud/domain/internal/VmImpl.java | 3 - .../vcloud/domain/network/DhcpService.java | 0 .../vcloud/domain/network/Features.java | 0 .../vcloud/domain/network/FenceMode.java | 2 - .../domain/network/FirewallService.java | 0 .../network/IpAddressAllocationMode.java | 2 - .../vcloud/domain/network/IpRange.java | 1 - .../vcloud/domain/network/IpScope.java | 1 - .../vcloud/domain/network/NatService.java | 0 .../vcloud/domain/network/NetworkConfig.java | 4 - .../vcloud/domain/network/OrgNetwork.java | 2 - .../network/firewall/FirewallPolicy.java | 1 - .../network/firewall/FirewallProtocols.java | 2 - .../domain/network/firewall/FirewallRule.java | 1 - .../network/internal/OrgNetworkImpl.java | 4 - .../vcloud/domain/network/nat/NatPolicy.java | 1 - .../domain/network/nat/NatProtocol.java | 2 - .../vcloud/domain/network/nat/NatRule.java | 2 - .../vcloud/domain/network/nat/NatType.java | 2 - .../domain/network/nat/rules/MappingMode.java | 1 - .../network/nat/rules/OneToOneVmRule.java | 1 - .../network/nat/rules/PortForwardingRule.java | 1 - .../domain/network/nat/rules/VmRule.java | 1 - ...EditableResourceAllocationSettingData.java | 4 - .../vcloud/domain/ovf/VCloudHardDisk.java | 4 - .../domain/ovf/VCloudNetworkAdapter.java | 4 - .../domain/ovf/VCloudNetworkSection.java | 0 .../ovf/VCloudOperatingSystemSection.java | 0 .../ovf/VCloudVirtualHardwareSection.java | 0 .../org/jclouds/vcloud/endpoints/Catalog.java | 3 - .../org/jclouds/vcloud/endpoints/Network.java | 3 - .../org/jclouds/vcloud/endpoints/Org.java | 3 - .../org/jclouds/vcloud/endpoints/OrgList.java | 3 - .../jclouds/vcloud/endpoints/TasksList.java | 3 - .../jclouds/vcloud/endpoints/VCloudLogin.java | 2 - .../org/jclouds/vcloud/endpoints/VDC.java | 3 - .../jclouds/vcloud/features/CatalogApi.java | 1 - .../jclouds/vcloud/features/NetworkApi.java | 1 - .../org/jclouds/vcloud/features/OrgApi.java | 2 - .../org/jclouds/vcloud/features/TaskApi.java | 2 - .../org/jclouds/vcloud/features/VAppApi.java | 1 - .../vcloud/features/VAppTemplateApi.java | 1 - .../org/jclouds/vcloud/features/VDCApi.java | 2 - .../org/jclouds/vcloud/features/VmApi.java | 2 - ...VCloudAuthorizationAndCookieToRequest.java | 31 +- .../functions/CatalogItemsInCatalog.java | 3 - .../vcloud/functions/CatalogItemsInOrg.java | 3 - .../vcloud/functions/CatalogsInOrg.java | 38 +- .../DefaultNetworkNameInTemplate.java | 0 .../vcloud/functions/NetworksInOrg.java | 3 - .../vcloud/functions/OrgNameToEndpoint.java | 4 - .../functions/OrgNameToTasksListEndpoint.java | 4 - .../vcloud/functions/OrgsForLocations.java | 3 - .../vcloud/functions/OrgsForNames.java | 3 - .../ParseLoginResponseFromHeaders.java | 4 +- .../VAppTemplatesForCatalogItems.java | 3 - .../vcloud/functions/VAppTemplatesInOrg.java | 3 - .../jclouds/vcloud/functions/VDCsInOrg.java | 3 - .../ParseVCloudErrorFromHttpResponse.java | 5 +- .../filters/VCloudBasicAuthentication.java | 0 .../http/filters/VCloudSupportedVersions.java | 0 .../vcloud/internal/VCloudLoginApi.java | 3 +- .../org/jclouds/vcloud/loaders/OVFLoader.java | 0 .../vcloud/loaders/VAppTemplateLoader.java | 0 .../jclouds/vcloud/location/DefaultVDC.java | 0 .../location/OrgAndVDCToLocationSupplier.java | 3 - .../vcloud/options/CaptureVAppOptions.java | 5 - .../vcloud/options/CatalogItemOptions.java | 5 - .../jclouds/vcloud/options/CloneOptions.java | 5 - .../vcloud/options/CloneVAppOptions.java | 5 - .../options/CloneVAppTemplateOptions.java | 5 - .../InstantiateVAppTemplateOptions.java | 5 - .../vcloud/predicates/TaskSuccess.java | 2 - .../vcloud/reference/VCloudConstants.java | 7 +- .../vcloud/reference/package-info.java | 1 - ...NameMatchingConfigurationKeyOrDefault.java | 4 - .../suppliers/VAppTemplatesSupplier.java | 3 - .../java/org/jclouds/vcloud/util/Utils.java | 4 - .../org/jclouds/vcloud/util/VCloudUtils.java | 2 - .../jclouds/vcloud/xml/CatalogHandler.java | 3 - .../vcloud/xml/CatalogItemHandler.java | 3 - .../org/jclouds/vcloud/xml/ErrorHandler.java | 3 - .../xml/GuestCustomizationSectionHandler.java | 3 - .../vcloud/xml/NetworkConnectionHandler.java | 3 - .../xml/NetworkConnectionSectionHandler.java | 3 - .../org/jclouds/vcloud/xml/OrgHandler.java | 3 - .../jclouds/vcloud/xml/OrgListHandler.java | 5 +- .../jclouds/vcloud/xml/OrgNetworkHandler.java | 3 - .../vcloud/xml/SupportedVersionsHandler.java | 3 - .../org/jclouds/vcloud/xml/TaskHandler.java | 3 - .../jclouds/vcloud/xml/TasksListHandler.java | 3 - .../org/jclouds/vcloud/xml/VAppHandler.java | 3 - .../vcloud/xml/VAppTemplateHandler.java | 3 - .../xml/VCloudVirtualHardwareHandler.java | 3 - .../org/jclouds/vcloud/xml/VDCHandler.java | 3 - .../org/jclouds/vcloud/xml/VmHandler.java | 3 - .../xml/ovf/VCloudNetworkSectionHandler.java | 3 - .../xml/ovf/VCloudOperatingSystemHandler.java | 3 - ...dResourceAllocationSettingDataHandler.java | 3 - .../services/org.jclouds.apis.ApiMetadata | 0 .../jclouds/vcloud/VCloudApiMetadataTest.java | 4 - .../org/jclouds/vcloud/VCloudApiTest.java | 2 - .../vcloud/VCloudSessionRefreshLiveTest.java | 2 - .../jclouds/vcloud/VCloudVersionsApiTest.java | 2 - .../BindCatalogItemToXmlPayloadTest.java | 2 - .../BindCloneVAppParamsToXmlPayloadTest.java | 2 - ...oneVAppTemplateParamsToXmlPayloadTest.java | 2 - .../BindDeployVAppParamsToXmlPayloadTest.java | 2 - ...ateVAppTemplateParamsToXmlPayloadTest.java | 2 - ...workConnectionSectionToXmlPayloadTest.java | 2 - ...indUndeployVAppParamsToXmlPayloadTest.java | 2 - .../BaseVCloudComputeServiceExpectTest.java | 20 +- .../compute/VCloudComputeServiceLiveTest.java | 5 - .../FindLocationForResourceTest.java | 2 - .../ListImagesInVCloudExpectTest.java | 4 - .../functions/VAppToNodeMetadataTest.java | 2 - .../options/VCloudTemplateOptionsTest.java | 2 - ...enCustomizeDeployAndPowerOnExpectTest.java | 4 - .../VCloudComputeServiceAdapterTest.java | 2 +- .../vcloud/features/CatalogApiLiveTest.java | 3 - .../vcloud/features/CatalogApiTest.java | 2 - .../vcloud/features/NetworkApiLiveTest.java | 3 - .../vcloud/features/NetworkApiTest.java | 2 - .../vcloud/features/OrgApiLiveTest.java | 3 - .../jclouds/vcloud/features/OrgApiTest.java | 2 - .../vcloud/features/TaskApiLiveTest.java | 3 - .../jclouds/vcloud/features/TaskApiTest.java | 2 - .../vcloud/features/VAppApiLiveTest.java | 4 - .../jclouds/vcloud/features/VAppApiTest.java | 2 - .../features/VAppTemplateApiLiveTest.java | 4 - .../vcloud/features/VAppTemplateApiTest.java | 2 - .../vcloud/features/VDCApiLiveTest.java | 3 - .../jclouds/vcloud/features/VDCApiTest.java | 2 - .../vcloud/features/VmApiLiveTest.java | 2 - .../jclouds/vcloud/features/VmApiTest.java | 2 - ...udAuthorizationAndCookieToRequestTest.java | 16 +- .../ParseLoginResponseFromHeadersTest.java | 2 - .../ParseVCloudErrorFromHttpResponseTest.java | 4 - .../vcloud/internal/BasePayloadTest.java | 0 .../internal/BaseVCloudApiLiveTest.java | 4 - .../vcloud/internal/BaseVCloudApiTest.java | 2 - .../vcloud/internal/VCloudLoginApiTest.java | 6 +- .../InstantiateVAppTemplateOptionsTest.java | 2 - ...MatchingConfigurationKeyOrDefaultTest.java | 2 - .../org/jclouds/vcloud/utils/TestUtils.java | 2 - .../vcloud/xml/CatalogHandlerTest.java | 2 - .../vcloud/xml/CatalogItemHandlerTest.java | 6 +- .../GuestCustomizationSectionHandlerTest.java | 2 - .../xml/NetworkConnectionHandlerTest.java | 2 - .../NetworkConnectionSectionHandlerTest.java | 2 - .../jclouds/vcloud/xml/OrgHandlerTest.java | 2 - .../vcloud/xml/OrgListHandlerTest.java | 2 - .../vcloud/xml/OrgNetworkHandlerTest.java | 2 - .../xml/SupportedVersionsHandlerTest.java | 2 - .../jclouds/vcloud/xml/TaskHandlerTest.java | 2 - .../vcloud/xml/TasksListHandlerTest.java | 2 - .../jclouds/vcloud/xml/VAppHandlerTest.java | 2 - .../vcloud/xml/VAppTemplateHandlerTest.java | 2 - .../jclouds/vcloud/xml/VDCHandlerTest.java | 2 - .../org/jclouds/vcloud/xml/VmHandlerTest.java | 2 - ...loudOperatingSystemSectionHandlerTest.java | 2 - ...loudVirtualHardwareSectionHandlerTest.java | 6 +- .../test/resources/captureVApp-default.xml | 0 .../src/test/resources/captureVApp.xml | 0 .../src/test/resources/catalog-blank.xml | 0 .../src/test/resources/catalog-hosting.xml | 0 .../src/test/resources/catalog.xml | 0 .../src/test/resources/catalog1.0-vcd15.xml | 0 ...ogItem-carrenza-with-default-namespace.xml | 0 ...logItem-carrenza-with-vcloud-namespace.xml | 0 .../test/resources/catalogItem-hosting.xml | 0 .../test/resources/catalogItem-terremark.xml | 0 .../test/resources/catalogItem1.0-vcd15.xml | 0 .../src/test/resources/copyVApp-default.xml | 0 .../src/test/resources/copyVApp.xml | 0 .../resources/copyVAppTemplate-default.xml | 0 .../src/test/resources/copyVAppTemplate.xml | 0 .../src/test/resources/cpuItem.xml | 0 .../src/test/resources/guestCustomization.xml | 0 .../resources/guestCustomizationSection.xml | 0 .../src/test/resources/instantiatedvapp.xml | 0 .../instantiationparams-description.xml | 0 .../resources/instantiationparams-network.xml | 0 .../test/resources/instantiationparams.xml | 0 .../src/test/resources/log4j.xml | 0 .../src/test/resources/memoryItem.xml | 0 .../src/test/resources/moveVApp.xml | 0 .../src/test/resources/moveVAppTemplate.xml | 0 .../src/test/resources/networkconnection.xml | 0 .../resources/networkconnectionsection.xml | 0 .../src/test/resources/org-1.0.xml | 0 .../src/test/resources/org-hosting.xml | 0 .../src/test/resources/org-savvis.xml | 0 .../src/test/resources/org.xml | 0 .../src/test/resources/org1.0-vcd15.xml | 0 .../src/test/resources/orgList1.0-vcd15.xml | 0 .../src/test/resources/orglist-savvis.xml | 0 .../src/test/resources/orglist.xml | 0 .../src/test/resources/orgnetwork-bridged.xml | 0 .../test/resources/orgnetwork-isolated.xml | 0 .../src/test/resources/os.xml | 0 .../src/test/resources/ovf-multi-vm.xml | 0 .../src/test/resources/ovf-ubuntu64.xml | 0 .../src/test/resources/task-1.0.xml | 0 .../src/test/resources/task-error.xml | 0 .../src/test/resources/task-hosting.xml | 0 .../src/test/resources/task-self.xml | 0 .../src/test/resources/task-vcd15.xml | 0 .../src/test/resources/task.xml | 0 .../src/test/resources/taskslist-hosting.xml | 0 .../src/test/resources/taskslist.xml | 0 .../resources/template1.0-vcd15-multi-vm.xml | 0 .../src/test/resources/template1.0-vcd15.xml | 0 .../test/resources/vAppTemplate-copying.xml | 0 .../src/test/resources/vAppTemplate.xml | 0 .../vAppTemplate1.0-vcd15_withNewlines.xml | 0 .../src/test/resources/vapp-hosting.xml | 0 .../src/test/resources/vapp-none.xml | 0 .../src/test/resources/vapp-pool.xml | 0 .../test/resources/vapp-rhel-off-static.xml | 0 .../test/resources/vapp-ubuntu-off-dhcp.xml | 0 .../src/test/resources/vapp-unresolved.xml | 0 .../test/resources/vapp-win-off-static.xml | 0 .../src/test/resources/vdc-1.0.xml | 0 .../src/test/resources/vdc-hosting.xml | 0 .../src/test/resources/vdc-nonet.xml | 0 .../src/test/resources/vdc.xml | 0 .../src/test/resources/vdc1.0-vcd15.xml | 0 .../src/test/resources/versions-vcd15.xml | 0 .../src/test/resources/versions.xml | 0 .../test/resources/virtualhardwaresection.xml | 0 .../src/test/resources/vm-rhel-off-static.xml | 0 .../aws/ec2/features/AWSAMIApiLiveTest.java | 58 -- .../README.txt | 0 .../{1.7.1-stratos => 1.8.0-stratos}/pom.xml | 6 +- .../src/main/clojure/org/jclouds/aws/ec2.clj | 0 .../java/org/jclouds/aws/ec2/AWSEC2Api.java | 2 - .../jclouds/aws/ec2/AWSEC2ApiMetadata.java | 0 .../aws/ec2/AWSEC2ProviderMetadata.java | 4 +- .../BindLaunchSpecificationToFormParams.java | 26 +- ...InstanceRequestIdsToIndexedFormParams.java | 2 - .../BindTagFiltersToIndexedFormParams.java | 5 +- .../binders/BindTagsToIndexedFormParams.java | 3 - .../aws/ec2/compute/AWSEC2ComputeService.java | 3 - .../compute/AWSEC2ComputeServiceContext.java | 3 - .../compute/AWSEC2TemplateBuilderImpl.java | 13 +- .../ec2/compute/AWSEC2TemplateOptions.java | 59 +- .../AWSEC2BindComputeSuppliersByClass.java | 3 - .../AWSEC2ComputeServiceContextModule.java | 4 - ...WSEC2ComputeServiceDependenciesModule.java | 4 - .../ec2/compute/config/ClusterCompute.java | 3 - .../aws/ec2/compute/config/ImageQuery.java | 3 - .../AWSEC2SecurityGroupExtension.java | 20 +- .../AWSEC2SecurityGroupToSecurityGroup.java | 2 - .../AWSRunningInstanceToNodeMetadata.java | 3 - .../PresentSpotRequestsAndInstances.java | 2 - .../AWSEC2ComputeServiceContextImpl.java | 3 - .../AWSEC2CreateSecurityGroupIfNeeded.java | 5 - .../AWSEC2CreateNodesInGroupThenAddToSet.java | 44 +- .../strategy/AWSEC2DestroyNodeStrategy.java | 4 - .../AWSEC2GetNodeMetadataStrategy.java | 4 - .../strategy/AWSEC2ListNodesStrategy.java | 8 +- .../strategy/AWSEC2ReviseParsedImage.java | 3 - ...rityGroupsAsNeededAndReturnRunOptions.java | 15 +- .../suppliers/AWSEC2HardwareSupplier.java | 6 +- .../suppliers/AWSEC2ImageSupplier.java | 4 - .../ec2/compute/suppliers/CallForImages.java | 4 - .../aws/ec2/config/AWSEC2HttpApiModule.java | 2 - .../aws/ec2/domain/AWSRunningInstance.java | 16 +- .../aws/ec2/domain/LaunchSpecification.java | 48 +- .../aws/ec2/domain/MonitoringState.java | 1 - .../aws/ec2/domain/PlacementGroup.java | 1 - .../RegionNameAndPublicKeyMaterial.java | 4 - .../java/org/jclouds/aws/ec2/domain/Spot.java | 1 - .../aws/ec2/domain/SpotInstanceRequest.java | 4 - .../jclouds/aws/ec2/features/AWSAMIApi.java | 2 - .../aws/ec2/features/AWSInstanceApi.java | 2 - .../aws/ec2/features/AWSKeyPairApi.java | 3 - .../aws/ec2/features/AWSSecurityGroupApi.java | 2 - .../aws/ec2/features/MonitoringApi.java | 2 - .../aws/ec2/features/PlacementGroupApi.java | 2 - .../aws/ec2/features/SpotInstanceApi.java | 2 - .../CreatePlacementGroupIfNeeded.java | 4 - .../ImportOrReturnExistingKeypair.java | 4 - ...otInstanceRequestToAWSRunningInstance.java | 3 - .../ec2/options/AWSDescribeImagesOptions.java | 1 - .../ec2/options/AWSRunInstancesOptions.java | 19 +- .../options/CreateSecurityGroupOptions.java | 1 - .../DescribeSpotPriceHistoryOptions.java | 1 - .../options/RequestSpotInstancesOptions.java | 1 - .../predicates/PlacementGroupAvailable.java | 5 - .../ec2/predicates/PlacementGroupDeleted.java | 5 - .../predicates/SpotInstanceRequestActive.java | 5 - .../aws/ec2/reference/AWSEC2Constants.java | 7 +- .../AWSDescribeInstancesResponseHandler.java | 1 - ...DescribeSecurityGroupsResponseHandler.java | 1 - .../ec2/xml/AWSEC2IpPermissionHandler.java | 4 - .../ec2/xml/AWSEC2SecurityGroupHandler.java | 3 - .../xml/AWSRunInstancesResponseHandler.java | 1 - .../ec2/xml/BaseAWSReservationHandler.java | 4 - .../CreateSecurityGroupResponseHandler.java | 4 - ...escribePlacementGroupsResponseHandler.java | 3 - ...ervedInstancesOfferingResponseHandler.java | 3 - ...scribeSpotPriceHistoryResponseHandler.java | 3 - .../ec2/xml/LaunchSpecificationHandler.java | 26 +- .../aws/ec2/xml/MonitoringStateHandler.java | 4 - .../aws/ec2/xml/PlacementGroupHandler.java | 4 - .../aws/ec2/xml/ProductCodesHandler.java | 1 - .../xml/ReservedInstancesOfferingHandler.java | 1 - .../org/jclouds/aws/ec2/xml/SpotHandler.java | 4 - .../aws/ec2/xml/SpotInstanceHandler.java | 4 - .../aws/ec2/xml/SpotInstancesHandler.java | 3 - .../org.jclouds.providers.ProviderMetadata | 0 .../test/clojure/org/jclouds/aws/ec2_test.clj | 0 .../aws/ec2/AWSEC2ContextBuilderTest.java | 3 - .../jclouds/aws/ec2/AWSEC2ProviderTest.java | 2 - ...ndLaunchSpecificationToFormParamsTest.java | 3 - .../BindTagsToIndexedFormParamsTest.java | 2 - .../AWSEC2ComputeServiceExpectTest.java | 2 - .../compute/AWSEC2ComputeServiceLiveTest.java | 4 - .../AWSEC2TemplateBuilderLiveTest.java | 4 - ...AWSEC2ComputeServiceContextModuleTest.java | 3 - .../AWSEC2ImageExtensionLiveTest.java | 3 - ...WSEC2SecurityGroupExtensionExpectTest.java | 80 ++- .../AWSEC2SecurityGroupExtensionLiveTest.java | 3 - ...WSEC2SecurityGroupToSecurityGroupTest.java | 3 - .../AWSRunningInstanceToNodeMetadataTest.java | 7 +- .../PresentSpotRequestsAndInstancesTest.java | 3 - .../BaseAWSEC2ComputeServiceExpectTest.java | 2 - ...AWSEC2CreateSecurityGroupIfNeededTest.java | 4 - .../options/AWSEC2TemplateOptionsTest.java | 2 - .../strategy/AWSEC2ImageParserTest.java | 7 +- .../strategy/AWSEC2ReviseParsedImageTest.java | 0 ...GroupsAsNeededAndReturnRunOptionsTest.java | 16 +- .../aws/ec2/features/AWSAMIApiLiveTest.java | 129 +++++ .../aws/ec2/features/AWSAMIApiTest.java | 35 +- .../AWSElasticBlockStoreApiLiveTest.java | 68 +++ .../ec2/features/AWSInstanceApiLiveTest.java | 2 - .../aws/ec2/features/AWSInstanceApiTest.java | 2 - .../ec2/features/AWSKeyPairApiLiveTest.java | 2 - .../aws/ec2/features/AWSKeyPairApiTest.java | 2 - .../features/AWSSecurityGroupApiLiveTest.java | 4 - .../ec2/features/AWSSecurityGroupApiTest.java | 2 - .../ec2/features/AWSSubnetApiLiveTest.java | 4 - .../aws/ec2/features/BaseAWSEC2ApiTest.java | 3 - .../ec2/features/MonitoringApiLiveTest.java | 2 - .../aws/ec2/features/MonitoringApiTest.java | 2 - .../features/PlacementGroupApiExpectTest.java | 3 - .../features/PlacementGroupApiLiveTest.java | 2 - .../ec2/features/PlacementGroupApiTest.java | 2 - .../features/SpotInstanceApiExpectTest.java | 3 - .../ec2/features/SpotInstanceApiLiveTest.java | 2 - .../aws/ec2/features/SpotInstanceApiTest.java | 2 - .../features/TagSecurityGroupLiveTest.java | 4 - .../ImportOrReturnExistingKeypairTest.java | 3 - ...stanceRequestToAWSRunningInstanceTest.java | 6 +- .../options/AWSDescribeImagesOptionsTest.java | 2 - .../options/AWSRunInstancesOptionsTest.java | 12 +- .../DescribeSpotPriceHistoryOptionsTest.java | 2 - .../RequestSpotInstancesOptionsTest.java | 2 - .../parse/DescribeInstancesResponseTest.java | 2 - .../DescribeSecurityGroupsResponseTest.java | 6 +- ...SDescribeInstancesResponseHandlerTest.java | 2 - .../AWSRunInstancesResponseHandlerTest.java | 2 - ...ibePlacementGroupsResponseHandlerTest.java | 2 - ...dInstancesOfferingResponseHandlerTest.java | 2 - ...beSpotPriceHistoryResponseHandlerTest.java | 2 - .../ec2/xml/MonitoringStateHandlerTest.java | 2 - .../aws/ec2/xml/ProductCodesHandlerTest.java | 2 - .../aws/ec2/xml/SpotInstanceHandlerTest.java | 2 - .../aws/ec2/xml/SpotInstancesHandlerTest.java | 2 - .../src/test/resources/alestic_canonical.xml | 0 .../src/test/resources/amzn_images.xml | 0 .../describe_image_attribute_productCodes.xml | 0 .../src/test/resources/describe_images_cc.xml | 0 .../test/resources/describe_instances_1.xml | 0 .../test/resources/describe_instances_2.xml | 0 .../test/resources/describe_instances_3.xml | 0 .../resources/describe_instances_latest.xml | 0 .../resources/describe_instances_pending.xml | 0 .../resources/describe_placement_groups.xml | 0 .../describe_reserved_instances_offerings.xml | 0 .../describe_security_groups_vpc.xml | 2 +- .../test/resources/describe_spot_instance.xml | 0 .../describe_spot_instance_requests.xml | 0 .../resources/describe_spot_instance_tags.xml | 0 .../resources/describe_spot_instances_1.xml | 0 .../resources/describe_spot_price_history.xml | 0 .../src/test/resources/monitoring.xml | 0 .../resources/request_spot_instances-ebs.xml | 0 .../test/resources/request_spot_instances.xml | 0 .../src/test/resources/rightscale_images.xml | 0 .../src/test/resources/run_instances_1.xml | 0 .../src/test/resources/vostok.xml | 0 dependencies/pom.xml | 10 +- .../pom.xml | 317 ++++++----- pom.xml | 17 +- .../distribution/src/main/license/LICENSE | 30 +- tools/pom.xml | 39 ++ tools/stratos-docker-images/README.md | 12 +- .../stratos-docker-images/activemq/Dockerfile | 14 +- .../activemq/docker-build.sh | 2 +- .../bind/docker-build.sh | 2 +- tools/stratos-docker-images/build-all.sh | 4 + tools/stratos-docker-images/mysql/Dockerfile | 7 +- .../mysql/docker-build.sh | 3 +- tools/stratos-docker-images/pom.xml | 103 ++++ .../puppetmaster/Dockerfile | 35 +- .../puppetmaster/addpuppetdomain.txt | 5 - .../puppetmaster/docker-build.sh | 48 +- .../puppetmaster/run-example.sh | 9 - .../puppettestnode/docker-build.sh | 2 +- tools/stratos-docker-images/push-all.sh | 15 +- .../remove_stratos_images.sh | 33 ++ tools/stratos-docker-images/run-example.sh | 27 +- tools/stratos-docker-images/run-nsenter.sh | 13 + ...ntainers.sh => stop_stratos_containers.sh} | 8 +- .../stratos-docker-images/stratos/Dockerfile | 26 +- .../stratos/docker-build.sh | 33 +- tools/stratos-docker-images/stratos/run | 2 +- 1345 files changed, 12340 insertions(+), 10712 deletions(-) delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/extensions/DockerImageExtension.java delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/internal/Archives.java delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/ubuntu/Dockerfile delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerExperimentLiveTest.java delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile delete mode 100644 dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/README.md (100%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/pom.xml (97%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/DockerApi.java (86%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/DockerApiMetadata.java (93%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java (91%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java (85%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java (76%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java (87%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java (88%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java (70%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java (75%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java (98%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/config/DockerParserModule.java (62%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/config/DockerProperties.java (96%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/Config.java (90%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/Container.java (72%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/ExposedPorts.java (92%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/HostConfig.java (58%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/Image.java (93%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/NetworkSettings.java (89%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/Port.java (95%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/State.java (97%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/domain/Version.java (96%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos/src/main/java/org/jclouds/docker/compute => 1.8.0-stratos/src/main/java/org/jclouds/docker}/features/RemoteApi.java (98%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/internal/Archives.java rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java (93%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/BuildOptions.java (98%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/CommitOptions.java (99%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/CreateImageOptions.java (77%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java (98%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/ListContainerOptions.java (98%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/ListImageOptions.java (97%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java (98%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata (100%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java (98%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/binders/BindInputStreamToRequestTest.java rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java (89%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java (62%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceLiveTest.java rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java (74%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java (97%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java (94%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/options/DockerTemplateOptionsTest.java create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java rename dependencies/jclouds/apis/docker/{1.7.1-stratos/src/test/java/org/jclouds/docker/compute => 1.8.0-stratos/src/test/java/org/jclouds/docker}/features/RemoteApiLiveTest.java (77%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos/src/test/java/org/jclouds/docker/compute => 1.8.0-stratos/src/test/java/org/jclouds/docker}/features/RemoteApiMockTest.java (81%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/internal/ArchivesTest.java rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java (99%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos/src/main/resources/centos => 1.8.0-stratos/src/test/resources}/Dockerfile (100%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/container-creation.json (100%) create mode 100644 dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container.json rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/containers.json (100%) rename dependencies/jclouds/apis/docker/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/logback.xml (97%) delete mode 100644 dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java delete mode 100644 dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-named.xml rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/README.txt (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/pom.xml (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/clojure/org/jclouds/ec2/ami2.clj (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/clojure/org/jclouds/ec2/ebs2.clj (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/clojure/org/jclouds/ec2/security_group2.clj (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/EC2Api.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/EC2Fallbacks.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java (96%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java (92%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java (87%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java (88%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java (93%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java (94%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Attachment.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/BlockDevice.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java (73%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/BundleTask.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Hypervisor.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Image.java (92%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/InstanceState.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/InstanceType.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/KeyPair.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/PasswordData.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Permission.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Reservation.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/RunningInstance.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Snapshot.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Subnet.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Tag.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java (95%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/domain/Volume.java (80%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/AMIApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java (95%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/InstanceApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/KeyPairApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/SubnetApi.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/TagApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/features/WindowsApi.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java (99%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateVolumeOptions.java rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java (62%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java (85%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/options/internal/BaseEC2RequestOptions.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/InstanceHasIpAddress.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/reference/EC2Constants.java (94%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/util/IpPermissions.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/util/Tags.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java (91%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java (93%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/InstanceTypeHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/SecurityGroupHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/SnapshotHandler.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/StringValueHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/TagHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java (98%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java (93%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java (95%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java (95%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java (79%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java (80%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java (89%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java (87%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/AMIApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java (73%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java (84%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java (97%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java (96%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java (98%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateVolumeOptionsTest.java rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java (80%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java (89%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/util/TagsTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java (90%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java (87%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java (82%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java (99%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java (98%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/allocate_address.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/amzn_images.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/attach.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/authorize_securitygroup_ingress_response.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-ap-northeast-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-ap-southeast-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-eu-west-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-sa-east-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-us-east-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-us-west-1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones-us-west-2.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/availabilityZones.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/bundle_instance.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/cancel_bundle_task.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/create_keypair.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/created_securitygroup.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/created_snapshot.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/created_volume.xml (80%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/delete_securitygroup.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_addresses.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_addresses_single.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_bundle_tasks.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_image_attribute_blockDeviceMapping.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_image_attribute_launchPermission.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_ebs.xml (88%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_imageextension0.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_imageextension1.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_imageextension2.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_nova.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_tags.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_windows.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_ebs.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_multiple.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_running-1.xml (100%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-named.xml rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_running.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_running_securitygroups.xml (100%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_three_ids.xml rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_keypairs.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups_empty.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups_extension_cidr.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups_extension_group.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups_extension_new.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_securitygroups_extension_single.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_snapshots.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_subnets.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_tags.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_volumes.xml (84%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_volumes_single.xml (83%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/disableApiTermination.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/get_console_output_response.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/get_passworddata.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instanceInitiatedShutdownBehavior.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instanceType.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/log4j.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_instance.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_securitygroup.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/ramdisk.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/regionEndpoints-additional.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/regionEndpoints-all.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/regionEndpoints.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/run_instances.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/run_instances_cloudbridge.xml (100%) create mode 100644 dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_three.xml rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/start_instances.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/stop_instances.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/terminate_instances.xml (100%) rename dependencies/jclouds/apis/ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/userData.xml (100%) delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json delete mode 100644 dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/README.txt (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/pom.xml (91%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java (79%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java (76%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java (51%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java (98%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NodeAndNovaTemplateOptions.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java (85%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java (89%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaHttpApiModule.java} (50%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java (79%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java (97%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Console.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java (83%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java (60%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java (52%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java} (54%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java} (59%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java (92%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java} (57%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java} (59%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java} (67%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java} (56%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java} (67%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java} (65%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java} (60%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java} (58%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java} (69%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java} (66%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java} (79%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java} (64%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java (55%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java} (58%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java} (62%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java => 1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java} (55%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java (82%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java (99%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java (72%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java (91%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java (66%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java (89%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java (58%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiLiveTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiMockTest.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java (92%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java (75%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java (59%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java (92%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java (92%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java (85%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java (83%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java (81%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java (75%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java (76%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java (86%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java (75%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java (80%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java (98%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseNOVNCConsoleTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseRDPConsoleTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSPICEConsoleTest.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java (98%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java (94%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsStatesTest.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java (59%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java (94%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java (92%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java (98%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithoutImageTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseXVPVNCConsoleTest.java rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java (99%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicatesMockTest.java create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/access.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_details.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/extension_list.json (99%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_full.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_normal.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_openstack.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_details.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/flavor_list.json (78%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail_openstack.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_new.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_with_host_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/hosts_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_active.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_details.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/image_list.json (50%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_imageextension.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_openstack.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/keypair_created_computeservice.json (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/test/resources/keypair_created.json => 1.8.0-stratos/src/test/resources/keypair_details.json} (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/keypair_list.json (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/listAvailabilityZones.json (100%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/metadata_item.json (93%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/metadata_list.json (95%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/metadata_updated.json (97%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server.json (55%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json => 1.8.0-stratos/src/test/resources/new_server_config_drive.json} (97%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_auto.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server_disk_config_manual.json (57%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server_in_zone.json (55%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server_networks_response.json (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server_no_adminpass.json (96%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/new_server_nova_networks.json (100%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/novnc_console.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/quotas.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/rdp_console.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/securitygroup_created.json (87%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_computeservice_typical.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension_norules.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_port22.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_extension.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/securitygrouprule_created.json (89%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/securitygrouprule_created_cidr.json (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/securitygrouprule_created_group.json (99%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/test/resources/server_list_details.json => 1.8.0-stratos/src/test/resources/server_details.json} (68%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_devstack.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/server_details_openstack.json (50%) rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos/src/test/resources/server_details.json => 1.8.0-stratos/src/test/resources/server_details_without_image.json} (72%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_diagnostics.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/server_list.json (78%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_essex.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_states.json rename dependencies/jclouds/apis/openstack-nova/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/server_public_ip_in_private.json (50%) create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups_extension.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usage.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usages.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list_detail.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/spice_console.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/virtual_interfaces_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_details.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list_detail.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_extra_specs.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_list.json create mode 100644 dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/xvpvnc_console.json rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/README.txt (100%) rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/pom.xml (97%) rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java (96%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java (96%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudMediaType.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudResponseException.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudToken.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java (84%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Capacity.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Catalog.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Org.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Status.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Task.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/TasksList.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VApp.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VCloudError.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java (96%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VDC.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/Vm.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java (93%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/Features.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/NatService.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/Network.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/Org.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/endpoints/VDC.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/CatalogApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/NetworkApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/OrgApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/TaskApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/VAppApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/VDCApi.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/features/VmApi.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java (63%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java (77%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java (100%) rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java (100%) rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/CloneOptions.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java (94%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/reference/package-info.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/util/Utils.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java (95%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/VmHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/VCloudApiTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java (91%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/features/VmApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java (87%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/utils/TestUtils.java (97%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java (96%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java (98%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java (99%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java (95%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/captureVApp-default.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/captureVApp.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalog-blank.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalog-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalog.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalog1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalogItem-carrenza-with-default-namespace.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalogItem-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalogItem-terremark.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/catalogItem1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/copyVApp-default.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/copyVApp.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/copyVAppTemplate-default.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/copyVAppTemplate.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/cpuItem.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/guestCustomization.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/guestCustomizationSection.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instantiatedvapp.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instantiationparams-description.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instantiationparams-network.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/instantiationparams.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/log4j.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/memoryItem.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/moveVApp.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/moveVAppTemplate.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/networkconnection.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/networkconnectionsection.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/org-1.0.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/org-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/org-savvis.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/org.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/org1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/orgList1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/orglist-savvis.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/orglist.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/orgnetwork-bridged.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/orgnetwork-isolated.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/os.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/ovf-multi-vm.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/ovf-ubuntu64.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task-1.0.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task-error.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task-self.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/task.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/taskslist-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/taskslist.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/template1.0-vcd15-multi-vm.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/template1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vAppTemplate-copying.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vAppTemplate.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-none.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-pool.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-rhel-off-static.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-ubuntu-off-dhcp.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-unresolved.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vapp-win-off-static.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vdc-1.0.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vdc-hosting.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vdc-nonet.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vdc.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vdc1.0-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/versions-vcd15.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/versions.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/virtualhardwaresection.xml (100%) mode change 100755 => 100644 rename dependencies/jclouds/apis/vcloud/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vm-rhel-off-static.xml (100%) mode change 100755 => 100644 delete mode 100644 dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/README.txt (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/pom.xml (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/clojure/org/jclouds/aws/ec2.clj (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java (88%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java (93%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java (82%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java (94%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java (93%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java (92%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/Spot.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java (90%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2DescribeSecurityGroupsResponseHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/BaseAWSReservationHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/CreateSecurityGroupResponseHandler.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/LaunchSpecificationHandler.java (92%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/MonitoringStateHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/clojure/org/jclouds/aws/ec2_test.clj (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java (95%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java (85%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java (97%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java (93%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java (99%) create mode 100644 dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java (93%) create mode 100644 dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSElasticBlockStoreApiLiveTest.java rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java (96%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java (99%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/alestic_canonical.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/amzn_images.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_image_attribute_productCodes.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_images_cc.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_1.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_2.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_3.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_latest.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_instances_pending.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_placement_groups.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_reserved_instances_offerings.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_security_groups_vpc.xml (98%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_spot_instance.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_spot_instance_requests.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_spot_instance_tags.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_spot_instances_1.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/describe_spot_price_history.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/monitoring.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/request_spot_instances-ebs.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/request_spot_instances.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/rightscale_images.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/run_instances_1.xml (100%) rename dependencies/jclouds/provider/aws-ec2/{1.7.1-stratos => 1.8.0-stratos}/src/test/resources/vostok.xml (100%) create mode 100644 tools/pom.xml create mode 100644 tools/stratos-docker-images/pom.xml delete mode 100644 tools/stratos-docker-images/puppetmaster/addpuppetdomain.txt create mode 100755 tools/stratos-docker-images/remove_stratos_images.sh create mode 100755 tools/stratos-docker-images/run-nsenter.sh rename tools/stratos-docker-images/{stop_and_remove_stratos_containers.sh => stop_stratos_containers.sh} (79%) diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index 4f2919b684..ec808d1690 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -17,12 +17,13 @@ # specific language governing permissions and limitations # under the License. --> - + - org.apache.stratos - stratos-components-parent - 4.1.0-SNAPSHOT + org.apache.stratos + stratos-components-parent + 4.1.0-SNAPSHOT 4.0.0 @@ -54,8 +55,8 @@ org.apache.stratos.cloud.controller.topology.*, org.apache.stratos.cloud.controller.iaases.*, org.apache.stratos.cloud.controller.pojo.*, - org.apache.stratos.cloud.controller.deployers.*, - org.apache.stratos.cloud.controller.exception.*, + org.apache.stratos.cloud.controller.deployers.*, + org.apache.stratos.cloud.controller.exception.*, !org.apache.stratos.cloud.controller.interfaces.*, @@ -69,18 +70,18 @@ org.apache.stratos.cloud.controller.*, - !org.apache.commons.logging, + !org.apache.commons.logging, org.apache.commons.logging; version=0.0.0, org.apache.commons.io.*, org.wso2.carbon.utils.*, + org.jclouds*;version="${jclouds.version}",--> *; resolution:=optional * - + CloudControllerDeployer - + @@ -91,171 +92,186 @@ org.wso2.carbon org.wso2.carbon.core - + org.wso2.carbon org.wso2.carbon.utils - + org.apache.stratos org.apache.stratos.messaging ${project.version} - - org.reflections - reflections - 0.9.9-RC1 - + + com.google.guava + guava + 17.0 + + + com.jcraft + jsch.agentproxy.jsch + 0.0.7 + + + com.jcraft + jsch.agentproxy.core + 0.0.7 + + + com.jcraft + jsch.agentproxy.connector-factory + 0.0.7 + + + org.reflections + reflections + 0.9.9-RC1 + - - org.wso2.carbon - org.wso2.carbon.securevault - ${wso2carbon.version} - - - org.hectorclient.wso2 - hector-core - 1.1.0.wso2v1 - - - com.google.guava.wso2 - guava - - - - - - com.google.guava - guava - 14.0.1 - - - org.wso2.andes.wso2 - andes-client - 0.13.wso2v3 - - - org.apache.geronimo.specs.wso2 - geronimo-jms_1.1_spec - ${orbit.version.geronimo-jms_1.1_spec} - + + org.wso2.carbon + org.wso2.carbon.securevault + ${wso2carbon.version} + + + org.hectorclient.wso2 + hector-core + 1.1.0.wso2v1 + + + com.google.guava.wso2 + guava + + - - org.wso2.carbon - org.wso2.carbon.analytics.hive.stub - 4.2.0 - + + + org.wso2.andes.wso2 + andes-client + 0.13.wso2v3 + + + org.apache.geronimo.specs.wso2 + geronimo-jms_1.1_spec + ${orbit.version.geronimo-jms_1.1_spec} + - - - org.apache.jclouds - jclouds-core - ${jclouds.version} - - - org.apache.jclouds - jclouds-compute - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-bouncycastle - ${jclouds.version} - - - org.bouncycastle - bcprov-jdk16 - - - - - org.apache.jclouds.driver - jclouds-sshj - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-log4j - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-enterprise - ${jclouds.version} - - - org.apache.stratos - ec2 - 1.7.1-stratos - - - org.apache.stratos - aws-ec2 - 1.7.1-stratos - - - org.apache.stratos - openstack-nova - 1.7.1-stratos - - - org.apache.jclouds.api - openstack-keystone - ${jclouds.version} - - - org.apache.jclouds - jclouds-scriptbuilder - ${jclouds.version} - - - org.apache.stratos - vcloud - 1.7.1-stratos - + + org.wso2.carbon + org.wso2.carbon.analytics.hive.stub + 4.2.0 + - - com.jamesmurty.utils.wso2 - java-xmlbuilder - 0.4.wso2v1 - - - com.google.code.gson - gson - ${gson2.version} - - - com.google.guice.wso2 - guice - ${google.guice.wso2.version} - - - com.google.guice.assistedinject.wso2 - guice-assistedinject - ${com.google.guice.assistedinject.wso2.version} - - - com.sun.jersey - jersey-core - ${sun.jersey.version} - - - net.oauth.core - oauth - 20100527 - - - commons-io.wso2 - commons-io - 2.0.0.wso2v1 - - - rhino.wso2 - js - 1.7.0.R1-wso2v3 - - + + + org.apache.jclouds + jclouds-core + ${jclouds.version} + + + org.apache.jclouds + jclouds-compute + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-bouncycastle + ${jclouds.version} + + + org.bouncycastle + bcprov-jdk16 + + + + + org.apache.jclouds.driver + jclouds-sshj + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-log4j + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-enterprise + ${jclouds.version} + + + org.apache.stratos + ec2 + 1.8.0-stratos + + + org.apache.stratos + aws-ec2 + 1.8.0-stratos + + + org.apache.stratos + openstack-nova + 1.8.0-stratos + + + org.apache.jclouds.api + openstack-keystone + ${jclouds.version} + + + org.apache.jclouds + jclouds-scriptbuilder + ${jclouds.version} + + + org.apache.stratos + vcloud + 1.8.0-stratos + + + + com.jamesmurty.utils.wso2 + java-xmlbuilder + 0.4.wso2v1 + + + com.google.code.gson + gson + ${gson2.version} + + + com.google.guice.wso2 + guice + ${google.guice.wso2.version} + + + com.google.guice.assistedinject.wso2 + guice-assistedinject + ${com.google.guice.assistedinject.wso2.version} + + + com.sun.jersey + jersey-core + ${sun.jersey.version} + + + net.oauth.core + oauth + 20100527 + + + commons-io.wso2 + commons-io + 2.0.0.wso2v1 + + + rhino.wso2 + js + 1.7.0.R1-wso2v3 + + org.wso2.carbon org.wso2.carbon.databridge.agent.thrift 4.2.0 diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java index 722b4b28b8..1c953a8ae1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/OpenstackNovaIaas.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.cloud.controller.iaases; +import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; @@ -44,10 +45,8 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.ec2.options.CreateSnapshotOptions; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.NovaApiMetadata; -import org.jclouds.openstack.nova.v2_0.NovaAsyncApi; import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.domain.FloatingIP; import org.jclouds.openstack.nova.v2_0.domain.HostAggregate; @@ -55,16 +54,14 @@ import org.jclouds.openstack.nova.v2_0.domain.Network; import org.jclouds.openstack.nova.v2_0.domain.Volume; import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; -import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; -import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI; +import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi; import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi; import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi; import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi; import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi; import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions; -import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions; import org.jclouds.rest.RestContext; import java.util.ArrayList; @@ -202,8 +199,8 @@ public synchronized boolean createKeyPairFromPublicKey(String region, String key ComputeServiceContext context = iaasInfo.getComputeService() .getContext(); - RestContext nova = context.unwrap(); - KeyPairApi api = nova.getApi().getKeyPairExtensionForZone(region).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + KeyPairApi api = novaApi.getKeyPairExtensionForZone(region).get(); KeyPair keyPair = api.createWithPublicKey(keyPairName, publicKey); @@ -231,8 +228,8 @@ public synchronized String associateAddress(NodeMetadata node) { String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); - RestContext nova = context.unwrap(); - FloatingIPApi floatingIp = nova.getApi().getFloatingIPExtensionForZone( + NovaApi novaApi = context.unwrapApi(NovaApi.class); + FloatingIPApi floatingIp = novaApi.getFloatingIPExtensionForZone( region).get(); String ip = null; @@ -314,11 +311,10 @@ public synchronized String associatePredefinedAddress (NodeMetadata node, String ComputeServiceContext context = iaasInfo.getComputeService() .getContext(); - NovaApi novaClient = context.unwrap(NovaApiMetadata.CONTEXT_TOKEN).getApi(); String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); - FloatingIPApi floatingIp = novaClient.getFloatingIPExtensionForZone( - region).get(); + FloatingIPApi floatingIp = context.unwrapApi(NovaApi.class).getFloatingIPExtensionForZone( + region).get(); if(log.isDebugEnabled()) { log.debug("OpenstackNovaIaas:associatePredefinedAddress:floatingip:" + floatingIp); @@ -406,9 +402,8 @@ public synchronized void releaseAddress(String ip) { String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); - RestContext nova = context.unwrap(); - FloatingIPApi floatingIPApi = nova.getApi() - .getFloatingIPExtensionForZone(region).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + FloatingIPApi floatingIPApi = novaApi.getFloatingIPExtensionForZone(region).get(); for (FloatingIP floatingIP : floatingIPApi.list()) { if (floatingIP.getIp().equals(ip)) { @@ -442,8 +437,8 @@ public boolean isValidRegion(String region) throws InvalidRegionException { } ComputeServiceContext context = iaasInfo.getComputeService().getContext(); - RestContext nova = context.unwrap(); - Set zones = nova.getApi().getConfiguredZones(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + Set zones = novaApi.getConfiguredZones(); for (String configuredZone : zones) { if (region.equalsIgnoreCase(configuredZone)) { if (log.isDebugEnabled()) { @@ -470,9 +465,9 @@ public boolean isValidZone(String region, String zone) throws InvalidZoneExcepti throw new InvalidZoneException(msg); } ComputeServiceContext context = iaasInfo.getComputeService().getContext(); - RestContext nova = context.unwrap(); - AvailabilityZoneAPI zoneApi = nova.getApi().getAvailabilityZoneApi(region); - for (AvailabilityZone z : zoneApi.list()) { + NovaApi novaApi = context.unwrapApi(NovaApi.class); + Optional availabilityZoneApi = novaApi.getAvailabilityZoneApi(region); + for (AvailabilityZone z : availabilityZoneApi.get().list()) { if (zone.equalsIgnoreCase(z.getName())) { if (log.isDebugEnabled()) { @@ -498,8 +493,8 @@ public boolean isValidHost(String zone, String host) throws InvalidHostException throw new InvalidHostException(msg); } ComputeServiceContext context = iaasInfo.getComputeService().getContext(); - RestContext nova = context.unwrap(); - HostAggregateApi hostApi = nova.getApi().getHostAggregateExtensionForZone(zone).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + HostAggregateApi hostApi = novaApi.getHostAggregateExtensionForZone(zone).get(); for (HostAggregate hostAggregate : hostApi.list()) { for (String configuredHost : hostAggregate.getHosts()) { if (host.equalsIgnoreCase(configuredHost)) { @@ -532,9 +527,9 @@ public String createVolume(int sizeGB, String snapshotId) { return null; } ComputeServiceContext context = iaasInfo.getComputeService().getContext(); - - RestContext nova = context.unwrap(); - VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); + + NovaApi novaApi = context.unwrapApi(NovaApi.class); + VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get(); Volume volume; if(StringUtils.isEmpty(snapshotId)){ if(log.isDebugEnabled()){ @@ -581,9 +576,8 @@ private boolean waitForStatus(String volumeId, Volume.Status expectedStatus, int IaasProvider iaasInfo = getIaasProvider(); String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo); ComputeServiceContext context = iaasInfo.getComputeService().getContext();; - RestContext nova = context.unwrap(); - VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); - VolumeAttachmentApi volumeAttachmentApi = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get(); Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); while(volumeStatus != expectedStatus){ @@ -633,9 +627,9 @@ public String attachVolume(String instanceId, String volumeId, String deviceName return null; } - RestContext nova = context.unwrap(); - VolumeApi volumeApi = nova.getApi().getVolumeExtensionForZone(region).get(); - VolumeAttachmentApi volumeAttachmentApi = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get(); + VolumeAttachmentApi volumeAttachmentApi = novaApi.getVolumeAttachmentExtensionForZone(region).get(); Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId); @@ -702,8 +696,8 @@ public void detachVolume(String instanceId, String volumeId) { log.debug(String.format("Starting to detach volume %s from the instance %s", volumeId, instanceId)); } - RestContext nova = context.unwrap(); - VolumeAttachmentApi api = nova.getApi().getVolumeAttachmentExtensionForZone(region).get(); + NovaApi novaApi = context.unwrapApi(NovaApi.class); + VolumeAttachmentApi api = novaApi.getVolumeAttachmentExtensionForZone(region).get(); if (api.detachVolumeFromServer(volumeId, instanceId)) { log.info(String.format("Detachment of Volume [id]: %s from instance [id]: %s was successful. [region] : %s of Iaas : %s", volumeId, instanceId, region, iaasInfo)); }else{ @@ -725,9 +719,9 @@ public void deleteVolume(String volumeId) { log.fatal(String.format("Cannot delete the volume [id]: %s of the [region] : %s of Iaas : %s", volumeId, region, iaasInfo)); return; } - - RestContext nova = context.unwrap(); - VolumeApi api = nova.getApi().getVolumeExtensionForZone(region).get(); + + NovaApi novaApi = context.unwrapApi(NovaApi.class); + VolumeApi api = novaApi.getVolumeExtensionForZone(region).get(); if (api.delete(volumeId)) { log.info(String.format("Deletion of Volume [id]: %s was successful. [region] : %s of Iaas : %s", volumeId, region, iaasInfo)); } diff --git a/components/org.apache.stratos.manager.console/console/cartridge_info.jag b/components/org.apache.stratos.manager.console/console/cartridge_info.jag index 653e31a709..3b45af6474 100644 --- a/components/org.apache.stratos.manager.console/console/cartridge_info.jag +++ b/components/org.apache.stratos.manager.console/console/cartridge_info.jag @@ -23,11 +23,15 @@ var caramel = require('caramel'); var error = []; var utils = require('/util/utility.jag'); var process = require('process'); - var log = new Log('utility.cartridgeInfo'); +var log = new Log('utility.cartridgeInfo'); var alias = request.getParameter("alias"); var lbCluster = {}; var cartridgeInfo = utils.consoleAppUtil.getCartridgeInfo(alias); +if(cartridgeInfo == null || cartridgeInfo == undefined || cartridgeInfo == ""){ + cartridgeInfo = {}; +} + if(cartridgeInfo.Error != undefined){ error.push(cartridgeInfo.Error); }else{ @@ -43,11 +47,17 @@ if(cartridgeInfo.Error != undefined){ } */ lbCluster = utils.consoleAppUtil.getLBClusterInfo(); - if(lbCluster.Error != undefined){ - error.push(lbCluster.Error); + if(lbCluster == null || lbCluster == undefined || lbCluster == ""){ + lbCluster = {}; } - + if(lbCluster.Error != undefined){ + error.push(lbCluster.Error); + } + var clusterInfo = utils.consoleAppUtil.getClusterInfoWithAlias(cartridgeInfo.cartridge.cartridgeType, alias); + if(clusterInfo == null || clusterInfo == undefined || clusterInfo == ""){ + clusterInfo = {}; + } if(clusterInfo.Error != undefined){ error.push(clusterInfo.Error); } diff --git a/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag b/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag index 0d1c52105a..7c874f3609 100644 --- a/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag +++ b/components/org.apache.stratos.manager.console/console/cartridge_info_sg.jag @@ -27,6 +27,10 @@ var process = require('process'); var serviceGroup = request.getParameter("serviceGroup"); //Get all alias for a service group var cartridges = utils.consoleAppUtil.getCartridgeServiceGroup(serviceGroup); + +if(cartridges == null || cartridges == undefined || cartridges == ""){ + cartridges = {}; +} cartridges=cartridges.cartridge; if(cartridges.Error != undefined){ @@ -41,24 +45,31 @@ if(cartridges.Error != undefined){ var alias = cartridges[i].cartridgeAlias; var lbCluster = {}; - lbCluster = utils.consoleAppUtil.getLBClusterInfo(); - if(lbCluster.Error != undefined){ - error.push(lbCluster.Error); - }else{ - //cartridges[i].lbClusterinfo = {member:[{memberIp:"foo"},{}]};//lbCluster.cluster; - //cartridges[i].lbClusterinfo = lbCluster.cluster[0]; - cartridges[i].lbclusterinfo = lbCluster.cluster[0]; - } + lbCluster = utils.consoleAppUtil.getLBClusterInfo(); + if(lbCluster == null || lbCluster == undefined || lbCluster == ""){ + lbCluster = {}; + } + if(lbCluster.Error != undefined){ + error.push(lbCluster.Error); + }else{ + //cartridges[i].lbClusterinfo = {member:[{memberIp:"foo"},{}]};//lbCluster.cluster; + //cartridges[i].lbClusterinfo = lbCluster.cluster[0]; + cartridges[i].lbclusterinfo = lbCluster.cluster[0]; + } + //Getting the clusterInfo and putting it to the relevant cartridge json var clusterInfo = utils.consoleAppUtil.getClusterInfoWithAlias(cartridgeInfo.cartridgeType, alias); + if(clusterInfo == null || clusterInfo == undefined || clusterInfo == ""){ + clusterInfo = {}; + } if(clusterInfo.Error != undefined){ error.push(clusterInfo.Error); }else{ cartridges[i].clusterInfo = clusterInfo.cluster[0]; } - } } + var bamInfo ={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')}; caramel.render({ cartridges:cartridges, diff --git a/components/org.apache.stratos.manager.console/console/cartridges.jag b/components/org.apache.stratos.manager.console/console/cartridges.jag index 3060bc1c13..3403427ba4 100644 --- a/components/org.apache.stratos.manager.console/console/cartridges.jag +++ b/components/org.apache.stratos.manager.console/console/cartridges.jag @@ -24,9 +24,14 @@ var error = []; var utils = require('/util/utility.jag'); var process = require('process'); var availableCartridges = utils.consoleAppUtil.getCartridges(); + +if(availableCartridges == null || availableCartridges == undefined || availableCartridges == ""){ + availableCartridges = {}; +} if(availableCartridges.Error != undefined){ error.push(availableCartridges.Error); } + var bamInfo ={bamip:process.getProperty('bam.ip'),bamport:process.getProperty('bam.port')}; caramel.render({ cartridges:availableCartridges, diff --git a/components/org.apache.stratos.manager.console/console/configure_stratos.jag b/components/org.apache.stratos.manager.console/console/configure_stratos.jag index 6e8435fc84..8718bbc693 100644 --- a/components/org.apache.stratos.manager.console/console/configure_stratos.jag +++ b/components/org.apache.stratos.manager.console/console/configure_stratos.jag @@ -39,22 +39,29 @@ var config_status = utils.consoleAppUtil.getConfigStatus(); if(wizard.step == 1){ var step_data = utils.consoleAppUtil.getPartitions(); + if(step_data == null || step_data == undefined || step_data == ""){ + step_data = {}; + } if(step_data.Error != undefined){ error.push(step_data.Error); }else{ step_data = step_data.partition; } - }else if(wizard.step == 2){ step_data = utils.consoleAppUtil.getPolicyAutoScale(); + if(step_data == null || step_data == undefined || step_data == ""){ + step_data = {}; + } if(step_data.Error != undefined){ error.push(step_data.Error); }else{ step_data = step_data.autoscalePolicy; } - }else if(wizard.step == 3){ step_data = utils.consoleAppUtil.getPolicyDeployment(); + if(step_data == null || step_data == undefined || step_data == ""){ + step_data = {}; + } if(step_data.Error != undefined){ error.push(step_data.Error); }else{ @@ -62,6 +69,9 @@ if(wizard.step == 1){ } }else if(wizard.step == 4){ step_data = utils.consoleAppUtil.getLbCartridges(); + if(step_data == null || step_data == undefined || step_data == ""){ + step_data = {}; + } if(step_data.Error != undefined){ error.push(step_data.Error); }else{ @@ -69,25 +79,32 @@ if(wizard.step == 1){ } }else if(wizard.step == 5){ step_data = utils.consoleAppUtil.getCartridges(); + if(step_data == null || step_data == undefined || step_data == ""){ + step_data = {}; + } if(step_data.Error != undefined){ error.push(step_data.Error); }else{ step_data = step_data.cartridge; - for(var i=0;i>>>>>> 400 + has_help: false, help: 'Create cartridges like PHP, Python, Ruby etc.. Or create data cartridges with mySql, PostgreSQL. Directly install applications like Drupal, Wordpress etc..' } } diff --git a/components/org.apache.stratos.manager.console/console/util/utility.jag b/components/org.apache.stratos.manager.console/console/util/utility.jag index 3cd93ebd8f..083b33065f 100644 --- a/components/org.apache.stratos.manager.console/console/util/utility.jag +++ b/components/org.apache.stratos.manager.console/console/util/utility.jag @@ -98,150 +98,150 @@ consoleAppUtil = new function(){ var log = new Log('utility.consoleAppUtil'); this.getAvailableSingleTenantCartridges = function(){ - return this.sendReceive("GET","/cartridge/list",{}).data; + return this.sendReceive("GET","/cartridge/list",{}); }; this.getAvailableMultiTenantCartridges = function(){ - return this.sendReceive("GET","/cartridge/tenanted/list",{}).data; + return this.sendReceive("GET","/cartridge/tenanted/list",{}); }; this.getSubscribedCartridges = function(){ - return this.sendReceive("GET","/cartridge/list/subscribed",{}).data; + return this.sendReceive("GET","/cartridge/list/subscribed",{}); } this.getTenants = function(){ - return this.sendReceive("GET","/tenant/list",{}).data; + return this.sendReceive("GET","/tenant/list",{}); }; this.getServices = function(){ - return this.sendReceive("GET","/service",{}).data; + return this.sendReceive("GET","/service",{}); }; this.deployCartridgeDefinition = function(cartridgeDefinition){ - return this.send("POST","/cartridge/definition",cartridgeDefinition).data; + return this.send("POST","/cartridge/definition",cartridgeDefinition); }; this.deployServiceDefinition = function(serviceDefinition){ - return this.send("POST","/service/definition",serviceDefinition).data; + return this.send("POST","/service/definition",serviceDefinition); }; this.deployLbDefinition = function(lbDefinition){ - return this.send("POST","/cartridge/definition",lbDefinition).data; + return this.send("POST","/cartridge/definition",lbDefinition); }; this.activateTenant = function(tenantDomain){ - return this.send("POST","/tenant/activate/" + tenantDomain,{}).data; + return this.send("POST","/tenant/activate/" + tenantDomain,{}); }; this.deactivateTenant = function(tenantDomain){ - return this.send("POST","/tenant/deactivate/" + tenantDomain,{}).data; + return this.send("POST","/tenant/deactivate/" + tenantDomain,{}); }; this.deleteTenant = function(tenantDomain){ - return this.send("DELETE","/tenant/" + tenantDomain,{}).data; + return this.send("DELETE","/tenant/" + tenantDomain,{}); }; this.checkAvailability = function(tenantDomain){ - return this.send("POST","/tenant/availability/" + tenantDomain,{}).data; + return this.send("POST","/tenant/availability/" + tenantDomain,{}); }; this.deployPartitionDefinition = function(partitionDefinition){ - return this.send("POST","/policy/deployment/partition",partitionDefinition).data; + return this.send("POST","/policy/deployment/partition",partitionDefinition); }; this.deployDeploymentPolicyDefinition = function(policyDefinition){ - return this.send("POST","/policy/deployment",policyDefinition).data; + return this.send("POST","/policy/deployment",policyDefinition); }; this.deployAutoscalePolicyDefinition = function(policyDefinition){ - return this.send("POST","/policy/autoscale",policyDefinition).data; + return this.send("POST","/policy/autoscale",policyDefinition); }; this.subscribeToCartridge = function(cartridgeBeanInfo){ - return this.sendReceive("POST","/cartridge/subscribe", cartridgeBeanInfo).data; + return this.sendReceive("POST","/cartridge/subscribe", cartridgeBeanInfo); }; this.addTenant = function(tenantInfoBean){ - return this.sendReceive("POST","/tenant",tenantInfoBean).data; + return this.sendReceive("POST","/tenant",tenantInfoBean); }; this.syncRepo = function(alias){ - return this.send("POST","/cartridge/sync",alias).data; + return this.send("POST","/cartridge/sync",alias); }; this.getAutoScalePolicies = function(){ - return this.sendReceive("GET","/policy/autoscale",{}).data; + return this.sendReceive("GET","/policy/autoscale",{}); }; this.getDeploymentPolicies = function(){ - return this.sendReceive("GET","/policy/deployment",{}).data; + return this.sendReceive("GET","/policy/deployment",{}); }; this.getApplicableDeploymentPolicies = function(cartridgeType){ - return this.sendReceive("GET","/" + cartridgeType + "/policy/deployment/",{}).data; + return this.sendReceive("GET","/" + cartridgeType + "/policy/deployment/",{}); }; this.getPartitions = function(){ - return this.sendReceive("GET","/partition",{}).data; + return this.sendReceive("GET","/partition",{}); }; this.getSingleTenantCartridgeInfo = function(cartridgeType){ - return this.sendReceive("GET","/cartridge/available/info/" + cartridgeType,{}).data; + return this.sendReceive("GET","/cartridge/available/info/" + cartridgeType,{}); }; this.getServiceInfo = function(cartridgeType){ - return this.sendReceive("GET","/service/" + cartridgeType,{}).data; + return this.sendReceive("GET","/service/" + cartridgeType,{}); }; this.getPolicyAutoScale = function(){ - return this.sendReceive("GET","/policy/autoscale",{}).data; + return this.sendReceive("GET","/policy/autoscale",{}); }; this.getPolicyDeployment = function(){ - return this.sendReceive("GET","/policy/deployment",{}).data; + return this.sendReceive("GET","/policy/deployment",{}); }; this.unsubscribeCartridge = function(alias){ - return this.send("POST","/cartridge/unsubscribe",alias).data; + return this.send("POST","/cartridge/unsubscribe",alias); }; this.getCartridges = function(){ - return this.sendReceive("GET","/cartridge/available/list",{}).data; + return this.sendReceive("GET","/cartridge/available/list",{}); }; this.getLbCartridges = function(){ - return this.sendReceive("GET","/cartridge/lb",{}).data; + return this.sendReceive("GET","/cartridge/lb",{}); }; this.getClusterInfo = function(clusterId){ - return this.sendReceive("GET","/cluster/clusterId/" + clusterId,{}).data; + return this.sendReceive("GET","/cluster/clusterId/" + clusterId,{}); }; this.getLBClusterInfo = function(){ - return this.sendReceive("GET","/cluster/lb",{}).data; + return this.sendReceive("GET","/cluster/lb",{}); }; this.getClusterInfoWithAlias = function(cartridgeType, alias){ - return this.sendReceive("GET","/cluster/" + cartridgeType + "/" + alias,{}).data; + return this.sendReceive("GET","/cluster/" + cartridgeType + "/" + alias,{}); }; this.getCartridgeInfo = function(alias){ - return this.sendReceive("GET","/cartridge/info/"+alias,{}).data; + return this.sendReceive("GET","/cartridge/info/"+alias,{}); }; this.getCartridgeServiceGroup = function(serviceGroup){ - return this.sendReceive("GET","/cartridge/list/subscribed/group/"+serviceGroup,{}).data; + return this.sendReceive("GET","/cartridge/list/subscribed/group/"+serviceGroup,{}); }; this.validateCaptcha = function(captchaText){ - return this.sendReceive("POST","/captcha",captchaText).data; + return this.sendReceive("POST","/captcha",captchaText); }; this.getCaptcha = function(){ return this.sendReceiveImage("Get","/simpleImg",{}); }; this.undeployCartridge = function(cartridgeType){ - return this.sendReceive("DELETE","/cartridge/definition/"+cartridgeType,{}).data; + return this.sendReceive("DELETE","/cartridge/definition/"+cartridgeType,{}); }; this.getConfigStatus = function(){ var configStatus = {}; var error; - var par_res = this.sendReceive("GET","/partition",{}).data; + var par_res = this.sendReceive("GET","/partition",{}); var get_status = session.get("get-status"); if(par_res.Error != undefined){ error = par_res.Error; @@ -251,7 +251,7 @@ consoleAppUtil = new function(){ if(par_res.partition.length == 0){ configStatus.first_use = true; }else{ - var car_res = this.sendReceive("GET","/cartridge/available/list",{}).data; + var car_res = this.sendReceive("GET","/cartridge/available/list",{}); if(car_res.Error != undefined){ error=car_res.Error; configStatus.first_use = false; @@ -301,33 +301,43 @@ consoleAppUtil = new function(){ // getting the access token from the session. var endpoint = backendServerURL + urlPostFix; var headers = this.getRequestHeaders(config.ssoConfiguration.enabled); - var type = "json"; // response format var response; switch (httpMethod){ case "GET": - response = get(endpoint,{},headers,type); + response = get(endpoint,{},headers); break; case "POST": - response = post(endpoint,stringify(data),headers,type); + response = post(endpoint,stringify(data),headers); break; case "PUT": - response = put(endpoint,stringify(data),headers,type); + response = put(endpoint,stringify(data),headers); break; case "DELETE": - response = del(endpoint,stringify(data),headers,type); + response = del(endpoint,stringify(data),headers); break; default : log.error("Error in the programme flow."); } - log.debug("-----------------------:" + stringify(response)); - if(response.data.Error) { - session.put("get-status", response.data.Error.errorMessage); - } else { - session.put("get-status", "succeeded"); + + if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success + session.put("get-status", "succeeded"); + } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error + if(response.data != null && response.data != undefined) { + session.put("get-status", parse(response.data).Error.errorMessage); + } + } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error + if(response.data != null && response.data != undefined) { + session.put("get-status", response.data); return; + } } - log.debug("--------------------: + " + urlPostFix + " "+ session.get("get-status")); - return response; + log.debug("sent is: " + stringify(response)); + + if (response.data != null && response.data != undefined) { + return parse(response.data); + } else { + return response.data; + } }; // refactor sendRecive and send method. duplicate code... @@ -365,33 +375,43 @@ consoleAppUtil = new function(){ // getting the access token from the session. var endpoint = backendServerURL + urlPostFix; var headers = this.getRequestHeaders(config.ssoConfiguration.enabled); - var type = "json"; // response format var response; switch (httpMethod){ case "GET": - response = get(endpoint,{},headers, 'json'); + response = get(endpoint,{},headers); break; case "POST": - response = post(endpoint,data,headers, 'json'); + response = post(endpoint,data,headers); break; case "PUT": - response = put(endpoint,data,headers, 'json'); + response = put(endpoint,data,headers); break; case "DELETE": - response = del(endpoint,data,headers, 'json'); + response = del(endpoint,data,headers); break; default : log.error("Error in the programme flow."); } - if (response.data.Error) { - session.put("deploy-status", response.data.Error.errorMessage); - } else { - session.put("deploy-status", "succeeded"); + if (response.xhr.status >= 200 && response.xhr.status < 300) { //if success + session.put("deploy-status", "succeeded"); + } else if (response.xhr.status >= 400 && response.xhr.status < 500) { //if client error + if(response.data != null && response.data != undefined) { + session.put("deploy-status", parse(response.data).Error.errorMessage); + } + } else if (response.xhr.status >= 500 && response.xhr.status < 600) { //if server error + if(response.data != null && response.data != undefined) { + session.put("deploy-status", response.data); return; + } } + log.debug("sent is: " + stringify(response)); - return response; + if (response.data != null && response.data != undefined) { + return parse(response.data); + } else { + return response.data; + } }; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 2759ad476b..5c86c5045c 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -516,7 +516,8 @@ public Response getAvailableSingleTenantCartridgeInfo(@PathParam("cartridgeType" @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getAvailableLbCartridges() throws RestAPIException { - return Response.ok().entity(ServiceUtils.getAvailableLbCartridges(false, getConfigContext())).build(); + List lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext()); + return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build(); } @GET diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/schemas/schema.xsd index e6fd796c12..768aeb98d1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos-test/WEB-INF/schemas/schema.xsd @@ -88,7 +88,7 @@ - + @@ -219,11 +219,8 @@ - - - - - + + diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd index f59bf28ea4..0de935f712 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd @@ -88,7 +88,7 @@ - + @@ -219,11 +219,8 @@ - - - - - + + diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/extensions/DockerImageExtension.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/extensions/DockerImageExtension.java deleted file mode 100644 index 8b4820db9a..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/extensions/DockerImageExtension.java +++ /dev/null @@ -1,120 +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.jclouds.docker.compute.extensions; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_IMAGE_AVAILABLE; -import java.util.NoSuchElementException; -import java.util.concurrent.Callable; -import java.util.concurrent.atomic.AtomicReference; - -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.Constants; -import org.jclouds.compute.domain.CloneImageTemplate; -import org.jclouds.compute.domain.Image; -import org.jclouds.compute.domain.ImageTemplate; -import org.jclouds.compute.domain.ImageTemplateBuilder; -import org.jclouds.compute.extensions.ImageExtension; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.docker.DockerApi; -import org.jclouds.docker.compute.functions.ImageToImage; -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.options.CommitOptions; -import org.jclouds.logging.Logger; - -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.util.concurrent.Atomics; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.UncheckedTimeoutException; - -/** - * Docker implementation of {@link org.jclouds.compute.extensions.ImageExtension} - * - * @author Andrea Turli - */ -@Singleton -public class DockerImageExtension implements ImageExtension { - - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - private Logger logger = Logger.NULL; - private final DockerApi api; - private final ListeningExecutorService userExecutor; - private final Predicate> imageAvailablePredicate; - - @Inject - public DockerImageExtension(DockerApi api, @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService - userExecutor, @Named(TIMEOUT_IMAGE_AVAILABLE) Predicate> imageAvailablePredicate) { - this.api = checkNotNull(api, "api"); - this.userExecutor = checkNotNull(userExecutor, "userExecutor"); - this.imageAvailablePredicate = checkNotNull(imageAvailablePredicate, "imageAvailablePredicate"); - } - - @Override - public ImageTemplate buildImageTemplateFromNode(String name, final String id) { - Container container = api.getRemoteApi().inspectContainer(id); - if (container == null) - throw new NoSuchElementException("Cannot find container with id: " + id); - CloneImageTemplate template = new ImageTemplateBuilder.CloneImageTemplateBuilder().nodeId(id).name(name).build(); - return template; - } - - @Override - public ListenableFuture createImage(ImageTemplate template) { - checkArgument(template instanceof CloneImageTemplate, - " docker only currently supports creating images through cloning."); - CloneImageTemplate cloneTemplate = (CloneImageTemplate) template; - - Container container = api.getRemoteApi().inspectContainer(cloneTemplate.getSourceNodeId()); - CommitOptions options = CommitOptions.Builder.containerId(container.getId()).tag(cloneTemplate.getName()); - org.jclouds.docker.domain.Image dockerImage = api.getRemoteApi().commit(options); - - dockerImage = org.jclouds.docker.domain.Image.builder().fromImage(dockerImage) - .repoTags(ImmutableList.of(cloneTemplate.getName() + ":latest")) - .build(); - - logger.info(">> Registered new image %s, waiting for it to become available.", dockerImage.getId()); - final AtomicReference image = Atomics.newReference(new ImageToImage().apply(dockerImage)); - return userExecutor.submit(new Callable() { - @Override - public Image call() throws Exception { - if (imageAvailablePredicate.apply(image)) - return image.get(); - throw new UncheckedTimeoutException("Image was not created within the time limit: " + image.get()); - } - }); - } - - @Override - public boolean deleteImage(String id) { - try { - api.getRemoteApi().deleteImage(id); - } catch (Exception e) { - logger.error(e, "Could not delete image with id %s ", id); - return false; - } - return true; - } - -} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/internal/Archives.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/internal/Archives.java deleted file mode 100644 index 49641b9a6a..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/internal/Archives.java +++ /dev/null @@ -1,96 +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.jclouds.docker.compute.features.internal; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.collect.Iterables.getLast; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; - -import org.apache.commons.compress.archivers.tar.TarArchiveEntry; -import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; - -import com.google.common.base.Splitter; - -/** - * @author Andrea Turli - */ -public class Archives { - - public static File tar(File baseDir, String archivePath) throws IOException { - // Check that the directory is a directory, and get its contents - checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); - File[] files = baseDir.listFiles(); - File tarFile = new File(archivePath); - - String token = getLast(Splitter.on("/").split(archivePath.substring(0, archivePath.lastIndexOf("/")))); - - byte[] buf = new byte[1024]; - int len; - TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile)); - tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); - for (File file : files) { - TarArchiveEntry tarEntry = new TarArchiveEntry(file); - tarEntry.setName("/" + getLast(Splitter.on(token).split(file.toString()))); - tos.putArchiveEntry(tarEntry); - if (!file.isDirectory()) { - FileInputStream fin = new FileInputStream(file); - BufferedInputStream in = new BufferedInputStream(fin); - while ((len = in.read(buf)) != -1) { - tos.write(buf, 0, len); - } - in.close(); - } - tos.closeArchiveEntry(); - } - tos.close(); - return tarFile; - } - - public static File tar(File baseDir, File tarFile) throws IOException { - // Check that the directory is a directory, and get its contents - checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); - File[] files = baseDir.listFiles(); - - String token = getLast(Splitter.on("/").split(baseDir.getAbsolutePath())); - - byte[] buf = new byte[1024]; - int len; - TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile)); - tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); - for (File file : files) { - TarArchiveEntry tarEntry = new TarArchiveEntry(file); - tarEntry.setName("/" + getLast(Splitter.on(token).split(file.toString()))); - tos.putArchiveEntry(tarEntry); - if (!file.isDirectory()) { - FileInputStream fin = new FileInputStream(file); - BufferedInputStream in = new BufferedInputStream(fin); - while ((len = in.read(buf)) != -1) { - tos.write(buf, 0, len); - } - in.close(); - } - tos.closeArchiveEntry(); - } - tos.close(); - return tarFile; - } - -} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/ubuntu/Dockerfile b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/ubuntu/Dockerfile deleted file mode 100644 index fe21ef4a63..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/ubuntu/Dockerfile +++ /dev/null @@ -1,30 +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. -# - -FROM ubuntu:12.04 -MAINTAINER Andrea Turli - -RUN apt-get update -RUN apt-get install -y openssh-server - -RUN mkdir /var/run/sshd -RUN /usr/sbin/sshd - -RUN echo 'root:password' | chpasswd - -EXPOSE 22 -CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerExperimentLiveTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerExperimentLiveTest.java deleted file mode 100644 index 1476c9f8c6..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerExperimentLiveTest.java +++ /dev/null @@ -1,144 +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.jclouds.docker.compute; - -import com.beust.jcommander.internal.Maps; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; -import org.jclouds.ContextBuilder; -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.RunNodesException; -import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.docker.compute.options.DockerTemplateOptions; -import org.jclouds.logging.Logger; -import org.jclouds.logging.slf4j.config.SLF4JLoggingModule; -import org.jclouds.scriptbuilder.domain.Statement; -import org.jclouds.scriptbuilder.statements.login.AdminAccess; -import org.jclouds.ssh.SshClient; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import javax.annotation.Resource; -import javax.inject.Named; -import java.io.IOException; -import java.util.Map; -import java.util.Set; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -/** - * @author Andrea Turli - */ -@Test(groups = "live", singleThreaded = true, testName = "DockerExperimentLiveTest") -public class DockerExperimentLiveTest extends BaseDockerApiLiveTest { - - public static final String TEST_LAUNCH_CLUSTER = "jclouds"; - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - - ComputeServiceContext context; - - @BeforeMethod - public void setUp() throws IOException { - context = ContextBuilder.newBuilder("docker") - .overrides(super.setupProperties()) - .modules(ImmutableSet.of(new SLF4JLoggingModule(), new SshjSshClientModule())) - .build(ComputeServiceContext.class); - } - - @AfterMethod - public void tearDown() { - context.close(); - } - - @Test - public void testLaunchUbuntuServerWithInboundPorts() throws RunNodesException { - int numNodes = 1; - ComputeService compute = context.getComputeService(); - - Template template = compute.templateBuilder().smallest() - .osFamily(OsFamily.UBUNTU).os64Bit(true) - .osDescriptionMatches("jclouds/ubuntu:latest") - .build(); - Statement bootInstructions = AdminAccess.standard(); - - DockerTemplateOptions templateOptions = template.getOptions().as(DockerTemplateOptions.class); - - Map volumes = Maps.newHashMap(); - volumes.put("/var/lib/docker", "/root"); - templateOptions.volumes(volumes).runScript(bootInstructions) - .inboundPorts(22, 80, 8080); - - Set nodes = context.getComputeService().createNodesInGroup(TEST_LAUNCH_CLUSTER, numNodes, template); - assertEquals(numNodes, nodes.size(), "wrong number of nodes"); - for (NodeMetadata node : nodes) { - assertTrue(node.getGroup().equals(TEST_LAUNCH_CLUSTER)); - logger.debug("Created Node: %s", node); - SshClient client = context.utils().sshForNode().apply(node); - client.connect(); - ExecResponse hello = client.exec("echo hello"); - assertEquals(hello.getOutput().trim(), "hello"); - } - context.getComputeService().destroyNodesMatching(new Predicate() { - @Override - public boolean apply(NodeMetadata input) { - return input.getGroup().contains(TEST_LAUNCH_CLUSTER); - } - }); - } - - public void testLaunchUbuntuCluster() throws RunNodesException { - int numNodes = 1; - ComputeService compute = context.getComputeService(); - Template template = compute.templateBuilder() - .smallest().osFamily(OsFamily.UBUNTU) - .os64Bit(true) - .osDescriptionMatches("jclouds/ubuntu:latest") - .build(); - Statement bootInstructions = AdminAccess.standard(); - template.getOptions().runScript(bootInstructions) - .inboundPorts(22); - - Set nodes = context.getComputeService().createNodesInGroup(TEST_LAUNCH_CLUSTER, numNodes, template); - assertEquals(numNodes, nodes.size(), "wrong number of nodes"); - for (NodeMetadata node : nodes) { - assertTrue(node.getGroup().equals(TEST_LAUNCH_CLUSTER)); - logger.debug("Created Node: %s", node); - SshClient client = context.utils().sshForNode().apply(node); - client.connect(); - ExecResponse hello = client.exec("echo hello"); - assertEquals(hello.getOutput().trim(), "hello"); - } - context.getComputeService().destroyNodesMatching(new Predicate() { - @Override - public boolean apply(NodeMetadata input) { - return input.getGroup().contains(TEST_LAUNCH_CLUSTER); - } - }); - } - -} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java deleted file mode 100644 index 23d387d763..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.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.jclouds.docker.config; - -import static org.jclouds.docker.config.DockerParserModule.ContainerTypeAdapter; -import static org.jclouds.docker.config.DockerParserModule.ImageTypeAdapter; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.Image; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -/** - * Unit tests for the {@link org.jclouds.docker.config.DockerParserModule} class. - * - * @author Andrea Turli - */ -@Test(groups = "unit", testName = "DockerParserModuleTest") -public class DockerParserModuleTest { - - private Gson gson; - - @BeforeMethod - public void setup() { - gson = new GsonBuilder() - .registerTypeAdapter(Container.class, new ContainerTypeAdapter()) - .registerTypeAdapter(Image.class, new ImageTypeAdapter()) - .create(); - } - - @Test - public void testContainerID() { - Container container = gson.fromJson( - "{ \"ID\": \"1111111111111111111111111111111111111111111111111111111111111111\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getId(), "1111111111111111111111111111111111111111111111111111111111111111"); - } - - - @Test - public void testContainerId() { - Container container = gson.fromJson( - "{ \"Id\": \"2222222222222222222222222222222222222222222222222222222222222222\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getId(), "2222222222222222222222222222222222222222222222222222222222222222"); - } - - @Test - public void testContainerName() { - Container container = gson.fromJson( - "{ \"Name\": \"example\" }", - Container.class); - assertNotNull(container); - assertEquals(container.getName(), "example"); - } - - - @Test - public void testContainerNames() { - Container container = gson.fromJson("{ \"Names\": [\"/jclouds-b45\"] }", Container.class); - assertNotNull(container); - assertEquals(container.getName(), "/jclouds-b45"); - } - - @Test - public void testImageid() { - Image image = gson.fromJson( - "{ \"id\": \"3333333333333333333333333333333333333333333333333333333333333333\" }", Image.class); - assertNotNull(image); - assertEquals(image.getId(), "3333333333333333333333333333333333333333333333333333333333333333"); - } - - - @Test - public void testImageId() { - Image image = gson.fromJson( - "{ \"Id\": \"4444444444444444444444444444444444444444444444444444444444444444\" }", Image.class); - assertNotNull(image); - assertEquals(image.getId(), "4444444444444444444444444444444444444444444444444444444444444444"); - } -} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile deleted file mode 100644 index 131871544c..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/Dockerfile +++ /dev/null @@ -1,29 +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. -# - -FROM centos:6.4 -MAINTAINER Andrea Turli - -# RUN yum -y groupinstall 'Development Tools' -RUN yum -y install openssh-server openssh-clients - -RUN chkconfig sshd on -RUN service sshd start -RUN echo 'root:password' | chpasswd - -EXPOSE 22 -CMD ["/usr/sbin/sshd", "-D"] \ No newline at end of file diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json b/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json deleted file mode 100644 index acb4a217be..0000000000 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "ID": "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9", - "Created": "2014-03-22T07:16:45.784120972Z", - "Path": "/usr/sbin/sshd", - "Args": [ - "-D" - ], - "Config": { - "Hostname": "6d35806c1bd2", - "Domainname": "", - "User": "", - "Memory": 0, - "MemorySwap": 0, - "CpuShares": 0, - "AttachStdin": false, - "AttachStdout": false, - "AttachStderr": false, - "PortSpecs": null, - "ExposedPorts": { - "22/tcp": {} - }, - "Tty": false, - "OpenStdin": false, - "StdinOnce": false, - "Env": null, - "Cmd": [ - "/usr/sbin/sshd", - "-D" - ], - "Dns": null, - "Image": "jclouds/ubuntu", - "Volumes": null, - "VolumesFrom": "", - "WorkingDir": "", - "Entrypoint": null, - "NetworkDisabled": false, - "OnBuild": null - }, - "State": { - "Running": true, - "Pid": 7051, - "ExitCode": 0, - "StartedAt": "2014-03-22T07:16:45.845347434Z", - "FinishedAt": "0001-01-01T00:00:00Z", - "Ghost": false - }, - "Image": "af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6", - "NetworkSettings": { - "IPAddress": "172.17.0.2", - "IPPrefixLen": 16, - "Gateway": "172.17.42.1", - "Bridge": "docker0", - "PortMapping": null, - "Ports": { - "22/tcp": [ - { - "HostIp": "0.0.0.0", - "HostPort": "49231" - } - ] - } - }, - "ResolvConfPath": "/etc/resolv.conf", - "HostnamePath": "/mnt/sda1/var/lib/docker/containers/6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9/hostname", - "HostsPath": "/mnt/sda1/var/lib/docker/containers/6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9/hosts", - "Name": "/hopeful_mclean", - "Driver": "aufs", - "ExecDriver": "native-0.1", - "Volumes": {}, - "VolumesRW": {}, - "HostConfig": { - "Binds": null, - "ContainerIDFile": "", - "LxcConf": [], - "Privileged": false, - "PortBindings": { - "22/tcp": [ - { - "HostIp": "0.0.0.0", - "HostPort": "49231" - } - ] - }, - "Links": null, - "PublishAllPorts": false - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/README.md b/dependencies/jclouds/apis/docker/1.8.0-stratos/README.md similarity index 100% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/README.md rename to dependencies/jclouds/apis/docker/1.8.0-stratos/README.md diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/pom.xml b/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml similarity index 97% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/pom.xml rename to dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml index 0fb9b96bde..d2a3cca436 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/pom.xml +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/pom.xml @@ -23,19 +23,19 @@ org.apache.jclouds.labs jclouds-labs - 1.7.1 + 1.8.0 org.apache.stratos docker jclouds docker API - 1.7.1-stratos + 1.8.0-stratos ComputeService binding to the Docker API bundle - 1.7.1 + 1.8.0 https://localhost:4243 1.10 FIXME diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApi.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java similarity index 86% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApi.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java index 9fe6135791..54bf5c9a06 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApi.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApi.java @@ -16,7 +16,7 @@ */ package org.jclouds.docker; -import org.jclouds.docker.compute.features.RemoteApi; +import org.jclouds.docker.features.RemoteApi; import org.jclouds.rest.annotations.Delegate; import java.io.Closeable; @@ -24,8 +24,7 @@ /** * Provides synchronous access to Docker Remote API. * - * @author Andrea Turli - * @see + * @see */ public interface DockerApi extends Closeable { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java similarity index 93% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java index c627d827bf..b281eb7566 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/DockerApiMetadata.java @@ -16,11 +16,8 @@ */ package org.jclouds.docker; -import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; -import static org.jclouds.reflect.Reflection2.typeToken; -import java.net.URI; -import java.util.Properties; - +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; import org.jclouds.Constants; import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; @@ -30,13 +27,14 @@ import org.jclouds.docker.config.DockerParserModule; import org.jclouds.rest.internal.BaseHttpApiMetadata; -import com.google.common.collect.ImmutableSet; -import com.google.inject.Module; +import java.net.URI; +import java.util.Properties; + +import static org.jclouds.compute.config.ComputeServiceProperties.TEMPLATE; +import static org.jclouds.reflect.Reflection2.typeToken; /** * Implementation of {@link BaseHttpApiMetadata} for the Docker API - * - * @author Andrea Turli */ public class DockerApiMetadata extends BaseHttpApiMetadata { @@ -71,9 +69,9 @@ protected Builder() { .name("Docker API") .identityName("user") .credentialName("password") - .documentation(URI.create("http://docs.docker.io/en/latest/api/docker_remote_api/")) - .version("1.10") - .defaultEndpoint("http://127.0.0.1:4243") + .documentation(URI.create("https://docs.docker.com/reference/api/docker_remote_api/")) + .version("1.12") + .defaultEndpoint("http://127.0.0.1:2375") .defaultProperties(DockerApiMetadata.defaultProperties()) .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>of( diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java similarity index 91% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java index ea485d2c6c..855a2e5d41 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/binders/BindInputStreamToRequest.java @@ -16,31 +16,26 @@ */ package org.jclouds.docker.binders; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -import javax.annotation.Resource; -import javax.inject.Named; -import javax.inject.Singleton; -import javax.ws.rs.core.MediaType; - +import com.google.common.base.Throwables; +import com.google.common.io.Files; import org.jclouds.compute.reference.ComputeServiceConstants; -import org.jclouds.docker.compute.features.internal.Archives; +import org.jclouds.docker.features.internal.Archives; import org.jclouds.http.HttpRequest; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.logging.Logger; import org.jclouds.rest.Binder; -import com.google.common.base.Throwables; -import com.google.common.io.Files; +import javax.annotation.Resource; +import javax.inject.Named; +import javax.inject.Singleton; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Andrea Turli - */ @Singleton public class BindInputStreamToRequest implements Binder { @@ -48,7 +43,6 @@ public class BindInputStreamToRequest implements Binder { @Named(ComputeServiceConstants.COMPUTE_LOGGER) protected Logger logger = Logger.NULL; - @SuppressWarnings("unchecked") @Override public R bindToRequest(R request, Object input) { checkArgument(checkNotNull(input, "input") instanceof File, "this binder is only valid for File!"); @@ -63,7 +57,7 @@ public R bindToRequest(R request, Object input) { FileInputStream data = new FileInputStream(archive); Payload payload = Payloads.newInputStreamPayload(data); payload.getContentMetadata().setContentLength(data.getChannel().size()); - payload.getContentMetadata().setContentType(MediaType.TEXT_PLAIN); + payload.getContentMetadata().setContentType("application/tar"); request.setPayload(payload); } catch (IOException e) { logger.error(e, "Couldn't create a tarball for %s", targetFile); diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java similarity index 85% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java index 73682994d2..063d6c9e87 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/config/DockerComputeServiceContextModule.java @@ -17,16 +17,12 @@ package org.jclouds.docker.compute.config; import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.inject.Injector; import com.google.inject.TypeLiteral; import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.compute.extensions.ImageExtension; import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.docker.compute.extensions.DockerImageExtension; import org.jclouds.docker.compute.functions.ContainerToNodeMetadata; import org.jclouds.docker.compute.functions.ImageToImage; import org.jclouds.docker.compute.functions.StateToStatus; @@ -38,12 +34,10 @@ import org.jclouds.domain.Location; import org.jclouds.functions.IdentityFunction; -/** - * @author Andrea Turli - */ public class DockerComputeServiceContextModule extends ComputeServiceAdapterContextModule { + @SuppressWarnings("unchecked") @Override protected void configure() { super.configure(); @@ -60,14 +54,6 @@ protected void configure() { bind(new TypeLiteral>() { }).to(StateToStatus.class); bind(TemplateOptions.class).to(DockerTemplateOptions.class); - - bind(new TypeLiteral() { - }).to(DockerImageExtension.class); - } - - @Override - protected Optional provideImageExtension(Injector i) { - return Optional.of(i.getInstance(ImageExtension.class)); } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java similarity index 76% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java index 8cbcd6ce2c..72c16af55c 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadata.java @@ -21,51 +21,48 @@ import java.net.URI; import java.util.List; import java.util.Map; +import java.util.Set; -import javax.annotation.Resource; import javax.inject.Inject; -import javax.inject.Named; +import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; -import org.jclouds.compute.domain.OperatingSystem; -import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Processor; import org.jclouds.compute.functions.GroupNamingConvention; -import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.docker.domain.Container; import org.jclouds.docker.domain.Port; import org.jclouds.docker.domain.State; -import org.jclouds.domain.LocationBuilder; -import org.jclouds.domain.LocationScope; -import org.jclouds.logging.Logger; +import org.jclouds.domain.Location; import org.jclouds.providers.ProviderMetadata; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; import com.google.inject.Singleton; -/** - * @author Andrea Turli - */ @Singleton public class ContainerToNodeMetadata implements Function { - @Resource - @Named(ComputeServiceConstants.COMPUTE_LOGGER) - protected Logger logger = Logger.NULL; - private final ProviderMetadata providerMetadata; private final Function toPortableStatus; private final GroupNamingConvention nodeNamingConvention; + private final Supplier> images; + private final Supplier> locations; @Inject public ContainerToNodeMetadata(ProviderMetadata providerMetadata, Function toPortableStatus, GroupNamingConvention.Factory namingConvention) { + NodeMetadata.Status> toPortableStatus, GroupNamingConvention.Factory namingConvention, + Supplier> images, + @Memoized Supplier> locations) { this.providerMetadata = checkNotNull(providerMetadata, "providerMetadata"); this.toPortableStatus = checkNotNull(toPortableStatus, "toPortableStatus cannot be null"); this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix(); + this.images = checkNotNull(images, "images cannot be null"); + this.locations = checkNotNull(locations, "locations"); } @Override @@ -76,25 +73,23 @@ public NodeMetadata apply(Container container) { builder.ids(container.getId()) .name(name) .group(group) - .hostname(container.getConfig().getHostname()) + .hostname(container.getContainerConfig().getHostname()) // TODO Set up hardware .hardware(new HardwareBuilder() .id("") - .ram(container.getConfig().getMemory()) - .processor(new Processor(container.getConfig().getCpuShares(), container.getConfig().getCpuShares())) + .ram(container.getContainerConfig().getMemory()) + .processor(new Processor(container.getContainerConfig().getCpuShares(), container.getContainerConfig().getCpuShares())) .build()); - // TODO Set up location properly - LocationBuilder locationBuilder = new LocationBuilder(); - locationBuilder.description(""); - locationBuilder.id(""); - locationBuilder.scope(LocationScope.HOST); - builder.location(locationBuilder.build()); builder.status(toPortableStatus.apply(container.getState())); builder.imageId(container.getImage()); builder.loginPort(getLoginPort(container)); builder.publicAddresses(getPublicIpAddresses()); builder.privateAddresses(getPrivateIpAddresses(container)); - builder.operatingSystem(OperatingSystem.builder().description("linux").family(OsFamily.LINUX).build()); + builder.location(Iterables.getOnlyElement(locations.get())); + Image image = images.get().get(container.getImage()); + builder.imageId(image.getId()); + builder.operatingSystem(image.getOperatingSystem()); + return builder.build(); } @@ -114,8 +109,8 @@ private List getPublicIpAddresses() { protected static int getLoginPort(Container container) { if (container.getNetworkSettings() != null) { - Map>> ports = container.getNetworkSettings().getPorts(); - if(ports != null) { + Map>> ports = container.getNetworkSettings().getPorts(); + if (ports != null) { return Integer.parseInt(getOnlyElement(ports.get("22/tcp")).get("HostPort")); } // this is needed in case the container list is coming from listContainers diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java similarity index 87% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java index bcbc53f599..4e3358df44 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/ImageToImage.java @@ -32,9 +32,6 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterables.get; -/** - * @author Andrea Turli - */ public class ImageToImage implements Function { private static final String CENTOS = "centos"; @@ -47,7 +44,7 @@ public class ImageToImage implements Function osFamily() { return new Function() { - OsFamily osFamily = OsFamily.UNRECOGNIZED; @Override public OsFamily apply(final String description) { if (description != null) { - if (description.contains(CENTOS)) osFamily = OsFamily.CENTOS; - else if (description.contains(UBUNTU)) - osFamily = OsFamily.UBUNTU; + if (description.contains(CENTOS)) return OsFamily.CENTOS; + else if (description.contains(UBUNTU)) return OsFamily.UBUNTU; } - logger.debug("os family for item: %s is %s", description, osFamily); - return osFamily; + return OsFamily.UNRECOGNIZED; } }; } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java similarity index 88% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java index d2df1460fe..2d87384005 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/functions/StateToStatus.java @@ -16,17 +16,15 @@ */ package org.jclouds.docker.compute.functions; -import com.google.common.base.Function; -import org.jclouds.compute.domain.NodeMetadata; +import javax.inject.Singleton; + import org.jclouds.compute.domain.NodeMetadata.Status; import org.jclouds.docker.domain.State; -import javax.inject.Singleton; +import com.google.common.base.Function; /** * Transforms an {@link org.jclouds.docker.domain.Container} to the jclouds portable model. - * - * @author Andrea Turli */ @Singleton public class StateToStatus implements Function { @@ -34,7 +32,7 @@ public class StateToStatus implements Function { @Override public Status apply(final State state) { if (state == null) return Status.UNRECOGNIZED; - return state.isRunning() ? NodeMetadata.Status.RUNNING : NodeMetadata.Status.SUSPENDED; + return state.isRunning() ? Status.RUNNING : Status.TERMINATED; } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java similarity index 70% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java index 1303756fc3..5e4669b9ea 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/options/DockerTemplateOptions.java @@ -16,16 +16,20 @@ */ package org.jclouds.docker.compute.options; -import static com.google.common.base.Objects.equal; -import java.util.Map; - +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.LoginCredentials; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.scriptbuilder.domain.Statement; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkNotNull; /** * Contains options supported in the {@code ComputeService#runNode} operation on the @@ -34,16 +38,22 @@ * creation method followed by an instance mutator (if needed): *

* - * import static org.jclouds.aws.ec2.compute.options.DockerTemplateOptions.Builder.*; + * import static org.jclouds.docker.compute.options.DockerTemplateOptions.Builder.*; *

* ComputeService api = // get connection * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * Set set = api.createNodesInGroup(tag, 2, templateBuilder.build()); * - * - * @author Andrea Turli */ public class DockerTemplateOptions extends TemplateOptions implements Cloneable { + + protected Optional dns = Optional.absent(); + protected Optional hostname = Optional.absent(); + protected Optional memory = Optional.absent(); + protected Optional cpuShares = Optional.absent(); + protected Optional> commands = Optional.absent(); + protected Optional> volumes = Optional.absent(); + @Override public DockerTemplateOptions clone() { DockerTemplateOptions options = new DockerTemplateOptions(); @@ -56,14 +66,27 @@ public void copyTo(TemplateOptions to) { super.copyTo(to); if (to instanceof DockerTemplateOptions) { DockerTemplateOptions eTo = DockerTemplateOptions.class.cast(to); - if (getVolumes().isPresent()) { + if (volumes.isPresent()) { eTo.volumes(getVolumes().get()); } + if (hostname.isPresent()) { + eTo.hostname(hostname.get()); + } + if (dns.isPresent()) { + eTo.dns(dns.get()); + } + if (memory.isPresent()) { + eTo.memory(memory.get()); + } + if (commands.isPresent()) { + eTo.commands(commands.get()); + } + if (cpuShares.isPresent()) { + eTo.cpuShares(cpuShares.get()); + } } } - protected Optional> volumes = Optional.absent(); - @Override public boolean equals(Object o) { if (this == o) @@ -71,20 +94,29 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; DockerTemplateOptions that = DockerTemplateOptions.class.cast(o); - return super.equals(that) && equal(this.volumes, that.volumes); + return super.equals(that) && equal(this.volumes, that.volumes) && + equal(this.hostname, that.hostname) && + equal(this.dns, that.dns) && + equal(this.memory, that.memory) && + equal(this.commands, that.commands) && + equal(this.cpuShares, that.cpuShares); } @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), volumes); + return Objects.hashCode(super.hashCode(), volumes, hostname, dns, memory, commands, cpuShares); } @Override - public Objects.ToStringHelper string() { - Objects.ToStringHelper toString = super.string(); - if (volumes.isPresent()) - toString.add("volumes", volumes.get()); - return toString; + public String toString() { + return Objects.toStringHelper(this) + .add("dns", dns) + .add("hostname", hostname) + .add("memory", memory) + .add("cpuShares", cpuShares) + .add("commands", commands) + .add("volumes", volumes) + .toString(); } public static final DockerTemplateOptions NONE = new DockerTemplateOptions(); @@ -94,10 +126,53 @@ public DockerTemplateOptions volumes(Map volumes) { return this; } + public TemplateOptions dns(@Nullable String dns) { + this.dns = Optional.fromNullable(dns); + return this; + } + + public TemplateOptions hostname(@Nullable String hostname) { + this.hostname = Optional.fromNullable(hostname); + return this; + } + + public TemplateOptions memory(@Nullable Integer memory) { + this.memory = Optional.fromNullable(memory); + return this; + } + + public TemplateOptions commands(Iterable commands) { + for (String command : checkNotNull(commands, "commands")) + checkNotNull(command, "all commands must be non-empty"); + this.commands = Optional.> of(ImmutableList.copyOf(commands)); + return this; + } + + public TemplateOptions commands(String... commands) { + return commands(ImmutableList.copyOf(checkNotNull(commands, "commands"))); + } + + public TemplateOptions cpuShares(@Nullable Integer cpuShares) { + this.cpuShares = Optional.fromNullable(cpuShares); + return this; + } + public Optional> getVolumes() { return volumes; } + public Optional getDns() { return dns; } + + public Optional getHostname() { return hostname; } + + public Optional getMemory() { return memory; } + + public Optional> getCommands() { + return commands; + } + + public Optional getCpuShares() { return cpuShares; } + public static class Builder { /** @@ -108,6 +183,51 @@ public static DockerTemplateOptions volumes(Map volumes) { return DockerTemplateOptions.class.cast(options.volumes(volumes)); } + /** + * @see DockerTemplateOptions#dns(String) + */ + public static DockerTemplateOptions dns(String dns) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.dns(dns)); + } + + /** + * @see DockerTemplateOptions#hostname(String) + */ + public static DockerTemplateOptions hostname(String hostname) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.hostname(hostname)); + } + + /** + * @see DockerTemplateOptions#memory(int) + */ + public static DockerTemplateOptions memory(int memory) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.memory(memory)); + } + + /** + * @see DockerTemplateOptions#commands(Iterable) + */ + public static DockerTemplateOptions commands(String... commands) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.commands(commands)); + } + + public static DockerTemplateOptions commands(Iterable commands) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.commands(commands)); + } + + /** + * @see DockerTemplateOptions#cpuShares(int) + */ + public static DockerTemplateOptions cpuShares(int cpuShares) { + DockerTemplateOptions options = new DockerTemplateOptions(); + return DockerTemplateOptions.class.cast(options.cpuShares(cpuShares)); + } + // methods that only facilitate returning the correct object type /** diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java similarity index 75% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java index 5646054a22..7bbead38fa 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/compute/strategy/DockerComputeServiceAdapter.java @@ -16,14 +16,21 @@ */ package org.jclouds.docker.compute.strategy; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.find; + +import java.util.Map; +import java.util.Set; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.jclouds.compute.ComputeServiceAdapter; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.HardwareBuilder; +import org.jclouds.compute.domain.Processor; import org.jclouds.compute.domain.Template; import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.docker.DockerApi; @@ -32,22 +39,17 @@ import org.jclouds.docker.domain.Container; import org.jclouds.docker.domain.HostConfig; import org.jclouds.docker.domain.Image; +import org.jclouds.docker.options.ListContainerOptions; +import org.jclouds.docker.options.RemoveContainerOptions; import org.jclouds.domain.Location; import org.jclouds.domain.LoginCredentials; import org.jclouds.logging.Logger; -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.contains; -import static com.google.common.collect.Iterables.filter; -import static com.google.common.collect.Iterables.find; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; /** * defines the connection between the {@link org.jclouds.docker.DockerApi} implementation and @@ -73,48 +75,58 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(S Template template) { checkNotNull(template, "template was null"); checkNotNull(template.getOptions(), "template options was null"); - DockerTemplateOptions templateOptions = DockerTemplateOptions.class.cast(template.getOptions()); String imageId = checkNotNull(template.getImage().getId(), "template image id must not be null"); String loginUser = template.getImage().getDefaultCredentials().getUser(); String loginUserPassword = template.getImage().getDefaultCredentials().getPassword(); + DockerTemplateOptions templateOptions = DockerTemplateOptions.class.cast(template.getOptions()); + int[] inboundPorts = templateOptions.getInboundPorts(); + Map exposedPorts = Maps.newHashMap(); - int[] inboundPorts = template.getOptions().getInboundPorts(); for (int inboundPort : inboundPorts) { exposedPorts.put(inboundPort + "/tcp", Maps.newHashMap()); } - Config.Builder configBuilder = Config.builder() - .imageId(template.getImage().getName()) - //.cmd(ImmutableList.of("/usr/sbin/sshd", "-D")) - .attachStdout(true) - .attachStderr(true) + Config.Builder containerConfigBuilder = Config.builder() + .imageId(imageId) .exposedPorts(exposedPorts); + if (templateOptions.getCommands().isPresent()) { + containerConfigBuilder.cmd(templateOptions.getCommands().get()); + } + + if (templateOptions.getMemory().isPresent()) { + containerConfigBuilder.memory(templateOptions.getMemory().get()); + } + + if (templateOptions.getCpuShares().isPresent()) { + containerConfigBuilder.cpuShares(templateOptions.getCpuShares().get()); + } + if (templateOptions.getVolumes().isPresent()) { Map volumes = Maps.newLinkedHashMap(); for (String containerDir : templateOptions.getVolumes().get().values()) { volumes.put(containerDir, Maps.newHashMap()); } - configBuilder.volumes(volumes); + containerConfigBuilder.volumes(volumes); } - Config config = configBuilder.build(); + Config containerConfig = containerConfigBuilder.build(); - logger.debug(">> creating new container with config(%s)", config); - Container container = api.getRemoteApi().createContainer(name, config); + logger.debug(">> creating new container with containerConfig(%s)", containerConfig); + Container container = api.getRemoteApi().createContainer(name, containerConfig); logger.trace("<< container(%s)", container.getId()); - // set up for port bindings - Map>> portBindings = Maps.newHashMap(); HostConfig.Builder hostConfigBuilder = HostConfig.builder() - .portBindings(portBindings) .publishAllPorts(true) .privileged(true); + if (templateOptions.getDns().isPresent()) { + hostConfigBuilder.dns(templateOptions.getDns().get()); + } // set up for volume bindings if (templateOptions.getVolumes().isPresent()) { - for (Map.Entry entry : templateOptions.getVolumes().get().entrySet()) { + for (Map.Entry entry : templateOptions.getVolumes().get().entrySet()) { hostConfigBuilder.binds(ImmutableList.of(entry.getKey() + ":" + entry.getValue())); } } @@ -122,7 +134,7 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(S api.getRemoteApi().startContainer(container.getId(), hostConfig); container = api.getRemoteApi().inspectContainer(container.getId()); - if (!container.getState().isRunning()) { + if (container.getState().getExitCode() != 0) { destroyNode(container.getId()); throw new IllegalStateException(String.format("Container %s has not started correctly", container.getId())); } @@ -134,21 +146,20 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoName(S public Iterable listHardwareProfiles() { Set hardware = Sets.newLinkedHashSet(); // todo they are only placeholders at the moment - hardware.add(new HardwareBuilder().ids("micro").hypervisor("lxc").name("micro").ram(512).build()); - hardware.add(new HardwareBuilder().ids("small").hypervisor("lxc").name("small").ram(1024).build()); - hardware.add(new HardwareBuilder().ids("medium").hypervisor("lxc").name("medium").ram(2048).build()); - hardware.add(new HardwareBuilder().ids("large").hypervisor("lxc").name("large").ram(3072).build()); + hardware.add(new HardwareBuilder().ids("micro").hypervisor("lxc").name("micro").processor(new Processor(1, 1)).ram(512).build()); + hardware.add(new HardwareBuilder().ids("small").hypervisor("lxc").name("small").processor(new Processor(1, 1)).ram(1024).build()); + hardware.add(new HardwareBuilder().ids("medium").hypervisor("lxc").name("medium").processor(new Processor(1, 1)).ram(2048).build()); + hardware.add(new HardwareBuilder().ids("large").hypervisor("lxc").name("large").processor(new Processor(1, 1)).ram(3072).build()); return hardware; } @Override public Set listImages() { - //return api.getRemoteApi().listImages(); Set images = Sets.newHashSet(); for (Image image : api.getRemoteApi().listImages()) { - // less efficient than just listNodes but returns richer json that needs repoTags coming from listImages + // less efficient than just listImages but returns richer json that needs repoTags coming from listImages Image inspected = api.getRemoteApi().inspectImage(image.getId()); - if(image.getRepoTags() != null) { + if (inspected.getRepoTags().isEmpty()) { inspected = Image.builder().fromImage(inspected).repoTags(image.getRepoTags()).build(); } images.add(inspected); @@ -158,20 +169,20 @@ public Set listImages() { @Override public Image getImage(final String imageId) { + // less efficient than just inspectImage but listImages return repoTags return find(listImages(), new Predicate() { @Override public boolean apply(Image input) { return input.getId().equals(imageId); } - }, null); } @Override public Iterable listNodes() { Set containers = Sets.newHashSet(); - for (Container container : api.getRemoteApi().listContainers()) { + for (Container container : api.getRemoteApi().listContainers(ListContainerOptions.Builder.all(true))) { // less efficient than just listNodes but returns richer json containers.add(api.getRemoteApi().inspectContainer(container.getId())); } @@ -180,13 +191,11 @@ public Iterable listNodes() { @Override public Iterable listNodesByIds(final Iterable ids) { - return filter(listNodes(), new Predicate() { - - @Override - public boolean apply(Container server) { - return contains(ids, server.getId()); - } - }); + Set containers = Sets.newHashSet(); + for (String id : ids) { + containers.add(api.getRemoteApi().inspectContainer(id)); + } + return containers; } @Override @@ -201,23 +210,23 @@ public Container getNode(String id) { @Override public void destroyNode(String id) { - api.getRemoteApi().stopContainer(id); - api.getRemoteApi().removeContainer(id); + api.getRemoteApi().removeContainer(id, RemoveContainerOptions.Builder.force(true)); } @Override public void rebootNode(String id) { + api.getRemoteApi().stopContainer(id); api.getRemoteApi().startContainer(id); } @Override public void resumeNode(String id) { - api.getRemoteApi().startContainer(id); + throw new UnsupportedOperationException("resume not supported"); } @Override public void suspendNode(String id) { - api.getRemoteApi().stopContainer(id); + throw new UnsupportedOperationException("suspend not supported"); } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java index 464eb8dd82..e6da554704 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerHttpApiModule.java @@ -27,8 +27,6 @@ /** * Configures the Docker connection. - * - * @author Andrea Turli */ @ConfiguresHttpApi public class DockerHttpApiModule extends HttpApiModule { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java similarity index 62% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java index abdeea36ce..533184f82e 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerParserModule.java @@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; @@ -28,16 +27,12 @@ import com.google.inject.AbstractModule; import com.google.inject.Provides; import org.jclouds.docker.domain.Container; -import org.jclouds.docker.domain.Image; import org.jclouds.json.config.GsonModule; import javax.inject.Singleton; import java.lang.reflect.Type; import java.util.Map; -/** - * @author Andrea Turli - */ public class DockerParserModule extends AbstractModule { @Override @@ -50,7 +45,6 @@ protected void configure() { public Map provideCustomAdapterBindings() { return new ImmutableMap.Builder() .put(Container.class, new ContainerTypeAdapter()) - .put(Image.class, new ImageTypeAdapter()) .build(); } @@ -61,41 +55,8 @@ public Container deserialize(JsonElement json, Type typeOfT, JsonDeserialization JsonParseException { Gson gson = new GsonBuilder().serializeNulls().create(); final JsonObject jsonObject = json.getAsJsonObject(); - - // container:inspect returns ID instead of Id as listContainers - if (jsonObject.has("ID")) { - JsonElement id = jsonObject.get("ID"); - jsonObject.remove("ID"); - jsonObject.add("Id", id); - } - // container:inspect returns Name instead of Names as listContainers - if (jsonObject.has("Names")) { - final JsonArray jsonNamesArray = jsonObject.getAsJsonArray("Names"); - jsonObject.remove("Names"); - jsonObject.add("Name", jsonNamesArray.get(0)); - } return gson.fromJson(jsonObject, Container.class); } - - } - - protected static class ImageTypeAdapter implements JsonDeserializer { - - @Override - public Image deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws - JsonParseException { - Gson gson = new GsonBuilder().serializeNulls().create(); - final JsonObject jsonObject = json.getAsJsonObject(); - - // image:inspect returns id instead of Id as listImages - if (jsonObject.has("Id")) { - JsonElement id = jsonObject.get("Id"); - jsonObject.remove("Id"); - jsonObject.add("id", id); - } - return gson.fromJson(jsonObject, Image.class); - } - } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java similarity index 96% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java index 487b19b3c3..b870feac0f 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/config/DockerProperties.java @@ -16,9 +16,6 @@ */ package org.jclouds.docker.config; -/** - * @author Andrea Turli - */ public class DockerProperties { /** diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Config.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Config.java similarity index 90% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Config.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Config.java index 91dd47ec3b..9c80472d96 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Config.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Config.java @@ -16,21 +16,18 @@ */ package org.jclouds.docker.domain; -import static com.google.common.base.Preconditions.checkNotNull; -import java.beans.ConstructorProperties; -import java.util.List; -import java.util.Map; - -import org.jclouds.javax.annotation.Nullable; - import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; +import org.jclouds.javax.annotation.Nullable; + +import java.beans.ConstructorProperties; +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Andrea Turli - */ public class Config { @SerializedName("Hostname") @@ -74,22 +71,23 @@ public class Config { @SerializedName("WorkingDir") private final String workingDir; @SerializedName("Entrypoint") - private final List entrypoint; + private final String entrypoint; @SerializedName("NetworkDisabled") private final boolean networkDisabled; @SerializedName("OnBuild") - private final String onBuild; + private final List onBuild; @ConstructorProperties({ "Hostname", "Domainname", "User", "Memory", "MemorySwap", "CpuShares", "AttachStdin", - "AttachStdout", "AttachStderr", "PortSpecs", "ExposedPorts", "Tty", "OpenStdin", "StdinOnce", "Env", "Cmd", + "AttachStdout", "AttachStderr", "ExposedPorts", "Tty", "OpenStdin", "StdinOnce", "Env", "Cmd", "Dns", "Image", "Volumes", "VolumesFrom", "WorkingDir", "Entrypoint", "NetworkDisabled", "OnBuild" }) - Config(@Nullable String hostname, @Nullable String domainName, @Nullable String user, int memory, int memorySwap, - int cpuShares, boolean attachStdin, boolean attachStdout, boolean attachStderr, - Map exposedPorts, boolean tty, boolean openStdin, boolean stdinOnce, - @Nullable List env, @Nullable List cmd, @Nullable List dns, String imageId, - Map volumes, @Nullable String volumesFrom, @Nullable String workingDir, - @Nullable List entrypoint, @Nullable boolean networkDisabled, @Nullable String onBuild) { + protected Config(@Nullable String hostname, @Nullable String domainName, @Nullable String user, + int memory, int memorySwap, int cpuShares, boolean attachStdin, boolean attachStdout, + boolean attachStderr, Map exposedPorts, boolean tty, boolean openStdin, + boolean stdinOnce, @Nullable List env, @Nullable List cmd, + @Nullable List dns, String imageId, @Nullable Map volumes, + @Nullable String volumesFrom, @Nullable String workingDir, @Nullable String entrypoint, + @Nullable boolean networkDisabled, @Nullable List onBuild) { this.hostname = hostname; this.domainName = domainName; this.user = user; @@ -103,7 +101,7 @@ public class Config { this.tty = checkNotNull(tty, "tty"); this.openStdin = checkNotNull(openStdin, "openStdin"); this.stdinOnce = checkNotNull(stdinOnce, "stdinOnce"); - this.env = env != null ? ImmutableList.copyOf(cmd) : ImmutableList. of(); + this.env = env != null ? ImmutableList.copyOf(env) : ImmutableList. of(); this.cmd = cmd != null ? ImmutableList.copyOf(cmd) : ImmutableList. of(); this.dns = dns != null ? ImmutableList.copyOf(dns) : ImmutableList. of(); this.imageId = checkNotNull(imageId, "imageId"); @@ -112,7 +110,7 @@ public class Config { this.workingDir = workingDir; this.entrypoint = entrypoint; this.networkDisabled = networkDisabled; - this.onBuild = onBuild; + this.onBuild = onBuild != null ? ImmutableList.copyOf(onBuild) : ImmutableList. of(); } public String getHostname() { @@ -195,7 +193,7 @@ public String getWorkingDir() { return workingDir; } - public List getEntrypoint() { + public String getEntrypoint() { return entrypoint; } @@ -203,7 +201,7 @@ public boolean isNetworkDisabled() { return networkDisabled; } - public String getOnBuild() { + public List getOnBuild() { return onBuild; } @@ -292,7 +290,6 @@ public static final class Builder { private boolean attachStdin; private boolean attachStdout; private boolean attachStderr; - private Map portSpecs = ImmutableMap.of(); private Map exposedPorts = ImmutableMap.of(); private boolean tty; private boolean openStdin; @@ -304,9 +301,9 @@ public static final class Builder { private Map volumes = ImmutableMap.of(); private String volumesFrom; private String workingDir; - private List entrypoint = ImmutableList.of(); + private String entrypoint; private boolean networkDisabled; - private String onBuild; + private List onBuild = ImmutableList.of(); public Builder hostname(String hostname) { this.hostname = hostname; @@ -408,7 +405,7 @@ public Builder workingDir(String workingDir) { return this; } - public Builder entrypoint(List entrypoint) { + public Builder entrypoint(String entrypoint) { this.entrypoint = entrypoint; return this; } @@ -418,8 +415,8 @@ public Builder networkDisabled(boolean networkDisabled) { return this; } - public Builder onBuild(String onBuild) { - this.onBuild = onBuild; + public Builder onBuild(List onBuild) { + this.onBuild = ImmutableList.copyOf(checkNotNull(onBuild, "onBuild")); return this; } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Container.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Container.java similarity index 72% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Container.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Container.java index 8f0129e231..27525292e0 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Container.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Container.java @@ -16,19 +16,18 @@ */ package org.jclouds.docker.domain; -import static com.google.common.base.Preconditions.checkNotNull; -import java.beans.ConstructorProperties; -import java.util.List; -import java.util.Map; - import com.google.common.base.Objects; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.annotations.SerializedName; +import org.jclouds.javax.annotation.Nullable; + +import java.beans.ConstructorProperties; +import java.util.List; +import java.util.Map; + +import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Andrea Turli - */ public class Container { @SerializedName("Id") @@ -42,7 +41,7 @@ public class Container { @SerializedName("Args") private final String[] args; @SerializedName("Config") - private final Config config; + private final Config containerConfig; @SerializedName("State") private final State state; @SerializedName("Image") @@ -58,7 +57,7 @@ public class Container { @SerializedName("Volumes") private final Map volumes; @SerializedName("VolumesRW") - private final Map volumesRw; + private final Map volumesRW; @SerializedName("Command") private final String command; @SerializedName("Status") @@ -67,31 +66,36 @@ public class Container { private final HostConfig hostConfig; @SerializedName("Ports") private final List ports; + @SerializedName("HostnamePath") + private final String hostnamePath; @ConstructorProperties({ "Id", "Name", "Created", "Path", "Args", "Config", "State", "Image", "NetworkSettings", - "ResolvConfPath", "Driver", "ExecDriver", "Volumes", "VolumesRW", "Command", "Status", "HostConfig", "Ports" }) - public Container(String id, String name, String created, String path, String[] args, Config config, State state, - String image, NetworkSettings networkSettings, String resolvConfPath, - String driver, String execDriver, Map volumes, Map volumesRW, - String command, String status, HostConfig hostConfig, List ports) { + "ResolvConfPath", "Driver", "ExecDriver", "Volumes", "VolumesRW", "Command", "Status", "HostConfig", + "Ports", "HostnamePath" }) + protected Container(String id, @Nullable String name, @Nullable String created, @Nullable String path, @Nullable String[] args, + @Nullable Config containerConfig, @Nullable State state, @Nullable String image, @Nullable NetworkSettings networkSettings, + @Nullable String resolvConfPath, @Nullable String driver, @Nullable String execDriver, @Nullable Map volumes, + @Nullable Map volumesRW, @Nullable String command, @Nullable String status, + @Nullable HostConfig hostConfig, @Nullable List ports, @Nullable String hostnamePath) { this.id = checkNotNull(id, "id"); - this.name = checkNotNull(name, "name"); - this.created = checkNotNull(created, "created"); - this.path = checkNotNull(path, "path"); - this.args = checkNotNull(args, "args"); - this.config = checkNotNull(config, "config"); - this.state = checkNotNull(state, "state"); - this.image = checkNotNull(image, "image"); - this.networkSettings = checkNotNull(networkSettings, "networkSettings"); - this.resolvConfPath = checkNotNull(resolvConfPath, "resolvConfPath"); - this.driver = checkNotNull(driver, "driver"); - this.execDriver = checkNotNull(execDriver, "execDriver"); - this.volumes = checkNotNull(volumes, "volumes"); - this.volumesRw = checkNotNull(volumesRW, "volumesRW"); - this.command = checkNotNull(command, "command"); - this.status = checkNotNull(status, "status"); - this.hostConfig = checkNotNull(hostConfig, "hostConfig"); - this.ports = checkNotNull(ports, "ports"); + this.name = name; + this.created = created; + this.path = path; + this.args = args; + this.containerConfig = containerConfig; + this.state = state; + this.image = image; + this.networkSettings = networkSettings; + this.resolvConfPath = resolvConfPath; + this.driver = driver; + this.execDriver = execDriver; + this.volumes = volumes != null ? ImmutableMap.copyOf(volumes) : ImmutableMap.of(); + this.volumesRW = volumesRW != null ? ImmutableMap.copyOf(volumesRW) : ImmutableMap.of(); + this.command = command; + this.status = status; + this.hostConfig = hostConfig; + this.ports = ports != null ? ImmutableList.copyOf(ports) : ImmutableList.of(); + this.hostnamePath = hostnamePath; } public String getId() { @@ -114,8 +118,8 @@ public String[] getArgs() { return args; } - public Config getConfig() { - return config; + public Config getContainerConfig() { + return containerConfig; } public State getState() { @@ -146,8 +150,8 @@ public Map getVolumes() { return volumes; } - public Map getVolumesRw() { - return volumesRw; + public Map getvolumesRW() { + return volumesRW; } public String getCommand() { @@ -166,6 +170,10 @@ public List getPorts() { return ports; } + public String getHostnamePath() { + return hostnamePath; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -178,7 +186,7 @@ public boolean equals(Object o) { Objects.equal(this.created, that.created) && Objects.equal(this.path, that.path) && Objects.equal(this.args, that.args) && - Objects.equal(this.config, that.config) && + Objects.equal(this.containerConfig, that.containerConfig) && Objects.equal(this.state, that.state) && Objects.equal(this.image, that.image) && Objects.equal(this.networkSettings, that.networkSettings) && @@ -186,17 +194,18 @@ public boolean equals(Object o) { Objects.equal(this.driver, that.driver) && Objects.equal(this.execDriver, that.execDriver) && Objects.equal(this.volumes, that.volumes) && - Objects.equal(this.volumesRw, that.volumesRw) && + Objects.equal(this.volumesRW, that.volumesRW) && Objects.equal(this.command, that.command) && Objects.equal(this.status, that.status) && Objects.equal(this.hostConfig, that.hostConfig) && - Objects.equal(this.ports, that.ports); + Objects.equal(this.ports, that.ports) && + Objects.equal(this.hostnamePath, that.hostnamePath); } @Override public int hashCode() { - return Objects.hashCode(id, name, created, path, args, config, state, image, networkSettings, resolvConfPath, - driver, execDriver, volumes, volumesRw, command, status, hostConfig, ports); + return Objects.hashCode(id, name, created, path, args, containerConfig, state, image, networkSettings, resolvConfPath, + driver, execDriver, volumes, volumesRW, command, status, hostConfig, ports, hostnamePath); } @Override @@ -207,7 +216,7 @@ public String toString() { .add("created", created) .add("path", path) .add("args", args) - .add("config", config) + .add("containerConfig", containerConfig) .add("state", state) .add("image", image) .add("networkSettings", networkSettings) @@ -215,11 +224,12 @@ public String toString() { .add("driver", driver) .add("execDriver", execDriver) .add("volumes", volumes) - .add("volumesRw", volumesRw) + .add("volumesRW", volumesRW) .add("command", command) .add("status", status) .add("hostConfig", hostConfig) .add("ports", ports) + .add("hostnamePath", hostnamePath) .toString(); } @@ -238,7 +248,7 @@ public static final class Builder { private String created; private String path; private String[] args; - private Config config; + private Config containerConfig; private State state; private String image; private NetworkSettings networkSettings; @@ -246,11 +256,12 @@ public static final class Builder { private String driver; private String execDriver; private Map volumes = ImmutableMap.of(); - private Map volumesRw = ImmutableMap.of(); + private Map volumesRW = ImmutableMap.of(); private String command; private String status; private HostConfig hostConfig; private List ports = ImmutableList.of(); + private String hostnamePath; public Builder id(String id) { this.id = id; @@ -277,8 +288,8 @@ public Builder args(String[] args) { return this; } - public Builder config(Config config) { - this.config = config; + public Builder containerConfig(Config containerConfig) { + this.containerConfig = containerConfig; return this; } @@ -317,8 +328,8 @@ public Builder volumes(Map volumes) { return this; } - public Builder volumesRw(Map volumesRw) { - this.volumesRw = volumesRw; + public Builder volumesRW(Map volumesRW) { + this.volumesRW = volumesRW; return this; } @@ -342,9 +353,14 @@ public Builder ports(List ports) { return this; } + public Builder hostnamePath(String hostnamePath) { + this.hostnamePath = hostnamePath; + return this; + } + public Container build() { - return new Container(id, name, created, path, args, config, state, image, networkSettings, resolvConfPath, - driver, execDriver, volumes, volumesRw, command, status, hostConfig, ports); + return new Container(id, name, created, path, args, containerConfig, state, image, networkSettings, resolvConfPath, + driver, execDriver, volumes, volumesRW, command, status, hostConfig, ports, hostnamePath); } public Builder fromContainer(Container in) { @@ -354,7 +370,7 @@ public Builder fromContainer(Container in) { .created(in.getCreated()) .path(in.getPath()) .args(in.getArgs()) - .config(in.getConfig()) + .containerConfig(in.getContainerConfig()) .state(in.getState()) .image(in.getImage()) .networkSettings(in.getNetworkSettings()) @@ -362,11 +378,12 @@ public Builder fromContainer(Container in) { .driver(in.getDriver()) .execDriver(in.getExecDriver()) .volumes(in.getVolumes()) - .volumesRw(in.getVolumesRw()) + .volumesRW(in.getvolumesRW()) .command(in.getCommand()) .status(in.getStatus()) .hostConfig(in.getHostConfig()) - .ports(in.getPorts()); + .ports(in.getPorts()) + .hostnamePath(in.getHostnamePath()); } } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java similarity index 92% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java index 146c38b3e7..b7a831a64c 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/ExposedPorts.java @@ -16,24 +16,25 @@ */ package org.jclouds.docker.domain; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableSet; - +import static com.google.common.base.Preconditions.checkNotNull; import java.beans.ConstructorProperties; import java.util.Set; -import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; +import com.google.gson.annotations.SerializedName; -/** - * @author Andrea Turli - */ public class ExposedPorts { + @SerializedName("PortAndProtocol") private final String portAndProtocol; + @SerializedName("HostPorts") private final Set hostPorts; @ConstructorProperties({ "PortAndProtocol", "HostPorts" }) - public ExposedPorts(String portAndProtocol, Set hostPorts) { + protected ExposedPorts(String portAndProtocol, @Nullable Set hostPorts) { this.portAndProtocol = checkNotNull(portAndProtocol, "portAndProtocol"); this.hostPorts = hostPorts != null ? ImmutableSet.copyOf(hostPorts) : ImmutableSet. of(); } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java similarity index 58% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java index 10ae1c1d62..275961fe9e 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/HostConfig.java @@ -16,47 +16,59 @@ */ package org.jclouds.docker.domain; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.gson.annotations.SerializedName; -import org.jclouds.javax.annotation.Nullable; - +import static com.google.common.base.Preconditions.checkNotNull; import java.beans.ConstructorProperties; import java.util.List; import java.util.Map; -import static com.google.common.base.Preconditions.checkNotNull; +import org.jclouds.javax.annotation.Nullable; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.gson.annotations.SerializedName; -/** - * @author Andrea Turli - */ public class HostConfig { @SerializedName("ContainerIDFile") private final String containerIDFile; @SerializedName("Binds") private final List binds; + @SerializedName("LxcConf") + private final Map lxcConf; @SerializedName("Privileged") private final boolean privileged; + @SerializedName("Dns") + private final String dns; + @SerializedName("DnsSearch") + private final String dnsSearch; @SerializedName("PortBindings") private final Map>> portBindings; @SerializedName("Links") private final List links; @SerializedName("PublishAllPorts") private final boolean publishAllPorts; - - @ConstructorProperties({ "ContainerIDFile", "Binds", "Privileged", "PortBindings", "Links", "Size", - "PublishAllPorts" }) - public HostConfig(@Nullable String containerIDFile, @Nullable List binds, @Nullable boolean privileged, - @Nullable Map>> portBindings, @Nullable List links, - @Nullable boolean publishAllPorts) { + @SerializedName("VolumesFrom") + private final List volumesFrom; + + @ConstructorProperties({ "ContainerIDFile", "Binds", "LxcConf", "Privileged", "Dns", "DnsSearch", "PortBindings", + "Links", "PublishAllPorts", "VolumesFrom" }) + protected HostConfig(@Nullable String containerIDFile, @Nullable List binds, + Map lxcConf, boolean privileged, @Nullable String dns, + @Nullable String dnsSearch, @Nullable Map>> portBindings, + @Nullable List links, boolean publishAllPorts, @Nullable List volumesFrom) { this.containerIDFile = containerIDFile; this.binds = binds != null ? ImmutableList.copyOf(binds) : ImmutableList. of(); - this.privileged = privileged; + this.lxcConf = lxcConf != null ? ImmutableMap.copyOf(lxcConf) : ImmutableMap. of(); + this.privileged = checkNotNull(privileged, "privileged"); + this.dns = dns; + this.dnsSearch = dnsSearch; this.portBindings = portBindings != null ? ImmutableMap.copyOf(portBindings) : ImmutableMap.>> of(); this.links = links != null ? ImmutableList.copyOf(links) : ImmutableList. of(); - this.publishAllPorts = publishAllPorts; + this.publishAllPorts = checkNotNull(publishAllPorts, "publishAllPorts"); + this.volumesFrom = volumesFrom != null ? ImmutableList.copyOf(volumesFrom) : ImmutableList. of(); } public String getContainerIDFile() { @@ -67,10 +79,18 @@ public List getBinds() { return binds; } + public Map getLxcConf() { + return lxcConf; + } + public boolean isPrivileged() { return privileged; } + public String getDns() { return dns; } + + public String getDnsSearch() { return dnsSearch; } + public Map>> getPortBindings() { return portBindings; } @@ -84,6 +104,10 @@ public boolean isPublishAllPorts() { return publishAllPorts; } + public List getVolumesFrom() { + return volumesFrom; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -93,15 +117,20 @@ public boolean equals(Object o) { return Objects.equal(this.containerIDFile, that.containerIDFile) && Objects.equal(this.binds, that.binds) && + Objects.equal(this.lxcConf, that.lxcConf) && Objects.equal(this.privileged, that.privileged) && + Objects.equal(this.dns, that.dns) && + Objects.equal(this.dnsSearch, that.dnsSearch) && Objects.equal(this.portBindings, that.portBindings) && Objects.equal(this.links, that.links) && - Objects.equal(this.publishAllPorts, that.publishAllPorts); + Objects.equal(this.publishAllPorts, that.publishAllPorts) && + Objects.equal(this.volumesFrom, that.volumesFrom); } @Override public int hashCode() { - return Objects.hashCode(containerIDFile, binds, privileged, portBindings, links, publishAllPorts); + return Objects.hashCode(containerIDFile, binds, lxcConf, privileged, dns, dnsSearch, portBindings, links, + publishAllPorts, volumesFrom); } @Override @@ -109,10 +138,14 @@ public String toString() { return Objects.toStringHelper(this) .add("containerIDFile", containerIDFile) .add("binds", binds) + .add("lxcConf", lxcConf) .add("privileged", privileged) + .add("dns", dns) + .add("dnsSearch", dnsSearch) .add("portBindings", portBindings) .add("links", links) .add("publishAllPorts", publishAllPorts) + .add("volumesFrom", volumesFrom) .toString(); } @@ -127,11 +160,15 @@ public Builder toBuilder() { public static final class Builder { private String containerIDFile; - private List binds = ImmutableList.of(); + private List binds = Lists.newArrayList(); + private Map lxcConf = Maps.newLinkedHashMap(); private boolean privileged; - private Map>> portBindings = ImmutableMap.of(); - private List links = ImmutableList.of(); + private String dns; + private String dnsSearch; + private Map>> portBindings = Maps.newLinkedHashMap(); + private List links = Lists.newArrayList(); private boolean publishAllPorts; + private List volumesFrom = Lists.newArrayList(); public Builder containerIDFile(String containerIDFile) { this.containerIDFile = containerIDFile; @@ -139,7 +176,12 @@ public Builder containerIDFile(String containerIDFile) { } public Builder binds(List binds) { - this.binds = ImmutableList.copyOf(checkNotNull(binds, "binds")); + this.binds.addAll(checkNotNull(binds, "binds")); + return this; + } + + public Builder lxcConf(Map lxcConf) { + this.lxcConf.putAll(checkNotNull(lxcConf, "lxcConf")); return this; } @@ -148,13 +190,23 @@ public Builder privileged(boolean privileged) { return this; } + public Builder dns(String dns) { + this.dns = dns; + return this; + } + + public Builder dnsSearch(String dnsSearch) { + this.dnsSearch = dnsSearch; + return this; + } + public Builder links(List links) { - this.links = ImmutableList.copyOf(checkNotNull(links, "links")); + this.links.addAll(checkNotNull(links, "links")); return this; } public Builder portBindings(Map>> portBindings) { - this.portBindings = ImmutableMap.copyOf(portBindings); + this.portBindings.putAll(portBindings); return this; } @@ -163,18 +215,28 @@ public Builder publishAllPorts(boolean publishAllPorts) { return this; } + public Builder volumesFrom(List volumesFrom) { + this.volumesFrom.addAll(checkNotNull(volumesFrom, "volumesFrom")); + return this; + } + public HostConfig build() { - return new HostConfig(containerIDFile, binds, privileged, portBindings, links, publishAllPorts); + return new HostConfig(containerIDFile, binds, lxcConf, privileged, dns, dnsSearch, portBindings, links, + publishAllPorts, volumesFrom); } public Builder fromHostConfig(HostConfig in) { return this .containerIDFile(in.getContainerIDFile()) .binds(in.getBinds()) + .lxcConf(in.getLxcConf()) .privileged(in.isPrivileged()) + .dns(in.getDns()) + .dnsSearch(in.getDnsSearch()) .links(in.getLinks()) .portBindings(in.getPortBindings()) - .publishAllPorts(in.isPublishAllPorts()); + .publishAllPorts(in.isPublishAllPorts()) + .volumesFrom(in.getVolumesFrom()); } } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Image.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Image.java similarity index 93% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Image.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Image.java index aa811f3378..186ece32f4 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Image.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Image.java @@ -28,19 +28,19 @@ public class Image { - @SerializedName("id") + @SerializedName("Id") private final String id; - @SerializedName("parent") + @SerializedName("Parent") private final String parent; @SerializedName("Created") private final String created; - @SerializedName("container") + @SerializedName("Container") private final String container; - @SerializedName("docker_version") + @SerializedName("DockerVersion") private final String dockerVersion; - @SerializedName("architecture") + @SerializedName("Architecture") private final String architecture; - @SerializedName("os") + @SerializedName("Os") private final String os; @SerializedName("Size") private final long size; @@ -49,9 +49,9 @@ public class Image { @SerializedName("RepoTags") private final List repoTags; - @ConstructorProperties({ "id", "parent", "created", "container", "docker_version", "architecture", "os", "Size", - "VirtualSize", "RepoTags" }) - public Image(String id, @Nullable String parent, @Nullable String created, @Nullable String container, + @ConstructorProperties({ "Id", "Parent", "Created", "Container", "DockerVersion", "Architecture", "Os", "Size", + "VirtualSize", "RepoTags", "Architecture" }) + protected Image(String id, @Nullable String parent, @Nullable String created, @Nullable String container, @Nullable String dockerVersion, @Nullable String architecture, @Nullable String os, long size, @Nullable long virtualSize, @Nullable List repoTags) { this.id = checkNotNull(id, "id"); @@ -160,7 +160,6 @@ public static final class Builder { private String parent; private String created; private String container; - private Config containerConfig; private String dockerVersion; private String architecture; private String os; diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java similarity index 89% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java index d700c77566..23f3fbede1 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/NetworkSettings.java @@ -16,18 +16,17 @@ */ package org.jclouds.docker.domain; -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableMap; +import com.google.gson.annotations.SerializedName; +import org.jclouds.javax.annotation.Nullable; + import java.beans.ConstructorProperties; import java.util.List; import java.util.Map; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; -import com.google.gson.annotations.SerializedName; +import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Andrea Turli - */ public class NetworkSettings { @SerializedName("IPAddress") @@ -43,13 +42,13 @@ public class NetworkSettings { @SerializedName("Ports") private final Map>> ports; - @ConstructorProperties({ "IpAddress", "IpPrefixLen", "Gateway", "Bridge", "Ports" }) - public NetworkSettings(String ipAddress, int ipPrefixLen, String gateway, String bridge, String portMapping, - Map>> ports) { - this.ipAddress = ipAddress; - this.ipPrefixLen = ipPrefixLen; - this.gateway = gateway; - this.bridge = bridge; + @ConstructorProperties({ "IPAddress", "IPPrefixLen", "Gateway", "Bridge", "PortMapping", "Ports" }) + protected NetworkSettings(String ipAddress, int ipPrefixLen, String gateway, String bridge, + @Nullable String portMapping, @Nullable Map>> ports) { + this.ipAddress = checkNotNull(ipAddress, "ipAddress"); + this.ipPrefixLen = checkNotNull(ipPrefixLen, "ipPrefixLen"); + this.gateway = checkNotNull(gateway, "gateway"); + this.bridge = checkNotNull(bridge, "bridge"); this.portMapping = portMapping; this.ports = ports != null ? ImmutableMap.copyOf(ports) : ImmutableMap.>> of(); } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Port.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Port.java similarity index 95% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Port.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Port.java index e5aad02d18..b49dfa6945 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Port.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Port.java @@ -23,9 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Andrea Turli - */ public class Port { @SerializedName("PrivatePort") @@ -37,8 +34,8 @@ public class Port { @SerializedName("IP") private final String ip; - @ConstructorProperties({ "PrivatePort", "PublicPort", "Type", "Ip" }) - public Port(int privatePort, int publicPort, String type, String ip) { + @ConstructorProperties({ "PrivatePort", "PublicPort", "Type", "IP" }) + protected Port(int privatePort, int publicPort, String type, String ip) { this.privatePort = checkNotNull(privatePort, "privatePort"); this.publicPort = checkNotNull(publicPort, "publicPort"); this.type = checkNotNull(type, "type"); diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/State.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/State.java similarity index 97% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/State.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/State.java index 7207a8698b..ac1ba85e01 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/State.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/State.java @@ -22,9 +22,6 @@ import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; -/** - * @author Andrea Turli - */ public class State { @SerializedName("Pid") private final int pid; @@ -40,7 +37,7 @@ public class State { private final boolean ghost; @ConstructorProperties({ "Pid", "Running", "ExitCode", "StartedAt", "FinishedAt", "Ghost" }) - public State(int pid, boolean running, int exitCode, String startedAt, String finishedAt, boolean ghost) { + protected State(int pid, boolean running, int exitCode, String startedAt, String finishedAt, boolean ghost) { this.pid = checkNotNull(pid, "pid"); this.running = checkNotNull(running, "running"); this.exitCode = checkNotNull(exitCode, "exitCode"); diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Version.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Version.java similarity index 96% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Version.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Version.java index 1b6984e8d8..445a225c3d 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/domain/Version.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/domain/Version.java @@ -22,9 +22,6 @@ import com.google.common.base.Objects; import com.google.gson.annotations.SerializedName; -/** - * @author Andrea Turli - */ public class Version { @SerializedName("Arch") private final String arch; @@ -40,7 +37,7 @@ public class Version { private final String version; @ConstructorProperties({ "Arch", "GitCommit", "GoVersion", "KernelVersion", "Os", "Version" }) - public Version(String arch, String gitCommit, String goVersion, String kernelVersion, String os, String version) { + protected Version(String arch, String gitCommit, String goVersion, String kernelVersion, String os, String version) { this.arch = checkNotNull(arch, "arch"); this.gitCommit = checkNotNull(gitCommit, "gitCommit"); this.goVersion = checkNotNull(goVersion, "goVersion"); diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/RemoteApi.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/RemoteApi.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/RemoteApi.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/RemoteApi.java index bc4abff234..96b0228f94 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/compute/features/RemoteApi.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/RemoteApi.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.docker.compute.features; +package org.jclouds.docker.features; import java.io.Closeable; import java.io.File; @@ -51,9 +51,6 @@ import org.jclouds.rest.annotations.Headers; import org.jclouds.rest.binders.BindToJsonPayload; -/** - * @author Andrea Turli - */ @Consumes(MediaType.APPLICATION_JSON) public interface RemoteApi extends Closeable { @@ -203,7 +200,7 @@ public interface RemoteApi extends Closeable { /** * Inspect an image * - * @param imageId The id of the image to inspect. + * @param imageName The id of the image to inspect. * @return low-level information on the image name */ @Named("image:inspect") diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/internal/Archives.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/internal/Archives.java new file mode 100644 index 0000000000..43b69c3e30 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/features/internal/Archives.java @@ -0,0 +1,60 @@ +/* + * 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.jclouds.docker.features.internal; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.collect.Iterables.getLast; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; + +import com.google.common.base.Splitter; +import com.google.common.io.Files; + +public class Archives { + + public static File tar(File baseDir, String archivePath) throws IOException { + return tar(baseDir, new File(archivePath)); + } + + public static File tar(File baseDir, File tarFile) throws IOException { + // Check that the directory is a directory, and get its contents + checkArgument(baseDir.isDirectory(), "%s is not a directory", baseDir); + File[] files = baseDir.listFiles(); + String token = getLast(Splitter.on("/").split(baseDir.getAbsolutePath())); + TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(tarFile)); + tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU); + try { + for (File file : files) { + TarArchiveEntry tarEntry = new TarArchiveEntry(file); + tarEntry.setName("/" + getLast(Splitter.on(token).split(file.toString()))); + tos.putArchiveEntry(tarEntry); + if (!file.isDirectory()) { + Files.asByteSource(file).copyTo(tos); + } + tos.closeArchiveEntry(); + } + } finally { + tos.close(); + } + return tarFile; + } + +} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java similarity index 93% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java index 964a958daa..72d3069fba 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/handlers/DockerErrorHandler.java @@ -16,8 +16,10 @@ */ package org.jclouds.docker.handlers; -import com.google.common.base.Throwables; -import com.google.common.io.Closeables; +import java.io.IOException; + +import javax.annotation.Resource; + import org.jclouds.http.HttpCommand; import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpResponse; @@ -27,8 +29,8 @@ import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.util.Strings2; -import javax.annotation.Resource; -import java.io.IOException; +import com.google.common.base.Throwables; +import com.google.common.io.Closeables; /** * This will parse and set an appropriate exception on the command object. @@ -36,8 +38,6 @@ *

* Errors are returned with an appropriate HTTP status code, an X-Elastic- Error header specifying * the error type, and a text description in the HTTP body. - * - * @author Andrea Turli */ public class DockerErrorHandler implements HttpErrorHandler { @Resource @@ -94,15 +94,9 @@ public String parseMessage(HttpResponse response) { if (response.getPayload() == null) return null; try { - return Strings2.toString(response.getPayload()); + return Strings2.toStringAndClose(response.getPayload().openStream()); } catch (IOException e) { throw Throwables.propagate(e); - } finally { - try { - response.getPayload().getInput().close(); - } catch (IOException e) { - throw Throwables.propagate(e); - } } } } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java index 8a8bc05b97..4d7196ceee 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/BuildOptions.java @@ -20,8 +20,6 @@ /** * Options to customize image builder. - * - * @author Andrea Turli */ public class BuildOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java similarity index 99% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java index 7f058d4b31..5653fba57e 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CommitOptions.java @@ -20,8 +20,6 @@ /** * Options to customize image commit. - * - * @author Andrea Turli */ public class CommitOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java similarity index 77% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java index 5ff65af8d7..51dc399d4d 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/CreateImageOptions.java @@ -20,43 +20,9 @@ /** * Options to customize container creation. - * - * @author Andrea Turli */ public class CreateImageOptions extends BaseHttpRequestOptions { - /* - private final String fromImage; - private final String fromSrc; - private final String repo; - private final String tag; - private final String registry; - - public CreateImageOptions(String fromImage, String fromSrc, String repo, String tag, String registry) { - this.fromImage = fromImage; - this.fromSrc = fromSrc; - this.repo = repo; - this.tag = tag; - this.registry = registry; - - if (fromImage != null) { - queryParameters.put("fromImage", fromImage); - } - if (fromSrc != null) { - queryParameters.put("fromSrc", fromSrc); - } - if (repo != null) { - queryParameters.put("repo", repo); - } - if (tag != null) { - queryParameters.put("tag", tag); - } - if (registry != null) { - queryParameters.put("registry", registry); - } - } - */ - public static final CreateImageOptions NONE = new CreateImageOptions(); public CreateImageOptions fromImage(String fromImage) { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java index 767dc7d89c..9438616b56 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/DeleteImageOptions.java @@ -20,8 +20,6 @@ /** * Options to customize image deletion. - * - * @author Andrea Turli */ public class DeleteImageOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java index 6e9f129900..af16664010 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListContainerOptions.java @@ -19,7 +19,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions; /** - * @author Andrea Turli + * Options to customize container's listing. */ public class ListContainerOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java similarity index 97% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java index 510fae282a..fab75d4233 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/ListImageOptions.java @@ -19,7 +19,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions; /** - * @author Andrea Turli + * Options to customize image's listing. */ public class ListImageOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java index 636b352fd5..5c3abba3a3 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/java/org/jclouds/docker/options/RemoveContainerOptions.java @@ -20,8 +20,6 @@ /** * Options to customize container removal. - * - * @author Andrea Turli */ public class RemoveContainerOptions extends BaseHttpRequestOptions { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata similarity index 100% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java similarity index 98% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java index a8e325b20f..41d00679ef 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/DockerApiMetadataTest.java @@ -16,19 +16,17 @@ */ package org.jclouds.docker; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - /** * Unit tests for the {@link DockerApiMetadata} class. - * - * @author Andrea Turli */ @Test(groups = "unit", testName = "AbiquoApiMetadataTest") public class DockerApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/binders/BindInputStreamToRequestTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/binders/BindInputStreamToRequestTest.java new file mode 100644 index 0000000000..a21999c6f3 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/binders/BindInputStreamToRequestTest.java @@ -0,0 +1,66 @@ +/* + * 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.jclouds.docker.binders; + +import com.google.common.io.CharStreams; +import org.jclouds.http.HttpRequest; +import org.testng.annotations.Test; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; + +import static org.testng.Assert.assertEquals; +import static org.testng.AssertJUnit.assertTrue; + +@Test(groups = "unit", testName = "BindInputStreamToRequestTest") +public class BindInputStreamToRequestTest { + + @Test + public void testBindInputStreamToRequest() throws IOException { + BindInputStreamToRequest binder = new BindInputStreamToRequest(); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build(); + request = binder.bindToRequest(request, File.createTempFile("dockerfile", "")); + String rawContent = CharStreams.toString(new InputStreamReader((FileInputStream) request.getPayload().getRawContent(), "UTF-8")); + assertTrue(rawContent.startsWith("Dockerfile")); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/tar"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testBindInputStreamToRequestWithObjectAsInput() throws IOException { + BindInputStreamToRequest binder = new BindInputStreamToRequest(); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build(); + request = binder.bindToRequest(request, new Object()); + String rawContent = CharStreams.toString(new InputStreamReader((FileInputStream) request.getPayload().getRawContent(), "UTF-8")); + assertTrue(rawContent.startsWith("Dockerfile")); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/tar"); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testBindInputStreamToRequestWithNullInput() throws IOException { + BindInputStreamToRequest binder = new BindInputStreamToRequest(); + + HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build(); + request = binder.bindToRequest(request, null); + String rawContent = CharStreams.toString(new InputStreamReader((FileInputStream) request.getPayload().getRawContent(), "UTF-8")); + assertTrue(rawContent.startsWith("Dockerfile")); + assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/tar"); + } +} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java similarity index 89% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java index cfafe4120c..77115f248e 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/BaseDockerApiLiveTest.java @@ -26,14 +26,13 @@ import org.jclouds.Constants; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.docker.DockerApi; -import org.jclouds.docker.compute.features.internal.Archives; +import org.jclouds.docker.features.internal.Archives; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.Assert; import org.testng.annotations.Test; -import javax.ws.rs.core.MediaType; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -42,10 +41,7 @@ import java.net.URL; import java.util.Properties; -/** - * @author Andrea Turli - */ -@Test(groups = "live", singleThreaded = true) +@Test(groups = "live") public class BaseDockerApiLiveTest extends BaseApiLiveTest { public BaseDockerApiLiveTest() { @@ -59,10 +55,9 @@ protected Iterable setupModules() { @Override protected Properties setupProperties() { - Properties overrides = new Properties(); + Properties overrides = super.setupProperties(); overrides.setProperty(Constants.PROPERTY_MAX_RETRIES, "15"); overrides.setProperty("jclouds.ssh.retry-auth", "true"); - endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint"); return overrides; } @@ -89,7 +84,7 @@ protected Payload createPayload() throws IOException { FileInputStream data = new FileInputStream(archive); Payload payload = Payloads.newInputStreamPayload(data); payload.getContentMetadata().setContentLength(data.getChannel().size()); - payload.getContentMetadata().setContentType(MediaType.TEXT_PLAIN); + payload.getContentMetadata().setContentType("application/tar"); return payload; } diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java similarity index 62% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java index 9ae95aaf01..faee98267e 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceAdapterLiveTest.java @@ -16,97 +16,54 @@ */ package org.jclouds.docker.compute; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.net.HostAndPort; -import com.google.inject.Injector; -import com.google.inject.Module; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; +import java.util.Properties; +import java.util.Random; + import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; -import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; -import org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials; -import org.jclouds.compute.strategy.PrioritizeCredentialsFromTemplate; import org.jclouds.docker.DockerApi; import org.jclouds.docker.compute.strategy.DockerComputeServiceAdapter; import org.jclouds.docker.domain.Container; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.ssh.SshClient; -import org.jclouds.ssh.SshClient.Factory; import org.jclouds.sshj.config.SshjSshClientModule; import org.testng.annotations.AfterGroups; import org.testng.annotations.Test; -import java.net.URI; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Random; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.inject.Injector; +import com.google.inject.Module; @Test(groups = "live", singleThreaded = true, testName = "DockerComputeServiceAdapterLiveTest") public class DockerComputeServiceAdapterLiveTest extends BaseDockerApiLiveTest { private DockerComputeServiceAdapter adapter; private TemplateBuilder templateBuilder; - private Factory sshFactory; private NodeAndInitialCredentials guest; - private URI endpoint; @Override protected DockerApi create(Properties props, Iterable modules) { Injector injector = newBuilder().modules(modules).overrides(props).buildInjector(); adapter = injector.getInstance(DockerComputeServiceAdapter.class); templateBuilder = injector.getInstance(TemplateBuilder.class); - sshFactory = injector.getInstance(SshClient.Factory.class); - endpoint = URI.create(props.getProperty("docker.endpoint")); return injector.getInstance(DockerApi.class); } - @Test - public void testListImages() { - assertFalse(Iterables.isEmpty(adapter.listImages()), "images must not be empty"); - } - - private static final PrioritizeCredentialsFromTemplate prioritizeCredentialsFromTemplate = new PrioritizeCredentialsFromTemplate( - new DefaultCredentialsFromImageOrOverridingCredentials()); - - @Test public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "container-" + new Random().nextInt(); - Template template = templateBuilder.smallest().osFamily(OsFamily.UBUNTU).os64Bit(true) - .osDescriptionMatches("jclouds/ubuntu:latest").build(); + Template template = templateBuilder.smallest() + .osDescriptionMatches("jclouds/default:latest").build(); guest = adapter.createNodeWithGroupEncodedIntoName(group, name, template); assertEquals(guest.getNodeId(), guest.getNode().getId() + ""); - doConnectViaSsh(guest.getNode(), prioritizeCredentialsFromTemplate.apply(template, guest.getCredentials())); - } - - protected void doConnectViaSsh(Container guest, LoginCredentials creds) { - // todo this is an hack as I'm using host-only IF - Map>> portBindings = guest.getHostConfig().getPortBindings(); - int loginPort = Integer.parseInt(portBindings.get("22/tcp").get(0).get("HostPort")); - SshClient ssh = sshFactory.create(HostAndPort.fromParts(endpoint.getHost(), loginPort), creds); - try { - ssh.connect(); - ExecResponse hello = ssh.exec("echo hello"); - assertEquals(hello.getOutput().trim(), "hello"); - System.err.println(ssh.exec("mount").getOutput()); - System.err.println(ssh.exec("uname -a").getOutput()); - } finally { - if (ssh != null) - ssh.disconnect(); - } } - @Test public void testListHardwareProfiles() { Iterable profiles = adapter.listHardwareProfiles(); assertFalse(Iterables.isEmpty(profiles)); diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceLiveTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceLiveTest.java new file mode 100644 index 0000000000..cc460c3c4b --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/DockerComputeServiceLiveTest.java @@ -0,0 +1,142 @@ +/* + * 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.jclouds.docker.compute; + +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.Template; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.compute.internal.BaseComputeServiceLiveTest; +import org.jclouds.sshj.config.SshjSshClientModule; +import org.testng.Assert; +import org.testng.annotations.Test; + +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.inject.Module; + +/** + * Live tests for the {@link org.jclouds.compute.ComputeService} integration. + */ +@Test(groups = "live", singleThreaded = true, testName = "DockerComputeServiceLiveTest") +public class DockerComputeServiceLiveTest extends BaseComputeServiceLiveTest { + + private static final String DEFAULT_JCLOUDS_IMAGE = "jclouds/default"; + private Image defaultImage; + + public DockerComputeServiceLiveTest() { + provider = "docker"; + } + + @Override + protected Module getSshModule() { + return new SshjSshClientModule(); + } + + @Override + protected void initializeContext() { + super.initializeContext(); + Optional optionalImage = Iterables.tryFind(client.listImages(), new Predicate() { + @Override + public boolean apply(Image image) { + return image.getName().equals(DEFAULT_JCLOUDS_IMAGE); + } + }); + if (optionalImage.isPresent()) { + defaultImage = optionalImage.get(); + } else { + Assert.fail("Please create an ssh-able image called " + DEFAULT_JCLOUDS_IMAGE); + } + } + + @Override + protected Template buildTemplate(TemplateBuilder templateBuilder) { + return templateBuilder.imageId(defaultImage.getId()).build(); + } + + @Override + public void testOptionToNotBlock() throws Exception { + // Docker ComputeService implementation has to block until the node + // is provisioned, to be able to return it. + } + + @Override + protected void checkTagsInNodeEquals(NodeMetadata node, ImmutableSet tags) { + // Docker does not support tags + } + + @Override + protected void checkUserMetadataContains(NodeMetadata node, ImmutableMap userMetadata) { + // Docker does not support user metadata + } + + @Override + public void testCreateAndRunAService() throws Exception { + // Docker does not support blockOnPort + } + + @Override + @Test(enabled = true, dependsOnMethods = { "testCompareSizes" }) + public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception { + super.testAScriptExecutionAfterBootWithBasicTemplate(); + } + + @Override + @Test(enabled = true, dependsOnMethods = "testReboot", expectedExceptions = UnsupportedOperationException.class) + public void testSuspendResume() throws Exception { + super.testSuspendResume(); + } + + @Override + @Test(enabled = true, dependsOnMethods = "testSuspendResume") + public void testGetNodesWithDetails() throws Exception { + super.testGetNodesWithDetails(); + } + + @Override + @Test(enabled = true, dependsOnMethods = "testSuspendResume") + public void testListNodes() throws Exception { + super.testListNodes(); + } + + @Override + @Test(enabled = true, dependsOnMethods = "testSuspendResume") + public void testListNodesByIds() throws Exception { + super.testListNodesByIds(); + } + + @Override + @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "testListNodesByIds" }) + public void testDestroyNodes() { + super.testDestroyNodes(); + } + + @Test(enabled = true, expectedExceptions = NullPointerException.class) + public void testCorrectExceptionRunningNodesNotFound() throws Exception { + super.testCorrectExceptionRunningNodesNotFound(); + } + + @Test(enabled = true, expectedExceptions = NullPointerException.class) + public void testCorrectAuthException() throws Exception { + // Docker does not support authentication yet + super.testCorrectAuthException(); + } + +} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java similarity index 74% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java index 3394cde5ad..f7a3b57637 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ContainerToNodeMetadataTest.java @@ -23,9 +23,14 @@ import static org.testng.Assert.assertEquals; import java.util.List; import java.util.Map; +import java.util.Set; import org.easymock.EasyMock; +import org.jclouds.compute.domain.Image; +import org.jclouds.compute.domain.ImageBuilder; import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.compute.domain.OperatingSystem; +import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.docker.domain.Config; import org.jclouds.docker.domain.Container; @@ -33,19 +38,22 @@ import org.jclouds.docker.domain.NetworkSettings; import org.jclouds.docker.domain.Port; import org.jclouds.docker.domain.State; +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationBuilder; +import org.jclouds.domain.LocationScope; import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import com.google.common.base.Function; +import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.inject.Guice; /** * Unit tests for the {@link org.jclouds.docker.compute.functions.ContainerToNodeMetadata} class. - * - * @author Andrea Turli */ @Test(groups = "unit", testName = "ContainerToNodeMetadataTest") public class ContainerToNodeMetadataTest { @@ -55,7 +63,7 @@ public class ContainerToNodeMetadataTest { @BeforeMethod public void setup() { - Config config = Config.builder() + Config containerConfig = Config.builder() .hostname("6d35806c1bd2") .domainName("") .user("") @@ -76,7 +84,6 @@ public void setup() { .workingDir("") .entrypoint(null) .networkDisabled(false) - .onBuild(null) .build(); State state = State.builder() .pid(3626) @@ -92,7 +99,7 @@ public void setup() { .created("2014-03-22T07:16:45.784120972Z") .path("/usr/sbin/sshd") .args(new String[] {"-D"}) - .config(config) + .containerConfig(containerConfig) .state(state) .image("af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6") .networkSettings(NetworkSettings.builder() @@ -108,7 +115,7 @@ public void setup() { .driver("aufs") .execDriver("native-0.1") .volumes(ImmutableMap.of()) - .volumesRw(ImmutableMap.of()) + .volumesRW(ImmutableMap.of()) .command("") .status("") .hostConfig(HostConfig.builder().publishAllPorts(true).build()) @@ -120,7 +127,42 @@ public void setup() { GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class); - function = new ContainerToNodeMetadata(providerMetadata, toPortableStatus(), namingConvention); + Supplier> images = new Supplier>() { + @Override + public Map get() { + OperatingSystem os = OperatingSystem.builder() + .description("Ubuntu 12.04 64bit") + .family(OsFamily.UBUNTU) + .version("12.04") + .is64Bit(true) + .build(); + + return ImmutableMap.of("af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6", + new ImageBuilder() + .ids("af0f59f1c19eef9471c3b8c8d587c39b8f130560b54f3766931b37d76d5de4b6") + .name("ubuntu") + .description("Ubuntu 12.04 64bit") + .operatingSystem(os) + .status(Image.Status.AVAILABLE) + .build()); + } + }; + + Supplier> locations = new Supplier>() { + @Override + public Set get() { + + return ImmutableSet.of( + new LocationBuilder() + .id("docker") + .description("http://localhost:2375") + .scope(LocationScope.PROVIDER) + .build() + ); + } + }; + + function = new ContainerToNodeMetadata(providerMetadata, toPortableStatus(), namingConvention, images, locations); } private Function toPortableStatus() { @@ -145,16 +187,15 @@ public void testVirtualMachineToNodeMetadata() { assertEquals(node.getPublicAddresses().size(), 1); } - @SuppressWarnings("unchecked") private Container mockContainer() { Container mockContainer = EasyMock.createMock(Container.class); expect(mockContainer.getId()).andReturn(container.getId()); expect(mockContainer.getName()).andReturn(container.getName()); - expect(mockContainer.getConfig()).andReturn(container.getConfig()).anyTimes(); + expect(mockContainer.getContainerConfig()).andReturn(container.getContainerConfig()).anyTimes(); expect(mockContainer.getNetworkSettings()).andReturn(container.getNetworkSettings()).anyTimes(); expect(mockContainer.getState()).andReturn(container.getState()); - expect(mockContainer.getImage()).andReturn(container.getImage()); + expect(mockContainer.getImage()).andReturn(container.getImage()).anyTimes(); replay(mockContainer); return mockContainer; diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java similarity index 97% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java index c46bdb1c35..e9754d0101 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/ImageToImageTest.java @@ -16,21 +16,20 @@ */ package org.jclouds.docker.compute.functions; -import com.google.common.collect.ImmutableList; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.testng.Assert.assertEquals; + import org.easymock.EasyMock; import org.jclouds.compute.domain.Image; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; +import com.google.common.collect.ImmutableList; /** * Unit tests for the {@link org.jclouds.docker.compute.functions.ImageToImage} class. - * - * @author Andrea Turli */ @Test(groups = "unit", testName = "ImageToImageTest") public class ImageToImageTest { @@ -61,7 +60,6 @@ public void testImageToImage() { assertEquals(mockImage.getId(), image.getId().toString()); } - @SuppressWarnings("unchecked") private org.jclouds.docker.domain.Image mockImage() { org.jclouds.docker.domain.Image mockImage = EasyMock.createMock(org.jclouds.docker.domain.Image.class); diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java similarity index 94% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java index c1a8002490..899a66c9d3 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/functions/StateToStatusTest.java @@ -16,21 +16,19 @@ */ package org.jclouds.docker.compute.functions; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.testng.Assert.assertEquals; + import org.easymock.EasyMock; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.docker.domain.State; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - /** * Unit tests for the {@link StateToStatus} class. - * - * @author Andrea Turli */ @Test(groups = "unit", testName = "StateToStatusTest") public class StateToStatusTest { @@ -52,7 +50,7 @@ public void testStateRunningToStatusRunning() { assertEquals(status, NodeMetadata.Status.RUNNING); } - public void testStateNotRunningToStatusSuspended() { + public void testStateNotRunningToStatusTerminated() { State mockState = mockStateNotRunning(); NodeMetadata.Status status = function.apply(mockState); @@ -60,7 +58,7 @@ public void testStateNotRunningToStatusSuspended() { verify(mockState); assertEquals(mockState.isRunning(), false); - assertEquals(status, NodeMetadata.Status.SUSPENDED); + assertEquals(status, NodeMetadata.Status.TERMINATED); } private State mockStateRunning() { diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/options/DockerTemplateOptionsTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/options/DockerTemplateOptionsTest.java new file mode 100644 index 0000000000..3a982288b8 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/compute/options/DockerTemplateOptionsTest.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.jclouds.docker.compute.options; + +import static org.testng.Assert.assertEquals; + +import org.jclouds.compute.options.TemplateOptions; +import org.testng.annotations.Test; + +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableMap; + +/** + * Unit tests for the {@link DockerTemplateOptions} class. + */ +@Test(groups = "unit", testName = "DockerTemplateOptionsTest") +public class DockerTemplateOptionsTest { + + @Test + public void testHostname() { + TemplateOptions options = new DockerTemplateOptions().hostname("hostname"); + assertEquals(options.as(DockerTemplateOptions.class).getHostname(), Optional.of("hostname")); + } + + @Test + public void testMemory() { + TemplateOptions options = new DockerTemplateOptions().memory(1024); + assertEquals(options.as(DockerTemplateOptions.class).getMemory(), Optional.of(1024)); + } + + @Test + public void testCpuShares() { + TemplateOptions options = new DockerTemplateOptions().cpuShares(2); + assertEquals(options.as(DockerTemplateOptions.class).getCpuShares(), Optional.of(2)); + } + + @Test + public void testVolumes() { + TemplateOptions options = new DockerTemplateOptions().volumes(ImmutableMap.of("/tmp", "/tmp")); + assertEquals(options.as(DockerTemplateOptions.class).getVolumes(), Optional.of(ImmutableMap.of("/tmp", "/tmp"))); + } + + @Test + public void testDns() { + TemplateOptions options = new DockerTemplateOptions().dns("8.8.8.8"); + assertEquals(options.as(DockerTemplateOptions.class).getDns(), Optional.of("8.8.8.8")); + } +} diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.java new file mode 100644 index 0000000000..4f5ba7586e --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/config/DockerParserModuleTest.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.jclouds.docker.config; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.jclouds.docker.domain.Container; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import static org.jclouds.docker.config.DockerParserModule.ContainerTypeAdapter; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +/** + * Unit tests for the {@link org.jclouds.docker.config.DockerParserModule} class. + */ +@Test(groups = "unit", testName = "DockerParserModuleTest") +public class DockerParserModuleTest { + + private Gson gson; + + @BeforeMethod + public void setup() { + gson = new GsonBuilder() + .registerTypeAdapter(Container.class, new ContainerTypeAdapter()) + .create(); + } + + @Test + public void testContainerWithVolumesNull() { + Container container = gson.fromJson( + "{ \"Volumes\": null }", Container.class); + assertNotNull(container); + assertEquals(container.getVolumes(), null); + } + +} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiLiveTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java similarity index 77% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiLiveTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java index 2b48f64575..34fedddd65 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiLiveTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiLiveTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.docker.compute.features; +package org.jclouds.docker.features; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; @@ -28,8 +28,6 @@ import org.jclouds.docker.options.CreateImageOptions; import org.jclouds.docker.options.DeleteImageOptions; import org.jclouds.rest.ResourceNotFoundException; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import java.io.File; @@ -37,29 +35,22 @@ import java.io.InputStream; import java.net.URISyntaxException; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; -/** - * @author Andrea Turli - */ +@Test(groups = "live", testName = "RemoteApiLiveTest", singleThreaded = true) public class RemoteApiLiveTest extends BaseDockerApiLiveTest { private static final String BUSYBOX_IMAGE = "busybox"; private Container container = null; private Image image = null; - @BeforeClass - private void init() { - setupProperties(); - CreateImageOptions options = CreateImageOptions.Builder.fromImage(BUSYBOX_IMAGE); - InputStream createImageStream = api().createImage(options); - consumeStream(createImageStream, false); - } - @Test public void testVersion() { - Assert.assertEquals(api().getVersion().getVersion(), "0.9.0"); + assertEquals(api().getVersion().getVersion(), "1.0.0"); } @Test(dependsOnMethods = "testVersion") @@ -73,39 +64,35 @@ public void testCreateImage() throws IOException, InterruptedException { @Test(dependsOnMethods = "testCreateImage") public void testListImages() { - Assert.assertNotNull(api().listImages()); + assertNotNull(api().listImages()); } @Test(dependsOnMethods = "testListImages") public void testCreateContainer() throws IOException, InterruptedException { - if(image == null) Assert.fail(); - Config config = Config.builder().imageId(image.getId()) + Config containerConfig = Config.builder().imageId(image.getId()) .cmd(ImmutableList.of("/bin/sh", "-c", "while true; do echo hello world; sleep 1; done")) .build(); - container = api().createContainer("testCreateContainer", config); + container = api().createContainer("testCreateContainer", containerConfig); assertNotNull(container); assertNotNull(container.getId()); } @Test(dependsOnMethods = "testCreateContainer") public void testStartContainer() throws IOException, InterruptedException { - if(container == null) Assert.fail(); api().startContainer(container.getId()); - Assert.assertTrue(api().inspectContainer(container.getId()).getState().isRunning()); + assertTrue(api().inspectContainer(container.getId()).getState().isRunning()); } @Test(dependsOnMethods = "testStartContainer") public void testStopContainer() { - if(container == null) Assert.fail(); api().stopContainer(container.getId()); - Assert.assertFalse(api().inspectContainer(container.getId()).getState().isRunning()); + assertFalse(api().inspectContainer(container.getId()).getState().isRunning()); } @Test(dependsOnMethods = "testStopContainer", expectedExceptions = NullPointerException.class) public void testRemoveContainer() { - if(container == null) Assert.fail(); api().removeContainer(container.getId()); - Assert.assertFalse(api().inspectContainer(container.getId()).getState().isRunning()); + assertFalse(api().inspectContainer(container.getId()).getState().isRunning()); } @Test(dependsOnMethods = "testRemoveContainer", expectedExceptions = ResourceNotFoundException.class) @@ -115,18 +102,16 @@ public void testDeleteImage() { assertNull(api().inspectImage(image.getId())); } - @Test(dependsOnMethods = "testDeleteImage") public void testBuildImage() throws IOException, InterruptedException, URISyntaxException { BuildOptions options = BuildOptions.Builder.tag("testBuildImage").verbose(false).nocache(false); - InputStream buildImageStream = api().build(new File(Resources.getResource("centos/Dockerfile").toURI()), options); + InputStream buildImageStream = api().build(new File(Resources.getResource("Dockerfile").toURI()), options); String buildStream = consumeStream(buildImageStream, false); Iterable splitted = Splitter.on("\n").split(buildStream.replace("\r", "").trim()); String lastStreamedLine = Iterables.getLast(splitted).trim(); String rawImageId = Iterables.getLast(Splitter.on("Successfully built ").split(lastStreamedLine)); String imageId = rawImageId.substring(0, 11); Image image = api().inspectImage(imageId); - api().removeContainer(image.getContainer()); - api().deleteImage(imageId, DeleteImageOptions.Builder.force(true)); + api().deleteImage(image.getId(), DeleteImageOptions.Builder.force(true)); } private RemoteApi api() { diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiMockTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java similarity index 81% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiMockTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java index 8fb0ffeb4a..760f7234b3 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/compute/features/RemoteApiMockTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/RemoteApiMockTest.java @@ -14,12 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.jclouds.docker.compute.features; +package org.jclouds.docker.features; -import com.google.common.base.Charsets; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; -import com.google.common.io.Files; import com.squareup.okhttp.mockwebserver.MockResponse; import com.squareup.okhttp.mockwebserver.MockWebServer; import org.jclouds.docker.DockerApi; @@ -29,23 +27,22 @@ import org.jclouds.docker.options.BuildOptions; import org.jclouds.docker.options.CreateImageOptions; import org.jclouds.docker.options.ListContainerOptions; +import org.jclouds.io.Payload; +import org.jclouds.io.Payloads; import org.jclouds.rest.ResourceNotFoundException; -import org.testng.Assert; import org.testng.annotations.Test; import java.io.File; -import java.io.IOException; +import java.io.FileInputStream; import java.util.Set; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.AssertJUnit.fail; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; /** * Mock tests for the {@link org.jclouds.docker.DockerApi} class. - * - * @author Andrea Turli */ @Test(groups = "unit", testName = "RemoteApiMockTest") public class RemoteApiMockTest extends BaseDockerMockTest { @@ -67,17 +64,33 @@ public void testListContainers() throws Exception { } } - public void testListAllContainers() throws Exception { + public void testListNonexistentContainers() throws Exception { MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); + server.enqueue(new MockResponse().setResponseCode(404)); DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); + try { + Set containers = remoteApi.listContainers(); + assertRequestHasCommonFields(server.takeRequest(), "/containers/json"); + assertTrue(containers.isEmpty()); + } finally { + api.close(); + server.shutdown(); + } + } + + + @Test(timeOut = 10000l) + public void testListAllContainers() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setBody(payloadFromResource("/containers.json"))); + DockerApi api = api(server.getUrl("/")); + RemoteApi remoteApi = api.getRemoteApi(); try { Set containers = remoteApi.listContainers(ListContainerOptions.Builder.all(true)); - assertRequestHasParameters(server.takeRequest(), "/containers/json", ImmutableMultimap.of("all", - "true")); + assertRequestHasParameters(server.takeRequest(), "/containers/json", ImmutableMultimap.of("all", "true")); assertEquals(containers.size(), 1); } finally { api.close(); @@ -90,14 +103,15 @@ public void testGetContainer() throws Exception { server.enqueue(new MockResponse().setBody(payloadFromResource("/container.json"))); DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); - String containerId = "6d35806c1bd2b25cd92bba2d2c2c5169dc2156f53ab45c2b62d76e2d2fee14a9"; + String containerId = "b03d4cd15b76f8876110615cdeed15eadf77c9beb408d62f1687dcc69192cd6d"; try { Container container = remoteApi.inspectContainer(containerId); assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); assertNotNull(container); - assertNotNull(container.getConfig()); + assertNotNull(container.getId(), containerId); + assertNotNull(container.getContainerConfig()); assertNotNull(container.getHostConfig()); - assertEquals(container.getName(), "/hopeful_mclean"); + assertEquals(container.getName(), "/tender_lumiere"); assertEquals(container.getState().isRunning(), true); } finally { api.close(); @@ -114,7 +128,6 @@ public void testGetNonExistingContainer() throws Exception { try { Container container = remoteApi.inspectContainer(containerId); assertRequestHasCommonFields(server.takeRequest(), "/containers/" + containerId + "/json"); - assertNull(container); } finally { api.close(); server.shutdown(); @@ -127,7 +140,7 @@ public void testCreateContainer() throws Exception { DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); - Config config = Config.builder().cmd(ImmutableList.of("date")) + Config containerConfig = Config.builder().cmd(ImmutableList.of("date")) .attachStdin(false) .attachStderr(true) .attachStdout(true) @@ -135,7 +148,8 @@ public void testCreateContainer() throws Exception { .imageId("base") .build(); try { - Container container = remoteApi.createContainer("test", config); + Container container = remoteApi.createContainer("test", containerConfig); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/create?name=test"); assertNotNull(container); assertEquals(container.getId(), "c6c74153ae4b1d1633d68890a68d89c40aa5e284a1ea016cbc6ef0e634ee37b2"); } finally { @@ -154,7 +168,7 @@ public void testRemoveContainer() throws Exception { try { remoteApi.removeContainer(containerId); - assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/containers/"+containerId); + assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/containers/" + containerId); } finally { api.close(); server.shutdown(); @@ -169,9 +183,9 @@ public void testRemoveNonExistingContainer() throws Exception { String containerId = "nonExisting"; try { remoteApi.removeContainer(containerId); + fail("Remove container must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception - assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/containers/"+containerId); } finally { api.close(); server.shutdown(); @@ -194,16 +208,16 @@ public void testStartContainer() throws Exception { public void testStartNonExistingContainer() throws Exception { MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); + server.enqueue(new MockResponse().setResponseCode(404)); DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); try { try { remoteApi.startContainer("1"); + fail("Start container must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception } - assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/start"); } finally { api.close(); server.shutdown(); @@ -226,14 +240,14 @@ public void testStopContainer() throws Exception { public void testStopNonExistingContainer() throws Exception { MockWebServer server = mockWebServer(); - server.enqueue(new MockResponse().setResponseCode(204)); + server.enqueue(new MockResponse().setResponseCode(404)); DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); try { remoteApi.stopContainer("1"); + fail("Stop container must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception - assertRequestHasCommonFields(server.takeRequest(), "POST", "/containers/1/stop"); } finally { api.close(); server.shutdown(); @@ -262,12 +276,9 @@ public void testCreateImageFailure() throws Exception { RemoteApi remoteApi = api.getRemoteApi(); try { remoteApi.createImage(CreateImageOptions.Builder.fromImage("base")); - assertRequestHasParameters(server.takeRequest(), "POST", "/images/create", ImmutableMultimap.of("fromImage", - "base")); + fail("Create image must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception - assertRequestHasParameters(server.takeRequest(), "POST", "/images/create", ImmutableMultimap.of("fromImage", - "base")); } finally { api.close(); server.shutdown(); @@ -295,9 +306,9 @@ public void testDeleteNotExistingImage() throws Exception { RemoteApi remoteApi = api.getRemoteApi(); try { remoteApi.deleteImage("1"); + fail("Delete image must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception - assertRequestHasCommonFields(server.takeRequest(), "DELETE", "/images/1"); } finally { api.close(); server.shutdown(); @@ -309,13 +320,32 @@ public void testBuildContainer() throws Exception { server.enqueue(new MockResponse().setResponseCode(200)); DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); - String content = new String(payloadFromResource("/Dockerfile")); - File dockerFile = createDockerFile(content); + File dockerFile = File.createTempFile("docker", "tmp"); try { remoteApi.build(dockerFile, BuildOptions.NONE); assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); } finally { - dockerFile.deleteOnExit(); + dockerFile.delete(); + api.close(); + server.shutdown(); + } + } + + public void testBuildContainerUsingPayload() throws Exception { + MockWebServer server = mockWebServer(); + server.enqueue(new MockResponse().setResponseCode(200)); + DockerApi api = api(server.getUrl("/")); + RemoteApi remoteApi = api.getRemoteApi(); + + File file = File.createTempFile("docker", "tmp"); + FileInputStream data = new FileInputStream(file); + Payload payload = Payloads.newInputStreamPayload(data); + payload.getContentMetadata().setContentLength(file.length()); + + try { + remoteApi.build(payload, BuildOptions.NONE); + assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); + } finally { api.close(); server.shutdown(); } @@ -328,31 +358,19 @@ public void testBuildNonexistentContainer() throws Exception { DockerApi api = api(server.getUrl("/")); RemoteApi remoteApi = api.getRemoteApi(); - String content = new String(payloadFromResource("/Dockerfile")); - File dockerFile = createDockerFile(content); + File dockerFile = File.createTempFile("docker", "tmp"); try { try { remoteApi.build(dockerFile, BuildOptions.NONE); - fail("Build container should fail on 404"); + fail("Build container must fail on 404"); } catch (ResourceNotFoundException ex) { // Expected exception } - assertRequestHasCommonFields(server.takeRequest(), "POST", "/build"); } finally { - dockerFile.deleteOnExit(); + dockerFile.delete(); api.close(); server.shutdown(); } } - private File createDockerFile(String content) { - File newTempDir = Files.createTempDir(); - File dockerFile = new File(newTempDir + "/dockerFile"); - try { - Files.write(content, dockerFile, Charsets.UTF_8); - } catch(IOException e) { - Assert.fail(); - } - return dockerFile; - } } diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/internal/ArchivesTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/internal/ArchivesTest.java new file mode 100644 index 0000000000..15eb3ffe69 --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/features/internal/ArchivesTest.java @@ -0,0 +1,112 @@ +/* + * 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.jclouds.docker.features.internal; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.getOnlyElement; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.List; + +import javax.annotation.Resource; +import javax.inject.Named; + +import org.apache.commons.compress.archivers.ArchiveStreamFactory; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +import org.apache.commons.compress.archivers.tar.TarUtils; +import org.jclouds.compute.reference.ComputeServiceConstants; +import org.jclouds.logging.Logger; +import org.testng.Assert; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import com.beust.jcommander.internal.Lists; +import com.google.common.io.ByteStreams; +import com.google.common.io.Files; + +@Test(groups = "unit", testName = "ArchivesTest") +public class ArchivesTest { + + @Resource + @Named(ComputeServiceConstants.COMPUTE_LOGGER) + protected Logger logger = Logger.NULL; + + private File tmpDir; + private File outputDir; + private long checkSum; + + @BeforeClass + private void init() throws IOException { + tmpDir = Files.createTempDir(); + outputDir = Files.createTempDir(); + File sampleFile = writeSampleFile("test", "this is a test to tar a hierarchy of folders and files\n"); + checkSum = TarUtils.computeCheckSum(Files.asByteSource(sampleFile).read()); + } + + public void testTarSingleFile() throws Exception { + File archive = Archives.tar(tmpDir, new File(outputDir + File.separator + "test.tar.gz")); + List untarredFiles = unTar(archive, outputDir); + File untarredSampleFile = getOnlyElement(untarredFiles, null); + assertNotNull(untarredSampleFile); + assertTrue(checkSum == TarUtils.computeCheckSum(Files.asByteSource(untarredSampleFile).read())); + } + + private List unTar(final File inputFile, final File outputDir) throws Exception { + final List untarredFiles = Lists.newArrayList(); + final InputStream is = new FileInputStream(inputFile); + final TarArchiveInputStream tarArchiveInputStream = (TarArchiveInputStream) + new ArchiveStreamFactory().createArchiveInputStream("tar", is); + TarArchiveEntry entry; + while ((entry = (TarArchiveEntry) tarArchiveInputStream.getNextEntry()) != null) { + final File outputFile = new File(outputDir, entry.getName()); + if (entry.isDirectory()) { + if (!outputFile.exists()) { + if (!outputFile.mkdirs()) { + throw new IllegalStateException(String.format("Couldn't create directory %s.", outputFile.getAbsolutePath())); + } + } + } else { + OutputStream outputFileStream = new FileOutputStream(outputFile); + ByteStreams.copy(tarArchiveInputStream, outputFileStream); + outputFileStream.close(); + } + untarredFiles.add(outputFile); + } + tarArchiveInputStream.close(); + return untarredFiles; + } + + private File writeSampleFile(String fileName, final String contents) { + checkNotNull(fileName, "Provided file name for writing must NOT be null."); + checkNotNull(contents, "Unable to write null contents."); + File sampleFile = new File(tmpDir + File.separator + fileName); + try { + Files.write(contents.getBytes(), sampleFile); + } catch (IOException e) { + logger.error("ERROR trying to write to file '" + fileName + "' - " + e.toString()); + Assert.fail(); + } + return sampleFile; + } +} diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java similarity index 99% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java index c0fe074047..146b2a051d 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/java/org/jclouds/docker/internal/BaseDockerMockTest.java @@ -16,6 +16,22 @@ */ package org.jclouds.docker.internal; +import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; +import static org.jclouds.http.utils.Queries.encodeQueryLine; +import static org.jclouds.util.Strings2.toStringAndClose; +import static org.testng.Assert.assertEquals; +import java.io.IOException; +import java.net.URL; +import java.util.Properties; +import java.util.Set; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; + +import org.jclouds.ContextBuilder; +import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.docker.DockerApi; + import com.google.common.base.Charsets; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMultimap; @@ -24,26 +40,9 @@ import com.google.inject.Module; import com.squareup.okhttp.mockwebserver.MockWebServer; import com.squareup.okhttp.mockwebserver.RecordedRequest; -import org.jclouds.ContextBuilder; -import org.jclouds.concurrent.config.ExecutorServiceModule; -import org.jclouds.docker.DockerApi; - -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import java.io.IOException; -import java.net.URL; -import java.util.Properties; -import java.util.Set; - -import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor; -import static org.jclouds.http.utils.Queries.encodeQueryLine; -import static org.jclouds.util.Strings2.toStringAndClose; -import static org.testng.Assert.assertEquals; /** * Base class for all Docker mock tests. - * - * @author Andrea Turli */ public class BaseDockerMockTest { private final Set modules = ImmutableSet. of(new ExecutorServiceModule(sameThreadExecutor(), diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/centos/Dockerfile b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/Dockerfile similarity index 100% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/main/resources/centos/Dockerfile rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/Dockerfile diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container-creation.json similarity index 100% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/container-creation.json rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container-creation.json diff --git a/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container.json b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container.json new file mode 100644 index 0000000000..b35301278f --- /dev/null +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/container.json @@ -0,0 +1,81 @@ +{ + "Args": [ + "-c", + "yum -y install openssh-server openssh-clients" + ], + "Config": { + "AttachStderr": false, + "AttachStdin": false, + "AttachStdout": false, + "Cmd": [ + "/bin/sh", + "-c", + "yum -y install openssh-server openssh-clients" + ], + "CpuShares": 0, + "Cpuset": "", + "Domainname": "", + "Entrypoint": null, + "Env": [ + "HOME=/", + "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" + ], + "ExposedPorts": null, + "Hostname": "9088c45a9592", + "Image": "1e2d12a45cd57ae3fe3c31ede149d800aaf6a711c61646fad340080f531775c8", + "Memory": 0, + "MemorySwap": 0, + "NetworkDisabled": false, + "OnBuild": [], + "OpenStdin": false, + "PortSpecs": null, + "StdinOnce": false, + "Tty": false, + "User": "", + "Volumes": null, + "WorkingDir": "" + }, + "Created": "2014-06-18T08:49:25.36448943Z", + "Driver": "aufs", + "ExecDriver": "native-0.2", + "HostConfig": { + "Binds": null, + "ContainerIDFile": "", + "Dns": null, + "DnsSearch": null, + "Links": null, + "LxcConf": null, + "NetworkMode": "", + "PortBindings": null, + "Privileged": false, + "PublishAllPorts": false, + "VolumesFrom": null + }, + "HostnamePath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/hostname", + "HostsPath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/hosts", + "Id": "be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2", + "Image": "1e2d12a45cd57ae3fe3c31ede149d800aaf6a711c61646fad340080f531775c8", + "MountLabel": "", + "Name": "/tender_lumiere", + "NetworkSettings": { + "Bridge": "docker0", + "Gateway": "172.17.42.1", + "IPAddress": "172.17.0.100", + "IPPrefixLen": 16, + "PortMapping": null, + "Ports": {} + }, + "Path": "/bin/sh", + "ProcessLabel": "", + "ResolvConfPath": "/mnt/sda1/var/lib/docker/containers/be1d295c091720abc9a3105219ab75a0a7367d74156cc6048aa599fcc7d650e2/resolv.conf", + "State": { + "ExitCode": 0, + "FinishedAt": "0001-01-01T00:00:00Z", + "Paused": false, + "Pid": 16422, + "Running": true, + "StartedAt": "2014-06-18T08:49:25.63685385Z" + }, + "Volumes": {}, + "VolumesRW": {} +} \ No newline at end of file diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/containers.json similarity index 100% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/containers.json rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/containers.json diff --git a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/logback.xml similarity index 97% rename from dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml rename to dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/logback.xml index 94f593832e..bbb5d7f063 100644 --- a/dependencies/jclouds/apis/docker/1.7.1-stratos/src/test/resources/logback.xml +++ b/dependencies/jclouds/apis/docker/1.8.0-stratos/src/test/resources/logback.xml @@ -1,34 +1,34 @@ - - - - - - - %msg%n - - - - - - - - - - + + + + + + - %msg%n + + + + + + + + + + \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java deleted file mode 100644 index 24e03cf6d3..0000000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.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.jclouds.ec2.compute; - -import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.blockUntilRunning; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.domain.NodeMetadata; -import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; - -/** - * Tests the compute service abstraction of the EC2 api. - * - * @author Adrian Cole - */ -@Test(groups = "unit", testName = "EC2ComputeServiceExpectTest") -public class EC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest { - - public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUser() throws Exception { - Builder requestResponseMap = ImmutableMap. builder(); - requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); - requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); - requestResponseMap.put(describeImagesRequest, describeImagesResponse); - requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); - requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); - requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(runInstancesRequest, runInstancesResponse); - requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); - requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse); - requestResponseMap.put(describeImageRequest, describeImagesResponse); - requestResponseMap.put(createTagsRequest, createTagsResponse); - - ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); - - NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, - blockUntilRunning(false).overrideLoginUser("ec2-user"))); - assertEquals(node.getCredentials().getUser(), "ec2-user"); - System.out.println(node.getImageId()); - assertNotNull(node.getCredentials().getPrivateKey()); - } - - public void testCreateNodeWithSpecifiedName() throws Exception { - HttpRequest createNamedTagsRequest = - formSigner.filter(HttpRequest.builder() - .method("POST") - .endpoint("https://ec2.us-east-1.amazonaws.com/") - .addHeader("Host", "ec2.us-east-1.amazonaws.com") - .payload( - payloadFromStringWithContentType( - "Action=CreateTags" + - "&ResourceId.1=i-2baa5550" + - "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + - "&SignatureMethod=HmacSHA256" + - "&SignatureVersion=2" + - "&Tag.1.Key=Name" + - "&Tag.1.Value=test-node" + - "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + - "&Version=2010-08-31" + - "&AWSAccessKeyId=identity", - "application/x-www-form-urlencoded")) - .build()); - - HttpResponse describeNamedInstanceResponse = - HttpResponse.builder().statusCode(200) - .payload(payloadFromResourceWithContentType( - "/describe_instances_running-named.xml", MediaType.APPLICATION_XML)).build(); - - - Builder requestResponseMap = ImmutableMap. builder(); - requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); - requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); - requestResponseMap.put(describeImagesRequest, describeImagesResponse); - requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); - requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); - requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(runInstancesRequest, runInstancesResponse); - requestResponseMap.put(describeInstanceRequest, describeNamedInstanceResponse); - requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse); - requestResponseMap.put(describeImageRequest, describeImagesResponse); - requestResponseMap.put(createNamedTagsRequest, createTagsResponse); - - ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); - - NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, - blockUntilRunning(false).overrideLoginUser("ec2-user").nodeNames(ImmutableSet.of("test-node")))); - assertEquals(node.getCredentials().getUser(), "ec2-user"); - assertNotNull(node.getCredentials().getPrivateKey()); - assertEquals(node.getName(), "test-node"); - } - - //FIXME - issue-1051 - @Test(enabled = false) - public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUserWithTemplateBuilder() throws Exception { - Builder requestResponseMap = ImmutableMap. builder(); - requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); - requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); - requestResponseMap.put(describeImagesRequest, describeImagesResponse); - requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); - requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); - requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); - requestResponseMap.put(runInstancesRequest, runInstancesResponse); - requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); - requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse); - requestResponseMap.put(describeImageRequest, describeImagesResponse); - requestResponseMap.put(createTagsRequest, createTagsResponse); - - ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); - - NodeMetadata node = Iterables.getOnlyElement( - apiThatCreatesNode.createNodesInGroup("test", 1, - apiThatCreatesNode.templateBuilder().from("osDescriptionMatches=.*fedora.*,loginUser=ec2-user").build())); - assertEquals(node.getCredentials().getUser(), "ec2-user"); - assertNotNull(node.getCredentials().getPrivateKey()); - } - -} diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-named.xml b/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-named.xml deleted file mode 100644 index 4f46adae0c..0000000000 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-named.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - f6d3252e-35e5-4ef5-b2c5-62da95dd829b - - - r-205ad944 - 993194456877 - - - sg-3c6ef654 - jclouds#mygroup2 - - - - - i-2baa5550 - ami-aecd60c7 - - 16 - running - - ip-10-28-89-195.ec2.internal - ec2-50-16-1-166.compute-1.amazonaws.com - - jclouds#mygroup2#81 - 0 - - t1.micro - 2012-08-02T04:28:30.000Z - - us-east-1e - - default - - aki-88aa75e1 - - disabled - - 10.28.89.195 - 50.16.1.166 - - - sg-3c6ef654 - jclouds#mygroup2 - - - x86_64 - ebs - /dev/sda1 - - - /dev/sda1 - - vol-f2d7c993 - attached - 2012-08-02T04:28:56.000Z - true - - - - paravirtual - - - - Name - test-node - - - xen - - - - - \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/README.txt b/dependencies/jclouds/apis/ec2/1.8.0-stratos/README.txt similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/README.txt rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/README.txt diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/pom.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/pom.xml similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/pom.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/pom.xml index c4de90c4d1..fc95b3df96 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/pom.xml +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/pom.xml @@ -22,17 +22,17 @@ org.apache.jclouds jclouds-project - 1.7.1 + 1.8.0 org.apache.stratos ec2 - 1.7.1-stratos + 1.8.0-stratos jclouds ec2 api jclouds components to access an implementation of EC2 bundle - 1.7.1 + 1.8.0 https://ec2.us-east-1.amazonaws.com 2010-08-31 diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/ami2.clj b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/ami2.clj similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/ami2.clj rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/ami2.clj diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/ebs2.clj b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/ebs2.clj similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/ebs2.clj rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/ebs2.clj diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/elastic_ip2.clj diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/security_group2.clj b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/security_group2.clj similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/clojure/org/jclouds/ec2/security_group2.clj rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/clojure/org/jclouds/ec2/security_group2.clj diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2Api.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2Api.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2Api.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2Api.java index d8637e8487..a7e7ee07f8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2Api.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2Api.java @@ -52,8 +52,6 @@ * Optional<? extends WindowsApi> windowsOption = ec2Api.getWindowsApi(); * checkState(windowsOption.isPresent(), "windows feature required, but not present"); * - * - * @author Adrian Cole */ public interface EC2Api extends Closeable { /** diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2ApiMetadata.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2Fallbacks.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2Fallbacks.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/EC2Fallbacks.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/EC2Fallbacks.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java index 2286d56e81..bc41217aa2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParams.java @@ -32,10 +32,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; -/** - * @author Oleksiy Yarmula - * @author Adrian Cole - */ public class BindBlockDeviceMappingToIndexedFormParams implements Binder { private static final String deviceNamePattern = "BlockDeviceMapping.%d.DeviceName"; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java index c37d3e1bc9..0f936ef01e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to form parameters named with BundleId.index - * - * @author Adrian Cole */ @Singleton public class BindBundleIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java index db228955f0..5478d64542 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParams.java @@ -41,8 +41,6 @@ * &Filter.3.Value.2=Production * &AUTHPARAMS * - * - * @author Adrian Cole */ @Singleton public class BindFiltersToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java index bafc493d3c..bec6dd7297 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to query parameters named with GroupId.index - * - * @author Adrian Cole */ @Singleton public class BindGroupIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java index 1efc743390..71a01142eb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to query parameters named with GroupName.index - * - * @author Adrian Cole */ @Singleton public class BindGroupNamesToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java index 1c90791d66..ca0ab58b1a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to form parameters named with InstanceId.index - * - * @author Adrian Cole */ @Singleton public class BindInstanceIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java index 403f59225b..0a058f69e0 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionToIndexedFormParams.java @@ -24,9 +24,6 @@ import org.jclouds.net.domain.IpPermission; import org.jclouds.rest.Binder; -/** - * @author Adrian Cole - */ public class BindIpPermissionToIndexedFormParams implements Binder { @SuppressWarnings("unchecked") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java index 4bead83a8f..f8030e9c75 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindIpPermissionsToIndexedFormParams.java @@ -27,9 +27,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap.Builder; -/** - * @author Adrian Cole - */ public class BindIpPermissionsToIndexedFormParams implements Binder { @SuppressWarnings("unchecked") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java index 44f0076308..c1b72f1201 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to query parameters named with KeyName.index - * - * @author Adrian Cole */ @Singleton public class BindKeyNamesToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java index 7a088dc9ea..4651807a9d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the Iterable to form parameters named with ProductCode.index - * - * @author Adrian Cole */ @Singleton public class BindProductCodesToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java index 1a2687d4e7..12dc23f5e4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParams.java @@ -27,8 +27,6 @@ /** * Binds the String [] to form parameters named with InstanceId.index - * - * @author Adrian Cole */ @Singleton public class BindPublicIpsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java index b32d8edae4..f9d2b9646d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParams.java @@ -27,8 +27,6 @@ /** * Binds Ids to query parameters named with ResourceId.index - * - * @author grkvlt@apache.org */ @Singleton public class BindResourceIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java index 5397f4e716..bc5b9fdaca 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignature.java @@ -30,10 +30,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableMultimap.Builder; -/** - * - * @author Adrian Cole - */ @Singleton public class BindS3UploadPolicyAndSignature implements Binder { private final FormSigner signer; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java index 0ed7cd3e0a..7b19cc7c01 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParams.java @@ -29,8 +29,6 @@ /** * Binds the Iterable to form parameters named with Tag.index.Key - * - * @author Adrian Cole */ @Singleton public class BindTagKeysToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java index 322e0b5066..55801fbbd2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParams.java @@ -27,9 +27,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; -/** - * @author Adrian Cole - */ public class BindTagsToIndexedFormParams implements Binder { @SuppressWarnings("unchecked") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java index 5982193d51..8faf0f49d9 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParams.java @@ -29,8 +29,6 @@ /** * Binds the Iterable to query parameters named with UserGroup.index - * - * @author Adrian Cole */ @Singleton public class BindUserGroupsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java index 4e0b3bc595..e1b6995175 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParams.java @@ -30,8 +30,6 @@ /** * Binds the String [] to query parameters named with GroupName.index - * - * @author Adrian Cole */ @Singleton public class BindUserIdGroupPairToSourceSecurityGroupFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java index 508971fef0..d57022a641 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the Iterable to form parameters named with UserId.index - * - * @author Adrian Cole */ @Singleton public class BindUserIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java index c1b0cdd92f..cf9d8b388c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to form parameters named with VolumeId.index - * - * @author Adrian Cole */ @Singleton public class BindVolumeIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java index f319935a6f..8013c1bcf2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParam.java @@ -26,8 +26,6 @@ /** * Binds the AvailabilityZone to a form parameter if set. - * - * @author Adrian Cole */ @Singleton public class IfNotNullBindAvailabilityZoneToFormParam implements Binder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java index 9a81a94efa..682786e046 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeService.java @@ -20,6 +20,7 @@ import static com.google.common.base.Strings.emptyToNull; import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.transform; +import static com.google.common.collect.Lists.newArrayList; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; import static org.jclouds.compute.config.ComputeServiceProperties.RESOURCENAME_DELIMITER; @@ -32,16 +33,31 @@ import static org.jclouds.ec2.util.Tags.resourceToTagsAsMap; import static org.jclouds.util.Predicates2.retry; +import javax.inject.Named; +import javax.inject.Provider; +import javax.inject.Singleton; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReference; -import javax.inject.Named; -import javax.inject.Provider; -import javax.inject.Singleton; - +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.base.Supplier; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableMultimap.Builder; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.inject.Inject; import org.jclouds.Constants; import org.jclouds.aws.util.AWSUtils; import org.jclouds.collect.Memoized; @@ -85,26 +101,6 @@ import org.jclouds.scriptbuilder.functions.InitAdminAccess; import org.jclouds.util.Strings2; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableMultimap.Builder; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.inject.Inject; - -/** - * @author Adrian Cole - */ @Singleton public class EC2ComputeService extends BaseComputeService { private final EC2Api client; @@ -175,12 +171,13 @@ private Set addTagsAndNamesToInstancesInRegion(Map Map instancesById = Maps.uniqueIndex(input, instanceId); ImmutableSet.Builder builder = ImmutableSet. builder(); + List namesToUse = newArrayList(nodeNames); if (generateInstanceNames && !common.containsKey("Name")) { for (Map.Entry entry : instancesById.entrySet()) { String id = entry.getKey(); String name; - if (!nodeNames.isEmpty()) { - name = Iterables.get(nodeNames, 0); + if (!namesToUse.isEmpty()) { + name = namesToUse.remove(0); } else { name = id.replaceAll(".*-", group + "-"); } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java index 76473c6f4b..4e4d4dbc55 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/EC2ComputeServiceContext.java @@ -21,9 +21,6 @@ import com.google.inject.ImplementedBy; -/** - * @author Adrian Cole - */ @ImplementedBy(EC2ComputeServiceContextImpl.class) public interface EC2ComputeServiceContext extends ComputeServiceContext { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java index 6fd1ca5413..91cb11668f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeStrategiesByClass.java @@ -35,9 +35,6 @@ import org.jclouds.ec2.compute.strategy.EC2ResumeNodeStrategy; import org.jclouds.ec2.compute.strategy.EC2SuspendNodeStrategy; -/** - * @author Adrian Cole - */ public class EC2BindComputeStrategiesByClass extends BindComputeStrategiesByClass { @Override protected Class defineRunNodesAndAddToSetStrategy() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java index c131608794..84f10677dc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2BindComputeSuppliersByClass.java @@ -25,9 +25,6 @@ import org.jclouds.ec2.compute.suppliers.EC2ImageSupplier; import com.google.common.base.Supplier; -/** - * @author Adrian Cole - */ public class EC2BindComputeSuppliersByClass extends BindComputeSuppliersByClass { @Override protected Class>> defineHardwareSupplier() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java index 81c874d3be..1aa7f5b351 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModule.java @@ -54,8 +54,6 @@ /** * Configures the {@link ComputeServiceContext}; requires {@link EC2ComputeService} bound. - * - * @author Adrian Cole */ public class EC2ComputeServiceContextModule extends BaseComputeServiceContextModule { @Override diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java index 9f6c285c00..b9ef0ca64e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ComputeServiceDependenciesModule.java @@ -78,10 +78,6 @@ import com.google.inject.TypeLiteral; import com.google.inject.name.Names; -/** - * - * @author Adrian Cole - */ public class EC2ComputeServiceDependenciesModule extends AbstractModule { public static final Map toPortableNodeStatus = ImmutableMap diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java index e3e98e60d2..7805fc094f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/config/EC2ResolveImagesModule.java @@ -22,9 +22,6 @@ import com.google.inject.AbstractModule; -/** - * @author Oleksiy Yarmula - */ @ResolvesImages public class EC2ResolveImagesModule extends AbstractModule { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java similarity index 96% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java index 185644e053..38c48d11fa 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/EC2HardwareBuilder.java @@ -47,7 +47,6 @@ /** * - * @author Adrian Cole * @see @@ -335,7 +334,12 @@ public static EC2HardwareBuilder m3_large() { */ public static EC2HardwareBuilder m3_xlarge() { return new EC2HardwareBuilder(InstanceType.M3_XLARGE).ram(15360) - .processors(ImmutableList.of(new Processor(4.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true); + .processors(ImmutableList.of(new Processor(4.0, 3.25))) + .is64Bit(true) + .volumes(ImmutableList. of( + new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(), + new VolumeBuilder().type(LOCAL).size(40.0f).device("/dev/sdb").bootDevice(false).durable(false).build(), + new VolumeBuilder().type(LOCAL).size(40.0f).device("/dev/sdc").bootDevice(false).durable(false).build())); } /** @@ -343,7 +347,12 @@ public static EC2HardwareBuilder m3_xlarge() { */ public static EC2HardwareBuilder m3_2xlarge() { return new EC2HardwareBuilder(InstanceType.M3_2XLARGE).ram(30720) - .processors(ImmutableList.of(new Processor(8.0, 3.25))).rootDeviceType(RootDeviceType.EBS).is64Bit(true); + .processors(ImmutableList.of(new Processor(8.0, 3.25))) + .is64Bit(true) + .volumes(ImmutableList. of( + new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(), + new VolumeBuilder().type(LOCAL).size(80.0f).device("/dev/sdb").bootDevice(false).durable(false).build(), + new VolumeBuilder().type(LOCAL).size(80.0f).device("/dev/sdc").bootDevice(false).durable(false).build())); } /** @@ -484,7 +493,7 @@ public static EC2HardwareBuilder cc2_8xlarge() { */ public static EC2HardwareBuilder g2_2xlarge() { return new EC2HardwareBuilder(InstanceType.G2_2XLARGE) - .ram(15*1024) + .ram(15 * 1024) .processors(ImmutableList.of(new Processor(8.0, 3.25))) .volumes(ImmutableList. of( new VolumeBuilder().type(LOCAL).size(10.0f).device("/dev/sda1").bootDevice(true).durable(false).build(), diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java index 9e0748f682..b3d9100cf8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/PasswordDataAndPrivateKey.java @@ -22,8 +22,6 @@ /** * An encrypted Windows Administrator password, and the private key that can decrypt it. - * - * @author Richard Downer */ public class PasswordDataAndPrivateKey { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java index bdfc04dc31..cf38056cc2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionAndName.java @@ -22,10 +22,6 @@ import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -/** - * - * @author Adrian Cole - */ public class RegionAndName { protected final String region; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java index 0063104f2f..081d0754cd 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/domain/RegionNameAndIngressRules.java @@ -16,10 +16,6 @@ */ package org.jclouds.ec2.compute.domain; -/** - * - * @author Adrian Cole - */ public class RegionNameAndIngressRules extends RegionAndName { private final int[] ports; private final boolean authorizeSelf; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java index fe3dc9bc64..03c18d7428 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2ImageExtension.java @@ -60,9 +60,6 @@ /** * EC2 implementation of {@link ImageExtension} please note that {@link #createImage(ImageTemplate)} * only works by cloning EBS backed instances for the moment. - * - * @author David Alves - * */ public class EC2ImageExtension implements ImageExtension { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java index a9e174187a..789a7b67dc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtension.java @@ -58,8 +58,6 @@ /** * An extension to compute service to allow for the manipulation of {@link SecurityGroup}s. Implementation * is optional by providers. - * - * @author Andrew Bayer */ public class EC2SecurityGroupExtension implements SecurityGroupExtension { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java index cfb18d10a6..72528a11ae 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadata.java @@ -38,8 +38,6 @@ /** * This class searches for elastic ip addresses that are associated with the node, and adds them to * the publicIpAddress collection if present. - * - * @author Adrian Cole */ @Singleton public class AddElasticIpsToNodemetadata implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java index 412cda2725..37f4c1588f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPair.java @@ -33,10 +33,6 @@ import com.google.common.base.Function; import com.google.inject.Inject; -/** - * - * @author Adrian Cole - */ @Singleton public class CreateUniqueKeyPair implements Function { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java index c6849f84f2..f9ee0a7d89 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/CredentialsForInstance.java @@ -37,10 +37,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -/** - * - * @author Adrian Cole - */ @Singleton public class CredentialsForInstance extends CacheLoader> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java index 202b4f9b86..fc8b184860 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2ImageParser.java @@ -52,9 +52,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class EC2ImageParser implements Function { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java index f7bc3fbe79..640a9671fa 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupIdFromName.java @@ -27,9 +27,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * @author Andrew Bayer - */ @Singleton public class EC2SecurityGroupIdFromName implements Function { protected EC2Api api; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java index ffa54436ed..ae3b5b5f1c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroup.java @@ -42,8 +42,6 @@ /** * A function for transforming an EC2-specific SecurityGroup into a generic * SecurityGroup object. - * - * @author Andrew Bayer */ @Singleton public class EC2SecurityGroupToSecurityGroup implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java index 3df5b4c8f9..1e71648a29 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/ImagesToRegionAndIdMap.java @@ -28,9 +28,6 @@ import com.google.common.base.Function; -/** - * @author Adrian Cole - */ @Singleton public class ImagesToRegionAndIdMap implements Function, Map> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java index 939daf008d..93ea29e4a5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PasswordCredentialsFromWindowsInstance.java @@ -48,9 +48,6 @@ import com.google.common.base.Strings; import com.google.common.util.concurrent.Atomics; -/** - * @author Adrian Cole - */ @Singleton public class PasswordCredentialsFromWindowsInstance implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java index f74000f8d3..b3410079df 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/PresentInstances.java @@ -44,8 +44,6 @@ /** * returns the instances present in the list. Makes a single rest call per aggregate on region. - * - * @author Adrian Cole */ @Singleton public class PresentInstances implements Function, Set> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java index 25dd6d0d77..e0f5e9573d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadata.java @@ -66,9 +66,6 @@ import com.google.common.util.concurrent.UncheckedExecutionException; import com.google.inject.Inject; -/** - * @author Adrian Cole - */ @Singleton public class RunningInstanceToNodeMetadata implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java index eec73bc91c..6e1b646abc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedData.java @@ -38,8 +38,6 @@ /** * Given an encrypted Windows Administrator password and the decryption key, return a LoginCredentials instance. - * - * @author Richard Downer */ @Singleton public class WindowsLoginCredentialsFromEncryptedData implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java index ef9e19fa95..74d61c0d0a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java @@ -28,9 +28,6 @@ import com.google.common.reflect.TypeToken; -/** - * @author Adrian Cole - */ @Singleton public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext { @Inject diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java similarity index 92% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java index 04ce9c0f9a..180bd62f1e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImpl.java @@ -32,6 +32,8 @@ import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.TemplateBuilderImpl; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.compute.strategy.GetImageStrategy; +import org.jclouds.compute.suppliers.ImageCacheSupplier; import org.jclouds.domain.Location; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.util.Throwables2; @@ -42,20 +44,17 @@ import com.google.common.collect.ImmutableSet; import com.google.common.util.concurrent.UncheckedExecutionException; -/** - * - * @author Adrian Cole - */ public class EC2TemplateBuilderImpl extends TemplateBuilderImpl { private final Supplier> lazyImageCache; @Inject protected EC2TemplateBuilderImpl(@Memoized Supplier> locations, - @Memoized Supplier> images, @Memoized Supplier> sizes, + ImageCacheSupplier images, @Memoized Supplier> sizes, Supplier defaultLocation, @Named("DEFAULT") Provider optionsProvider, - @Named("DEFAULT") Provider defaultTemplateProvider, Supplier> imageMap) { - super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider); + @Named("DEFAULT") Provider defaultTemplateProvider, GetImageStrategy getImageStrategy, + Supplier> imageMap) { + super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy); this.lazyImageCache = imageMap; } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java index 301f41f08c..191f965d28 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeeded.java @@ -36,10 +36,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class CreateSecurityGroupIfNeeded extends CacheLoader { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java index 9161c20ad4..dd21344963 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNull.java @@ -29,9 +29,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class LoadPublicIpForInstanceOrNull extends CacheLoader { private final EC2Api client; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java index 3b6fa8976b..c28d0c51fa 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImage.java @@ -33,10 +33,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class RegionAndIdToImage extends CacheLoader { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java similarity index 87% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java index 1d837fe41f..64c1ccdb54 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/options/EC2TemplateOptions.java @@ -16,6 +16,16 @@ */ package org.jclouds.ec2.compute.options; +import static com.google.common.base.Objects.equal; +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; +import static com.google.common.base.Strings.emptyToNull; + +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; @@ -32,16 +42,6 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.scriptbuilder.domain.Statement; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static com.google.common.base.Objects.equal; -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; -import static com.google.common.base.Strings.emptyToNull; - /** * Contains options supported in the {@code ComputeService#runNode} operation on * the "ec2" provider.

@@ -56,8 +56,6 @@ * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * - * - * @author Adrian Cole */ public class EC2TemplateOptions extends TemplateOptions implements Cloneable { @Override @@ -82,6 +80,10 @@ public void copyTo(TemplateOptions to) { eTo.noKeyPair(); if (getUserData() != null) eTo.userData(getUserData()); + if (getMaxCount() > 0) + eTo.maxCount(getMaxCount()); + if (getClientToken() != null) + eTo.clientToken(getClientToken()); } } @@ -90,6 +92,8 @@ public void copyTo(TemplateOptions to) { private boolean noKeyPair; private List userData; private ImmutableSet.Builder blockDeviceMappings = ImmutableSet.builder(); + private Integer maxCount; + private String clientToken = null; @Override public boolean equals(Object o) { @@ -99,14 +103,17 @@ public boolean equals(Object o) { return false; EC2TemplateOptions that = EC2TemplateOptions.class.cast(o); return super.equals(that) && equal(this.groupNames, that.groupNames) && equal(this.keyPair, that.keyPair) - && equal(this.noKeyPair, that.noKeyPair) && equal(this.userData, that.userData) - && equal(this.blockDeviceMappings, that.blockDeviceMappings); + && equal(this.noKeyPair, that.noKeyPair) && equal(this.userData, that.userData) + && equal(this.blockDeviceMappings, that.blockDeviceMappings) + && equal(this.maxCount, that.maxCount) + && equal(this.clientToken, that.clientToken); } @Override public int hashCode() { return Objects - .hashCode(super.hashCode(), groupNames, keyPair, noKeyPair, userData, userData, blockDeviceMappings); + .hashCode(super.hashCode(), groupNames, keyPair, noKeyPair, userData, userData, blockDeviceMappings, + maxCount, clientToken); } @Override @@ -122,6 +129,10 @@ public ToStringHelper string() { ImmutableSet mappings = blockDeviceMappings.build(); if (mappings.size() != 0) toString.add("blockDeviceMappings", mappings); + if (maxCount != null && maxCount.intValue() > 0) + toString.add("maxCount", maxCount); + if (clientToken != null) + toString.add("clientToken", clientToken); return toString; } @@ -176,12 +187,27 @@ public EC2TemplateOptions noKeyPair() { public EC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, @Nullable Integer sizeInGib, boolean deleteOnTermination) { - blockDeviceMappings.add(new MapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination)); + return mapEBSSnapshotToDeviceName(deviceName, snapshotId, sizeInGib, deleteOnTermination, null, null, false); + } + + public EC2TemplateOptions mapEBSSnapshotToDeviceName(String deviceName, String snapshotId, + @Nullable Integer sizeInGib, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, + boolean encrypted) { + blockDeviceMappings.add(new MapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination, + volumeType, iops, encrypted)); return this; } public EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination) { - blockDeviceMappings.add(new MapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination)); + return mapNewVolumeToDeviceName(deviceName, sizeInGib, deleteOnTermination, null, null, false); + } + + public EC2TemplateOptions mapNewVolumeToDeviceName(String deviceName, int sizeInGib, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, + boolean encrypted) { + blockDeviceMappings.add(new MapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination, volumeType, + iops, encrypted)); return this; } @@ -200,6 +226,16 @@ public EC2TemplateOptions blockDeviceMappings(Iterable getBlockDeviceMappings() { return blockDeviceMappings.build(); } + /** + * @return the maximum number of instances to create + */ + public int getMaxCount() { + return maxCount != null ? maxCount.intValue() : 0; + } + + /** + * See here for more information. + * + * @return the optional client token string, used for idempotency + */ + public String getClientToken() { + return clientToken; + } + } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java index ec1d14c723..46808fa36f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/EC2ImagePredicates.java @@ -29,8 +29,6 @@ * * This class has static methods that create customized predicates to use with * {@link org.jclouds.compute.ComputeService}. - * - * @author Adrian Cole */ public class EC2ImagePredicates { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java index 33e492a617..7899478d35 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/predicates/SecurityGroupPresent.java @@ -33,10 +33,6 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; -/** - * - * @author Adrian Cole - */ @Singleton public class SecurityGroupPresent implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java similarity index 88% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java index 675396f099..454172c96b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions.java @@ -22,13 +22,18 @@ import static org.jclouds.ssh.SshKeys.fingerprintPrivateKey; import static org.jclouds.ssh.SshKeys.sha1PrivateKey; -import java.util.Set; -import java.util.concurrent.ConcurrentMap; - import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; +import java.util.Set; +import java.util.concurrent.ConcurrentMap; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableSet.Builder; +import com.google.inject.Inject; import org.jclouds.compute.domain.Template; import org.jclouds.compute.functions.GroupNamingConvention; import org.jclouds.compute.functions.GroupNamingConvention.Factory; @@ -41,17 +46,6 @@ import org.jclouds.ec2.options.RunInstancesOptions; import org.jclouds.javax.annotation.Nullable; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSet.Builder; -import com.google.inject.Inject; - -/** - * - * @author Adrian Cole - */ @Singleton public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions { @VisibleForTesting @@ -101,6 +95,12 @@ public RunInstancesOptions execute(String region, String group, Template templat "BlockDeviceMapping only available on ebs boot"); instanceOptions.withBlockDeviceMappings(blockDeviceMappings); } + + String clientToken = EC2TemplateOptions.class.cast(template.getOptions()).getClientToken(); + + if (clientToken != null) { + instanceOptions.withClientToken(clientToken); + } } return instanceOptions; } @@ -166,25 +166,24 @@ protected String createOrImportKeyPair(String region, String group, TemplateOpti public Set getSecurityGroupsForTagAndOptions(String region, @Nullable String group, TemplateOptions options) { Builder groups = ImmutableSet.builder(); - if (group != null) { - - if (userSpecifiedTheirOwnGroups(options)) { - groups.addAll(EC2TemplateOptions.class.cast(options) - .getGroups()); - } else { - String markerGroup = namingConvention.create() - .sharedNameForGroup(group); - - groups.add(markerGroup); - - RegionNameAndIngressRules regionNameAndIngressRulesForMarkerGroup; - regionNameAndIngressRulesForMarkerGroup = new RegionNameAndIngressRules( - region, markerGroup, options.getInboundPorts(), true); - // this will create if not yet exists. - securityGroupMap - .getUnchecked(regionNameAndIngressRulesForMarkerGroup); - } - } + if (group != null) { + String markerGroup = namingConvention.create().sharedNameForGroup(group); + + groups.add(markerGroup); + + RegionNameAndIngressRules regionNameAndIngressRulesForMarkerGroup; + + if (userSpecifiedTheirOwnGroups(options)) { + regionNameAndIngressRulesForMarkerGroup = new RegionNameAndIngressRules(region, markerGroup, new int[] {}, + false); + groups.addAll(EC2TemplateOptions.class.cast(options).getGroups()); + } else { + regionNameAndIngressRulesForMarkerGroup = new RegionNameAndIngressRules(region, markerGroup, options + .getInboundPorts(), true); + } + // this will create if not yet exists. + securityGroupMap.getUnchecked(regionNameAndIngressRulesForMarkerGroup); + } return groups.build(); } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java index bddbbba2e0..9640e4b05a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/DescribeImagesParallel.java @@ -41,10 +41,6 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * - * @author Adrian Cole - */ @Singleton public class DescribeImagesParallel implements Function>, Iterable> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java similarity index 93% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java index e40abe9d1a..e41c0f8f4a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSet.java @@ -26,15 +26,24 @@ import static org.jclouds.compute.functions.DefaultCredentialsFromImageOrOverridingCredentials.overrideDefaultCredentialsWithOptionsIfPresent; import static org.jclouds.ec2.compute.util.EC2ComputeUtils.getZoneFromLocationOrNull; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; +import com.google.common.collect.Multimap; +import com.google.common.util.concurrent.ListenableFuture; import org.jclouds.aws.util.AWSUtils; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.NodeMetadata; @@ -48,26 +57,14 @@ import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.PresentInstances; +import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.options.RunInstancesOptions; import org.jclouds.ec2.reference.EC2Constants; import org.jclouds.logging.Logger; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListenableFuture; - /** * creates futures that correlate to - * - * @author Adrian Cole */ @Singleton public class EC2CreateNodesInGroupThenAddToSet implements CreateNodesInGroupThenAddToSet { @@ -173,7 +170,7 @@ private Set runInstancesAndWarnOnInvisible(String group, int co private void populateCredentials(Set input, TemplateOptions options) { LoginCredentials credentials = null; for (RunningInstance instance : input) { - credentials = instanceToCredentials.apply(instance).orNull(); + credentials = instanceToCredentials.getUnchecked(instance).orNull(); if (credentials != null) break; } @@ -218,12 +215,23 @@ private Set createKeyPairAndSecurityGroupsAsNeededThenRunInstan return createNodesInRegionAndZone(region, zone, group, count, template, instanceOptions); } - protected Set createNodesInRegionAndZone(String region, String zone, String group, int count, - Template template, RunInstancesOptions instanceOptions) { + protected Set createNodesInRegionAndZone(String region, String zone, String group, + int count, Template template, + RunInstancesOptions instanceOptions) { int countStarted = 0; int tries = 0; Set started = ImmutableSet. of(); + int maxCount = EC2TemplateOptions.class.cast(template.getOptions()).getMaxCount(); + int countToProvision; + + if (maxCount == 0) { + maxCount = count; + countToProvision = 1; + } else { + countToProvision = count; + } + while (countStarted < count && tries++ < count) { if (logger.isDebugEnabled()) logger.debug(">> running %d instance region(%s) zone(%s) ami(%s) params(%s)", count - countStarted, region, @@ -231,8 +239,8 @@ protected Set createNodesInRegionAndZone(String region, String started = ImmutableSet.copyOf(concat( started, - client.getInstanceApi().get().runInstancesInRegion(region, zone, template.getImage().getProviderId(), 1, - count - countStarted, instanceOptions))); + client.getInstanceApi().get().runInstancesInRegion(region, zone, template.getImage().getProviderId(), + countToProvision, maxCount - countStarted, instanceOptions))); countStarted = size(started); if (countStarted < count) diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java index 2061b4969f..b8a1b5c0e8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategy.java @@ -39,10 +39,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2DestroyNodeStrategy implements DestroyNodeStrategy { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java index a20c48c649..55a7889d70 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetImageStrategy.java @@ -32,10 +32,6 @@ import com.google.common.base.Function; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2GetImageStrategy implements GetImageStrategy { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java index e446697649..0d7fa77fe3 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2GetNodeMetadataStrategy.java @@ -33,10 +33,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2GetNodeMetadataStrategy implements GetNodeMetadataStrategy { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java index 21bfef2fb1..2f0204a146 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ListNodesStrategy.java @@ -55,10 +55,6 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2ListNodesStrategy implements ListNodesStrategy { @@ -121,7 +117,7 @@ protected Iterable pollRunningInstances() { return concat(concat(reservations)); } - protected Iterable pollRunningInstancesByRegionsAndIds(final Multimap idsByRegions) { + protected Iterable pollRunningInstancesByRegionsAndIds(final Multimap idsByRegions) { Iterable>> reservations = transform(idsByRegions.keySet(), instancesByIdInRegion(idsByRegions)); @@ -150,7 +146,7 @@ public Set> apply(String from) } protected Function>> - instancesByIdInRegion(final Multimap idsByRegions) { + instancesByIdInRegion(final Multimap idsByRegions) { return new Function>>() { @Override diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java index c954661766..91eaaa9163 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2PopulateDefaultLoginCredentialsForImageStrategy.java @@ -34,9 +34,6 @@ import com.google.common.collect.ImmutableMap; -/** - * @author Oleksiy Yarmula - */ @Singleton public class EC2PopulateDefaultLoginCredentialsForImageStrategy extends ReturnCredentialsBoundToImage { public EC2PopulateDefaultLoginCredentialsForImageStrategy() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java index c8cafc0e1e..fbc80961c9 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2RebootNodeStrategy.java @@ -26,10 +26,6 @@ import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.features.InstanceApi; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2RebootNodeStrategy implements RebootNodeStrategy { private final InstanceApi client; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java index 5ecccfc549..6c5a09316c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2ResumeNodeStrategy.java @@ -26,10 +26,6 @@ import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.features.InstanceApi; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2ResumeNodeStrategy implements ResumeNodeStrategy { private final InstanceApi client; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java index cf9edd9b40..ec737a2ca8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/EC2SuspendNodeStrategy.java @@ -26,10 +26,6 @@ import org.jclouds.ec2.EC2Api; import org.jclouds.ec2.features.InstanceApi; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2SuspendNodeStrategy implements SuspendNodeStrategy { private final InstanceApi client; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java index 3df595b292..18dabd7da5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/strategy/ReviseParsedImage.java @@ -24,10 +24,6 @@ import com.google.inject.ImplementedBy; -/** - * - * @author Adrian Cole - */ @ImplementedBy(ReviseParsedImage.NoopReviseParsedImage.class) public interface ReviseParsedImage { void reviseParsedImage(org.jclouds.ec2.domain.Image from, ImageBuilder builder, OsFamily family, diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java index 2a4daab033..7ba4d1cda6 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2HardwareSupplier.java @@ -31,10 +31,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2HardwareSupplier implements Supplier> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java index 810b602734..4fd4d6caf9 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/EC2ImageSupplier.java @@ -48,10 +48,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2ImageSupplier implements Supplier> { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java index 87dce206a2..ae9daeaab3 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/suppliers/RegionAndNameToImageSupplier.java @@ -32,10 +32,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -/** - * - * @author Adrian Cole - */ @Singleton public class RegionAndNameToImageSupplier implements Supplier> { private final LoadingCache cache; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java index bb21e94fbc..766da1cd2e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/compute/util/EC2ComputeUtils.java @@ -21,10 +21,6 @@ import org.jclouds.domain.Location; import org.jclouds.domain.LocationScope; -/** - * - * @author Adrian Cole - */ @Singleton public class EC2ComputeUtils { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java index e52ca01f94..5db1728431 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/BaseEC2HttpApiModule.java @@ -38,8 +38,6 @@ /** * Configures the EC2 connection. - * - * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) */ @ConfiguresHttpApi public abstract class BaseEC2HttpApiModule extends diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java similarity index 94% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java index ca45843b59..99805137fe 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/config/EC2HttpApiModule.java @@ -25,8 +25,6 @@ /** * Configures the EC2 connection. - * - * @author Adrian Cole (EDIT: Nick Terry nterry@familysearch.org) */ @ConfiguresHttpApi public class EC2HttpApiModule extends BaseEC2HttpApiModule { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java index 0961623945..23f2722432 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Attachment.java @@ -21,7 +21,6 @@ import java.util.Date; /** - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java index 63c993fe8c..dcc94322e8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/AvailabilityZoneInfo.java @@ -27,7 +27,6 @@ * * @see - * @author Adrian Cole */ public class AvailabilityZoneInfo implements Comparable { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java index 7d341d1203..b4a2710b1d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDevice.java @@ -25,7 +25,6 @@ * @see - * @author Adrian Cole */ public class BlockDevice { private final String volumeId; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java similarity index 73% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java index 47bb456c44..b270c3f5df 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BlockDeviceMapping.java @@ -22,10 +22,6 @@ import org.jclouds.javax.annotation.Nullable; -/** - * - * @author Lili Nadar - */ public class BlockDeviceMapping implements Comparable { public static Builder builder() { return new Builder(); @@ -38,6 +34,9 @@ public static class Builder { private Integer sizeInGib; private Boolean noDevice; private Boolean deleteOnTermination; + private String volumeType; + private Integer iops; + private Boolean encrypted; public Builder deviceName(String deviceName) { this.deviceName = deviceName; @@ -69,8 +68,24 @@ public Builder deleteOnTermination(Boolean deleteOnTermination) { return this; } + public Builder volumeType(String volumeType) { + this.volumeType = volumeType; + return this; + } + + public Builder iops(Integer iops) { + this.iops = iops; + return this; + } + + public Builder encrypted(Boolean encrypted) { + this.encrypted = encrypted; + return this; + } + public BlockDeviceMapping build() { - return new BlockDeviceMapping(deviceName, virtualName, snapshotId, sizeInGib, noDevice, deleteOnTermination); + return new BlockDeviceMapping(deviceName, virtualName, snapshotId, sizeInGib, noDevice, deleteOnTermination, + volumeType, iops, encrypted); } public Builder clear() { @@ -80,6 +95,9 @@ public Builder clear() { this.sizeInGib = null; this.noDevice = null; this.deleteOnTermination = null; + this.volumeType = null; + this.iops = null; + this.encrypted = null; return this; } } @@ -90,13 +108,17 @@ public Builder clear() { private final Integer sizeInGib; private final Boolean noDevice; private final Boolean deleteOnTermination; + private final String volumeType; + private final Integer iops; + private final Boolean encrypted; // values expressed in GB private static final Integer VOLUME_SIZE_MIN_VALUE = 1; private static final Integer VOLUME_SIZE_MAX_VALUE = 1000; BlockDeviceMapping(String deviceName, @Nullable String virtualName, @Nullable String snapshotId, - @Nullable Integer sizeInGib, @Nullable Boolean noDevice, @Nullable Boolean deleteOnTermination) { + @Nullable Integer sizeInGib, @Nullable Boolean noDevice, @Nullable Boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, @Nullable Boolean encrypted) { checkNotNull(deviceName, "deviceName cannot be null"); checkNotNull(emptyToNull(deviceName), "deviceName must be defined"); @@ -111,6 +133,9 @@ public Builder clear() { this.sizeInGib = sizeInGib; this.noDevice = noDevice; this.deleteOnTermination = deleteOnTermination; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; } public String getDeviceName() { @@ -137,6 +162,18 @@ public Boolean getEbsDeleteOnTermination() { return deleteOnTermination; } + public String getEbsVolumeType() { + return volumeType; + } + + public Integer getEbsIops() { + return iops; + } + + public Boolean getEbsEncrypted() { + return encrypted; + } + @Override public int hashCode() { final int prime = 31; @@ -147,6 +184,9 @@ public int hashCode() { result = prime * result + ((sizeInGib == null) ? 0 : sizeInGib.hashCode()); result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); result = prime * result + ((virtualName == null) ? 0 : virtualName.hashCode()); + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.hashCode()); + result = prime * result + ((encrypted == null ) ? 0 : encrypted.hashCode()); return result; } @@ -189,41 +229,59 @@ public boolean equals(Object obj) { return false; } else if (!virtualName.equals(other.virtualName)) return false; + if (volumeType == null) { + if (other.volumeType != null) + return false; + } else if (!volumeType.equals(other.volumeType)) + return false; + if (iops == null) { + if (other.iops != null) + return false; + } else if (!iops.equals(other.iops)) + return false; + if (encrypted == null) { + if (other.encrypted != null) + return false; + } else if (!encrypted.equals(other.encrypted)) + return false; return true; } @Override public String toString() { return "[deviceName=" + deviceName + ", virtualName=" + virtualName + ", snapshotId=" + snapshotId - + ", sizeInGib=" + sizeInGib + ", noDevice=" + noDevice + ", deleteOnTermination=" + deleteOnTermination - + "]"; + + ", sizeInGib=" + sizeInGib + ", noDevice=" + noDevice + ", deleteOnTermination=" + deleteOnTermination + + ", volumeType=" + volumeType + ", iops=" + iops + ", encrypted=" + encrypted + + "]"; } public static class MapEBSSnapshotToDevice extends BlockDeviceMapping { public MapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib, - @Nullable Boolean deleteOnTermination) { - super(deviceName, null, snapshotId, sizeInGib, null, deleteOnTermination); + @Nullable Boolean deleteOnTermination, @Nullable String volumeType, + @Nullable Integer iops, @Nullable Boolean encrypted) { + super(deviceName, null, snapshotId, sizeInGib, null, deleteOnTermination, volumeType, iops, encrypted); checkNotNull(emptyToNull(snapshotId), "snapshotId must be defined"); } } public static class MapNewVolumeToDevice extends BlockDeviceMapping { - public MapNewVolumeToDevice(String deviceName, Integer sizeInGib, @Nullable Boolean deleteOnTermination) { - super(deviceName, null, null, sizeInGib, null, deleteOnTermination); + public MapNewVolumeToDevice(String deviceName, Integer sizeInGib, @Nullable Boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, @Nullable Boolean encrypted) { + super(deviceName, null, null, sizeInGib, null, deleteOnTermination, volumeType, iops, encrypted); checkNotNull(sizeInGib, "sizeInGib cannot be null"); } } public static class MapEphemeralDeviceToDevice extends BlockDeviceMapping { public MapEphemeralDeviceToDevice(String deviceName, String virtualName) { - super(deviceName, virtualName, null, null, null, null); + super(deviceName, virtualName, null, null, null, null, null, null, null); checkNotNull(emptyToNull(virtualName), "virtualName must be defined"); } } public static class UnmapDeviceNamed extends BlockDeviceMapping { public UnmapDeviceNamed(String deviceName) { - super(deviceName, null, null, null, true, null); + super(deviceName, null, null, null, true, null, null, null, null); } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java index cabf88e00a..03a0a1f4fb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleInstanceS3Storage.java @@ -24,7 +24,6 @@ * * @see - * @author Adrian Cole */ public class BundleInstanceS3Storage { private final String ccessKeyId; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java index 159cebb2ba..2a13241212 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/BundleTask.java @@ -26,7 +26,6 @@ * * @see - * @author Adrian Cole */ public class BundleTask implements Comparable { /** @@ -41,7 +40,6 @@ public int compareTo(BundleTask o) { * * @see - * @author Adrian Cole */ public static class Error { private final String code; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java index 76ac80a807..a85ed0df2f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Hypervisor.java @@ -20,8 +20,6 @@ /** * Hypervisor of the image. - * - * @author Adrian Cole */ public enum Hypervisor { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Image.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java similarity index 92% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Image.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java index 6304c43782..42136cd31c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Image.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Image.java @@ -31,7 +31,6 @@ * * @see - * @author Adrian Cole */ public class Image implements Comparable { @@ -160,11 +159,18 @@ public static class EbsBlockDevice { private final String snapshotId; private final long volumeSize; private final boolean deleteOnTermination; + private final String volumeType; + private final Integer iops; + private final boolean encrypted; - public EbsBlockDevice(@Nullable String snapshotId, long volumeSize, boolean deleteOnTermination) { + public EbsBlockDevice(@Nullable String snapshotId, long volumeSize, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, boolean encrypted) { this.snapshotId = snapshotId; this.volumeSize = volumeSize; this.deleteOnTermination = deleteOnTermination; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; } public String getSnapshotId() { @@ -179,6 +185,18 @@ public boolean isDeleteOnTermination() { return deleteOnTermination; } + public String getVolumeType() { + return volumeType; + } + + public Integer getIops() { + return iops; + } + + public boolean isEncrypted() { + return encrypted; + } + @Override public int hashCode() { final int prime = 31; @@ -186,6 +204,9 @@ public int hashCode() { result = prime * result + (deleteOnTermination ? 1231 : 1237); result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); result = prime * result + (int) (volumeSize ^ (volumeSize >>> 32)); + result = prime * result + (encrypted ? 1249 : 1259); + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.hashCode()); return result; } @@ -200,11 +221,23 @@ public boolean equals(Object obj) { EbsBlockDevice other = (EbsBlockDevice) obj; if (deleteOnTermination != other.deleteOnTermination) return false; + if (encrypted != other.encrypted) + return false; if (snapshotId == null) { if (other.snapshotId != null) return false; } else if (!snapshotId.equals(other.snapshotId)) return false; + if (volumeType == null) { + if (other.volumeType != null) + return false; + } else if (!volumeType.equals(other.volumeType)) + return false; + if (iops == null) { + if (other.iops != null) + return false; + } else if (!iops.equals(other.iops)) + return false; if (volumeSize != other.volumeSize) return false; return true; @@ -213,7 +246,8 @@ public boolean equals(Object obj) { @Override public String toString() { return "EbsBlockDevice [deleteOnTermination=" + deleteOnTermination + ", snapshotId=" + snapshotId - + ", volumeSize=" + volumeSize + "]"; + + ", volumeSize=" + volumeSize + ", volumeType=" + volumeType + ", iops=" + iops + + ", encrypted=" + encrypted + "]"; } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java index 263f1df3c7..cf1e7d48fb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ImageAttribute.java @@ -20,11 +20,9 @@ * * An attribute of an AMI. * - * @author Adrian Cole * @see EC2AsyncClient#modifyImageAttribute * @see EC2AsyncClient#resetImageAttribute * @see EC2AsyncClient#describeImageAttribute - * */ public enum ImageAttribute { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java index 137e4928ad..2a38809481 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceState.java @@ -24,11 +24,9 @@ * * The current state of the instance.. * - * @author Adrian Cole * @see EC2AsyncClient#describeInstances * @see EC2AsyncClient#runInstances * @see EC2AsyncClient#terminateInstances - * */ public enum InstanceState { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java index cae658324f..5f454efb3b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceStateChange.java @@ -23,7 +23,6 @@ * * @see - * @author Adrian Cole */ public class InstanceStateChange implements Comparable { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java index b57811c16d..32fcec537b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/InstanceType.java @@ -20,11 +20,9 @@ * * The type of the instance. Description accurate as of 8-15-2009 release. * - * @author Adrian Cole * @see EC2AsyncClient#describeInstances * @see EC2AsyncClient#runInstances * @see EC2AsyncClient#terminateInstances - * */ public class InstanceType { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java index 03cf5e8346..74e6f17663 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/KeyPair.java @@ -26,7 +26,6 @@ * @see - * @author Adrian Cole */ public class KeyPair implements Comparable { @Override diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java index 94659281da..4103286376 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PasswordData.java @@ -35,8 +35,6 @@ * @see doc - * - * @author Richard Downer */ public class PasswordData { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java index 611b19d112..355fc06101 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Permission.java @@ -27,7 +27,6 @@ * * @see - * @author Adrian Cole */ public class Permission { private final Set groups = Sets.newHashSet(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java index f0f02703e2..b0d24bff28 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/PublicIpInstanceIdPair.java @@ -24,7 +24,6 @@ * * @see - * @author Adrian Cole */ public class PublicIpInstanceIdPair implements Comparable { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java index 85db98eb49..4fb7e22bf4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Reservation.java @@ -33,7 +33,6 @@ * @see - * @author Adrian Cole */ public class Reservation extends ForwardingSet implements Comparable> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java index 779fe9c34a..4dfd868c87 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/ReservedInstancesOffering.java @@ -20,7 +20,6 @@ * * @see - * @author Adrian Cole */ public class ReservedInstancesOffering implements Comparable { private final String region; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java index 687d8422d1..0b6e99e2d4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RootDeviceType.java @@ -21,8 +21,6 @@ /** * The root device type used by the AMI. The AMI can use an Amazon EBS or instance store root * device. - * - * @author Adrian Cole */ public enum RootDeviceType { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java index 725165acdf..ee359015d5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/RunningInstance.java @@ -38,7 +38,6 @@ * * @see - * @author Adrian Cole */ public class RunningInstance implements Comparable { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java index caccebcb43..5db66eda98 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/SecurityGroup.java @@ -33,7 +33,6 @@ * @see - * @author Adrian Cole */ public class SecurityGroup extends ForwardingSet { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java index 1800d336d7..64faabb5fc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Snapshot.java @@ -24,7 +24,6 @@ * * @see - * @author Adrian Cole */ public class Snapshot implements Comparable { public static enum Status { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java index 5e14ad8f26..eecc169195 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Subnet.java @@ -28,9 +28,6 @@ * Amazon EC2 VPCs contain one or more subnets. * * @see doc - * - * @author Adrian Cole - * @author Andrew Bayer */ public final class Subnet { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java index e64048807a..4c2b376694 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Tag.java @@ -30,8 +30,6 @@ * @see doc - * - * @author Adrian Cole */ public class Tag { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java similarity index 95% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java index 657ad177fe..5177cb02e6 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/UserIdGroupPair.java @@ -23,15 +23,14 @@ * @see - * @author Adrian Cole */ public class UserIdGroupPair implements Comparable { private final String userId; private final String groupName; public UserIdGroupPair(String userId, String groupName) { - this.userId = checkNotNull(userId,"userId"); - this.groupName = checkNotNull(groupName,"groupName"); + this.userId = checkNotNull(userId, "userId"); + this.groupName = checkNotNull(groupName, "groupName"); } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java index ce5dc3313b..68ddc33178 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/VirtualizationType.java @@ -20,8 +20,6 @@ /** * Virtualization type of the image. - * - * @author Adrian Cole */ public enum VirtualizationType { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java similarity index 80% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java index a5ca30b301..76e40c1d2f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/domain/Volume.java @@ -32,7 +32,6 @@ * @see - * @author Adrian Cole, Andrei Savu */ public class Volume implements Comparable { @@ -44,7 +43,6 @@ public Builder toBuilder() { * Specifies whether the instance's Amazon EBS volumes are stopped or terminated when the * instance is shut down. * - * @author Adrian Cole */ public static enum InstanceInitiatedShutdownBehavior { STOP, TERMINATE, UNRECOGNIZED; @@ -100,6 +98,11 @@ public static class Builder { private Status status; private Date createTime; private Set attachments = ImmutableSet.of(); + @Nullable + private String volumeType; + @Nullable + private Integer iops; + private boolean encrypted = false; public Builder region(String region) { this.region = region; @@ -145,15 +148,31 @@ public Builder attachments(Set attachments) { this.attachments = ImmutableSet.copyOf(attachments); return this; } - + + public Builder volumeType(String volumeType) { + this.volumeType = volumeType; + return this; + } + + public Builder iops(Integer iops) { + this.iops = iops; + return this; + } + + public Builder encrypted(boolean encrypted) { + this.encrypted = encrypted; + return this; + } + public Volume build() { - return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, attachments); + return new Volume(region, id, size, snapshotId, availabilityZone, status, createTime, + volumeType, iops, encrypted, attachments); } public Builder fromVolume(Volume in) { return region(in.region).id(in.id).size(in.size).snapshotId(in.snapshotId) .availabilityZone(in.availabilityZone).status(in.status).createTime(in.createTime) - .attachments(in.attachments); + .volumeType(in.volumeType).iops(in.iops).encrypted(in.encrypted).attachments(in.attachments); } } @@ -167,8 +186,14 @@ public Builder fromVolume(Volume in) { private final Date createTime; private final Set attachments; + @Nullable + private final String volumeType; + @Nullable + private final Integer iops; + private final boolean encrypted; + public Volume(String region, String id, int size, String snapshotId, String availabilityZone, Volume.Status status, - Date createTime, Iterable attachments) { + Date createTime, String volumeType, Integer iops, boolean encrypted, Iterable attachments) { this.region = checkNotNull(region, "region"); this.id = id; this.size = size; @@ -176,6 +201,9 @@ public Volume(String region, String id, int size, String snapshotId, String avai this.availabilityZone = availabilityZone; this.status = status; this.createTime = createTime; + this.volumeType = volumeType; + this.iops = iops; + this.encrypted = encrypted; this.attachments = ImmutableSet.copyOf(attachments); } @@ -214,6 +242,18 @@ public Date getCreateTime() { return createTime; } + public String getVolumeType() { + return volumeType; + } + + public Integer getIops() { + return iops; + } + + public boolean getEncrypted() { + return encrypted; + } + public Set getAttachments() { return attachments; } @@ -230,7 +270,10 @@ public int hashCode() { result = prime * result + size; result = prime * result + ((snapshotId == null) ? 0 : snapshotId.hashCode()); result = prime * result + ((status == null) ? 0 : status.hashCode()); - return result; + result = prime * result + ((volumeType == null) ? 0 : volumeType.hashCode()); + result = prime * result + ((iops == null) ? 0 : iops.hashCode()); + result = prime * result + (encrypted ? 1249 : 1259); + return result; } @Override @@ -279,6 +322,18 @@ public boolean equals(Object obj) { return false; } else if (!status.equals(other.status)) return false; + if (volumeType == null) { + if (other.volumeType != null) + return false; + } else if (!volumeType.equals(other.volumeType)) + return false; + if (iops == null) { + if (other.iops != null) + return false; + } else if (!iops.equals(other.iops)) + return false; + if (encrypted != other.encrypted) + return false; return true; } @@ -290,7 +345,8 @@ public int compareTo(Volume that) { @Override public String toString() { return "Volume [attachments=" + attachments + ", availabilityZone=" + availabilityZone + ", createTime=" - + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId - + ", status=" + status + "]"; + + createTime + ", id=" + id + ", region=" + region + ", size=" + size + ", snapshotId=" + snapshotId + + ", status=" + status + ", volumeType=" + volumeType + ", iops=" + iops + ", encrypted=" + encrypted + + "]"; } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java index bdc7756322..71e513a6f2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AMIApi.java @@ -57,8 +57,6 @@ /** * Provides access to AMI Services. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java index 7de7a48a13..eae60e2e6a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApi.java @@ -45,8 +45,6 @@ /** * Provides access to EC2 Availability Zones and Regions via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java similarity index 95% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java index 69c92bf07c..0da808b76c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticBlockStoreApi.java @@ -37,6 +37,7 @@ import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.options.CreateSnapshotOptions; +import org.jclouds.ec2.options.CreateVolumeOptions; import org.jclouds.ec2.options.DescribeSnapshotsOptions; import org.jclouds.ec2.options.DetachVolumeOptions; import org.jclouds.ec2.xml.AttachmentHandler; @@ -61,8 +62,6 @@ /** * Provides access to EC2 Elastic Block Store services via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost @@ -166,6 +165,36 @@ Volume createVolumeInAvailabilityZone( @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, @FormParam("Size") int size); + /** + * Creates a new Amazon EBS volume to which any Amazon EC2 instance can attach within the same + * Availability Zone. For more information about Amazon EBS, go to the Amazon Elastic Compute + * Cloud Developer Guide or Amazon Elastic Compute Cloud User Guide. + * + * @param availabilityZone + * An Amazon EBS volume must be located within the same Availability Zone as the + * instance to which it attaches. + * @param options + * options like specifying a snapshot, EBS volume type, etc + * + * + * @see #describeVolumesInRegion + * @see #deleteVolumeInRegion + * @see #attachVolumeInRegion + * @see #detachVolumeInRegion + * @see AvailabilityZoneAndRegionApi#describeAvailabilityZonesInRegion + * @see + */ + @Named("CreateVolume") + @POST + @Path("/") + @FormParams(keys = ACTION, values = "CreateVolume") + @XMLResponseParser(CreateVolumeResponseHandler.class) + Volume createVolumeInAvailabilityZone( + @EndpointParam(parser = ZoneToEndpoint.class) @FormParam("AvailabilityZone") String availabilityZone, + CreateVolumeOptions... options); + /** * Describes the specified Amazon EBS volumes that you own. If you do not specify one or more * volume IDs, Amazon EBS describes all volumes that you own. For more information about Amazon diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java index 3401cde1d0..89e0230f51 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/ElasticIPAddressApi.java @@ -48,8 +48,6 @@ /** * Provides access to EC2 Elastic IP Addresses via REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java index 5d7a5913ba..830773dc9e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/InstanceApi.java @@ -66,8 +66,6 @@ /** * Provides access to EC2 Instance Services via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java index c10f3eb342..ee9209ed56 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/KeyPairApi.java @@ -47,8 +47,6 @@ /** * Provides access to EC2 via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java index c082bd0f2c..28fd4972d5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SecurityGroupApi.java @@ -50,8 +50,6 @@ /** * Provides access to EC2 via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java index c9aa1c43cb..e4a773c51e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/SubnetApi.java @@ -43,8 +43,6 @@ * * @see doc - * @author Adrian Cole - * @author Andrew Bayer */ @SinceApiVersion("2011-01-01") @RequestFilters(FormSigner.class) diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java index cdc6623c34..05ac06aaf2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/TagApi.java @@ -49,7 +49,6 @@ * @see doc - * @author Adrian Cole */ @SinceApiVersion("2010-08-31") @RequestFilters(FormSigner.class) diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java index 5461b2331d..4cb7147638 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/features/WindowsApi.java @@ -55,7 +55,6 @@ *

* * @see doc - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java index d44dc29659..0ff9dde1be 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedString.java @@ -26,8 +26,6 @@ /** * Binds base64 encodes the byte [] input - * - * @author Adrian Cole */ @Singleton public class ConvertUnencodedBytesToBase64EncodedString implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java index 9099a41acb..f42022ce1b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64.java @@ -33,7 +33,6 @@ * @see - * @author Adrian Cole */ @Singleton public class EncodedRSAPublicKeyToBase64 implements Function { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java index ec655ae5ea..6347e21b41 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java @@ -43,7 +43,6 @@ * String imageId = connection.getWindowsServices().bundleInstanceInRegion(...bucketOwnedBy(anotherAccessKey)); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java index 8c604d5143..04a63d1cf0 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateImageOptions.java @@ -33,7 +33,6 @@ * Future> images = connection.getAMIApi().get().createImage(withDescription("123125").noReboot()); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java index 2c05a27783..ffe40fcb5b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateSnapshotOptions.java @@ -33,7 +33,6 @@ * Snapshot snapshot = connection.getElasticBlockStoreApi().get().createSnapshotInRegion(volumeId, withDescription("123125")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateVolumeOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateVolumeOptions.java new file mode 100644 index 0000000000..9c2e1821ad --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/CreateVolumeOptions.java @@ -0,0 +1,146 @@ +/* + * 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.jclouds.ec2.options; + +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; + +/** + * Contains options supported in the Form API for the CreateVolume operation.

+ * Usage

The recommended way to instantiate a CreateVolumeOptions object is to statically + * import CreateVolumeOptions.Builder.* and invoke a static creation method followed by an + * instance mutator (if needed): + *

+ * + * import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.* + *

+ * EC2Api connection = // get connection + * Volume volume = connection.getElasticBlockStoreApi().get().createVolumeInAvailabilityZone(availabilityZone, fromSnapshotId("123125")); + * + * + * @see + */ +public class CreateVolumeOptions extends BaseEC2RequestOptions { + + /** + * Snapshot ID to create this volume from. + */ + public CreateVolumeOptions withSize(int size) { + formParameters.put("Size", Integer.toString(size)); + return this; + } + + public int getSize() { + return Integer.parseInt(getFirstFormOrNull("Size")); + } + + /** + * Snapshot ID to create this volume from. + */ + public CreateVolumeOptions fromSnapshotId(String snapshotId) { + formParameters.put("SnapshotId", checkNotNull(snapshotId, "snapshotId")); + return this; + } + + public String getSnapshotId() { + return getFirstFormOrNull("SnapshotId"); + } + + /** + * EBS volume type to use - if not specified, will be "standard". + */ + public CreateVolumeOptions volumeType(String volumeType) { + formParameters.put("VolumeType", checkNotNull(volumeType, "volumeType")); + return this; + } + + public String getVolumeType() { + return getFirstFormOrNull("VolumeType"); + } + + /** + * EBS provisioned IOPS + */ + public CreateVolumeOptions withIops(Integer iops) { + formParameters.put("Iops", checkNotNull(iops, "iops").toString()); + return this; + } + + public Integer getIops() { + return Integer.valueOf(getFirstFormOrNull("Iops")); + } + + /** + * Should this EBS volume be encrypted? + */ + public CreateVolumeOptions isEncrypted(boolean encrypted) { + if (encrypted) + formParameters.put("Encrypted", "true"); + return this; + } + + public boolean getEncrypted() { + return Boolean.parseBoolean(getFirstFormOrNull("Encrypted")); + } + + public static class Builder { + + /** + * @see CreateVolumeOptions#fromSnapshotId(String) + */ + public static CreateVolumeOptions fromSnapshotId(String snapshotId) { + CreateVolumeOptions options = new CreateVolumeOptions(); + return options.fromSnapshotId(snapshotId); + } + + /** + * @see CreateVolumeOptions#withSize(int) + */ + public static CreateVolumeOptions withSize(int size) { + CreateVolumeOptions options = new CreateVolumeOptions(); + return options.withSize(size); + } + + /** + * @see CreateVolumeOptions#volumeType(String) + */ + public static CreateVolumeOptions volumeType(String volumeType) { + CreateVolumeOptions options = new CreateVolumeOptions(); + return options.volumeType(volumeType); + } + + /** + * @see CreateVolumeOptions#withIops(Integer) + */ + public static CreateVolumeOptions withIops(Integer iops) { + CreateVolumeOptions options = new CreateVolumeOptions(); + return options.withIops(iops); + } + + /** + * @see CreateVolumeOptions#isEncrypted(boolean) + */ + public static CreateVolumeOptions isEncrypted(boolean encrypted) { + CreateVolumeOptions options = new CreateVolumeOptions(); + return options.isEncrypted(encrypted); + } + } + +} diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java index 5b3f6936c9..daef882ed1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeAvailabilityZonesOptions.java @@ -34,7 +34,6 @@ * Future> images = connection.getAvailabilityZoneAndRegionApi().get().describeAvailabilityZones(zones("us-east-1a", "us-east-1b")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java index d81ba887d0..5e4720628b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeImagesOptions.java @@ -35,7 +35,6 @@ * Future> images = connection.getAMIApi().get().describeImages(executableBy("123125").imageIds(1000, 1004)); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java index 594194d628..670b06f4e2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeRegionsOptions.java @@ -34,7 +34,6 @@ * Future> images = connection.getRegionsAndRegionsServices().describeRegions(regions("us-east-1a", "us-east-1b")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java index 8dfe3cb7e0..31a4486171 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DescribeSnapshotsOptions.java @@ -33,7 +33,6 @@ * Set snapshots = connection.getElasticBlockStoreApi().get().describeSnapshots(restorableBy("123125").snapshotIds(1000, 1004)); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java index 0b9fc89e02..0777402183 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/DetachVolumeOptions.java @@ -33,7 +33,6 @@ * client.getElasticBlockStoreApi().get().detachVolumeInRegion(null, id, fromDevice("123125").force()); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java similarity index 62% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java index 1da21c0ede..813593a5b7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptions.java @@ -35,7 +35,6 @@ * String imageId = connection.getImageServices().registerImageBackedByEbs(...addEphemeralBlockDeviceFromSnapshot("/dev/sda2","virtual-1","snapshot-id")); * * - * @author Adrian Cole * @see @@ -95,9 +94,90 @@ public RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceN /** * + * adds a block device to the image from an ebs snapshot. + * + * @param deviceName + * The device name (e.g., /dev/sdh). + * @param virtualName + * The virtual device name. (nullable) + * @param snapshotId + * The ID of the snapshot. + * @param deleteOnTermination + * Whether this volume should be automatically deleted on instance termination. + * Defaults to false. + * @param volumeType + * What EBS volume type should be used. + * @param iops + * EBS provisioned IOPS for this volume. + * @param encrypted + * Whether this volume should be encrypted. + */ + public RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, + @Nullable String virtualName, String snapshotId, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, boolean encrypted) { + + addAdvancedEbsOptions(deleteOnTermination, volumeType, iops, encrypted); + addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); + + return this; + } + + /** + * + * adds a new block device to the image. + * + * @param deviceName + * The device name (e.g., /dev/sdh). + * @param virtualName + * The virtual device name. (nullable) + * @param volumeSize + * The size of the volume, in GiBs.. + * @param deleteOnTermination + * Whether this volume should be automatically deleted on instance termination. + * Defaults to false. + * @param volumeType + * What EBS volume type should be used. + * @param iops + * EBS provisioned IOPS for this volume. + * @param encrypted + * Whether this volume should be encrypted. + */ + public RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName, + @Nullable String virtualName, + int volumeSize, + boolean deleteOnTermination, + @Nullable String volumeType, + @Nullable Integer iops, + boolean encrypted) { + addAdvancedEbsOptions(deleteOnTermination, volumeType, iops, encrypted); + addNewEphemeralBlockDevice(deviceName, virtualName, volumeSize); + + return this; + } + + private RegisterImageBackedByEbsOptions addAdvancedEbsOptions(boolean deleteOnTermination, + @Nullable String volumeType, + @Nullable Integer iops, + boolean encrypted) { + + formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", + Boolean.toString(deleteOnTermination)); + + if (volumeType != null) + formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.VolumeType", volumeType); + if (iops != null) + formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.Iops", iops.toString()); + if (encrypted) + formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.Encrypted", "true"); + + return this; + } + + /** + * * adds a block device to the image from an ebs snapshot. This device is retained on instance * termination. - * + * * @param name * The device name (e.g., /dev/sdh). * @param virtualName @@ -106,7 +186,7 @@ public RegisterImageBackedByEbsOptions addNewEphemeralBlockDevice(String deviceN * The ID of the snapshot. */ public RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, - @Nullable String virtualName, String snapshotId) { + @Nullable String virtualName, String snapshotId) { formParameters.put("BlockDeviceMapping." + deviceIndex + ".Ebs.DeleteOnTermination", "false"); addEphemeralBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); return this; @@ -172,6 +252,21 @@ public static RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String return options.addBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId); } + /** + * @see RegisterImageBackedByEbsOptions#addBlockDeviceFromSnapshot(String, String, String, boolean, String, Integer, boolean) + */ + public static RegisterImageBackedByEbsOptions addBlockDeviceFromSnapshot(String deviceName, + @Nullable String virtualName, + String snapshotId, + boolean deleteOnTermination, + @Nullable String volumeType, + @Nullable Integer iops, + boolean encrypted) { + RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); + return options.addBlockDeviceFromSnapshot(deviceName, virtualName, snapshotId, deleteOnTermination, + volumeType, iops, encrypted); + } + /** * @see RegisterImageBackedByEbsOptions#addEphemeralBlockDeviceFromSnapshot(String, String, * String) @@ -191,6 +286,21 @@ public static RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceNam return options.addNewBlockDevice(deviceName, virtualName, volumeSize); } + /** + * @see RegisterImageBackedByEbsOptions#addNewBlockDevice(String, String, int, boolean, String, Integer, boolean) + */ + public static RegisterImageBackedByEbsOptions addNewBlockDevice(String deviceName, + @Nullable String virtualName, + int volumeSize, + boolean deleteOnTermination, + @Nullable String volumeType, + @Nullable Integer iops, + boolean encrypted) { + RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); + return options.addNewBlockDevice(deviceName, virtualName, volumeSize, deleteOnTermination, + volumeType, iops, encrypted); + } + /** * @see RegisterImageBackedByEbsOptions#addNewEphemeralBlockDevice(String, String, int) */ diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java index 76c2a01f85..178d9b2098 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RegisterImageOptions.java @@ -34,7 +34,6 @@ * String imageId = connection.getImageServices().registerImageFromManifest(...withArchitecture(Architecture.I386).withDescription("description")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java similarity index 85% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java index 7ccb209a7e..95975da69c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/options/RunInstancesOptions.java @@ -38,7 +38,6 @@ * Future instances = connection.runInstances(executableBy("123125").imageIds(1000, 1004)); * * - * @author Adrian Cole * @see @@ -140,11 +139,27 @@ public RunInstancesOptions withBlockDeviceMappings(Sethere for more details. + */ + public RunInstancesOptions withClientToken(String clientToken) { + formParameters.put("ClientToken", checkNotNull(clientToken, "clientToken")); + return this; + } + public static class Builder { /** * @see RunInstancesOptions#withKeyName(String) @@ -171,7 +186,7 @@ public static RunInstancesOptions withUserData(byte[] unencodedData) { } /** - * @see RunInstancesOptions#asType(InstanceType) + * @see RunInstancesOptions#asType(String) */ public static RunInstancesOptions asType(String instanceType) { RunInstancesOptions options = new RunInstancesOptions(); @@ -202,5 +217,13 @@ public static RunInstancesOptions withBlockDeviceMappings(Set { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java index 893e6898f5..28fe078df0 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateRunning.java @@ -32,8 +32,6 @@ /** * * Tests to see if a task succeeds. - * - * @author Adrian Cole */ @Singleton public class InstanceStateRunning implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java index 644d858124..1d8be7beff 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateStopped.java @@ -31,8 +31,6 @@ /** * * Tests to see if a task succeeds. - * - * @author Adrian Cole */ @Singleton public class InstanceStateStopped implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java index 8c9a3fdb10..102b3e847c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/InstanceStateTerminated.java @@ -33,8 +33,6 @@ /** * * Tests to see if a task succeeds. - * - * @author Adrian Cole */ @Singleton public class InstanceStateTerminated implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java index ef5281a888..9ec5a03501 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/SnapshotCompleted.java @@ -32,8 +32,6 @@ /** * * Tests to see if a snapshot is completed. - * - * @author Adrian Cole */ @Singleton public class SnapshotCompleted implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java index f3ebfaf2b2..8eb4303c3a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAttached.java @@ -32,8 +32,6 @@ /** * * Tests to see if a volume is attached. - * - * @author Adrian Cole */ @Singleton public class VolumeAttached implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java index 9688add7b3..051531c2e5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeAvailable.java @@ -30,8 +30,6 @@ /** * * Tests to see if a volume is completed. - * - * @author Adrian Cole */ @Singleton public class VolumeAvailable implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java index accabe8284..55995bb9b7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/predicates/VolumeDetached.java @@ -32,8 +32,6 @@ /** * Tests to see if a volume is detached. - * - * @author Karthik Arunachalam */ @Singleton public class VolumeDetached implements Predicate { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java similarity index 94% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java index 0d4578952a..a30c627a6b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/reference/EC2Constants.java @@ -19,10 +19,8 @@ /** * Configuration properties and constants used in EC2 connections. - * - * @author Adrian Cole */ -public interface EC2Constants { +public class EC2Constants { /** * Listing the universe of amis is extremely expensive. set this to a comma separated value of * the ami owners you wish to use in {@link ComputeService} @@ -46,4 +44,7 @@ public interface EC2Constants { */ public static final String PROPERTY_EC2_GENERATE_INSTANCE_NAMES = "jclouds.ec2.generate-instance-names"; + protected EC2Constants() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegion.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/suppliers/DescribeRegionsForRegionURIs.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java index cc2b68a2cb..99e25242d5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/IpPermissions.java @@ -36,8 +36,6 @@ /** * * Shortcut to create ingress rules - * - * @author Adrian Cole */ public class IpPermissions extends IpPermission { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java index 6944bb3a6e..e1a23b3fa7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/SubnetFilterBuilder.java @@ -45,8 +45,6 @@ * example, a value of {@code \*amazon\?\\} searches for the literal string * {@code *amazon?\}. * - * @author Adrian Cole - * @author Andrew Bayer * @see SubnetApi */ public class SubnetFilterBuilder extends ImmutableMultimap.Builder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java index c2ccedd2b5..f0b5715a3c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/TagFilterBuilder.java @@ -44,7 +44,6 @@ * example, a value of {@code \*amazon\?\\} searches for the literal string * {@code *amazon?\}. * - * @author Adrian Cole * @see TagApi */ public class TagFilterBuilder extends ImmutableMultimap.Builder { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/Tags.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/Tags.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/Tags.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/Tags.java index 23e5ca1816..066f92c4f5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/util/Tags.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/util/Tags.java @@ -25,10 +25,6 @@ import com.google.common.base.Function; import com.google.common.collect.Maps; -/** - * - * @author Adrian Cole - */ public class Tags { private Tags() { } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java index a7982010de..ec50f4494f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AllocateAddressResponseHandler.java @@ -21,9 +21,6 @@ import org.jclouds.http.functions.ParseSax.HandlerWithResult; import org.jclouds.logging.Logger; -/** - * @author Adrian Cole - */ public class AllocateAddressResponseHandler extends HandlerWithResult { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java index 24affca4b3..af532fa39d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/AttachmentHandler.java @@ -31,10 +31,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class AttachmentHandler extends ParseSax.HandlerForGeneratedRequestWithResult { @Resource diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java index 521d5a621a..969d8acf69 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BaseReservationHandler.java @@ -41,10 +41,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ public abstract class BaseReservationHandler extends HandlerForGeneratedRequestWithResult { protected final DateCodec dateCodec; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java index fc5a33f1ae..962a53e3d7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BlockDeviceMappingHandler.java @@ -28,10 +28,6 @@ import com.google.common.collect.Maps; import com.google.inject.Inject; -/** - * - * @author Adrian Cole - */ public class BlockDeviceMappingHandler extends ParseSax.HandlerWithResult> { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java index 35112d956d..b04386452d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BooleanValueHandler.java @@ -22,7 +22,6 @@ * * @see - * @author Adrian Cole */ public class BooleanValueHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java index 2ffebc278d..48419af912 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/BundleTaskHandler.java @@ -29,10 +29,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class BundleTaskHandler extends ParseSax.HandlerForGeneratedRequestWithResult { protected final DateCodec dateCodec; protected final Supplier defaultRegion; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java similarity index 91% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java index ca1c77d378..af910a70d4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/CreateVolumeResponseHandler.java @@ -18,13 +18,16 @@ import static com.google.common.base.Preconditions.checkNotNull; +import javax.inject.Inject; import java.util.Date; import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import javax.inject.Inject; - +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.jclouds.aws.util.AWSUtils; import org.jclouds.date.DateCodec; import org.jclouds.date.DateCodecFactory; @@ -37,15 +40,6 @@ import org.jclouds.rest.internal.GeneratedHttpRequest; import org.xml.sax.Attributes; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - -/** - * - * @author Adrian Cole - */ public class CreateVolumeResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult { protected final DateCodec dateCodec; protected final Supplier defaultRegion; @@ -77,6 +71,9 @@ protected CreateVolumeResponseHandler(DateCodecFactory dateCodecFactory, @Region protected String device; protected Attachment.Status attachmentStatus; protected Date attachTime; + protected String volumeType; + protected Integer iops; + protected boolean encrypted; protected boolean inAttachmentSet; @@ -129,6 +126,14 @@ public void endElement(String uri, String name, String qName) { device = currentText.toString().trim(); } else if (qName.equals("attachTime")) { attachTime = dateCodec.toDate(currentText.toString().trim()); + } else if (qName.equals("volumeType")) { + volumeType = currentText.toString().trim(); + if (volumeType.equals("")) + volumeType = null; + } else if (qName.equals("iops")) { + iops = Integer.parseInt(currentText.toString().trim()); + } else if (qName.equals("encrypted")) { + encrypted = Boolean.parseBoolean(currentText.toString().trim()); } else if (qName.equals("item")) { if (inAttachmentSet) { attachments.add(new Attachment(region, volumeId, instanceId, device, attachmentStatus, attachTime)); @@ -144,7 +149,8 @@ public void endElement(String uri, String name, String qName) { } private Volume newVolume() { - Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, attachments); + Volume volume = new Volume(region, id, size, snapshotId, availabilityZone, volumeStatus, createTime, + volumeType, iops, encrypted, attachments); id = null; size = 0; snapshotId = null; @@ -152,6 +158,9 @@ private Volume newVolume() { volumeStatus = null; createTime = null; attachments = Sets.newLinkedHashSet(); + volumeType = null; + iops = null; + encrypted = false; return volume; } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java index 731b8ff780..dd0a1e14fe 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandler.java @@ -30,10 +30,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ public class DescribeAddressesResponseHandler extends HandlerForGeneratedRequestWithResult> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java index 66d1403b2f..403979470f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandler.java @@ -30,10 +30,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ public class DescribeAvailabilityZonesResponseHandler extends ParseSax.HandlerWithResult> { private StringBuilder currentText = new StringBuilder(); private final Supplier defaultRegion; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java index 1d826ce85a..7724f5b8ca 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandler.java @@ -29,9 +29,6 @@ import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class DescribeBundleTasksResponseHandler extends ParseSax.HandlerWithResult> { private Set bundleTasks = Sets.newLinkedHashSet(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java similarity index 93% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java index b55875a539..8cfea0ff98 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeImagesResponseHandler.java @@ -19,36 +19,33 @@ import static org.jclouds.util.SaxUtils.currentOrNull; import static org.jclouds.util.SaxUtils.equalsOrSuffix; -import java.util.Map; -import java.util.Set; - import javax.annotation.Resource; import javax.inject.Inject; +import java.util.Map; +import java.util.Set; +import com.google.common.base.Supplier; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.jclouds.aws.util.AWSUtils; import org.jclouds.ec2.domain.Hypervisor; import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.domain.RootDeviceType; -import org.jclouds.ec2.domain.VirtualizationType; import org.jclouds.ec2.domain.Image.Architecture; import org.jclouds.ec2.domain.Image.EbsBlockDevice; import org.jclouds.ec2.domain.Image.ImageState; import org.jclouds.ec2.domain.Image.ImageType; +import org.jclouds.ec2.domain.RootDeviceType; +import org.jclouds.ec2.domain.VirtualizationType; import org.jclouds.http.functions.ParseSax; import org.jclouds.location.Region; import org.jclouds.logging.Logger; import org.xml.sax.Attributes; -import com.google.common.base.Supplier; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - /** * Parses the following XML document: *

* DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" * - * @author Adrian Cole * @see */ @@ -95,7 +92,9 @@ public DescribeImagesResponseHandler(@Region Supplier defaultRegion, Tag private int volumeSize; private boolean deleteOnTermination = true;// correct default is true. - + private boolean encrypted = false; + private String volumeType; + private Integer iops; private String rootDeviceName; public Set getResult() { @@ -160,6 +159,12 @@ public void endElement(String uri, String name, String qName) { volumeSize = Integer.parseInt(currentText.toString().trim()); } else if (qName.equals("deleteOnTermination")) { deleteOnTermination = Boolean.parseBoolean(currentText.toString().trim()); + } else if (qName.equals("encrypted")) { + encrypted = Boolean.parseBoolean(currentText.toString().trim()); + } else if (qName.equals("iops")) { + iops = Integer.valueOf(currentText.toString().trim()); + } else if (qName.equals("volumeType")) { + volumeType = currentText.toString().trim(); } else if (qName.equals("ramdiskId")) { ramdiskId = currentText.toString().trim(); } else if (qName.equals("rootDeviceType")) { @@ -172,11 +177,15 @@ public void endElement(String uri, String name, String qName) { hypervisor = Hypervisor.fromValue(currentText.toString().trim()); } else if (qName.equals("item")) { if (inBlockDeviceMapping) { - ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize, deleteOnTermination)); + ebsBlockDevices.put(deviceName, new Image.EbsBlockDevice(snapshotId, volumeSize, deleteOnTermination, + volumeType, iops, encrypted)); this.deviceName = null; this.snapshotId = null; this.volumeSize = 0; this.deleteOnTermination = true; + this.encrypted = false; + this.volumeType = null; + this.iops = null; } else if (!inTagSet && !inProductCodes) { try { String region = getRequest() != null ? AWSUtils.findRegionInArgsOrNull(getRequest()) : null; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java index 2dc4c63148..f154fe40d8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandler.java @@ -37,7 +37,6 @@ *

* DescribeImagesResponse xmlns="http: * - * @author Adrian Cole * @see - * @author Adrian Cole */ public class DescribeKeyPairsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { private final Supplier defaultRegion; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java index a9607febed..b0dab5e313 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandler.java @@ -26,10 +26,6 @@ import com.google.common.collect.Maps; -/** - * - * @author Adrian Cole - */ public class DescribeRegionsResponseHandler extends ParseSax.HandlerWithResult> { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java index 8a00ac4a94..abd7fd4f21 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandler.java @@ -39,7 +39,6 @@ * @see - * @author Adrian Cole */ public class DescribeSecurityGroupsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java index a3c5870e9b..4aa1f704d4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandler.java @@ -28,9 +28,6 @@ import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class DescribeSnapshotsResponseHandler extends ParseSax.HandlerWithResult> { private Set snapshots = Sets.newLinkedHashSet(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java index 20037d04d5..cac4b2de02 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeSubnetsResponseHandler.java @@ -29,9 +29,6 @@ /** * @see xml - * - * @author Adrian Cole - * @author Andrew Bayer */ public class DescribeSubnetsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java index 2824634c8c..9efd6fb9eb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeTagsResponseHandler.java @@ -32,8 +32,6 @@ * @see xml - * - * @author Adrian Cole */ public class DescribeTagsResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java index 7eb5c50705..aa51fa3b1b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandler.java @@ -28,9 +28,6 @@ import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class DescribeVolumesResponseHandler extends ParseSax.HandlerWithResult> { private Set volumes = Sets.newLinkedHashSet(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java index 7952c71891..3c342b13a5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandler.java @@ -24,7 +24,6 @@ import org.jclouds.http.functions.ParseSax; /** - * @author Andrew Kennedy * @see * ApiReference query GetConsoleOutput */ diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java index 26db141d7a..124af5ea04 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/GetPasswordDataResponseHandler.java @@ -23,9 +23,6 @@ import org.jclouds.ec2.domain.PasswordData; import org.jclouds.http.functions.ParseSax; -/** - * @author Richard Downer - */ public class GetPasswordDataResponseHandler extends ParseSax.HandlerWithResult { protected final DateCodec dateCodec; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java index 1c5a50d7b2..9d1939c74b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/ImageIdHandler.java @@ -24,7 +24,6 @@ * /> * @see - * @author Adrian Cole */ public class ImageIdHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java index 7111a61462..1fb81b6d06 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceInitiatedShutdownBehaviorHandler.java @@ -23,7 +23,6 @@ * * @see - * @author Adrian Cole */ public class InstanceInitiatedShutdownBehaviorHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java index 9c8933faf3..5290e6b688 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/InstanceStateChangeHandler.java @@ -37,7 +37,6 @@ * StartInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" StopInstancesResponse * xmlns="http://ec2.amazonaws.com/doc/2010-08-31/" * - * @author Adrian Cole * @see * @see - * @author Adrian Cole */ public class InstanceTypeHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java index 980ef35b84..83393fb661 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/IpPermissionHandler.java @@ -24,10 +24,6 @@ import org.jclouds.net.domain.IpProtocol; import org.xml.sax.SAXException; -/** - * - * @author Adrian Cole - */ public class IpPermissionHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java index 9f0d305965..59f8f8f707 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/KeyPairResponseHandler.java @@ -33,7 +33,6 @@ * @see - * @author Adrian Cole */ public class KeyPairResponseHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private final Supplier defaultRegion; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java index 08e088a866..0eef83fa9e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/PermissionHandler.java @@ -27,7 +27,6 @@ * * @see - * @author Adrian Cole */ public class PermissionHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java index 22a919329a..4593989b9f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/RunInstancesResponseHandler.java @@ -30,7 +30,6 @@ *

* RunInstancesResponse xmlns="http: * - * @author Adrian Cole * @see - * @author Adrian Cole */ public class StringValueHandler extends ParseSax.HandlerWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java index 6b3ca5d522..f254140965 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/SubnetHandler.java @@ -27,9 +27,6 @@ /** * @see xml - * - * @author Adrian Cole - * @author Andrew Bayer */ public class SubnetHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java index 6cd2934dc5..d3f34d04dc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagHandler.java @@ -29,8 +29,6 @@ * @see xml - * - * @author Adrian Cole */ public class TagHandler extends ParseSax.HandlerForGeneratedRequestWithResult { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java index 847b4b4ca9..af8eea18dd 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/TagSetHandler.java @@ -27,9 +27,6 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; -/** - * @author grkvlt@apache.org - */ public class TagSetHandler extends ParseSax.HandlerForGeneratedRequestWithResult> { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java index f4db176781..0b42861aa7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/java/org/jclouds/ec2/xml/UnencodeStringValueHandler.java @@ -23,7 +23,6 @@ * * @see - * @author Adrian Cole */ public class UnencodeStringValueHandler extends StringValueHandler { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java index 2a999dab45..efeaf96083 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ApiLiveTest.java @@ -71,8 +71,6 @@ * adds in functionality to boot a lamp instance: http://alestic.com/2009/06/ec2-user-data-scripts *

* Generally disabled, as it incurs higher fees. - * - * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "CloudApplicationArchitecturesEC2ApiLiveTest") public class CloudApplicationArchitecturesEC2ApiLiveTest extends BaseComputeServiceContextLiveTest { @@ -98,7 +96,7 @@ public void setupContext() { Injector injector = view.utils().injector(); client = injector.getInstance(EC2Api.class); sshFactory = injector.getInstance(SshClient.Factory.class); - runningTester = retry(new InstanceStateRunning(client), 180, 5,SECONDS); + runningTester = retry(new InstanceStateRunning(client), 180, 5, SECONDS); hasIpTester = retry(new InstanceHasIpAddress(client), 180, 5, SECONDS); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); socketTester = retry(socketOpen, 180, 1, SECONDS); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java index 3cff3f282a..ff18a9d65c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EBSBootEC2ApiLiveTest.java @@ -82,8 +82,6 @@ *

* * Generally disabled, as it incurs higher fees. - * - * @author Adrian Cole */ @Test(groups = "live", enabled = false, singleThreaded = true, testName = "EBSBootEC2ApiLiveTest") public class EBSBootEC2ApiLiveTest extends BaseComputeServiceContextLiveTest { @@ -398,7 +396,7 @@ private void verifyImage() { assertEquals(ebsImage.getRootDeviceType(), RootDeviceType.EBS); assertEquals(ebsImage.getRootDeviceName(), "/dev/sda1"); assertEquals(ebsImage.getEbsBlockDevices().entrySet(), - ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), VOLUME_SIZE, true)).entrySet()); + ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), VOLUME_SIZE, true, "standard", null, false)).entrySet()); } private void tryToChangeStuff() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java index 584c1f0322..4c5bccbc14 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ApiMetadataTest.java @@ -19,10 +19,6 @@ import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2ApiMetadataTest") public class EC2ApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java index e672fd3b43..e71f847b88 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/EC2ContextBuilderText.java @@ -23,9 +23,6 @@ import org.jclouds.compute.ComputeServiceContext; import org.testng.annotations.Test; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "EC2ContextBuilderTest") public class EC2ContextBuilderText { public void testAssignability() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java index 86973e7185..d6ca4ab004 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBlockDeviceMappingToIndexedFormParamsTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of {@code BindBlockDeviceMappingToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindBlockDeviceMappingToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java index 57963732e4..8c02c8a6a1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindBundleIdsToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindBundleIdsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindBundleIdsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java index a4edc1cb5f..de64ec419a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindFiltersToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindFiltersToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindFiltersToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java index 6a6347220c..130453b5f3 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindGroupNamesToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindGroupNamesToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindGroupNamesToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java index b5a932a26f..eff0b103be 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindInstanceIdsToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindInstanceIdsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindInstanceIdsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java index 230f678e8b..9489fa2705 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindKeyNamesToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindKeyNamesToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindKeyNamesToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java index f452a699dc..ba921df7cb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindProductCodesToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindProductCodesToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindProductCodesToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java index ae9b79e48c..9fa6751a54 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindPublicIpsToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindPublicIpsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindPublicIpsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java index e90d0e2824..ec83682bbf 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindResourceIdsToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindResourceIdsToIndexedFormParams} - * - * @author grkvlt@apache.org */ @Test(groups = "unit") public class BindResourceIdsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java index 5c92aecd3e..ab896cef44 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindS3UploadPolicyAndSignatureTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindS3UploadPolicyAndSignature} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BindS3UploadPolicyAndSignatureTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java index 05c3c625fc..93dce11ba4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagKeysToIndexedFormParamsTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code BindTagKeysToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindTagKeysToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java index 12614ba3e1..6616f5823c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindTagsToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindTagsToIndexedFormParams} - * - * @author grkvlt@apache.org */ @Test(groups = "unit") public class BindTagsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java index a58d480c65..1118b93405 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserGroupsToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindUserGroupsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindUserGroupsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java index eb8e9f8dcc..d15b4c4353 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdGroupPairToSourceSecurityGroupFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindUserIdGroupPairToSourceSecurityGroupFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindUserIdGroupPairToSourceSecurityGroupFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java index d816836ed7..4d9aa41d7e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindUserIdsToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindUserIdsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindUserIdsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java index 8208879506..6235608cff 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/BindVolumeIdsToIndexedFormParamsTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code BindVolumeIdsToIndexedFormParams} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindVolumeIdsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java index 6ef75141a9..9833f46e2c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/binders/IfNotNullBindAvailabilityZoneToFormParamTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code IfNotNullBindAvailabilityZoneToFormParam} - * - * @author Adrian Cole */ @Test(groups = "unit") public class IfNotNullBindAvailabilityZoneToFormParamTest { diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java new file mode 100644 index 0000000000..4ffad1f1b1 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceExpectTest.java @@ -0,0 +1,319 @@ +/* + * 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.jclouds.ec2.compute; + +import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.blockUntilRunning; +import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.maxCount; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import javax.ws.rs.core.MediaType; +import java.util.Set; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import org.jclouds.compute.ComputeService; +import org.jclouds.compute.domain.NodeMetadata; +import org.jclouds.ec2.compute.internal.BaseEC2ComputeServiceExpectTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * Tests the compute service abstraction of the EC2 api. + */ +@Test(groups = "unit", testName = "EC2ComputeServiceExpectTest") +public class EC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest { + protected HttpRequest createFirstTagRequest; + protected HttpRequest createSecondTagRequest; + protected HttpRequest createThirdTagRequest; + + @BeforeClass + @Override + protected void setupDefaultRequests() { + super.setupDefaultRequests(); + createFirstTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2ba64342" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=test-2ba64342" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + + createSecondTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2bc64242" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=test-2bc64242" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + + createThirdTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2be64332" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=test-2be64332" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + } + + public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUser() throws Exception { + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeImagesRequest, describeImagesResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); + requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(runInstancesRequest, runInstancesResponse); + requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); + requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse); + requestResponseMap.put(describeImageRequest, describeImagesResponse); + requestResponseMap.put(createTagsRequest, createTagsResponse); + + ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); + + NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, + blockUntilRunning(false).overrideLoginUser("ec2-user"))); + assertEquals(node.getCredentials().getUser(), "ec2-user"); + System.out.println(node.getImageId()); + assertTrue(node.getCredentials().getOptionalPrivateKey().isPresent()); + } + + public void testCreateThreeNodesWithMaxCountThree() throws Exception { + + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeImagesRequest, describeImagesResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); + requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(runThreeInstancesRequest, runThreeInstancesResponse); + requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); + requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse); + requestResponseMap.put(describeImageRequest, describeImagesResponse); + requestResponseMap.put(createFirstTagRequest, createTagsResponse); + requestResponseMap.put(createSecondTagRequest, createTagsResponse); + requestResponseMap.put(createThirdTagRequest, createTagsResponse); + + ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); + + NodeMetadata node = Iterables.getFirst(apiThatCreatesNode.createNodesInGroup("test", 3, + maxCount(3).blockUntilRunning(false).overrideLoginUser("ec2-user")), null); + assertNotNull(node, "Node should exist"); + assertEquals(node.getCredentials().getUser(), "ec2-user", "User should be ec2-user"); + } + + public void testCreateThreeNodesWithMaxCountFourGetThreeNodes() throws Exception { + + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeImagesRequest, describeImagesResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); + requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(runThreeToFourInstancesRequest, runThreeInstancesResponse); + requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); + requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse); + requestResponseMap.put(describeImageRequest, describeImagesResponse); + requestResponseMap.put(createFirstTagRequest, createTagsResponse); + requestResponseMap.put(createSecondTagRequest, createTagsResponse); + requestResponseMap.put(createThirdTagRequest, createTagsResponse); + + ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); + + NodeMetadata node = Iterables.getFirst(apiThatCreatesNode.createNodesInGroup("test", 3, + maxCount(4).blockUntilRunning(false).overrideLoginUser("ec2-user")), null); + assertNotNull(node, "Node should exist"); + assertEquals(node.getCredentials().getUser(), "ec2-user", "User should be ec2-user"); + } + + public void testCreateThreeNodesWithSpecifiedName() throws Exception { + HttpRequest createFirstNamedTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2ba64342" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=test-node" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + + HttpRequest createSecondNamedTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2bc64242" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=second-node" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + + HttpRequest createThirdNamedTagRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload( + payloadFromStringWithContentType( + "Action=CreateTags" + + "&ResourceId.1=i-2be64332" + + "&Signature=Trp5e5%2BMqeBeBZbLYa9s9gxahQ9nkx6ETfsGl82IV8Y%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Tag.1.Key=Name" + + "&Tag.1.Value=third-node" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&AWSAccessKeyId=identity", + "application/x-www-form-urlencoded")) + .build()); + + HttpResponse describeNamedInstanceResponse = + HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType( + "/describe_instances_running-named.xml", MediaType.APPLICATION_XML)).build(); + + + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeImagesRequest, describeImagesResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); + requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(runThreeInstancesRequest, runThreeInstancesResponse); + requestResponseMap.put(describeInstanceRequest, describeNamedInstanceResponse); + requestResponseMap.put(describeInstanceThreeIdsRequest, describeInstanceThreeIdsResponse); + requestResponseMap.put(describeImageRequest, describeImagesResponse); + requestResponseMap.put(createFirstNamedTagRequest, createTagsResponse); + requestResponseMap.put(createSecondNamedTagRequest, createTagsResponse); + requestResponseMap.put(createThirdNamedTagRequest, createTagsResponse); + + ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); + + Set nodes = apiThatCreatesNode.createNodesInGroup("test", 3, + maxCount(3).blockUntilRunning(false).overrideLoginUser("ec2-user").nodeNames(ImmutableSet.of("test-node", "second-node", "third-node"))); + + NodeMetadata node = Iterables.get(nodes, 0); + assertEquals(node.getName(), "test-node"); + + NodeMetadata secondNode = Iterables.get(nodes, 1); + assertEquals(secondNode.getName(), "second-node"); + + NodeMetadata thirdNode = Iterables.get(nodes, 2); + assertEquals(thirdNode.getName(), "third-node"); + } + + //FIXME - issue-1051 + @Test(enabled = false) + public void testCreateNodeWithGeneratedKeyPairAndOverriddenLoginUserWithTemplateBuilder() throws Exception { + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeImagesRequest, describeImagesResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupRequest, createSecurityGroupResponse); + requestResponseMap.put(describeSecurityGroupRequest, describeSecurityGroupResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(runInstancesRequest, runInstancesResponse); + requestResponseMap.put(describeInstanceRequest, describeInstanceResponse); + requestResponseMap.put(describeInstanceMultiIdsRequest, describeInstanceMultiIdsResponse); + requestResponseMap.put(describeImageRequest, describeImagesResponse); + requestResponseMap.put(createTagsRequest, createTagsResponse); + + ComputeService apiThatCreatesNode = requestsSendResponses(requestResponseMap.build()); + + NodeMetadata node = Iterables.getOnlyElement( + apiThatCreatesNode.createNodesInGroup("test", 1, + apiThatCreatesNode.templateBuilder().from("osDescriptionMatches=.*fedora.*,loginUser=ec2-user").build())); + assertEquals(node.getCredentials().getUser(), "ec2-user"); + assertTrue(node.getCredentials().getOptionalPrivateKey().isPresent()); + } + +} diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index e37e881da7..1fa7e4b2a5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -20,6 +20,7 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; +import java.security.SecureRandom; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -63,10 +64,6 @@ import com.google.common.net.HostAndPort; import com.google.inject.Module; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", singleThreaded = true) public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @@ -111,6 +108,8 @@ public void testImagesResolveCorrectly() { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testExtendedOptionsAndLogin() throws Exception { + final SecureRandom random = new SecureRandom(); + SecurityGroupApi securityGroupClient = view.unwrapApi(EC2Api.class) .getSecurityGroupApi().get(); @@ -125,6 +124,7 @@ public void testExtendedOptionsAndLogin() throws Exception { TemplateOptions options = client.templateOptions(); options.as(EC2TemplateOptions.class).securityGroups(group); + options.as(EC2TemplateOptions.class).clientToken(Integer.toHexString(random.nextInt(65536 * 1024))); String startedId = null; try { @@ -151,6 +151,9 @@ public void testExtendedOptionsAndLogin() throws Exception { assert first.getCredentials() != null : first; assert first.getCredentials().identity != null : first; + // Verify that the output of createNodesInGroup is the same. + assertEquals(client.createNodesInGroup(group, 1, options), nodes, "Idempotency failing - got different instances"); + startedId = Iterables.getOnlyElement(nodes).getProviderId(); RunningInstance instance = getInstance(instanceClient, startedId); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java similarity index 93% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java index e581605545..0d2150052e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderTest.java @@ -48,6 +48,8 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.compute.strategy.GetImageStrategy; +import org.jclouds.compute.suppliers.ImageCacheSupplier; import org.jclouds.domain.Location; import org.jclouds.domain.LocationBuilder; import org.jclouds.domain.LocationScope; @@ -74,8 +76,6 @@ * interaction with Amazon Web Services. * * @see EC2ComputeServiceLiveTest - * - * @author Oleksiy Yarmula */ @Test(testName = "EC2TemplateBuilderTest") public class EC2TemplateBuilderTest { @@ -172,7 +172,7 @@ public void testTemplateChoiceForInstanceByImageIdDoesNotGetAllImages() throws E // weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818 Supplier> imageCache = Suppliers.> ofInstance( - CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(imageMap)))); + CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(imageMap)))); Template template = newTemplateBuilder(images, imageCache).imageId("us-east-1/cc-image").build(); @@ -180,7 +180,7 @@ public void testTemplateChoiceForInstanceByImageIdDoesNotGetAllImages() throws E assertEquals(template.getImage().getId(), "us-east-1/cc-image"); } - @Test(expectedExceptions={NoSuchElementException.class}) + @Test(expectedExceptions = {NoSuchElementException.class}) public void testNegativeTemplateChoiceForInstanceByImageId() throws Exception { newTemplateBuilder().imageId("wrongregion/wrongimageid").build(); } @@ -202,7 +202,7 @@ private TemplateBuilder newTemplateBuilder() { @SuppressWarnings("unchecked") ImmutableMap imageMap = (ImmutableMap) ImagesToRegionAndIdMap.imagesToMap(images.get()); Supplier> imageCache = Suppliers.> ofInstance( - CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(imageMap)))); + CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(imageMap)))); return newTemplateBuilder(images, imageCache); } @@ -212,23 +212,25 @@ private TemplateBuilder newTemplateBuilder(Supplier> images Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); TemplateOptions defaultOptions = createMock(TemplateOptions.class); + GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); expect(optionsProvider.get()).andReturn(defaultOptions); replay(optionsProvider); replay(templateBuilderProvider); + replay(getImageStrategy); Supplier> locations = Suppliers.> ofInstance(ImmutableSet . of(location)); Supplier> sizes = Suppliers.> ofInstance(ImmutableSet . of(t1_micro().build(), c1_medium().build(), c1_xlarge().build(), m1_large().build(), m1_small().build(), m1_xlarge().build(), m2_xlarge().build(), m2_2xlarge().build(), - m2_4xlarge().build(),g2_2xlarge().build(),CC1_4XLARGE)); + m2_4xlarge().build(), g2_2xlarge().build(), CC1_4XLARGE)); - return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(location), optionsProvider, - templateBuilderProvider, imageCache) { + return new EC2TemplateBuilderImpl(locations, new ImageCacheSupplier(images, 60), sizes, Suppliers.ofInstance(location), optionsProvider, + templateBuilderProvider, getImageStrategy, imageCache) { }; } - + Function indexer() { return new Function() { @Override diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java similarity index 95% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index e4e576152f..863229a86a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -24,11 +24,7 @@ import com.google.common.base.Throwables; -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", testName="TestCanRecreateGroupLiveTest") +@Test(groups = "live", testName = "TestCanRecreateGroupLiveTest") public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveTest { public TestCanRecreateGroupLiveTest() { provider = "ec2"; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java index d240ef5794..cd0170c424 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/config/EC2ComputeServiceContextModuleTest.java @@ -30,9 +30,6 @@ import com.google.common.base.Supplier; import com.google.common.cache.CacheLoader; -/** - * @author Aled Sage - */ @Test(groups = "unit") public class EC2ComputeServiceContextModuleTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java index d23ca07277..4ca6c627e2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionExpectTest.java @@ -32,10 +32,6 @@ import com.google.common.collect.ImmutableMap.Builder; import com.google.common.util.concurrent.Futures; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2ImageExtensionExpectTest") public class EC2ImageExtensionExpectTest extends BaseEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java index 1f29e66197..3be04dbfe5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2ImageExtensionLiveTest.java @@ -30,9 +30,6 @@ /** * Live test for ec2 {@link ImageExtension} implementation - * - * @author David Alves - * */ @Test(groups = "live", singleThreaded = true, testName = "EC2ImageExtensionLiveTest") public class EC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java index 496026c8ac..5bb73bb32a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionExpectTest.java @@ -46,10 +46,6 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2SecurityGroupExtensionExpectTest") public class EC2SecurityGroupExtensionExpectTest extends BaseEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java index 4054e06115..7020a937d2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/extensions/EC2SecurityGroupExtensionLiveTest.java @@ -22,9 +22,6 @@ /** * Live test for ec2 {@link SecurityGroupExtension} implementation - * - * @author Andrew Bayer - * */ @Test(groups = "live", singleThreaded = true, testName = "EC2SecurityGroupExtensionLiveTest") public class EC2SecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java index 7926362e0c..015b5a794a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/AddElasticIpsToNodemetadataTest.java @@ -30,9 +30,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "AddElasticIpsToNodemetadataTest") public class AddElasticIpsToNodemetadataTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java similarity index 95% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java index ddee5e1715..5870e4e9a6 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/CreateUniqueKeyPairTest.java @@ -38,9 +38,6 @@ import com.google.inject.TypeLiteral; import com.google.inject.name.Names; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "CreateUniqueKeyPairTest") public class CreateUniqueKeyPairTest { @@ -61,7 +58,7 @@ public void testApply() throws UnknownHostException { @Override protected void configure() { - Names.bindProperties(binder(),new EC2ApiMetadata().getDefaultProperties()); + Names.bindProperties(binder(), new EC2ApiMetadata().getDefaultProperties()); bind(new TypeLiteral>() { }).toInstance(Suppliers.ofInstance("1")); bind(EC2Api.class).toInstance(client); @@ -99,7 +96,7 @@ public void testApplyWithIllegalStateException() throws UnknownHostException { @Override protected void configure() { - Names.bindProperties(binder(),new EC2ApiMetadata().getDefaultProperties()); + Names.bindProperties(binder(), new EC2ApiMetadata().getDefaultProperties()); bind(new TypeLiteral>() { }).toInstance(uniqueIdSupplier); bind(EC2Api.class).toInstance(client); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java index 808051c77d..aadc0302ae 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2ImageParserTest.java @@ -48,9 +48,6 @@ import com.google.common.collect.Sets; import com.google.inject.Guice; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2ImageParserTest") public class EC2ImageParserTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java index 61eff5b8e8..fde86fac05 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/EC2SecurityGroupToSecurityGroupTest.java @@ -31,9 +31,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "EC2SecurityGroupToSecurityGroupTest") public class EC2SecurityGroupToSecurityGroupTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java index d27b4e9f1c..0abdc0eba1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/PresentInstancesTest.java @@ -34,9 +34,6 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class PresentInstancesTest { RunningInstance instance1 = createMock(RunningInstance.class); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java index b6c04c6cb1..4228da08bf 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/RunningInstanceToNodeMetadataTest.java @@ -57,9 +57,6 @@ import com.google.inject.Guice; import com.google.inject.name.Names; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "RunningInstanceToNodeMetadataTest") public class RunningInstanceToNodeMetadataTest { @@ -284,7 +281,7 @@ public Set get() { @Override protected void configure() { - Names.bindProperties(binder(),new EC2ApiMetadata().getDefaultProperties()); + Names.bindProperties(binder(), new EC2ApiMetadata().getDefaultProperties()); } }).getInstance(GroupNamingConvention.Factory.class); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java index 532c86b3d0..3859f531e3 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/functions/WindowsLoginCredentialsFromEncryptedDataTest.java @@ -27,9 +27,6 @@ import org.jclouds.encryption.internal.JCECrypto; import org.testng.annotations.Test; -/** - * @author Richard Downer - */ public class WindowsLoginCredentialsFromEncryptedDataTest { private static final String PRIVATE_KEY = "-----BEGIN RSA PRIVATE KEY-----\n" + @@ -71,7 +68,7 @@ public void testApply() throws Exception { LoginCredentials credentials = f.apply(new PasswordDataAndPrivateKey(passwordData, PRIVATE_KEY)); assertEquals(credentials.getUser(), "Administrator"); - assertEquals(credentials.getPassword(), "u4.y9mb;nR."); + assertEquals(credentials.getOptionalPassword().get(), "u4.y9mb;nR."); assertFalse(credentials.getOptionalPrivateKey().isPresent()); } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceContextExpectTest.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java similarity index 79% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java index 610cfb7af5..4178e74e4e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/BaseEC2ComputeServiceExpectTest.java @@ -18,9 +18,8 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS; -import java.util.Properties; - import javax.ws.rs.core.MediaType; +import java.util.Properties; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; @@ -54,10 +53,15 @@ protected Properties setupProperties() { protected HttpRequest authorizeSecurityGroupIngressRequestGroup; protected HttpRequest runInstancesRequest; protected HttpResponse runInstancesResponse; + protected HttpRequest runThreeInstancesRequest; + protected HttpRequest runThreeToFourInstancesRequest; + protected HttpResponse runThreeInstancesResponse; protected HttpRequest describeInstanceRequest; protected HttpResponse describeInstanceResponse; protected HttpRequest describeInstanceMultiIdsRequest; protected HttpResponse describeInstanceMultiIdsResponse; + protected HttpRequest describeInstanceThreeIdsRequest; + protected HttpResponse describeInstanceThreeIdsResponse; protected HttpRequest describeImageRequest; protected HttpRequest createTagsRequest; protected HttpResponse createTagsResponse; @@ -177,14 +181,45 @@ protected void setupDefaultRequests() { HttpResponse.builder().statusCode(200) .payload(payloadFromResourceWithContentType( "/new_instance.xml", MediaType.APPLICATION_XML)).build(); - - describeInstanceRequest = + + runThreeInstancesRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "RunInstances") + .addFormParam("ImageId", "ami-be3adfd7") + .addFormParam("InstanceType", "m1.small") + .addFormParam("KeyName", "jclouds#test#0") + .addFormParam("MaxCount", "3") + .addFormParam("MinCount", "3") + .addFormParam("SecurityGroup.1", "jclouds#test").build()); + + runThreeToFourInstancesRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "RunInstances") + .addFormParam("ImageId", "ami-be3adfd7") + .addFormParam("InstanceType", "m1.small") + .addFormParam("KeyName", "jclouds#test#0") + .addFormParam("MaxCount", "4") + .addFormParam("MinCount", "3") + .addFormParam("SecurityGroup.1", "jclouds#test").build()); + + runThreeInstancesResponse = + HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType( + "/run_instances_three.xml", MediaType.APPLICATION_XML)).build(); + + describeInstanceRequest = formSigner.filter(HttpRequest.builder() - .method("POST") - .endpoint("https://ec2." + region + ".amazonaws.com/") - .addHeader("Host", "ec2." + region + ".amazonaws.com") - .addFormParam("Action", "DescribeInstances") - .addFormParam("InstanceId.1", "i-2baa5550").build()); + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "DescribeInstances") + .addFormParam("InstanceId.1", "i-2baa5550").build()); describeInstanceResponse = HttpResponse.builder().statusCode(200) @@ -205,6 +240,21 @@ protected void setupDefaultRequests() { .payload(payloadFromResourceWithContentType( "/describe_instances_multiple.xml", MediaType.APPLICATION_XML)).build(); + describeInstanceThreeIdsRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "DescribeInstances") + .addFormParam("InstanceId.1", "i-2ba64342") + .addFormParam("InstanceId.2", "i-2bc64242") + .addFormParam("InstanceId.3", "i-2be64332").build()); + + describeInstanceThreeIdsResponse = + HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType( + "/describe_instances_multiple.xml", MediaType.APPLICATION_XML)).build(); + //TODO: duplicate.. shouldn't need this describeImageRequest = formSigner.filter(HttpRequest.builder() diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java similarity index 80% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java index c8cc78b72c..9c7de8db44 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/internal/EC2TemplateBuilderImplTest.java @@ -37,6 +37,8 @@ import org.jclouds.compute.domain.internal.TemplateBuilderImpl; import org.jclouds.compute.domain.internal.TemplateBuilderImplTest; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.compute.strategy.GetImageStrategy; +import org.jclouds.compute.suppliers.ImageCacheSupplier; import org.jclouds.domain.Location; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.functions.ImagesToRegionAndIdMap; @@ -52,10 +54,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true) public class EC2TemplateBuilderImplTest extends TemplateBuilderImplTest { @@ -68,7 +66,7 @@ protected TemplateOptions provideTemplateOptions() { protected EC2TemplateBuilderImpl createTemplateBuilder(final Image knownImage, @Memoized Supplier> locations, @Memoized final Supplier> images, @Memoized Supplier> sizes, Location defaultLocation, - Provider optionsProvider, Provider templateBuilderProvider) { + Provider optionsProvider, Provider templateBuilderProvider, GetImageStrategy getImageStrategy) { LoadingCache imageMap; if (knownImage != null) { @@ -87,13 +85,13 @@ public Image load(RegionAndName from) { ImagesToRegionAndIdMap.imagesToMap(images.get())))); } - return new EC2TemplateBuilderImpl(locations, images, sizes, Suppliers.ofInstance(defaultLocation), - optionsProvider, templateBuilderProvider, Suppliers.>ofInstance(imageMap)); + return new EC2TemplateBuilderImpl(locations, new ImageCacheSupplier(images, 60), sizes, Suppliers.ofInstance(defaultLocation), + optionsProvider, templateBuilderProvider, getImageStrategy, Suppliers.>ofInstance(imageMap)); } @Override protected String getProviderFormatId(String uniqueLabel) { - return "us-east-1/"+uniqueLabel; + return "us-east-1/" + uniqueLabel; } @Override @@ -118,6 +116,7 @@ public void testParseOnDemand() { TemplateOptions defaultOptions = createMock(TemplateOptions.class); Image knownImage = createMock(Image.class); OperatingSystem os = createMock(OperatingSystem.class); + GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); expect(optionsProvider.get()).andReturn(defaultOptions); @@ -137,22 +136,14 @@ public void testParseOnDemand() { expect(os.getArch()).andReturn("paravirtual").atLeastOnce(); expect(os.is64Bit()).andReturn(false).atLeastOnce(); - replay(knownImage); - replay(os); - replay(defaultOptions); - replay(optionsProvider); - replay(templateBuilderProvider); + replay(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, region, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider, getImageStrategy); assertEquals(template.imageId("us-east-1/ami").build().getImage(), knownImage); - verify(knownImage); - verify(os); - verify(defaultOptions); - verify(optionsProvider); - verify(templateBuilderProvider); + verify(knownImage, os, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); } @SuppressWarnings("unchecked") @@ -169,29 +160,25 @@ public void testParseOnDemandWithoutRegionEncodedIntoId() { Provider templateBuilderProvider = createMock(Provider.class); TemplateOptions defaultOptions = createMock(TemplateOptions.class); Image knownImage = createMock(Image.class); + GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); expect(knownImage.getId()).andReturn("region/ami").anyTimes(); expect(knownImage.getProviderId()).andReturn("ami").anyTimes(); expect(knownImage.getLocation()).andReturn(region).anyTimes(); expect(optionsProvider.get()).andReturn(defaultOptions); - replay(knownImage); - replay(defaultOptions); - replay(optionsProvider); - replay(templateBuilderProvider); + replay(knownImage, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, region, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider, getImageStrategy); try { template.imageId("ami").build(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } - verify(knownImage); - verify(defaultOptions); - verify(optionsProvider); - verify(templateBuilderProvider); + + verify(knownImage, defaultOptions, optionsProvider, templateBuilderProvider, getImageStrategy); } @SuppressWarnings("unchecked") @@ -208,6 +195,7 @@ public void testParseOnDemandNotFound() { Provider optionsProvider = createMock(Provider.class); Provider templateBuilderProvider = createMock(Provider.class); TemplateOptions defaultOptions = createMock(TemplateOptions.class); + GetImageStrategy getImageStrategy = createMock(GetImageStrategy.class); Image knownImage = createMock(Image.class); expect(knownImage.getId()).andReturn("region/ami").anyTimes(); expect(knownImage.getProviderId()).andReturn("ami").anyTimes(); @@ -216,22 +204,27 @@ public void testParseOnDemandNotFound() { expect(defaultLocation.getId()).andReturn("region"); expect(optionsProvider.get()).andReturn(defaultOptions); - replay(knownImage); - replay(defaultOptions); - replay(defaultLocation); - replay(optionsProvider); - replay(templateBuilderProvider); + replay(knownImage, defaultOptions, defaultLocation, optionsProvider, templateBuilderProvider, getImageStrategy); TemplateBuilderImpl template = createTemplateBuilder(knownImage, locations, images, sizes, defaultLocation, - optionsProvider, templateBuilderProvider); + optionsProvider, templateBuilderProvider, getImageStrategy); assertEquals(template.imageId("region/bad").build().getImage(), knownImage); - verify(knownImage); - verify(defaultOptions); - verify(defaultLocation); - verify(optionsProvider); - verify(templateBuilderProvider); + verify(knownImage, defaultOptions, defaultLocation, optionsProvider, templateBuilderProvider, getImageStrategy); + } + + // The EC2 provider already overrides the getImage method so this test is not useful for EC2 + @Override + @Test(enabled = false) + public void testFindImageWithIdDefaultToGetImageStrategy() { + + } + + // The EC2 provider already overrides the getImage method so this test is not useful for EC2 + @Override + public void testFindImageWithIdDefaultToGetImageStrategyAndPopulatesTheCache() { + } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java index 1a2b9b3a51..98ee834cc9 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/CreateSecurityGroupIfNeededTest.java @@ -39,9 +39,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "CreateSecurityGroupIfNeeded") public class CreateSecurityGroupIfNeededTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java index 9d3feff5e3..fde64cadca 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/LoadPublicIpForInstanceOrNullTest.java @@ -31,9 +31,6 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "LoadPublicIpForInstanceOrNullTest") public class LoadPublicIpForInstanceOrNullTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java index 5c1c2aae7d..86ff87188e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/loaders/RegionAndIdToImageTest.java @@ -39,9 +39,6 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class RegionAndIdToImageTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java similarity index 89% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java index 90b92c3be1..a3f6cde4fb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/options/EC2TemplateOptionsTest.java @@ -24,18 +24,16 @@ import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.noKeyPair; import static org.jclouds.ec2.compute.options.EC2TemplateOptions.Builder.securityGroups; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; import java.io.IOException; +import com.google.common.collect.ImmutableSet; import org.jclouds.compute.options.TemplateOptions; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; - /** * Tests possible uses of EC2TemplateOptions and EC2TemplateOptions.Builder.* - * - * @author Adrian Cole */ public class EC2TemplateOptionsTest { @@ -285,4 +283,43 @@ public void testinboundPortsStatic() { assertEquals(options.getInboundPorts()[0], 22); assertEquals(options.getInboundPorts()[1], 30); } + + @Test + public void testMaxCountDefault() { + EC2TemplateOptions options = new EC2TemplateOptions(); + assertEquals(options.getMaxCount(), 0); + } + + @Test + public void testMaxCount() { + EC2TemplateOptions options = new EC2TemplateOptions(); + options.maxCount(2); + assertEquals(options.getMaxCount(), 2); + } + + @Test + public void testMaxCountNull() { + EC2TemplateOptions options = new EC2TemplateOptions(); + options.maxCount(null); + assertEquals(options.getMaxCount(), 0); + } + + @Test + public void testClientTokenDefault() { + EC2TemplateOptions options = new EC2TemplateOptions(); + assertNull(options.getClientToken()); + } + + @Test + public void testClientToken() { + EC2TemplateOptions options = new EC2TemplateOptions(); + options.clientToken("some-token"); + assertEquals(options.getClientToken(), "some-token"); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testClientTokenNPE() { + EC2TemplateOptions options = new EC2TemplateOptions(); + options.clientToken(null); + } } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index d437e42cff..527123a927 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -23,13 +23,16 @@ import static org.easymock.EasyMock.verify; import static org.testng.Assert.assertEquals; +import javax.inject.Provider; import java.lang.reflect.Method; import java.util.Set; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ExecutionException; -import javax.inject.Provider; - +import com.google.common.base.Function; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; import org.jclouds.aws.domain.Region; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.Template; @@ -46,14 +49,6 @@ import org.jclouds.scriptbuilder.domain.Statements; import org.testng.annotations.Test; -import com.google.common.base.Function; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest") public class CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptionsTest { @@ -130,6 +125,7 @@ public void testExecuteWithDefaultOptionsEC2() throws SecurityException, NoSuchM systemGeneratedKeyPairName); expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups); expect(options.getUserData()).andReturn(null); + expect(options.getClientToken()).andReturn(null); // replay mocks replay(options); @@ -181,6 +177,7 @@ public void testExecuteWithUserData() throws SecurityException, NoSuchMethodExce expect(template.getHardware()).andReturn(size).atLeastOnce(); expect(template.getOptions()).andReturn(options).atLeastOnce(); expect(options.getBlockDeviceMappings()).andReturn(ImmutableSet. of()).atLeastOnce(); + expect(options.getClientToken()).andReturn("some-token"); expect(strategy.createNewKeyPairUnlessUserSpecifiedOtherwise(region, group, options)).andReturn( systemGeneratedKeyPairName); expect(strategy.getSecurityGroupsForTagAndOptions(region, group, options)).andReturn(generatedGroups); @@ -197,7 +194,8 @@ public void testExecuteWithUserData() throws SecurityException, NoSuchMethodExce assertEquals( customize.buildFormParameters().entries(), ImmutableMultimap. of("InstanceType", size.getProviderId(), "SecurityGroup.1", "group", - "KeyName", systemGeneratedKeyPairName, "UserData", base64().encode("hello".getBytes())).entries()); + "KeyName", systemGeneratedKeyPairName, "UserData", base64().encode("hello".getBytes()), + "ClientToken", "some-token").entries()); assertEquals(customize.buildRequestHeaders(), ImmutableMultimap. of()); assertEquals(customize.buildStringPayload(), null); @@ -319,7 +317,7 @@ public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo // setup expectations expect(options.getKeyPair()).andReturn(userSuppliedKeyPair); - expect(options.getLoginPrivateKey()).andReturn(CREDENTIALS.getPrivateKey()).atLeastOnce(); + expect(options.getLoginPrivateKey()).andReturn(CREDENTIALS.getOptionalPrivateKey().get()).atLeastOnce(); // Notice that the fingerprint and sha1 generated expect(strategy.credentialsMap.put(new RegionAndName(region, userSuppliedKeyPair), KEYPAIR)).andReturn(null); @@ -520,7 +518,7 @@ public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPort int[] ports = {}; boolean shouldAuthorizeSelf = true; boolean groupExisted = true; - Set returnVal = ImmutableSet. of("group1", "group2"); + Set returnVal = ImmutableSet. of(generatedMarkerGroup, "group1", "group2"); // create mocks CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy(); @@ -528,11 +526,11 @@ public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPort // setup expectations expect(options.getGroups()).andReturn(groupIds).atLeastOnce(); -// RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, -// ports, shouldAuthorizeSelf); -// -// expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules)) -// .andReturn(groupExisted ? "group" : null); + RegionNameAndIngressRules regionNameAndIngressRules = new RegionNameAndIngressRules(region, generatedMarkerGroup, + ports, shouldAuthorizeSelf); + + expect(strategy.securityGroupMap.getUnchecked(regionNameAndIngressRules)) + .andReturn(groupExisted ? "group" : null); // replay mocks replay(options); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java index f0201ad33d..86f39bc08e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2CreateNodesInGroupThenAddToSetTest.java @@ -26,6 +26,11 @@ import java.util.Map; import java.util.Set; +import com.google.common.base.Optional; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; import org.easymock.IArgumentMatcher; import org.jclouds.compute.config.CustomizationResponse; import org.jclouds.compute.domain.Hardware; @@ -49,21 +54,12 @@ import org.jclouds.ec2.compute.options.EC2TemplateOptions; import org.jclouds.ec2.domain.Reservation; import org.jclouds.ec2.domain.RunningInstance; -import org.jclouds.ec2.options.RunInstancesOptions; import org.jclouds.ec2.features.ElasticIPAddressApi; import org.jclouds.ec2.features.InstanceApi; +import org.jclouds.ec2.options.RunInstancesOptions; import org.testng.Assert; import org.testng.annotations.Test; -import com.google.common.base.Optional; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; - -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "EC2CreateNodesInGroupThenAddToSetTest") public class EC2CreateNodesInGroupThenAddToSetTest { @@ -114,7 +110,7 @@ ImmutableSet. of(), ImmutableSet. of(instance), "ownerI expect(instance.getId()).andReturn(instanceCreatedId).atLeastOnce(); // simulate a lazy credentials fetch LoginCredentials creds = LoginCredentials.builder().user("foo").privateKey("bar").build(); - expect(strategy.instanceToCredentials.apply(instance)).andReturn(Optional.of(creds)); + expect(strategy.instanceToCredentials.getUnchecked(instance)).andReturn(Optional.of(creds)); expect(instance.getRegion()).andReturn(region).atLeastOnce(); expect(strategy.credentialStore.put("node#" + region + "/" + instanceCreatedId, creds)).andReturn(null); @@ -124,6 +120,7 @@ ImmutableSet. of(), ImmutableSet. of(instance), "ownerI expect(input.options.getLoginPassword()).andReturn(null); expect(input.options.getLoginPrivateKey()).andReturn(null); expect(input.options.shouldAuthenticateSudo()).andReturn(null); + expect(input.options.getMaxCount()).andReturn(0); expect( strategy.utils.customizeNodesAndAddToGoodMapOrPutExceptionIntoBadMap(eq(input.options), @@ -212,7 +209,7 @@ ImmutableSet. of(), ImmutableSet. of(instance), "ownerI expect(instance.getId()).andReturn(instanceCreatedId).atLeastOnce(); // simulate a lazy credentials fetch LoginCredentials creds = LoginCredentials.builder().user("foo").privateKey("bar").build(); - expect(strategy.instanceToCredentials.apply(instance)).andReturn(Optional.of(creds)); + expect(strategy.instanceToCredentials.getUnchecked(instance)).andReturn(Optional.of(creds)); expect(instance.getRegion()).andReturn(region).atLeastOnce(); expect(strategy.credentialStore.put("node#" + region + "/" + instanceCreatedId, creds)).andReturn(null); @@ -222,7 +219,7 @@ ImmutableSet. of(), ImmutableSet. of(instance), "ownerI expect(input.options.getLoginPassword()).andReturn(null); expect(input.options.getLoginPrivateKey()).andReturn(null); expect(input.options.shouldAuthenticateSudo()).andReturn(null); - + expect(input.options.getMaxCount()).andReturn(0); expect(strategy.runningInstanceToNodeMetadata.apply(instance)).andReturn(nodeMetadata); expect( diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java index 6bc929c559..077f4c8d81 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/compute/strategy/EC2DestroyNodeStrategyTest.java @@ -36,9 +36,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "EC2DestroyNodeStrategyTest") public class EC2DestroyNodeStrategyTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java index 0785228775..737f8800c1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/config/EC2HttpApiModuleExpectTest.java @@ -43,9 +43,6 @@ import com.google.inject.Module; import com.google.inject.TypeLiteral; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2HttpApiModuleExpectTest") public class EC2HttpApiModuleExpectTest extends BaseEC2ApiExpectTest { private Injector injector; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java index 7b57b2ae1c..e82d079341 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiExpectTest.java @@ -29,9 +29,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "AMIApiExpectTest") public class AMIApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java similarity index 87% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java index 2b56e0a380..367de3fcbf 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiLiveTest.java @@ -45,7 +45,9 @@ import org.jclouds.ec2.domain.RootDeviceType; import org.jclouds.ec2.domain.RunningInstance; import org.jclouds.ec2.domain.Snapshot; +import org.jclouds.ec2.options.RegisterImageBackedByEbsOptions; import org.jclouds.ec2.predicates.InstanceStateRunning; +import org.jclouds.ec2.predicates.SnapshotCompleted; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -56,8 +58,6 @@ /** * Tests behavior of {@code AMIApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class AMIApiLiveTest extends BaseComputeServiceContextLiveTest { @@ -184,7 +184,7 @@ public void testCreateAndListEBSBackedImage() throws Exception { // Register a new image... ebsBackedImageId = client.registerUnixImageBackedByEbsInRegion(regionId, ebsBackedImageName, snapshot.getId(), - addNewBlockDevice("/dev/sda2", "myvirtual", 1).withDescription("adrian")); + newBlockDeviceOption()); imagesToDeregister.add(ebsBackedImageId); final Image ebsBackedImage = getOnlyElement(client.describeImagesInRegion(regionId, imageIds(ebsBackedImageId))); assertEquals(ebsBackedImage.getName(), ebsBackedImageName); @@ -194,20 +194,35 @@ public void testCreateAndListEBSBackedImage() throws Exception { assertEquals(ebsBackedImage.getDescription(), "adrian"); assertEquals( ebsBackedImage.getEbsBlockDevices().entrySet(), - ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true), - "/dev/sda2", new Image.EbsBlockDevice(null, 1, false)).entrySet()); + ImmutableMap.of("/dev/sda1", new Image.EbsBlockDevice(snapshot.getId(), snapshot.getVolumeSize(), true, null, null, false), + "/dev/sda2", newBlockDeviceInfo()).entrySet()); - // List of images after - should be one larger than before - int after = client.describeImagesInRegionWithFilter(regionId, - ImmutableMultimap.builder() - .put("name", ebsBackedImageName).build()).size(); + int describeCount = 0; + int after = 0; + // This loop is in here to deal with a lag between image creation and it showing up in filtered describeImage queries. + while (describeCount < 10 && after == 0) { + describeCount++; + Thread.sleep(30000); + // List of images after - should be one larger than before + after = client.describeImagesInRegionWithFilter(regionId, + ImmutableMultimap.builder() + .put("name", ebsBackedImageName).build()).size(); + } assertEquals(after, sizeBefore + 1); } + protected RegisterImageBackedByEbsOptions newBlockDeviceOption() { + return addNewBlockDevice("/dev/sda2", "myvirtual", 5, false, null, null, false).withDescription("adrian"); + } + + protected Image.EbsBlockDevice newBlockDeviceInfo() { + return new Image.EbsBlockDevice(null, 5, false, null, null, false); + } + // Fires up an instance, finds its root volume ID, takes a snapshot, then // terminates the instance. - private Snapshot createSnapshot() throws RunNodesException { + protected Snapshot createSnapshot() throws RunNodesException { String instanceId = null; try { @@ -224,6 +239,8 @@ private Snapshot createSnapshot() throws RunNodesException { Snapshot snapshot = ec2Api.getElasticBlockStoreApi().get().createSnapshotInRegion(regionId, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); + Predicate snapshotted = retry(new SnapshotCompleted(ec2Api.getElasticBlockStoreApi().get()), 600, 10, SECONDS); + assert snapshotted.apply(snapshot); return snapshot; } finally { if (instanceId != null) diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java index b4b7f85a2d..842a48b465 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AMIApiTest.java @@ -41,8 +41,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AMIApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AMIApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java index 61c1fb0bcc..c2eb0dfd9b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiLiveTest.java @@ -37,8 +37,6 @@ /** * Tests behavior of {@code AvailabilityZoneAndRegionApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "AvailabilityZoneAndRegionApiLiveTest") public class AvailabilityZoneAndRegionApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java index ae22fe80c7..6552dfad99 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/AvailabilityZoneAndRegionApiTest.java @@ -36,8 +36,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AvailabilityZoneAndRegionApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AvailabilityZoneAndRegionApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java index cff45124a4..3a2e64597c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/BaseEC2ApiTest.java @@ -54,9 +54,6 @@ import com.google.inject.Module; import com.google.inject.Provides; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public abstract class BaseEC2ApiTest extends BaseAsyncApiTest { @ConfiguresHttpApi diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java similarity index 73% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java index 9fc2338b0c..df711128e5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/EC2ElasticBlockStoreApiExpectTest.java @@ -23,6 +23,7 @@ import org.jclouds.ec2.domain.Snapshot; import org.jclouds.ec2.domain.Volume; import org.jclouds.ec2.internal.BaseEC2ApiExpectTest; +import org.jclouds.ec2.options.CreateVolumeOptions; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.rest.ResourceNotFoundException; @@ -33,20 +34,19 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "EC2ElasticBlockStoreApiExpectTest") public class EC2ElasticBlockStoreApiExpectTest extends BaseEC2ApiExpectTest { Volume creating = Volume.builder() - .id("vol-2a21e543") - .status(Volume.Status.CREATING) - .availabilityZone("us-east-1a") - .region("us-east-1") - .id("vol-2a21e543") - .size(1) - .createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z")) - .build(); + .id("vol-2a21e543") + .status(Volume.Status.CREATING) + .availabilityZone("us-east-1a") + .region("us-east-1") + .id("vol-2a21e543") + .volumeType("standard") + .iops(0) + .size(1) + .createTime(dateService.iso8601DateParse("2009-12-28T05:42:53.000Z")) + .build(); public void testCreateVolumeInAvailabilityZone() { Builder builder = ImmutableMap.builder(); @@ -66,7 +66,38 @@ public void testCreateVolumeInAvailabilityZone() { assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", 4), creating); } - + + public void testCreateVolumeInAvailabilityZoneWithOptions() { + Builder builder = ImmutableMap.builder(); + builder.put(describeRegionsRequest, describeRegionsResponse); + builder.putAll(describeAvailabilityZonesRequestResponse); + builder.put( + HttpRequest.builder() + .method("POST") + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .payload(payloadFromStringWithContentType("Action=CreateVolume" + + "&AvailabilityZone=us-east-1a" + + "&Iops=0" + + "&Signature=uI5tXrwV4zXB3uh0OP4RkfU2HMdQ2yICfpo4gKrajMI%3D" + + "&SignatureMethod=HmacSHA256" + + "&SignatureVersion=2" + + "&Size=4" + + "&Timestamp=2012-04-16T15%3A54%3A08.897Z" + + "&Version=2010-08-31" + + "&VolumeType=standard" + + "&AWSAccessKeyId=identity", "application/x-www-form-urlencoded")).build(), + HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/created_volume.xml")).build()); + + ElasticBlockStoreApi client = requestsSendResponses(builder.build()).getElasticBlockStoreApi().get(); + + assertEquals(client.createVolumeInAvailabilityZone("us-east-1a", + CreateVolumeOptions.Builder.withSize(4).isEncrypted(false).volumeType("standard").withIops(0)), + creating); + } + public void testCreateVolumeFromSnapshotInAvailabilityZoneEuSetsCorrectEndpoint() { String region = "eu-west-1"; @@ -75,16 +106,17 @@ public void testCreateVolumeFromSnapshotInAvailabilityZoneEuSetsCorrectEndpoint( builder.putAll(describeAvailabilityZonesRequestResponse); builder.put( formSigner.filter(HttpRequest.builder() - .method("POST") - .endpoint("https://ec2." + region + ".amazonaws.com/") - .addHeader("Host", "ec2." + region + ".amazonaws.com") - .addFormParam("Action", "CreateVolume") - .addFormParam("AvailabilityZone", "eu-west-1a") - .addFormParam("Size", "1") - .addFormParam("SnapshotId", "snap-8b7ffbdd").build()), - HttpResponse.builder() - .statusCode(200) - .payload(payloadFromResource("/created_volume.xml")).build()); + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "CreateVolume") + .addFormParam("AvailabilityZone", "eu-west-1a") + .addFormParam("Size", "1") + .addFormParam("SnapshotId", "snap-8b7ffbdd") + .build()), + HttpResponse.builder() + .statusCode(200) + .payload(payloadFromResource("/created_volume.xml")).build()); ElasticBlockStoreApi client = requestsSendResponses(builder.build()).getElasticBlockStoreApi().get(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java similarity index 84% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java index bc080a7126..ac3cf2931e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiLiveTest.java @@ -15,8 +15,11 @@ * limitations under the License. */ package org.jclouds.ec2.features; + import static com.google.common.base.Preconditions.checkNotNull; import static java.util.concurrent.TimeUnit.SECONDS; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.fromSnapshotId; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.withSize; import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.snapshotIds; import static org.jclouds.util.Predicates2.retry; import static org.testng.Assert.assertEquals; @@ -26,6 +29,12 @@ import java.util.Set; import java.util.SortedSet; +import com.google.common.base.Predicate; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; import org.jclouds.aws.AWSResponseException; import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; import org.jclouds.ec2.EC2Api; @@ -38,31 +47,23 @@ import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import com.google.common.base.Predicate; -import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - /** * Tests behavior of {@code ElasticBlockStoreApi} - * - * @author Adrian Cole */ -@Test(groups = "live", singleThreaded = true, testName = "ElasticBlockStoreApiLiveTest") +@Test(groups = "live", singleThreaded = true) public class ElasticBlockStoreApiLiveTest extends BaseComputeServiceContextLiveTest { public ElasticBlockStoreApiLiveTest() { provider = "ec2"; } - private EC2Api ec2Api; - private ElasticBlockStoreApi client; + protected EC2Api ec2Api; + protected ElasticBlockStoreApi client; - private String defaultRegion; - private String defaultZone; + protected String defaultRegion; + protected String defaultZone; - private String volumeId; - private Snapshot snapshot; + protected String volumeId; + protected Snapshot snapshot; @Override @BeforeClass(groups = { "integration", "live" }) @@ -118,10 +119,10 @@ void testDescribeVolumesWithInvalidFilter() { @Test void testCreateVolumeInAvailabilityZone() { - Volume expected = client.createVolumeInAvailabilityZone(defaultZone, 1); + Volume expected = client.createVolumeInAvailabilityZone(defaultZone, + withSize(1)); assertNotNull(expected); assertEquals(expected.getAvailabilityZone(), defaultZone); - this.volumeId = expected.getId(); Set result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId())); @@ -129,6 +130,7 @@ void testCreateVolumeInAvailabilityZone() { assertEquals(result.size(), 1); Volume volume = result.iterator().next(); assertEquals(volume.getId(), expected.getId()); + assertEquals(volume.getVolumeType(), expected.getVolumeType()); } @Test(dependsOnMethods = "testCreateVolumeInAvailabilityZone") @@ -158,10 +160,28 @@ void testCreateVolumeFromSnapshotInAvailabilityZone() { assertEquals(volume.getAvailabilityZone(), defaultZone); assertEquals(result.getStatus(), Volume.Status.AVAILABLE); - client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId()); + client.deleteVolumeInRegion(snapshot.getRegion(), result.getId()); } - @Test(dependsOnMethods = "testCreateSnapshotInRegion") + @Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZone") + void testCreateVolumeFromSnapshotInAvailabilityZoneWithOptions() { + Volume volume = client.createVolumeInAvailabilityZone(defaultZone, + fromSnapshotId(snapshot.getId())); + assertNotNull(volume); + + Predicate availabile = retry(new VolumeAvailable(client), 600, 10, SECONDS); + assert availabile.apply(volume); + + Volume result = Iterables.getOnlyElement(client.describeVolumesInRegion(snapshot.getRegion(), volume.getId())); + assertEquals(volume.getId(), result.getId()); + assertEquals(volume.getSnapshotId(), snapshot.getId()); + assertEquals(volume.getAvailabilityZone(), defaultZone); + assertEquals(result.getStatus(), Volume.Status.AVAILABLE); + + client.deleteVolumeInRegion(snapshot.getRegion(), result.getId()); + } + + @Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZoneWithOptions") void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() { Volume volume = client.createVolumeFromSnapshotInAvailabilityZone(defaultZone, 2, snapshot.getId()); assertNotNull(volume); @@ -176,7 +196,7 @@ void testCreateVolumeFromSnapshotInAvailabilityZoneWithSize() { assertEquals(volume.getSize(), 2); assertEquals(result.getStatus(), Volume.Status.AVAILABLE); - client.deleteVolumeInRegion(snapshot.getRegion(), volume.getId()); + client.deleteVolumeInRegion(snapshot.getRegion(), result.getId()); } @Test @@ -255,21 +275,21 @@ public void testResetCreateVolumePermissionsOnSnapshot() { // snapshotId); } - @Test(dependsOnMethods = "testCreateSnapshotInRegion") + @Test(dependsOnMethods = "testCreateVolumeFromSnapshotInAvailabilityZoneWithSize") public void testGetCreateVolumePermissionForSnapshot() { client.getCreateVolumePermissionForSnapshotInRegion(snapshot.getRegion(), snapshot.getId()); } - @Test(dependsOnMethods = "testCreateSnapshotInRegion") + @Test(dependsOnMethods = "testGetCreateVolumePermissionForSnapshot") void testDeleteVolumeInRegion() { client.deleteVolumeInRegion(defaultRegion, volumeId); - Set result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, volumeId)); - assertEquals(result.size(), 1); - Volume volume = result.iterator().next(); - assertEquals(volume.getStatus(), Volume.Status.DELETING); + assertEquals(client.describeVolumesInRegionWithFilter(defaultRegion, + ImmutableMultimap.builder() + .put("volume-id", volumeId).build()), + ImmutableSet.of()); } - @Test(dependsOnMethods = "testGetCreateVolumePermissionForSnapshot") + @Test(dependsOnMethods = "testDeleteVolumeInRegion") void testDeleteSnapshotInRegion() { client.deleteSnapshotInRegion(snapshot.getRegion(), snapshot.getId()); assert client.describeSnapshotsInRegion(snapshot.getRegion(), snapshotIds(snapshot.getId())).size() == 0; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java index fefd2a773e..f47e65b0bb 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticBlockStoreApiTest.java @@ -43,8 +43,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticBlockStoreApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "ElasticBlockStoreApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java index 824a4ffb21..f96610b71e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiExpectTest.java @@ -35,7 +35,6 @@ import com.google.common.collect.ImmutableSet; /** - * @author Andrew Bayer * * @see org.jclouds.ec2.features.ElasticIPAddressApi */ diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java index f4354044df..f2e7c69d1e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiLiveTest.java @@ -32,8 +32,6 @@ /** * Tests behavior of {@code ElasticIPAddressApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "ElasticIPAddressApiLiveTest") public class ElasticIPAddressApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java index abdfae6cfe..48f7b4c7c3 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/ElasticIPAddressApiTest.java @@ -33,8 +33,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code ElasticIPAddressApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "ElasticIPAddressApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java index 0c19bd7373..a862e30636 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiExpectTest.java @@ -36,7 +36,6 @@ import com.google.common.collect.ImmutableSet; /** - * @author Andrew Bayer * * @see InstanceApi */ diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java index 6b7818a11d..f8ce897f99 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiLiveTest.java @@ -34,8 +34,6 @@ /** * Tests behavior of {@code EC2Api} - * - * @author Adrian Cole, Andrew Bayer */ @Test(groups = "live", singleThreaded = true, testName = "InstanceApiLiveTest") public class InstanceApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java index fbeb57a7bd..8a68517692 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/InstanceApiTest.java @@ -48,8 +48,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code InstanceApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "InstanceApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java index 8c1c3d8019..edece18602 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiExpectTest.java @@ -29,9 +29,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "KeyPairApiExpectTest") public class KeyPairApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java index b9219a5ca2..8f2340fd74 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiLiveTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of {@code KeyPairApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "KeyPairApiLiveTest") public class KeyPairApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java index 1d4207654a..532d2c6177 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/KeyPairApiTest.java @@ -31,8 +31,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code KeyPairApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "KeyPairApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java index 5bef06ff94..b9f8cf89bf 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiExpectTest.java @@ -29,9 +29,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "SecurityGroupApiExpectTest") public class SecurityGroupApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java index edfc3ca535..931897509c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiLiveTest.java @@ -45,8 +45,6 @@ /** * Tests behavior of {@code SecurityGroupApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "SecurityGroupApiLiveTest") public class SecurityGroupApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java index b5d2d17621..aad6230e46 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SecurityGroupApiTest.java @@ -35,8 +35,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SecurityGroupApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SecurityGroupApiTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java index 50de81275a..e36bf9eca0 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiExpectTest.java @@ -30,9 +30,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class SubnetApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java index a9ca1b0b9d..ee3859b7d9 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/SubnetApiLiveTest.java @@ -36,9 +36,6 @@ /** * tests ability to list/filter subnets - * - * @author Adrian Cole - * @author Andrew Bayer */ @Test(groups = "live") public class SubnetApiLiveTest extends BaseEC2ApiLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java index 7ffdb8a2b1..880b650b8b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/TagApiExpectTest.java @@ -32,9 +32,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class TagApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java index 457b08d85a..bd60cddaf7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiExpectTest.java @@ -31,9 +31,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "WindowsApiExpectTest") public class WindowsApiExpectTest extends BaseEC2ApiExpectTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java similarity index 97% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java index 2cf8257634..9baeafc152 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiLiveTest.java @@ -22,9 +22,6 @@ import com.google.common.base.Optional; -/** - * @author Adrian Cole - */ @Test(groups = "live") public class WindowsApiLiveTest extends BaseEC2ApiLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java index d6b44e7a16..058e4699e5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/WindowsApiTest.java @@ -33,8 +33,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code WindowsApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "WindowsApiTest") @@ -87,7 +85,7 @@ Lists. newArrayList( .endpoint("https://ec2.us-east-1.amazonaws.com/") .addHeader("Host", "ec2.us-east-1.amazonaws.com") .addFormParam("Action", "BundleInstance") - .addFormParam("InstanceId","i-e468cd8d") + .addFormParam("InstanceId", "i-e468cd8d") .addFormParam("Signature", "9UbWwb%2BnO2vHn2O59K9FpmaK445RwX7vXsruHRznwik%3D") .addFormParam("SignatureMethod", "HmacSHA256") .addFormParam("SignatureVersion", "2") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java index 9d152b77a7..fc6515b858 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/features/internal/BaseTagApiLiveTest.java @@ -42,8 +42,6 @@ /** * tests ability to tag, filter, and delete tags from a resource. - * - * @author Adrian Cole */ @Test(groups = "live") public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java index 352dae0c03..e3495249a2 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/ConvertUnencodedBytesToBase64EncodedStringTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code ConvertUnencodedBytesToBase64EncodedString} - * - * @author Adrian Cole */ @Test(groups = "unit") public class ConvertUnencodedBytesToBase64EncodedStringTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java index cab55ba268..19b6149af7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/functions/EncodedRSAPublicKeyToBase64Test.java @@ -24,8 +24,6 @@ /** * Tests behavior of {@code EncodedRSAPublicKeyToBase64} - * - * @author Adrian Cole */ @Test(groups = "unit") public class EncodedRSAPublicKeyToBase64Test { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiExpectTest.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java similarity index 96% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java index 9ca0c96fd2..182fecf0e1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ApiLiveTest.java @@ -19,10 +19,6 @@ import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.ec2.EC2Api; -/** - * - * @author Adrian Cole - */ public class BaseEC2ApiLiveTest extends BaseApiLiveTest { public BaseEC2ApiLiveTest() { provider = "ec2"; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/internal/BaseEC2ExpectTest.java diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java index 5bb07ede5d..cf9e1908c4 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptionsTest.java @@ -29,8 +29,6 @@ /** * Tests possible uses of BundleInstanceS3StorageOptions and * BundleInstanceS3StorageOptions.Builder.* - * - * @author Adrian Cole */ public class BundleInstanceS3StorageOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java index 8c66ece8bb..8a2c8c2278 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateImageOptionsTest.java @@ -27,8 +27,6 @@ /** * Tests possible uses of CreateImageOptions and CreateImageOptions.Builder.* - * - * @author Adrian Cole */ public class CreateImageOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java index 845b606957..75a78eaf6f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateSnapshotOptionsTest.java @@ -26,8 +26,6 @@ /** * Tests possible uses of CreateSnapshotOptions and CreateSnapshotOptions.Builder.* - * - * @author Adrian Cole */ public class CreateSnapshotOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateVolumeOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateVolumeOptionsTest.java new file mode 100644 index 0000000000..20f74754ca --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/CreateVolumeOptionsTest.java @@ -0,0 +1,156 @@ +/* + * 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.jclouds.ec2.options; + +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.fromSnapshotId; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.isEncrypted; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.volumeType; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.withIops; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.withSize; +import static org.testng.Assert.assertEquals; + +import com.google.common.collect.ImmutableList; +import org.jclouds.http.options.HttpRequestOptions; +import org.testng.annotations.Test; + +/** + * Tests possible uses of CreateVolumeOptions and CreateVolumeOptions.Builder.* + */ +public class CreateVolumeOptionsTest { + + @Test + public void testAssignability() { + assert HttpRequestOptions.class.isAssignableFrom(CreateVolumeOptions.class); + assert !String.class.isAssignableFrom(CreateVolumeOptions.class); + } + + @Test + public void testVolumeType() { + CreateVolumeOptions options = new CreateVolumeOptions(); + options.volumeType("test"); + assertEquals(options.buildFormParameters().get("VolumeType"), + ImmutableList.of("test")); + } + + @Test + public void testNullVolumeType() { + CreateVolumeOptions options = new CreateVolumeOptions(); + assertEquals(options.buildFormParameters().get("VolumeType"), ImmutableList.of()); + } + + @Test + public void testVolumeTypeStatic() { + CreateVolumeOptions options = volumeType("test"); + assertEquals(options.buildFormParameters().get("VolumeType"), + ImmutableList.of("test")); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testVolmeTypeNPE() { + volumeType(null); + } + + @Test + public void testFromSnapshotId() { + CreateVolumeOptions options = new CreateVolumeOptions(); + options.fromSnapshotId("test"); + assertEquals(options.buildFormParameters().get("SnapshotId"), + ImmutableList.of("test")); + } + + @Test + public void testNullFromSnapshotId() { + CreateVolumeOptions options = new CreateVolumeOptions(); + assertEquals(options.buildFormParameters().get("SnapshotId"), ImmutableList.of()); + } + + @Test + public void testWithSnapshotIdStatic() { + CreateVolumeOptions options = fromSnapshotId("test"); + assertEquals(options.buildFormParameters().get("SnapshotId"), + ImmutableList.of("test")); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testFromSnapshotIdNPE() { + fromSnapshotId(null); + } + + @Test + public void testWithIops() { + CreateVolumeOptions options = new CreateVolumeOptions(); + options.withIops(5); + assertEquals(options.buildFormParameters().get("Iops"), + ImmutableList.of("5")); + } + + @Test + public void testNullWithIops() { + CreateVolumeOptions options = new CreateVolumeOptions(); + assertEquals(options.buildFormParameters().get("Iops"), ImmutableList.of()); + } + + @Test + public void testWithIopsStatic() { + CreateVolumeOptions options = withIops(5); + assertEquals(options.buildFormParameters().get("Iops"), + ImmutableList.of("5")); + } + + @Test + public void testWithSize() { + CreateVolumeOptions options = new CreateVolumeOptions(); + options.withSize(5); + assertEquals(options.buildFormParameters().get("Size"), + ImmutableList.of("5")); + } + + @Test + public void testNullWithSize() { + CreateVolumeOptions options = new CreateVolumeOptions(); + assertEquals(options.buildFormParameters().get("Size"), ImmutableList.of()); + } + + @Test + public void testWithSizeStatic() { + CreateVolumeOptions options = withSize(5); + assertEquals(options.buildFormParameters().get("Size"), + ImmutableList.of("5")); + } + + @Test + public void testIsEncrypted() { + CreateVolumeOptions options = new CreateVolumeOptions(); + options.isEncrypted(true); + assertEquals(options.buildFormParameters().get("Encrypted"), + ImmutableList.of("true")); + } + + @Test + public void testNullIsEncrypted() { + CreateVolumeOptions options = new CreateVolumeOptions(); + assertEquals(options.buildFormParameters().get("Encrypted"), ImmutableList.of()); + } + + @Test + public void testIsEncryptedStatic() { + CreateVolumeOptions options = isEncrypted(true); + assertEquals(options.buildFormParameters().get("Encrypted"), + ImmutableList.of("true")); + } + +} diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java index 7626c61b72..8435df4113 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeImagesOptionsTest.java @@ -28,8 +28,6 @@ /** * Tests possible uses of DescribeImagesOptions and DescribeImagesOptions.Builder.* - * - * @author Adrian Cole */ public class DescribeImagesOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java index d4d4c00424..27a09c2049 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DescribeSnapshotsOptionsTest.java @@ -28,8 +28,6 @@ /** * Tests possible uses of DescribeSnapshotsOptions and DescribeSnapshotsOptions.Builder.* - * - * @author Adrian Cole */ public class DescribeSnapshotsOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java index dd0680b115..2b7d5028b5 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/DetachVolumeOptionsTest.java @@ -27,8 +27,6 @@ /** * Tests possible uses of DetachVolumeOptions and DetachVolumeOptions.Builder.* - * - * @author Adrian Cole */ public class DetachVolumeOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java similarity index 80% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java index 621fdf3b2f..9d1612a723 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageBackedByEbsOptionsTest.java @@ -26,18 +26,15 @@ import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.withRamdisk; import static org.testng.Assert.assertEquals; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMultimap; import org.jclouds.ec2.domain.Image.Architecture; import org.jclouds.http.options.HttpRequestOptions; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMultimap; - /** * Tests possible uses of RegisterImageBackedByEbsOptions and * RegisterImageBackedByEbsOptions.Builder.* - * - * @author Adrian Cole */ public class RegisterImageBackedByEbsOptionsTest { @@ -190,6 +187,41 @@ public void testAddBlockDeviceFromSnapshotNPE() { addBlockDeviceFromSnapshot(null, null, null); } + @Test + public void testAdvancedAddBlockDeviceFromSnapshot() { + RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); + options.addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId", true, "gp2", 0, false); + assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.builder() + .put("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true") + .put("BlockDeviceMapping.1.Ebs.VolumeType", "gp2") + .put("BlockDeviceMapping.1.Ebs.Iops", "0") + .put("BlockDeviceMapping.1.DeviceName", "deviceName") + .put("BlockDeviceMapping.1.VirtualName", "virtualName") + .put("BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId") + .build() + .entries()); + } + + @Test + public void testAdvancedAddBlockDeviceFromSnapshotStatic() { + RegisterImageBackedByEbsOptions options = addBlockDeviceFromSnapshot("deviceName", "virtualName", "snapshotId", true, "gp2", 0, true); + assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.builder() + .put("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true") + .put("BlockDeviceMapping.1.Ebs.VolumeType", "gp2") + .put("BlockDeviceMapping.1.Ebs.Iops", "0") + .put("BlockDeviceMapping.1.Ebs.Encrypted", "true") + .put("BlockDeviceMapping.1.DeviceName", "deviceName") + .put("BlockDeviceMapping.1.VirtualName", "virtualName") + .put("BlockDeviceMapping.1.Ebs.SnapshotId", "snapshotId") + .build() + .entries()); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testAdvancedAddBlockDeviceFromSnapshotNPE() { + addBlockDeviceFromSnapshot(null, null, null, false, null, null, false); + } + @Test public void testAddEphemeralBlockDeviceFromSnapshot() { RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); @@ -269,6 +301,41 @@ public void testAddNewBlockDeviceNPE() { addNewBlockDevice(null, null, 1); } + @Test + public void testAdvancedAddNewBlockDevice() { + RegisterImageBackedByEbsOptions options = new RegisterImageBackedByEbsOptions(); + options.addNewBlockDevice("deviceName", "virtualName", 5, true, "gp2", 0, true); + assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.builder() + .put("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true") + .put("BlockDeviceMapping.1.Ebs.VolumeType", "gp2") + .put("BlockDeviceMapping.1.Ebs.Iops", "0") + .put("BlockDeviceMapping.1.Ebs.Encrypted", "true") + .put("BlockDeviceMapping.1.DeviceName", "deviceName") + .put("BlockDeviceMapping.1.VirtualName", "virtualName") + .put("BlockDeviceMapping.1.Ebs.VolumeSize", "5") + .build() + .entries()); + } + + @Test + public void testAdvancedAddNewBlockDeviceStatic() { + RegisterImageBackedByEbsOptions options = addNewBlockDevice("deviceName", "virtualName", 5, true, "gp2", 0, false); + assertEquals(options.buildFormParameters().entries(), ImmutableMultimap.builder() + .put("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "true") + .put("BlockDeviceMapping.1.Ebs.VolumeType", "gp2") + .put("BlockDeviceMapping.1.Ebs.Iops", "0") + .put("BlockDeviceMapping.1.DeviceName", "deviceName") + .put("BlockDeviceMapping.1.VirtualName", "virtualName") + .put("BlockDeviceMapping.1.Ebs.VolumeSize", "5") + .build() + .entries()); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testAdvancedAddNewBlockDeviceNPE() { + addNewBlockDevice(null, null, 5, false, null, null, false); + } + @Test(expectedExceptions = IllegalArgumentException.class) public void testAddNewBlockDeviceTooBig() { addNewBlockDevice("deviceName", "virtualName", 1025); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java index 907c5ac28a..20c352b797 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RegisterImageOptionsTest.java @@ -30,8 +30,6 @@ /** * Tests possible uses of RegisterImageOptions and RegisterImageOptions.Builder.* - * - * @author Adrian Cole */ public class RegisterImageOptionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java similarity index 89% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java index f9c292a38a..a5195414af 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/options/RunInstancesOptionsTest.java @@ -18,6 +18,7 @@ import static org.jclouds.ec2.options.RunInstancesOptions.Builder.asType; import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withBlockDeviceMappings; +import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withClientToken; import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withKernelId; import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withKeyName; import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withRamdisk; @@ -25,18 +26,15 @@ import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withUserData; import static org.testng.Assert.assertEquals; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; import org.jclouds.ec2.domain.BlockDeviceMapping; import org.jclouds.ec2.domain.InstanceType; import org.jclouds.http.options.HttpRequestOptions; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - /** * Tests possible uses of RunInstancesOptions and RunInstancesOptions.Builder.* - * - * @author Adrian Cole */ public class RunInstancesOptionsTest { @@ -209,7 +207,7 @@ public void testNullWithVirtualName() { @Test public void testWithBlockDeviceMapping() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); + BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, "gp2", 10, true); RunInstancesOptions options = new RunInstancesOptions().withBlockDeviceMappings(ImmutableSet . of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), @@ -218,6 +216,12 @@ public void testWithBlockDeviceMapping() { ImmutableList.of("120")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), ImmutableList.of("true")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeType"), + ImmutableList.of("gp2")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Iops"), + ImmutableList.of("10")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Encrypted"), + ImmutableList.of("true")); } @Test @@ -228,7 +232,7 @@ public void testNullWithBlockDeviceMapping() { @Test public void testWithBlockDeviceMappingStatic() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); + BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, null, null, false); RunInstancesOptions options = withBlockDeviceMappings(ImmutableSet . of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), @@ -237,6 +241,8 @@ public void testWithBlockDeviceMappingStatic() { ImmutableList.of("120")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), ImmutableList.of("true")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeType"), + ImmutableList.of()); } @Test(expectedExceptions = NullPointerException.class) @@ -244,4 +250,15 @@ public void testWithBlockDeviceMappingNPE() { withBlockDeviceMappings(null); } + @Test + public void testWithClientToken() { + RunInstancesOptions options = withClientToken("some-token"); + assertEquals(options.buildFormParameters().get("ClientToken"), ImmutableList.of("some-token")); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testWithClientTokenNPE() { + withClientToken(null); + } + } diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java index 7864015c2a..87dd2b18c7 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeSubnetsResponseTest.java @@ -28,10 +28,6 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - * @author Andrew Bayer - */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeSubnetsResponseTest") public class DescribeSubnetsResponseTest extends BaseHandlerTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java index 57157e96d6..065f98a99f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/DescribeTagsResponseTest.java @@ -28,9 +28,6 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeTagsResponseTest") public class DescribeTagsResponseTest extends BaseHandlerTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java index d29c852493..93edb3228d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/parse/GetPasswordDataResponseTest.java @@ -27,9 +27,6 @@ import org.jclouds.http.functions.BaseHandlerTest; import org.testng.annotations.Test; -/** - * @author Adrian Cole - */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "GetPasswordDataResponseTest") public class GetPasswordDataResponseTest extends BaseHandlerTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java index b5008ad828..79a692996b 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/predicates/VolumeDetachedTest.java @@ -35,9 +35,6 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -/** - * @author Andrei Savu - */ @Test(groups = "unit", singleThreaded = true) public class VolumeDetachedTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java index 89148056d6..8d00242444 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/suppliers/DescribeAvailabilityZonesInRegionTest.java @@ -40,8 +40,6 @@ /** * A test for {@link DescribeAvailabilityZonesInRegion}. - * - * @author Eric Pabst (pabstec@familysearch.org) */ public class DescribeAvailabilityZonesInRegionTest { @Test diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java index 242bf59a4c..01ce950841 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/IpPermissionsTest.java @@ -25,8 +25,6 @@ /** * Tests possible uses of IpPermissions - * - * @author Adrian Cole */ @Test(testName = "IpPermissionsTest") public class IpPermissionsTest { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java index 5a4af146a8..72018e596d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/util/TagsTest.java @@ -26,9 +26,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test public class TagsTest { Tag resourceTag1 = Tag.builder().resourceType(IMAGE).resourceId("1").key("key").value("value").build(); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java index 2e0980fd28..68b7265c16 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AllocateAddressResponseHandlerTest.java @@ -26,8 +26,6 @@ /** * Tests behavior of {@code AllocateAddressResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AllocateAddressResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java index 1555ffe4d0..d43306db60 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/AttachmentHandlerTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code AttachmentHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AttachmentHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java index 4bc0550309..d789d86ad1 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BaseEC2HandlerTest.java @@ -39,10 +39,6 @@ import com.google.inject.Guice; import com.google.inject.Provides; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit") public abstract class BaseEC2HandlerTest extends BaseHandlerTest { protected String defaultRegion = Region.US_EAST_1; diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java index 097feaeb01..16eb8fa18a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BlockDeviceMappingHandlerTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code BlockDeviceMappingHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BlockDeviceMappingHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java index 1d561446e5..3636fc9e61 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/BundleTaskHandlerTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code BundleTaskHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BundleTaskHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java similarity index 90% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java index 346c3baeef..278b97839c 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/CreateVolumeResponseHandlerTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code CreateVolumeResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "CreateVolumeResponseHandlerTest") @@ -43,9 +41,9 @@ public void testApplyInputStream() { InputStream is = getClass().getResourceAsStream("/created_volume.xml"); Volume expected = new Volume(Region.US_EAST_1, "vol-2a21e543", 1, null, - "us-east-1a", Volume.Status.CREATING, dateService - .iso8601DateParse("2009-12-28T05:42:53.000Z"), Sets - . newLinkedHashSet()); + "us-east-1a", Volume.Status.CREATING, dateService + .iso8601DateParse("2009-12-28T05:42:53.000Z"), "standard", 0, false, + Sets. newLinkedHashSet()); CreateVolumeResponseHandler handler = injector.getInstance(CreateVolumeResponseHandler.class); addDefaultRegionToHandler(handler); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java index 7c40ec54d3..65c61c26ed 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAddressesResponseHandlerTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code DescribeAddressesResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeAddressesResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java index a58e1c9664..b29dd8ddb0 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeAvailabilityZonesResponseHandlerTest.java @@ -38,8 +38,6 @@ /** * Tests behavior of {@code DescribeAvailabilityZonesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeAvailabilityZonesResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java index 07c9a4d9da..2f61eadace 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeBundleTasksResponseHandlerTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code DescribeBundleTasksResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeBundleTasksResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java similarity index 87% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java index f2b08946b6..d44efa6e5f 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeImagesResponseHandlerTest.java @@ -18,6 +18,7 @@ import static com.google.common.collect.Iterables.get; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; import java.io.InputStream; import java.util.Set; @@ -48,8 +49,6 @@ /** * Tests behavior of {@code DescribeImagesResponseHandler} - * - * @author Adrian Cole */ @Test(groups = "unit", testName = "DescribeImagesResponseHandlerTest") public class DescribeImagesResponseHandlerTest { @@ -85,17 +84,22 @@ null, RootDeviceType.INSTANCE_STORE, null, ImmutableMap. public void testEBS() { Set contents = ImmutableSet.of(new Image("us-east-1", Architecture.I386, "websrv_2009-12-10", - "Web Server AMI", "ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852", - ImageState.AVAILABLE, "available", ImageType.MACHINE, true, Sets. newHashSet(), null, "windows", null, - RootDeviceType.EBS, "/dev/sda1", ImmutableMap. of("/dev/sda1", - new EbsBlockDevice("snap-d01272b9", 30, true), "xvdf", new EbsBlockDevice("snap-d31272ba", 250, - false)), ImmutableMap. of(), VirtualizationType.HVM, Hypervisor.XEN)); + "Web Server AMI", "ami-246f8d4d", "706093390852/websrv_2009-12-10", "706093390852", + ImageState.AVAILABLE, "available", ImageType.MACHINE, true, Sets. newHashSet(), null, "windows", null, + RootDeviceType.EBS, "/dev/sda1", + ImmutableMap. of("/dev/sda1", + new EbsBlockDevice("snap-d01272b9", 30, true, "standard", null, false), + "xvdf", new EbsBlockDevice("snap-d31272ba", 250, false, "standard", null, false)), + ImmutableMap. of(), VirtualizationType.HVM, Hypervisor.XEN)); Set result = parseImages("/describe_images_ebs.xml"); assertEquals(result.toString(), contents.toString()); assertEquals(get(result, 0).getImageState(), ImageState.AVAILABLE); assertEquals(get(result, 0).getRawState(), "available"); + assertEquals(get(result, 0).getEbsBlockDevices().get("/dev/sda1").getVolumeType(), "standard"); + assertEquals(get(result, 0).getEbsBlockDevices().get("/dev/sda1").isEncrypted(), false); + assertNull(get(result, 0).getEbsBlockDevices().get("/dev/sda1").getIops()); } public void testTags() { diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java index 43b4ba36c0..d5aa7aac36 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstanceAttributeTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code DescribeInstanceAttribute} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeInstanceAttributeTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java index f1ac58b60b..862388fdd8 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeInstancesResponseHandlerTest.java @@ -48,8 +48,6 @@ /** * Tests behavior of {@code DescribeInstancesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeInstancesResponseHandlerTest") @@ -99,7 +97,7 @@ public void testApplyInputStream() { .availabilityZone("us-east-1b").virtualizationType("paravirtual").privateDnsName( "10-251-50-132.ec2.internal")// product codes // ImmutableSet.of("774F4FF8") - .tags(ImmutableMap.of("Name","ec2-o", "Empty","")) + .tags(ImmutableMap.of("Name", "ec2-o", "Empty", "")) .ramdiskId("ari-badbad00").rootDeviceType(RootDeviceType.INSTANCE_STORE).build(), RunningInstance.builder().region(defaultRegion).groupName("default").amiLaunchIndex("23") .dnsName("ec2-72-44-33-6.compute-1.amazonaws.com").imageId("ami-6ea54007").instanceId( diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java index b3644dd5cf..0ea51ed923 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeKeyPairsResponseHandlerTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code DescribeKeyPairsResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeKeyPairsResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java index 1e444e3cfa..a3df407805 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeRegionsResponseHandlerTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code DescribeRegionsResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeRegionsResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java index caabd1a401..d534b01501 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSecurityGroupsResponseHandlerTest.java @@ -34,8 +34,6 @@ /** * Tests behavior of {@code DescribeSecurityGroupsResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java index 9f6fbfbbe5..4d16d7c882 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeSnapshotsResponseHandlerTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code DescribeSnapshotsResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeSnapshotsResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java similarity index 82% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java index ae286c93d2..aba1d1b846 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/DescribeVolumesResponseHandlerTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code DescribeVolumesResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeVolumesResponseHandlerTest") @@ -45,13 +43,14 @@ public void testApplyInputStream() { Set expected = Sets.newLinkedHashSet(); expected.add(new Volume(defaultRegion, "vol-2a21e543", 1, null, "us-east-1a", Volume.Status.AVAILABLE, dateService.iso8601DateParse("2009-12-28T05:42:53.000Z"), - Sets. newLinkedHashSet())); + "standard", 0, false, Sets. newLinkedHashSet())); expected.add(new Volume(defaultRegion, "vol-4282672b", 800, "snap-536d1b3a", - "us-east-1a", Volume.Status.IN_USE, dateService - .iso8601DateParse("2008-05-07T11:51:50.000Z"), Sets - . newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509", - "/dev/sdh", Attachment.Status.ATTACHED, dateService - .iso8601DateParse("2008-05-07T12:51:50.000Z"))))); + "us-east-1a", Volume.Status.IN_USE, dateService + .iso8601DateParse("2008-05-07T11:51:50.000Z"), + "standard", 0, false, + Sets. newHashSet(new Attachment(defaultRegion, "vol-4282672b", "i-6058a509", + "/dev/sdh", Attachment.Status.ATTACHED, dateService + .iso8601DateParse("2008-05-07T12:51:50.000Z"))))); DescribeVolumesResponseHandler handler = injector .getInstance(DescribeVolumesResponseHandler.class); diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java index 1598192455..f823120b94 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/GetConsoleOutputResponseHandlerTest.java @@ -25,8 +25,6 @@ /** * Tests behavior of {@code GetConsoleOutputResponseHandler} - * - * @author Andrew Kennedy */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "GetConsoleOutputResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java index 929d5a51aa..6ec958902d 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/InstanceStateChangeHandlerTest.java @@ -32,8 +32,6 @@ /** * Tests behavior of {@code InstanceStateChangeHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "InstanceStateChangeHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java index 1ee4323bcf..9ec4b9a885 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/KeyPairResponseHandlerTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code KeyPairResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "KeyPairResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java index e031c3d629..73bfae670a 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/PermissionHandlerTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code PermissionHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "PermissionHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java index 1d22a667cb..ff818b0607 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/RunInstancesResponseHandlerTest.java @@ -34,8 +34,6 @@ /** * Tests behavior of {@code RunInstancesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "RunInstancesResponseHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java similarity index 98% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java index 993bf878a3..dc6fc6781e 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/java/org/jclouds/ec2/xml/SnapshotHandlerTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code SnapshotHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SnapshotHandlerTest") diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/allocate_address.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/allocate_address.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/allocate_address.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/amzn_images.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/amzn_images.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/amzn_images.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/amzn_images.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/attach.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/attach.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/attach.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/attach.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/authorize_securitygroup_ingress_response.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/authorize_securitygroup_ingress_response.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/authorize_securitygroup_ingress_response.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/authorize_securitygroup_ingress_response.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-ap-northeast-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-ap-northeast-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-ap-northeast-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-ap-northeast-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-ap-southeast-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-ap-southeast-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-ap-southeast-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-ap-southeast-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-eu-west-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-eu-west-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-eu-west-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-eu-west-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-sa-east-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-sa-east-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-sa-east-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-sa-east-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-east-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-east-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-east-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-east-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-west-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-west-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-west-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-west-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-west-2.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-west-2.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones-us-west-2.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones-us-west-2.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/availabilityZones.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/availabilityZones.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/bundle_instance.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/bundle_instance.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/bundle_instance.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/bundle_instance.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/cancel_bundle_task.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/cancel_bundle_task.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/cancel_bundle_task.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/cancel_bundle_task.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/create_keypair.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/create_keypair.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/create_keypair.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/create_keypair.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_securitygroup.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_securitygroup.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_securitygroup.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_securitygroup.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_snapshot.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_snapshot.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_snapshot.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_snapshot.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_volume.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_volume.xml similarity index 80% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_volume.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_volume.xml index acca927183..4fbcabe1cc 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/created_volume.xml +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/created_volume.xml @@ -6,4 +6,7 @@ us-east-1a creating 2009-12-28T05:42:53.000Z + standard + 0 + false \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/delete_securitygroup.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/delete_securitygroup.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/delete_securitygroup.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/delete_securitygroup.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_addresses.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_addresses.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_addresses.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_addresses.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_addresses_single.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_addresses_single.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_addresses_single.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_addresses_single.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_bundle_tasks.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_bundle_tasks.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_bundle_tasks.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_bundle_tasks.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_blockDeviceMapping.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_blockDeviceMapping.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_blockDeviceMapping.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_blockDeviceMapping.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_launchPermission.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_launchPermission.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_launchPermission.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_launchPermission.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_ebs.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_ebs.xml similarity index 88% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_ebs.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_ebs.xml index 12830ab032..794cd76a70 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_ebs.xml +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_ebs.xml @@ -23,6 +23,8 @@ snap-d01272b9 30 true + standard + false @@ -31,6 +33,8 @@ snap-d31272ba 250 false + standard + false diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension0.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension0.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension0.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension0.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension1.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension2.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension2.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_imageextension2.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_imageextension2.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_nova.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_nova.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_nova.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_nova.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_tags.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_tags.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_tags.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_tags.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_windows.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_windows.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_images_windows.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_images_windows.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_ebs.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_ebs.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_ebs.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_ebs.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_multiple.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_multiple.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_multiple.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_multiple.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-1.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-1.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running-1.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-1.xml diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-named.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-named.xml new file mode 100644 index 0000000000..4a432794ee --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running-named.xml @@ -0,0 +1,186 @@ + + + f6d3252e-35e5-4ef5-b2c5-62da95dd829b + + + r-205ad944 + 993194456877 + + + sg-3c6ef654 + jclouds#mygroup2 + + + + + i-2ba64342 + ami-aecd60c7 + + 16 + running + + ip-10-28-89-195.ec2.internal + ec2-50-16-1-166.compute-1.amazonaws.com + + jclouds#mygroup2#81 + 0 + + t1.micro + 2012-08-02T04:28:30.000Z + + us-east-1e + + default + + aki-88aa75e1 + + disabled + + 10.28.89.195 + 50.16.1.166 + + + sg-3c6ef654 + jclouds#mygroup2 + + + x86_64 + ebs + /dev/sda1 + + + /dev/sda1 + + vol-f2d7c993 + attached + 2012-08-02T04:28:56.000Z + true + + + + paravirtual + + + + Name + test-node + + + xen + + + i-2bc64242 + ami-aecd60c7 + + 16 + running + + ip-10-28-89-195.ec2.internal + ec2-50-16-1-166.compute-1.amazonaws.com + + jclouds#mygroup2#81 + 0 + + t1.micro + 2012-08-02T04:28:30.000Z + + us-east-1e + + default + + aki-88aa75e1 + + disabled + + 10.28.89.195 + 50.16.1.166 + + + sg-3c6ef654 + jclouds#mygroup2 + + + x86_64 + ebs + /dev/sda1 + + + /dev/sda1 + + vol-f2d7c993 + attached + 2012-08-02T04:28:56.000Z + true + + + + paravirtual + + + + Name + second-node + + + xen + + + i-2be64332 + ami-aecd60c7 + + 16 + running + + ip-10-28-89-195.ec2.internal + ec2-50-16-1-166.compute-1.amazonaws.com + + jclouds#mygroup2#81 + 0 + + t1.micro + 2012-08-02T04:28:30.000Z + + us-east-1e + + default + + aki-88aa75e1 + + disabled + + 10.28.89.195 + 50.16.1.166 + + + sg-3c6ef654 + jclouds#mygroup2 + + + x86_64 + ebs + /dev/sda1 + + + /dev/sda1 + + vol-f2d7c993 + attached + 2012-08-02T04:28:56.000Z + true + + + + paravirtual + + + + Name + third-node + + + xen + + + + + \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running_securitygroups.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running_securitygroups.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_instances_running_securitygroups.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_running_securitygroups.xml diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_three_ids.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_three_ids.xml new file mode 100644 index 0000000000..dbf3b71747 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_instances_three_ids.xml @@ -0,0 +1,74 @@ + + r-47a5402e + AIDADH4IGTRXXKCD + + + default + + + + + i-2ba64342 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 0 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + i-2bc64242 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 1 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + i-2be64332 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 2 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_keypairs.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_keypairs.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_keypairs.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_keypairs.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_empty.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_empty.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_empty.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_empty.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_cidr.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_cidr.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_cidr.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_cidr.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_group.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_group.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_group.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_group.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_new.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_new.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_new.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_new.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_single.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_single.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_securitygroups_extension_single.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_securitygroups_extension_single.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_snapshots.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_snapshots.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_snapshots.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_snapshots.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_subnets.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_subnets.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_subnets.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_subnets.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_tags.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_tags.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_tags.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_tags.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes.xml similarity index 84% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes.xml index 45b3efa64a..8861d6a883 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes.xml +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes.xml @@ -9,6 +9,9 @@ us-east-1a available 2009-12-28T05:42:53.000Z + standard + 0 + false @@ -18,6 +21,9 @@ us-east-1a in-use 2008-05-07T11:51:50.000Z + standard + 0 + false vol-4282672b diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes_single.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes_single.xml similarity index 83% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes_single.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes_single.xml index fcc10a5d84..5d501ea973 100644 --- a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/describe_volumes_single.xml +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/describe_volumes_single.xml @@ -9,6 +9,9 @@ us-east-1a in-use 2008-05-07T11:51:50.000Z + standard + 0 + false diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/disableApiTermination.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/disableApiTermination.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/disableApiTermination.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/disableApiTermination.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/get_console_output_response.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/get_console_output_response.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/get_console_output_response.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/get_console_output_response.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/get_passworddata.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/get_passworddata.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/get_passworddata.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/get_passworddata.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/instanceInitiatedShutdownBehavior.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/instanceInitiatedShutdownBehavior.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/instanceInitiatedShutdownBehavior.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/instanceInitiatedShutdownBehavior.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/instanceType.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/instanceType.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/instanceType.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/instanceType.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/log4j.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/log4j.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/log4j.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/log4j.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/new_instance.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/new_instance.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/new_instance.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/new_instance.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/new_securitygroup.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/new_securitygroup.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/new_securitygroup.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/new_securitygroup.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/ramdisk.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/ramdisk.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/ramdisk.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/ramdisk.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints-additional.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints-additional.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints-additional.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints-additional.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints-all.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints-all.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints-all.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints-all.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/regionEndpoints.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/regionEndpoints.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/run_instances.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/run_instances.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/run_instances_cloudbridge.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_cloudbridge.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/run_instances_cloudbridge.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_cloudbridge.xml diff --git a/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_three.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_three.xml new file mode 100644 index 0000000000..6530a7fc18 --- /dev/null +++ b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/run_instances_three.xml @@ -0,0 +1,74 @@ + + r-47a5402e + AIDADH4IGTRXXKCD + + + default + + + + + i-2ba64342 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 0 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + i-2bc64242 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 1 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + i-2be64332 + ami-aecd60c7 + + 0 + pending + + + + example-key-name + 2 + m1.small + 2007-08-07T11:51:50.000Z + + us-east-1b + + + enabled + + xen + + + \ No newline at end of file diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/start_instances.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/start_instances.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/start_instances.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/start_instances.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/stop_instances.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/stop_instances.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/stop_instances.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/stop_instances.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/terminate_instances.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/terminate_instances.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/terminate_instances.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/terminate_instances.xml diff --git a/dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/userData.xml b/dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/userData.xml similarity index 100% rename from dependencies/jclouds/apis/ec2/1.7.1-stratos/src/test/resources/userData.xml rename to dependencies/jclouds/apis/ec2/1.8.0-stratos/src/test/resources/userData.xml diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java deleted file mode 100644 index 9abea53124..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaAsyncApi.java +++ /dev/null @@ -1,214 +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.jclouds.openstack.nova.v2_0; - -import java.io.Closeable; -import java.util.Set; - -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Zone; -import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI; -import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.EndpointParam; - -import com.google.common.base.Optional; -import com.google.inject.Provides; - -/** - * Provides asynchronous access to Nova via their REST API. - *

- * - * @see NovaApi - * @see - * @author Adrian Cole - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as - * {@link NovaAsyncApi} interface will be removed in jclouds 1.7. - */ -@Deprecated -public interface NovaAsyncApi extends Closeable { - - /** - * - * @return the Zone codes configured - */ - @Provides - @Zone - Set getConfiguredZones(); - - /** - * Provides asynchronous access to availability zone features - */ - @Delegate - AvailabilityZoneAPI getAvailabilityZoneApi( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Server features. - */ - @Delegate - ServerAsyncApi getServerApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Flavor features. - */ - @Delegate - FlavorAsyncApi getFlavorApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Extension features. - */ - @Delegate - ExtensionAsyncApi getExtensionApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Image features. - */ - @Delegate - ImageAsyncApi getImageApiForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Floating IP features. - */ - @Delegate - Optional getFloatingIPExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Security Group features. - */ - @Delegate - Optional getSecurityGroupExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Key Pair features. - */ - @Delegate - Optional getKeyPairExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Host Administration features. - */ - @Delegate - Optional getHostAdministrationExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Simple Tenant Usage features. - */ - @Delegate - Optional getSimpleTenantUsageExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Virtual Interface features. - */ - @Delegate - Optional getVirtualInterfaceExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - - /** - * Provides asynchronous access to Server Extra Data features. - */ - @Delegate - Optional getServerWithSecurityGroupsExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Server Admin Actions features. - */ - @Delegate - Optional getServerAdminExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to HostAggregate features. - */ - @Delegate - Optional getHostAggregateExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Flavor extra specs features. - */ - @Delegate - Optional getFlavorExtraSpecsExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Quota features. - */ - @Delegate - Optional getQuotaExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Quota Classes features. - */ - @Delegate - Optional getQuotaClassExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Volume features. - */ - @Delegate - Optional getVolumeExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Volume features. - */ - @Delegate - Optional getVolumeAttachmentExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - - /** - * Provides asynchronous access to Volume Type features. - */ - @Delegate - Optional getVolumeTypeExtensionForZone( - @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.java deleted file mode 100644 index 27199ef4c6..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/QuotaClass.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.jclouds.openstack.nova.v2_0.domain; - -import java.beans.ConstructorProperties; - -/** - * Represents the set of limits (quota class) returned by the Quota Class Extension - * - * @see org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi -*/ -public class QuotaClass extends Quota { - - public static Builder builder() { - return new ConcreteBuilder(); - } - - public Builder toBuilder() { - return new ConcreteBuilder().fromQuotaClass(this); - } - - public abstract static class Builder> extends Quota.Builder { - - public QuotaClass build() { - return new QuotaClass(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs); - } - - public T fromQuotaClass(QuotaClass in) { - return super.fromQuotas(in); - } - } - - private static class ConcreteBuilder extends Builder { - @Override - protected ConcreteBuilder self() { - return this; - } - } - - - @ConstructorProperties({ - "id", "metadata_items", "injected_file_content_bytes", "volumes", "gigabytes", "ram", "floating_ips", "instances", "injected_files", "cores", "security_groups", "security_group_rules", "key_pairs" - }) - protected QuotaClass(String id, int metadataItems, int injectedFileContentBytes, int volumes, int gigabytes, int ram, int floatingIps, int instances, int injectedFiles, int cores, int securityGroups, int securityGroupRules, int keyPairs) { - super(id, metadataItems, injectedFileContentBytes, volumes, gigabytes, ram, floatingIps, instances, injectedFiles, cores, securityGroups, securityGroupRules, keyPairs); - } - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java deleted file mode 100644 index d248681f18..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAPI.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.jclouds.openstack.nova.v2_0.extensions; - - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -/** - * @author Inbar Stolberg - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS) -public interface AvailabilityZoneAPI { - - /** - * @return all availability zones - */ - FluentIterable list(); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java deleted file mode 100644 index d85f305976..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneAsyncApi.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.jclouds.openstack.nova.v2_0.extensions; - - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; -import org.jclouds.Fallbacks; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.core.MediaType; - -/** - * @author Inbar Stolberg - */ - -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS) -@RequestFilters(AuthenticateRequest.class) -public interface AvailabilityZoneAsyncApi { - - /** - * @return all availability zones - */ - @GET - @Path("/os-availability-zone") - @SelectJson("availabilityZoneInfo") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(Fallbacks.EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java deleted file mode 100644 index 946463cd8b..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java +++ /dev/null @@ -1,77 +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.jclouds.openstack.nova.v2_0.extensions; - -import java.util.Map; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; - -/** - * Provide access to extra metadata for Nova flavors. - * - * @author Adam Lowe - * @see - * @see org.jclouds.openstack.nova.v2_0.features.FlavorApi - * @see org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLAVOR_EXTRA_SPECS) -public interface FlavorExtraSpecsApi { - - /** - * Retrieve all extra specs for a flavor - * - * @return the set of extra metadata for the flavor - */ - Map getMetadata(String flavorId); - - /** - * Creates or updates the extra specs for a given flavor - * - * @param flavorId the id of the flavor to modify - * @param specs the extra specs to apply - */ - Boolean updateMetadata(String flavorId, Map specs); - - /** - * Return a single extra spec value - * - * @param flavorId the id of the flavor to modify - * @param key the extra spec key to retrieve - */ - String getMetadataKey(String flavorId, String key); - - /** - * Creates or updates a single extra spec value - * - * @param flavorId the id of the flavor to modify - * @param key the extra spec key (when creating ensure this does not include whitespace or other difficult characters) - * @param value the value to associate with the key - */ - Boolean updateMetadataEntry(String flavorId, String key, String value); - - /** - * Deletes an extra spec - * - * @param flavorId the id of the flavor to modify - * @param key the extra spec key to delete - */ - Boolean deleteMetadataKey(String flavorId, String key); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java deleted file mode 100644 index ddf720f0a8..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java +++ /dev/null @@ -1,98 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.FloatingIP; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Floating IPs. - *

- * - * @see FloatingIPAsyncApi - * @author Jeremy Daggett - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) -public interface FloatingIPApi { - - /** - * List all Floating IP addresses - * - * @return all Floating IPs - */ - FluentIterable list(); - - /** - * Get a specific Floating IP address - * - * @return all Floating IPs - */ - FloatingIP get(String id); - - /** - * Allocate a Floating IP address - * - * @return a newly created FloatingIP - */ - FloatingIP create(); - - /** - * Allocate a Floating IP address from a pool - * - * @param pool - * Pool to allocate IP address from - * @return a newly created FloatingIP - */ - FloatingIP allocateFromPool(String pool); - - /** - * Decreate a Floating IP address - * - * @param id - * the Floating IP id - */ - void delete(String id); - - /** - * Add a Floating IP address to a Server - * - * @param serverId - * the serverId - * @param address - * the IP address to add - * - * NOTE: Possibly move this to ServerApi? - */ - void addToServer(String address, String serverId); - - /** - * Remove a Floating IP address from a Server - * - * @param serverId - * the serverId - * @param address - * the IP address to remove - * - * NOTE: Possibly move this to ServerApi? - */ - void removeFromServer(String address, String serverId); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java deleted file mode 100644 index 95b8f429cb..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java +++ /dev/null @@ -1,103 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.Host; -import org.jclouds.openstack.nova.v2_0.domain.HostResourceUsage; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides asynchronous access to Host Administration features via the REST API. - *

- * - * @author Adam Lowe - * @see HostAdministrationAsyncApi - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.HOSTS) -public interface HostAdministrationApi { - - /** - * Returns the list of hosts - * - * @return the usage information - */ - FluentIterable list(); - - /** - * Retrieves the physical/usage resource on a specific host - * - * @return the usage information - */ - FluentIterable listResourceUsage(String hostId); - - /** - * Allow the specified host to accept new instances. - * - * @return true if successful - */ - boolean enable(String hostId); - - /** - * Prevent the specified host from accepting new instances. - * - * @return true if successful - */ - boolean disable(String hostId); - - /** - * Start host maintenance window. - *

- * Note: this triggers guest VMs evacuation. - * - * @return true if successful - */ - boolean startMaintenance(String hostId); - - /** - * Stop host maintenance window. - * - * @return true if successful - */ - boolean stopMaintenance(String hostId); - - /** - * Startup a host. - * - * @return true if successful - */ - boolean startup(String hostId); - - /** - * Shutdown a host. - * - * @return true if successful - */ - boolean shutdown(String hostId); - - /** - * Reboot a host. - * - * @return true if successful - */ - boolean reboot(String hostId); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java deleted file mode 100644 index a6461aaaaa..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.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.jclouds.openstack.nova.v2_0.extensions; - -import java.util.Map; -import org.jclouds.openstack.nova.v2_0.domain.HostAggregate; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provide access to Host Aggregates in Nova (alias "OS-AGGREGATES") - * - * @author Adam Lowe - * @see HostAggregateAsyncApi - * @see - * @see - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.AGGREGATES) -public interface HostAggregateApi { - - /** - * @return the set of host aggregates. - */ - FluentIterable list(); - - /** - * Retrieves the details of an aggregate, hosts and metadata included. - * - * @return the details of the aggregate requested. - */ - HostAggregate get(String id); - - /** - * Creates an aggregate, given its name and availability zone. - * - * @return the newly created Aggregate - */ - HostAggregate createInAvailabilityZone(String name, String availabilityZone); - - /** - * Updates the name of an aggregate. - */ - HostAggregate updateName(String id, String name); - - /** - * Updates the availability zone an aggregate. - */ - HostAggregate updateAvailabilityZone(String id, String availabilityZone); - - /** - * Removes an aggregate. - */ - Boolean delete(String id); - - /** - * Adds a host to an aggregate - */ - HostAggregate addHost(String id, String host); - - /** - * Removes a host from an aggregate - */ - HostAggregate removeHost(String id, String host); - - /** - * Adds metadata to an aggregate - */ - HostAggregate setMetadata(String id, Map metadata); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java deleted file mode 100644 index 6b4af7bdb4..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java +++ /dev/null @@ -1,65 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.KeyPair; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Security Groups. - *

- * - * @see KeyPairAsyncApi - * @author Jeremy Daggett - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) -public interface KeyPairApi { - - /** - * List all Key Pairs. - * - * @return all Key Pairs - */ - FluentIterable list(); - - /** - * Create a Key Pair. - * - * @return a Key Pair - */ - KeyPair create(String name); - - /** - * Create a Key Pair with a public key. - * - * @return a Key Pair with a public key. - */ - KeyPair createWithPublicKey(String name, String publicKey); - - /** - * Delete a Key Pairs. - * - * @return - */ - boolean delete(String name); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java deleted file mode 100644 index ea59d0ff9f..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java +++ /dev/null @@ -1,57 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.Quota; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; - -/** - * The quotas extension enables limiters placed on the resources used per tenant (project) for virtual instances. It is - * used with the OpenStack Compute API 1.1 for administrators who need to control the amount of volumes, memory, floating - * IP addresses, instances, or cores allowed within a defined tenant or project. - *

- * To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas. - * - * @author Adam Lowe - * @see QuotaAsyncApi - * @see - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTAS) -public interface QuotaApi { - - /** - * @return the quota settings for the tenant - */ - Quota getByTenant(String tenantId); - - /** - * Update the quotas for a given tenant - * - * @return true if successful - */ - boolean updateQuotaOfTenant(Quota quota, String tenantId); - - /** - * @return the set of default quotas for the tenant - */ - Quota getDefaultsForTenant(String tenantId); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.java deleted file mode 100644 index 4a6c01013a..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApi.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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.QuotaClass; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; - -/** - * Provides synchronous access to Quota Classes via the REST API. - *

- * To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas. - * - * @author Adam Lowe - * @see QuotaClassAsyncApi - * @see - * @see - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES) -public interface QuotaClassApi { - - /** - * @return the quota settings for the tenant - */ - QuotaClass get(String id); - - /** - * Update the quotas for a given tenant - * - * @return true if successful - */ - boolean update(String id, QuotaClass quotas); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java deleted file mode 100644 index 867ccd3807..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java +++ /dev/null @@ -1,89 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.Ingress; -import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; -import org.jclouds.openstack.nova.v2_0.domain.SecurityGroupRule; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Security Groups. - *

- * - * @see SecurityGroupAsyncApi - * @author Jeremy Daggett - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS) -public interface SecurityGroupApi { - - /** - * List all Security Groups. - * - * @return all Security Groups - */ - FluentIterable list(); - - /** - * Get a specific Security Group - * - * @return a specific Security Group - */ - SecurityGroup get(String id); - - /** - * Create a Security Group - * - * @return a new Security Group - */ - SecurityGroup createWithDescription(String name, String description); - - /** - * Delete a Security Group. - * - * @return - */ - boolean delete(String id); - - /** - * Create a Security Group Rule. - * - * @return a new Security Group Rule - */ - SecurityGroupRule createRuleAllowingCidrBlock(String parentGroup, Ingress ingress, String sourceCidr); - - /** - * Create a Security Group Rule. - * - * @return a new Security Group Rule - */ - SecurityGroupRule createRuleAllowingSecurityGroupId(String parentGroup, Ingress ingress, - String groupId); - - /** - * Delete a Security Group Rule. - * - * @return - */ - Boolean deleteRule(String id); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java deleted file mode 100644 index 6ad70c2d95..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java +++ /dev/null @@ -1,120 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.BackupType; -import org.jclouds.openstack.nova.v2_0.options.CreateBackupOfServerOptions; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; - -/** - * Provide additional actions for servers: - * 'suspend', 'resume', 'migrate', 'lock', 'unlock', 'resetNetwork', 'createBackup', 'pause', 'migrateLive', - * 'injectNetworkInfo', 'unpause' - * - * @author Adam Lowe - * @see org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS) -public interface ServerAdminApi { - - /** - * Suspend a server. - * - * @param id id of the server - */ - Boolean suspend(String id); - - /** - * Resume a server. - * - * @param id id of the server - */ - Boolean resume(String id); - - /** - * Migrate a server. - * - * @param id id of the server - */ - Boolean migrate(String id); - - /** - * Lock a server. - * - * @param id id of the server - */ - Boolean lock(String id); - - /** - * Unlock a server. - * - * @param id id of the server - */ - Boolean unlock(String id); - - /** - * Reset network of a server. - * - * @param id id of the server - */ - Boolean resetNetwork(String id); - - /** - * Create backup of a server. - * - * @param id id of the server - * @param imageName the name of the image to create - * @param backupType the type of backup - * @param rotation the number of images to retain (0 to simply overwrite) - * @param options optional rotation and/or metadata parameters - * @return the id of the newly created image - */ - String createBackup(String id, String imageName, BackupType backupType, int rotation, CreateBackupOfServerOptions... options); - - /** - * Pause a server. - * - * @param id id of the server - */ - Boolean pause(String id); - - /** - * Unpause a server. - * - * @param id id of the server - */ - Boolean unpause(String id); - - - /** - * Live migrate a server. - * - * @param id id of the server - */ - Boolean liveMigrate(String id, String host, boolean blockMigration, boolean diskOverCommit); - - /** - * Inject network info into a server. - * - * @param id id of the server - */ - Boolean injectNetworkInfo(String id); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java deleted file mode 100644 index f9c91ae58c..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; - -/** - * Provides synchronous access to Server details including security group, referred to as the CREATESERVEREXT extension - * in the nova documentation - *

- * NOTE: the equivalent to listServersInDetail() isn't available at the other end, so not extending ServerApi at this - * time. - * - * @author Adam Lowe - * @see org.jclouds.openstack.nova.v2_0.features.ServerApi - * @see ServerWithSecurityGroupsAsyncApi - * @see - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.CREATESERVEREXT) -public interface ServerWithSecurityGroupsApi { - - /** - * Retrieve details of the specified server, including security groups - * - * @param id id of the server - * @return server or null if not found - */ - ServerWithSecurityGroups get(String id); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java deleted file mode 100644 index daf089f676..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java +++ /dev/null @@ -1,43 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.VirtualInterface; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Virtual Interface features (VIFs). - * - * @see VirtualInterfaceAsyncApi - * @author Adam Lowe - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VIRTUAL_INTERFACES) -public interface VirtualInterfaceApi { - - /** - * Returns the list of Virtual Interfaces for a given instance. - * - * @return the list of snapshots - */ - FluentIterable listOnServer(String serverId); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java deleted file mode 100644 index f9ab865fb5..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java +++ /dev/null @@ -1,147 +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.jclouds.openstack.nova.v2_0.extensions; - -import org.jclouds.openstack.nova.v2_0.domain.Volume; -import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; -import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot; -import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions; -import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Volumes. - *

- * - * @see VolumeAsyncApi - * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi - * @author Adam Lowe - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES) -public interface VolumeApi { - /** - * Returns a summary list of snapshots. - * - * @return the list of snapshots - */ - FluentIterable list(); - - /** - * Returns a detailed list of volumes. - * - * @return the list of volumes. - */ - FluentIterable listInDetail(); - - /** - * Return data about the given volume. - * - * @return details of a specific snapshot. - */ - Volume get(String volumeId); - - /** - * Creates a new Snapshot - * - * @return the new Snapshot - */ - Volume create(int sizeGB, CreateVolumeOptions... options); - - /** - * Delete a snapshot. - * - * @return true if successful - */ - boolean delete(String volumeId); - - /** - * List volume attachments for a given instance. - * - * @return all Floating IPs - * @deprecated To be removed in jclouds 1.7 - * @see VolumeAttachmentApi#listAttachmentsOnServer(String) - */ - @Deprecated FluentIterable listAttachmentsOnServer(String serverId); - - /** - * Get a specific attached volume. - * - * @return data about the given volume attachment. - * @deprecated To be removed in jclouds 1.7 - * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String) - */ - @Deprecated VolumeAttachment getAttachmentForVolumeOnServer(String volumeId, String serverId); - - /** - * Attach a volume to an instance - * - * @return data about the new volume attachment - * @deprecated To be removed in jclouds 1.7 - * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String) - */ - @Deprecated VolumeAttachment attachVolumeToServerAsDevice(String volumeId, String serverId, String device); - - /** - * Detach a Volume from an instance. - * - * @return true if successful - * @deprecated To be removed in jclouds 1.7 - * @see VolumeAttachmentApi#detachVolumeFromServer(String, String) - */ - @Deprecated Boolean detachVolumeFromServer(String server_id, String volumeId); - - /** - * Returns a summary list of snapshots. - * - * @return the list of snapshots - */ - FluentIterable listSnapshots(); - - /** - * Returns a summary list of snapshots. - * - * @return the list of snapshots - */ - FluentIterable listSnapshotsInDetail(); - - /** - * Return data about the given snapshot. - * - * @return details of a specific snapshot. - */ - VolumeSnapshot getSnapshot(String snapshotId); - - /** - * Creates a new Snapshot - * - * @return the new Snapshot - */ - VolumeSnapshot createSnapshot(String volumeId, CreateVolumeSnapshotOptions... options); - - /** - * Delete a snapshot. - * - * @return true if successful - */ - boolean deleteSnapshot(String snapshotId); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java deleted file mode 100644 index 7aa576333a..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentAsyncApi.java +++ /dev/null @@ -1,107 +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.jclouds.openstack.nova.v2_0.extensions; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.WrapWith; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Volume Attachments . - * - * @see VolumeAttachmentApi - * @author Everett Toews - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES) -@RequestFilters(AuthenticateRequest.class) -public interface VolumeAttachmentAsyncApi { - /** - * @see VolumeAttachmentApi#listAttachmentsOnServer(String) - */ - @Named("volumeattachment:list") - @GET - @Path("/servers/{server_id}/os-volume_attachments") - @SelectJson("volumeAttachments") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listAttachmentsOnServer( - @PathParam("server_id") String serverId); - - /** - * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String) - */ - @Named("volumeattachment:get") - @GET - @Path("/servers/{server_id}/os-volume_attachments/{id}") - @SelectJson("volumeAttachment") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getAttachmentForVolumeOnServer( - @PathParam("id") String volumeId, - @PathParam("server_id") String serverId); - - /** - * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String) - */ - @Named("volumeattachment:attach") - @POST - @Path("/servers/{server_id}/os-volume_attachments") - @SelectJson("volumeAttachment") - @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) - @WrapWith("volumeAttachment") - ListenableFuture attachVolumeToServerAsDevice( - @PayloadParam("volumeId") String volumeId, - @PathParam("server_id") String serverId, - @PayloadParam("device") String device); - - /** - * @see VolumeAttachmentApi#detachVolumeFromServer(String, String) - */ - @Named("volumeattachment:detach") - @DELETE - @Path("/servers/{server_id}/os-volume_attachments/{id}") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture detachVolumeFromServer( - @PathParam("id") String volumeId, - @PathParam("server_id") String serverId); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java deleted file mode 100644 index be0e5cc51a..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.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.jclouds.openstack.nova.v2_0.extensions; - -import java.util.Map; -import org.jclouds.openstack.nova.v2_0.domain.VolumeType; -import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions; -import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.openstack.v2_0.services.Extension; - -import com.google.common.annotations.Beta; -import com.google.common.collect.FluentIterable; - -/** - * Provides synchronous access to Volume Type features - * - * @author Adam Lowe - * @see VolumeApi - * @see VolumeTypeAsyncApi - * @see - * @see - */ -@Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUME_TYPES) -public interface VolumeTypeApi { - - /** - * @return set of all volume types - */ - FluentIterable list(); - - /** - * @param id the id of the volume type to retrieve - * @return the requested volume type - */ - VolumeType get(String id); - - /** - * Creates a new volume type - * - * @param name the name of the new volume type - * @param options optional settings for the new volume type - * @return the new volume type - */ - VolumeType create(String name, CreateVolumeTypeOptions... options); - - /** - * Deletes a volume type - */ - boolean delete(String id); - - /** - * @param id the id of the volume type - * @return the set of extra metadata for the flavor - */ - Map getExtraSpecs(String id); - - /** - * Creates or updates the extra metadata for a given flavor - */ - boolean updateExtraSpecs(String id, Map specs); - - /** - * Retrieve a single extra spec value - * - * @param id the id of the volume type - * @param key the key of the extra spec item to retrieve - */ - String getExtraSpec(String id, String key); - - /** - * Creates or updates a single extra spec value - * - * @param id the id of the volume type - * @param key the extra spec key (when creating ensure this does not include whitespace or other difficult characters) - * @param value the new value to store associate with the key - */ - boolean updateExtraSpec(String id, String key, String value); - - /** - * Deletes an existing extra spec - * - * @param id the id of the volume type - * @param key the key of the extra spec to delete - */ - boolean deleteExtraSpec(String id, String key); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java deleted file mode 100644 index 792412003b..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.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.jclouds.openstack.nova.v2_0.features; - -import org.jclouds.collect.PagedIterable; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; -import org.jclouds.openstack.nova.v2_0.domain.Flavor; -import org.jclouds.openstack.v2_0.domain.Resource; -import org.jclouds.openstack.v2_0.options.PaginationOptions; - -/** - * Provides asynchronous access to Flavors via their REST API. - *

- * - * @see FlavorAsyncApi - * @see - * @author Jeremy Daggett, Ilja Bobkevic - */ -public interface FlavorApi { - - /** - * List all flavors (IDs, names, links) - * - * @return all flavors (IDs, names, links) - */ - PagedIterable list(); - - PaginatedCollection list(PaginationOptions options); - - /** - * List all flavors (all details) - * - * @return all flavors (all details) - */ - PagedIterable listInDetail(); - - PaginatedCollection listInDetail(PaginationOptions options); - - /** - * List details of the specified flavor - * - * @param id - * id of the flavor - * @return flavor or null if not found - */ - Flavor get(String id); - - /** - * Create flavor according to the provided object - * - * @param flavor - flavor object - * @return newly created flavor - */ - Flavor create(Flavor flavor); - - /** - * Delete flavor with a given id - * - * @param id - flavor id - */ - void delete(String id); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java deleted file mode 100644 index cc7f4685c1..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java +++ /dev/null @@ -1,142 +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.jclouds.openstack.nova.v2_0.features; - -import java.util.Map; -import org.jclouds.collect.PagedIterable; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; -import org.jclouds.openstack.nova.v2_0.domain.Image; -import org.jclouds.openstack.v2_0.domain.Resource; -import org.jclouds.openstack.v2_0.options.PaginationOptions; - -/** - * Provides synchronous access to Images. - *

- * - * @see ImageAsyncApi - * @see - * @author Adrian Cole - */ -public interface ImageApi { - - /** - * List all images (IDs, names, links) - * - * @return all images (IDs, names, links) - */ - PagedIterable list(); - - PaginatedCollection list(PaginationOptions options); - - /** - * List all images (all details) - * - * @return all images (all details) - */ - PagedIterable listInDetail(); - - PaginatedCollection listInDetail(PaginationOptions options); - - /** - * List details of the specified image - * - * @param id - * id of the server - * @return server or null if not found - */ - Image get(String id); - - /** - * Delete the specified image - * - * @param id - * id of the image - * @return server or null if not found - */ - void delete(String id); - - /** - * List all metadata for an image. - * - * @param id - * id of the image - * @return the metadata as a Map - */ - Map getMetadata(String id); - - /** - * Sets the metadata for an image. - * - * @param id - * id of the image - * @param metadata - * a Map containing the metadata - * @return the metadata as a Map - */ - Map setMetadata(String id, Map metadata); - - /** - * Update the metadata for a server. - * - * @param id - * id of the image - * @param metadata - * a Map containing the metadata - * @return the metadata as a Map - */ - Map updateMetadata(String id, Map metadata); - - /** - * Update the metadata for an image. - * - * @param id - * id of the image - * @param metadata - * a Map containing the metadata - * @return the value or null if not present - */ - @Nullable - String getMetadata(String id, String key); - - - /** - * Set a metadata item for an image. - * - * @param id - * id of the image - * @param key - * the name of the metadata item - * @param value - * the value of the metadata item - * @return the value you updated - */ - String updateMetadata(String id, String key, String value); - - /** - * Delete a metadata item from an image. - * - * @param id - * id of the image - * @param key - * the name of the metadata item - */ - void deleteMetadata(String id, String key); - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java deleted file mode 100644 index 9354d9a54b..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java +++ /dev/null @@ -1,276 +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.jclouds.openstack.nova.v2_0.features; - -import com.google.common.base.Optional; -import java.util.Map; -import org.jclouds.collect.PagedIterable; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; -import org.jclouds.openstack.nova.v2_0.domain.RebootType; -import org.jclouds.openstack.nova.v2_0.domain.Server; -import org.jclouds.openstack.nova.v2_0.domain.ServerCreated; -import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; -import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions; -import org.jclouds.openstack.v2_0.domain.Resource; -import org.jclouds.openstack.v2_0.options.PaginationOptions; - -/** - * Provides synchronous access to Server. - *

- * - * @see ServerAsyncApi - * @see - * @author Adrian Cole - */ -public interface ServerApi { - - /** - * List all servers (IDs, names, links) - * - * @return all servers (IDs, names, links) - */ - PagedIterable list(); - - PaginatedCollection list(PaginationOptions options); - - /** - * List all servers (all details) - * - * @return all servers (all details) - */ - PagedIterable listInDetail(); - - PaginatedCollection listInDetail(PaginationOptions options); - - /** - * List details of the specified server - * - * @param id - * id of the server - * @return server or null if not found - */ - Server get(String id); - - /** - * Create a new server - * - * @param name - * name of the server to create - * @param imageRef - * reference to the image for the server to use - * @param flavorRef - * reference to the flavor to use when creating the server - * @param options - * optional parameters to be passed into the server creation - * request - * @return the newly created server - */ - ServerCreated create(String name, String imageRef, String flavorRef, CreateServerOptions... options); - - /** - * Terminate and delete a server. - * - * @param id - * id of the server - * @return True if successful, False otherwise - */ - boolean delete(String id); - - /** - * Start a server - * - * @param id - * id of the server - */ - void start(String id); - - /** - * Stop a server - * - * @param id - * id of the server - */ - void stop(String id); - - /** - * Reboot a server. - * - * @param id - * id of the server - * @param rebootType - * The type of reboot to perform (Hard/Soft) - */ - void reboot(String id, RebootType rebootType); - - /** - * Resize a server to a new flavor size. - * - * @param id - * id of the server - * @param flavorId - * id of the new flavor to use - */ - void resize(String id, String flavorId); - - /** - * Confirm a resize operation. - * - * @param id - * id of the server - */ - void confirmResize(String id); - - /** - * Revert a resize operation. - * - * @param id - * id of the server - */ - void revertResize(String id); - - /** - * Rebuild a server. - * - * @param id - * id of the server - * @param options - * Optional parameters to the rebuilding operation. - */ - void rebuild(String id, RebuildServerOptions... options); - - /** - * Change the administrative password to a server. - * - * @param id - * id of the server - * @param adminPass - * The new administrative password to use - */ - void changeAdminPass(String id, String adminPass); - - /** - * Rename a server. - * - * @param id - * id of the server - * @param newName - * The new name for the server - */ - void rename(String id, String newName); - - /** - * Create an image from a server. - * - * @param name - * The name of the new image - * @param id - * id of the server - * - * @return ID of the new / updated image - */ - String createImageFromServer(String name, String id); - - /** - * List all metadata for a server. - * - * @param id - * id of the server - * - * @return the metadata as a Map - */ - Map getMetadata(String id); - - /** - * Set the metadata for a server. - * - * @param id - * id of the server - * @param metadata - * a Map containing the metadata - * @return the metadata as a Map - */ - Map setMetadata(String id, Map metadata); - - /** - * Update the metadata for a server. - * - * @param id - * id of the server - * @param metadata - * a Map containing the metadata - * @return the metadata as a Map - */ - Map updateMetadata(String id, Map metadata); - - /** - * Update the metadata for a server. - * - * @param id - * id of the image - * @param metadata - * a Map containing the metadata - * @return the value or null if not present - */ - @Nullable - String getMetadata(String id, String key); - - /** - * Set a metadata item for a server. - * - * @param id - * id of the image - * @param key - * the name of the metadata item - * @param value - * the value of the metadata item - * @return the value you updated - */ - String updateMetadata(String id, String key, String value); - - /** - * Delete a metadata item from a server. - * - * @param id - * id of the image - * @param key - * the name of the metadata item - */ - void deleteMetadata(String id, String key); - - - /** - * Get usage information about the server such as CPU usage, Memory and IO. - * The information returned by this method is dependent on the hypervisor - * in use by the OpenStack installation and whether that hypervisor supports - * this method. More information can be found in the - * OpenStack API - * reference.
- * At the moment the returned response is a generic map. In future versions - * of OpenStack this might be subject to change. - * - * @param id - * id of the server - * @return A Map containing the collected values organized by key - value. - * @Beta - */ - Optional> getDiagnostics(String id); - - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java deleted file mode 100644 index 2d63d655ac..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerAsyncApi.java +++ /dev/null @@ -1,356 +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.jclouds.openstack.nova.v2_0.features; - -import java.util.Map; - -import javax.inject.Named; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.MediaType; - -import org.jclouds.Fallbacks.AbsentOn403Or404Or500; -import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; -import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; -import org.jclouds.Fallbacks.FalseOnNotFoundOr404; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.Fallbacks.VoidOnNotFoundOr404; -import org.jclouds.collect.PagedIterable; -import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; -import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; -import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload; -import org.jclouds.openstack.nova.v2_0.domain.RebootType; -import org.jclouds.openstack.nova.v2_0.domain.Server; -import org.jclouds.openstack.nova.v2_0.domain.ServerCreated; -import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader; -import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull; -import org.jclouds.openstack.nova.v2_0.functions.internal.ParseDiagnostics; -import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails; -import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers; -import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; -import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions; -import org.jclouds.openstack.v2_0.domain.Resource; -import org.jclouds.openstack.v2_0.options.PaginationOptions; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.MapBinder; -import org.jclouds.rest.annotations.Payload; -import org.jclouds.rest.annotations.PayloadParam; -import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.rest.annotations.ResponseParser; -import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.annotations.Transform; -import org.jclouds.rest.annotations.Unwrap; -import org.jclouds.rest.binders.BindToJsonPayload; - -import com.google.common.base.Optional; -import com.google.common.util.concurrent.ListenableFuture; - -/** - * Provides asynchronous access to Server via their REST API. - *

- * - * @see ServerApi - * @see - * @author Adrian Cole - */ -@RequestFilters(AuthenticateRequest.class) -public interface ServerAsyncApi { - - /** - * @see ServerApi#list() - */ - @Named("server:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseServers.class) - @Transform(ParseServers.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); - - /** @see ServerApi#list(PaginationOptions) */ - @Named("server:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseServers.class) - @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> list(PaginationOptions options); - - /** - * @see ServerApi#listInDetail() - */ - @Named("server:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers/detail") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseServerDetails.class) - @Transform(ParseServerDetails.ToPagedIterable.class) - @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> listInDetail(); - - /** @see ServerApi#listInDetail(PaginationOptions) */ - @Named("server:list") - @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers/detail") - @RequestFilters(AuthenticateRequest.class) - @ResponseParser(ParseServerDetails.class) - @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> listInDetail(PaginationOptions options); - - /** - * @see ServerApi#get - */ - @Named("server:get") - @GET - @SelectJson("server") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers/{id}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); - - /** - * @see ServerApi#delete - */ - @Named("server:delete") - @DELETE - @Consumes - @Fallback(FalseOnNotFoundOr404.class) - @Path("/servers/{id}") - ListenableFuture delete(@PathParam("id") String id); - - /** - * @see ServerApi#start - */ - @Named("server:start") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"os-start\":null}") - ListenableFuture start(@PathParam("id") String id); - - /** - * @see ServerApi#stop - */ - @Named("server:stop") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"os-stop\":null}") - ListenableFuture stop(@PathParam("id") String id); - - /** - * @see ServerApi#reboot - */ - @Named("server:reboot") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") - ListenableFuture reboot(@PathParam("id") String id, @PayloadParam("type") RebootType rebootType); - - /** - * @see ServerApi#resize - */ - @Named("server:resize") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"resize\":%7B\"flavorRef\":{flavorId}%7D%7D") - ListenableFuture resize(@PathParam("id") String id, @PayloadParam("flavorId") String flavorId); - - /** - * @see ServerApi#confirmResize - */ - @Named("server:resize") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"confirmResize\":null}") - ListenableFuture confirmResize(@PathParam("id") String id); - - /** - * @see ServerApi#revertResize - */ - @Named("server:resize") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"revertResize\":null}") - ListenableFuture revertResize(@PathParam("id") String id); - - /** - * @see ServerApi#create - */ - @Named("server:create") - @POST - @Unwrap - @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers") - @MapBinder(CreateServerOptions.class) - ListenableFuture create(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef, - @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options); - - /** - * @see ServerApi#rebuild - */ - @Named("server:rebuild") - @POST - @Path("/servers/{id}/action") - @Consumes - @MapBinder(RebuildServerOptions.class) - ListenableFuture rebuild(@PathParam("id") String id, RebuildServerOptions... options); - - /** - * @see ServerApi#changeAdminPass - */ - @Named("server:changeadminpass") - @POST - @Path("/servers/{id}/action") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") - ListenableFuture changeAdminPass(@PathParam("id") String id, @PayloadParam("adminPass") String adminPass); - - /** - * @see ServerApi#rename - */ - @Named("server:rename") - @PUT - @Path("/servers/{id}") - @Consumes - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") - ListenableFuture rename(@PathParam("id") String id, @PayloadParam("name") String newName); - - /** - * @see ServerApi#createImageFromServer - */ - @Named("server:create") - @POST - @Path("/servers/{id}/action") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Payload("%7B\"createImage\":%7B\"name\":\"{name}\", \"metadata\": %7B%7D%7D%7D") - @Fallback(MapHttp4xxCodesToExceptions.class) - @ResponseParser(ParseImageIdFromLocationHeader.class) - ListenableFuture createImageFromServer(@PayloadParam("name") String name, @PathParam("id") String id); - - /** - * @see ServerApi#getMetadata - */ - @Named("server:getmetadata") - @GET - @SelectJson("metadata") - @Path("/servers/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) - ListenableFuture> getMetadata(@PathParam("id") String id); - - /** - * @see ServerApi#setMetadata - */ - @Named("server:setmetadata") - @PUT - @SelectJson("metadata") - @Path("/servers/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) - @MapBinder(BindToJsonPayload.class) - ListenableFuture> setMetadata(@PathParam("id") String id, - @PayloadParam("metadata") Map metadata); - - /** - * @see ServerApi#updateMetadata - */ - @Named("server:updatemetadata") - @POST - @SelectJson("metadata") - @Path("/servers/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) - @MapBinder(BindToJsonPayload.class) - ListenableFuture> updateMetadata(@PathParam("id") String id, - @PayloadParam("metadata") Map metadata); - - /** - * @see ServerApi#getMetadata - */ - @Named("server:getmetadata") - @GET - @Path("/servers/{id}/metadata/{key}") - @Consumes(MediaType.APPLICATION_JSON) - @ResponseParser(OnlyMetadataValueOrNull.class) - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMetadata(@PathParam("id") String id, @PathParam("key") String key); - - /** - * @see ServerApi#updateMetadata - */ - @Named("server:updatemetadata") - @PUT - @Path("/servers/{id}/metadata/{key}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - @ResponseParser(OnlyMetadataValueOrNull.class) - @MapBinder(BindMetadataToJsonPayload.class) - ListenableFuture updateMetadata(@PathParam("id") String id, - @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value); - - /** - * @see ServerApi#deleteMetadata - */ - @Named("server:deletemetadata") - @DELETE - @Consumes - @Path("/servers/{id}/metadata/{key}") - @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture deleteMetadata(@PathParam("id") String id, @PathParam("key") String key); - - - /** - * @see ServerApi#getDiagnostics - */ - @Named("server:getdiagnostics") - @GET - @Path("/servers/{id}/diagnostics") - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(AbsentOn403Or404Or500.class) - @ResponseParser(ParseDiagnostics.class) - ListenableFuture>> getDiagnostics(@PathParam("id") String id); -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java deleted file mode 100644 index a7ad44f3f3..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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.jclouds.openstack.nova.v2_0.extensions; - -import com.google.common.collect.FluentIterable; -import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; -import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; -import org.testng.annotations.Test; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; - -/** - * @author inbar stolberg - */ -@Test(groups = "live", testName = "AvailabilityZonesApiLiveTest") -public class AvailabilityZonesApiLiveTest extends BaseNovaApiLiveTest { - - @Test - public void testListAvailabilityZones() throws Exception { - - AvailabilityZoneAPI availabilityZoneApi = api.getAvailabilityZoneApi("RegionOne"); - FluentIterable zones = availabilityZoneApi.list(); - - for (AvailabilityZone zone : zones) { - assertNotNull(zone.getName()); - assertTrue(zone.getState().available(), "zone: " + zone.getName() + " is not available."); - } - } -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java deleted file mode 100644 index 4611ea9123..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiExpectTest.java +++ /dev/null @@ -1,105 +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.jclouds.openstack.nova.v2_0.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; - -import java.net.URI; - -import javax.ws.rs.core.MediaType; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.v2_0.domain.QuotaClass; -import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiExpectTest; -import org.jclouds.rest.ResourceNotFoundException; -import org.testng.annotations.Test; - -/** - * Tests HostAdministrationApi guice wiring and parsing - * - * @author Adam Lowe - */ -@Test(groups = "unit", testName = "QuotaClassApiExpectTest") -public class QuotaClassApiExpectTest extends BaseNovaApiExpectTest { - - public void testGetQuotas() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas"); - QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, - responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, - authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/quota_class.json")).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get(); - - assertEquals(api.get("jcloudstestquotas"), getTestQuotas()); - } - - public void testGetQuotasFailsTenantNotFound() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas"); - QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, - responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, - authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get(); - assertNull(api.get("jcloudstestquotas")); - } - - public void testUpdateQuotas() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/myclass"); - QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, - responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, - HttpRequest.builder().endpoint(endpoint).method("PUT") - .addHeader("X-Auth-Token", authToken) - .payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON)) - .build(), - HttpResponse.builder().statusCode(200).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get(); - - assertTrue(api.update("myclass", getTestQuotas())); - } - - @Test(expectedExceptions = ResourceNotFoundException.class) - public void testUpdateQuotasFailsNotFound() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-class-sets/jcloudstestquotas"); - QuotaClassApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, - responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, - HttpRequest.builder().endpoint(endpoint).method("PUT") - .addHeader("X-Auth-Token", authToken) - .payload(payloadFromResourceWithContentType("/quota_class.json", MediaType.APPLICATION_JSON)) - .build(), - HttpResponse.builder().statusCode(404).build()).getQuotaClassExtensionForZone("az-1.region-a.geo-1").get(); - - api.update("jcloudstestquotas", getTestQuotas()); - } - - public static QuotaClass getTestQuotas() { - return QuotaClass.builder() - .metadataItems(128) - .injectedFileContentBytes(10240) - .injectedFiles(5) - .gigabytes(1000) - .ram(4096) - .floatingIps(10) - .securityGroups(10) - .securityGroupRules(20) - .instances(5) - .keyPairs(100) - .volumes(5) - .cores(10) - .id("jcloudstestquotas").build(); - } - -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.java deleted file mode 100644 index 43fd342979..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassApiLiveTest.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.jclouds.openstack.nova.v2_0.extensions; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; - -import org.jclouds.openstack.nova.v2_0.domain.QuotaClass; -import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.common.base.Optional; -import com.google.common.collect.Iterables; - -/** - * Tests behavior of QuotaApi - * - * @author Adam Lowe - */ -@Test(groups = "live", testName = "QuotaClassApiLiveTest", singleThreaded = true) -public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest { - private Optional apiOption; - private String zone; - - @BeforeClass(groups = {"integration", "live"}) - @Override - public void setup() { - super.setup(); - zone = Iterables.getLast(api.getConfiguredZones(), "nova"); - apiOption = api.getQuotaClassExtensionForZone(zone); - } - - public void testUpdateAndGetQuotaClass() { - if (apiOption.isPresent()) { - QuotaClassApi api = apiOption.get(); - - QuotaClass firstVersion = - QuotaClassApiExpectTest.getTestQuotas().toBuilder() - .id("jcloudstestquotas") - .cores(10) - .instances(5) - .ram(4096) - .volumes(5) - .build(); - - assertTrue(api.update(firstVersion.getId(), firstVersion)); - - assertEquals(api.get(firstVersion.getId()), firstVersion); - - // Change it again (since we may have run this test before and we can't delete the QuotaClass) - QuotaClass secondVersion = firstVersion.toBuilder().ram(8192).build(); - - assertTrue(api.update(secondVersion.getId(), secondVersion)); - - assertEquals(api.get(secondVersion.getId()), secondVersion); - } - } -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json deleted file mode 100644 index c436406780..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_details.json +++ /dev/null @@ -1 +0,0 @@ -{"volumeAttachment": {"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json deleted file mode 100644 index b40de0bd46..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/attachment_list.json +++ /dev/null @@ -1 +0,0 @@ -{"volumeAttachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json deleted file mode 100644 index 6336a4267e..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_details.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "extension" : { - "name" : "Public Image Extension", - "namespace" : "http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0", - "alias" : "RS-PIE", - "updated" : "2011-01-22T13:25:27-06:00", - "description" : "Adds the capability to share an image with other users.", - "links" : [ - { - "rel" : "describedby", - "type" : "application/pdf", - "href" : "http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf" - }, - { - "rel" : "describedby", - "type" : "application/vnd.sun.wadl+xml", - "href" : "http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl" - } - ] - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json deleted file mode 100644 index 490bebc0fe..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_full.json +++ /dev/null @@ -1,281 +0,0 @@ -{"extensions": [ -{ - "updated": "2011-09-27T00:00:00+00:00", - "name": "DiskConfig", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/disk_config/api/v1.1", - "alias": "OS-DCF", - "description": "Disk Management Extension" -}, -{ - "updated": "2011-06-29T00:00:00+00:00", - "name": "Hosts", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/hosts/api/v1.1", - "alias": "os-hosts", - "description": "Admin-only host administration" -}, -{ - "updated": "2011-07-19T00:00:00+00:00", - "name": "SchedulerHints", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/scheduler-hints/api/v2", - "alias": "os-scheduler-hints", - "description": "Pass arbitrary key/value pairs to the scheduler" -}, -{ - "updated": "2011-08-08T00:00:00+00:00", - "name": "Quotas", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1", - "alias": "os-quota-sets", - "description": "Quotas management support" -}, -{ - "updated": "2011-12-23T00:00:00+00:00", - "name": "Floating_ip_dns", - "links": [], - "namespace": "http://docs.openstack.org/ext/floating_ip_dns/api/v1.1", - "alias": "os-floating-ip-dns", - "description": "Floating IP DNS support" -}, -{ - "updated": "2011-09-14T00:00:00+00:00", - "name": "FlavorExtraData", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1", - "alias": "OS-FLV-EXT-DATA", - "description": "Provide additional data for flavors" -}, -{ - "updated": "2011-06-23T00:00:00+00:00", - "name": "FlavorExtraSpecs", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1", - "alias": "os-flavor-extra-specs", - "description": "Instance type (flavor) extra specs" -}, -{ - "updated": "2011-08-17T00:00:00+00:00", - "name": "VirtualInterfaces", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/virtual_interfaces/api/v1.1", - "alias": "virtual_interfaces", - "description": "Virtual interface support" -}, -{ - "updated": "2011-12-23T00:00:00+00:00", - "name": "Accounts", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/accounts/api/v1.1", - "alias": "os-accounts", - "description": "Admin-only access to accounts" -}, -{ - "updated": "2011-03-25T00:00:00+00:00", - "name": "Volumes", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/volumes/api/v1.1", - "alias": "os-volumes", - "description": "Volumes support" -}, -{ - "updated": "2011-11-03T00:00:00+00:00", - "name": "ExtendedStatus", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1", - "alias": "OS-EXT-STS", - "description": "Extended Status support" -}, -{ - "updated": "2011-12-23T00:00:00+00:00", - "name": "Consoles", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/os-consoles/api/v2", - "alias": "os-consoles", - "description": "Interactive Console support." -}, -{ - "updated": "2011-07-21T00:00:00+00:00", - "name": "SecurityGroups", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/securitygroups/api/v1.1", - "alias": "security_groups", - "description": "Security group support" -}, -{ - "updated": "2012-01-12T00:00:00+00:00", - "name": "Aggregates", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/aggregates/api/v1.1", - "alias": "os-aggregates", - "description": "Admin-only aggregate administration" -}, -{ - "updated": "2011-07-19T00:00:00+00:00", - "name": "Createserverext", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/createserverext/api/v1.1", - "alias": "os-create-server-ext", - "description": "Extended support to the Create Server v1.1 API" -}, -{ - "updated": "2011-09-01T00:00:00+00:00", - "name": "DeferredDelete", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/deferred-delete/api/v1.1", - "alias": "os-deferred-delete", - "description": "Instance deferred delete" -}, -{ - "updated": "2011-12-21T00:00:00+00:00", - "name": "ServerDiagnostics", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/server-diagnostics/api/v1.1", - "alias": "os-server-diagnostics", - "description": "Allow Admins to view server diagnostics through server action" -}, -{ - "updated": "2011-12-23T00:00:00+00:00", - "name": "Networks", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/networks/api/v1.1", - "alias": "os-networks", - "description": "Admin-only Network Management Extension" -}, -{ - "updated": "2011-11-03T00:00:00+00:00", - "name": "ExtendedServerAttributes", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1", - "alias": "OS-EXT-SRV-ATTR", - "description": "Extended Server Attributes support." -}, -{ - "updated": "2011-08-08T00:00:00+00:00", - "name": "Keypairs", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/keypairs/api/v1.1", - "alias": "os-keypairs", - "description": "Keypair Support" -}, -{ - "updated": "2011-08-24T00:00:00+00:00", - "name": "VolumeTypes", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/volume_types/api/v1.1", - "alias": "os-volume-types", - "description": "Volume types support" -}, -{ - "updated": "2011-08-19T00:00:00+00:00", - "name": "SimpleTenantUsage", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/os-simple-tenant-usage/api/v1.1", - "alias": "os-simple-tenant-usage", - "description": "Simple tenant usage extension" -}, -{ - "updated": "2012-01-04T00:00:00+00:00", - "name": "Floating_ip_pools", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/floating_ip_pools/api/v1.1", - "alias": "os-floating-ip-pools", - "description": "Floating IPs support" -}, -{ - "updated": "2012-01-23T00:00:00+00:00", - "name": "ServerStartStop", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/servers/api/v1.1", - "alias": "os-server-start-stop", - "description": "Start/Stop instance compute API support" -}, -{ - "updated": "2012-03-12T00:00:00+00:00", - "name": "QuotaClasses", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1", - "alias": "os-quota-class-sets", - "description": "Quota classes management support" -}, -{ - "updated": "2012-01-19T00:00:00+00:00", - "name": "Certificates", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/certificates/api/v1.1", - "alias": "os-certificates", - "description": "Certificates support" -}, -{ - "updated": "2011-08-18T00:00:00+00:00", - "name": "Rescue", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/rescue/api/v1.1", - "alias": "os-rescue", - "description": "Instance rescue mode" -}, -{ - "updated": "2012-01-19T00:00:00+00:00", - "name": "FlavorManage", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/flavor_manage/api/v1.1", - "alias": "os-flavor-manage", - "description": "\n Flavor create/delete API support\n " -}, -{ - "updated": "2011-12-16T00:00:00+00:00", - "name": "Cloudpipe", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/cloudpipe/api/v1.1", - "alias": "os-cloudpipe", - "description": "Adds actions to create cloudpipe instances.\n\n When running with the Vlan network mode, you need a mechanism to route\n from the public Internet to your vlans. This mechanism is known as a\n cloudpipe.\n\n At the time of creating this class, only OpenVPN is supported. Support for\n a SSH Bastion host is forthcoming.\n " -}, -{ - "updated": "2011-06-09T00:00:00+00:00", - "name": "Multinic", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/multinic/api/v1.1", - "alias": "NMN", - "description": "Multiple network support" -}, -{ - "updated": "2011-08-08T00:00:00+00:00", - "name": "Users", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/users/api/v1.1", - "alias": "os-users", - "description": "Allow admins to acces user information" -}, -{ - "updated": "2011-09-20T00:00:00+00:00", - "name": "AdminActions", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/admin-actions/api/v1.1", - "alias": "os-admin-actions", - "description": "Enable admin-only server actions\n\n Actions include: pause,unpause, suspend, resume, migrate,\n resetNetwork, injectNetworkInfo, lock, unlock, createBackup\n " -}, -{ - "updated": "2011-12-21T00:00:00+00:00", - "name": "ServerActionList", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/server-actions-list/api/v1.1", - "alias": "os-server-action-list", - "description": "Allow Admins to view pending server actions" -}, -{ - "updated": "2011-12-08T00:00:00+00:00", - "name": "Console_output", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/os-console-output/api/v2", - "alias": "os-console-output", - "description": "Console log output support, with tailing ability." -}, -{ - "updated": "2011-06-16T00:00:00+00:00", - "name": "Floating_ips", - "links": [], - "namespace": "http://docs.openstack.org/compute/ext/floating_ips/api/v1.1", - "alias": "os-floating-ips", - "description": "Floating IPs support"} -]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json deleted file mode 100644 index 37fd53f152..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_normal.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "extensions": [{ - "updated": "2011-08-08T00:00:00+00:00", - "name": "Keypairs", - "links": [], - "namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1", - "alias": "os-keypairs", - "description": "Keypair Support" - }, { - "updated": "2011-03-25T00:00:00+00:00", - "name": "Volumes", - "links": [], - "namespace": "http://docs.openstack.org/ext/volumes/api/v1.1", - "alias": "os-volumes", - "description": "Volumes support" - }, { - "updated": "2011-07-21T00:00:00+00:00", - "name": "SecurityGroups", - "links": [], - "namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1", - "alias": "security_groups", - "description": "Security group support" - }, { - "updated": "2011-06-16T00:00:00+00:00", - "name": "Floating_ips", - "links": [], - "namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1", - "alias": "os-floating-ips", - "description": "Floating IPs support" - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json deleted file mode 100644 index 0144af6ae4..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list_openstack.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "extensions": [{ - "updated": "2011-06-09T00:00:00+00:00", - "name": "Multinic", - "links": [], - "namespace": "https://docs.openstack.org/ext/multinic/api/v1.1", - "alias": "NMN", - "description": "Multiple network support" - }, { - "updated": "2011-06-29T00:00:00+00:00", - "name": "Hosts", - "links": [], - "namespace": "https://docs.openstack.org/ext/hosts/api/v1.1", - "alias": "os-hosts", - "description": "Host administration" - }, { - "updated": "2011-03-25T00:00:00+00:00", - "name": "Volumes", - "links": [], - "namespace": "https://docs.openstack.org/ext/volumes/api/v1.1", - "alias": "os-volumes", - "description": "Volumes support" - }, { - "updated": "2011-05-25 16:12:21.656723", - "name": "Admin Controller", - "links": [], - "namespace": "https:TODO/", - "alias": "ADMIN", - "description": "The Admin API Extension" - }, { - "updated": "2011-08-08T00:00:00+00:00", - "name": "Quotas", - "links": [], - "namespace": "https://docs.openstack.org/ext/quotas-sets/api/v1.1", - "alias": "os-quota-sets", - "description": "Quotas management support" - }, { - "updated": "2011-08-24T00:00:00+00:00", - "name": "VolumeTypes", - "links": [], - "namespace": "https://docs.openstack.org/ext/volume_types/api/v1.1", - "alias": "os-volume-types", - "description": "Volume types support" - }, { - "updated": "2011-06-23T00:00:00+00:00", - "name": "FlavorExtraSpecs", - "links": [], - "namespace": "https://docs.openstack.org/ext/flavor_extra_specs/api/v1.1", - "alias": "os-flavor-extra-specs", - "description": "Instance type (flavor) extra specs" - }, { - "updated": "2011-09-14T00:00:00+00:00", - "name": "FlavorExtraData", - "links": [], - "namespace": "https://docs.openstack.org/ext/flavor_extra_data/api/v1.1", - "alias": "os-flavor-extra-data", - "description": "Provide additional data for flavors" - }, { - "updated": "2011-08-17T00:00:00+00:00", - "name": "VirtualInterfaces", - "links": [], - "namespace": "https://docs.openstack.org/ext/virtual_interfaces/api/v1.1", - "alias": "virtual_interfaces", - "description": "Virtual interface support" - }, { - "updated": "2011-07-19T00:00:00+00:00", - "name": "Createserverext", - "links": [], - "namespace": "https://docs.openstack.org/ext/createserverext/api/v1.1", - "alias": "os-create-server-ext", - "description": "Extended support to the Create Server v1.1 API" - }, { - "updated": "2011-08-08T00:00:00+00:00", - "name": "Keypairs", - "links": [], - "namespace": "https://docs.openstack.org/ext/keypairs/api/v1.1", - "alias": "os-keypairs", - "description": "Keypair Support" - }, { - "updated": "2011-08-25T00:00:00+00:00", - "name": "VSAs", - "links": [], - "namespace": "https://docs.openstack.org/ext/vsa/api/v1.1", - "alias": "zadr-vsa", - "description": "Virtual Storage Arrays support" - }, { - "updated": "2011-08-19T00:00:00+00:00", - "name": "SimpleTenantUsage", - "links": [], - "namespace": "https://docs.openstack.org/ext/os-simple-tenant-usage/api/v1.1", - "alias": "os-simple-tenant-usage", - "description": "Simple tenant usage extension" - }, { - "updated": "2011-08-18T00:00:00+00:00", - "name": "Rescue", - "links": [], - "namespace": "https://docs.openstack.org/ext/rescue/api/v1.1", - "alias": "os-rescue", - "description": "Instance rescue mode" - }, { - "updated": "2011-07-21T00:00:00+00:00", - "name": "SecurityGroups", - "links": [], - "namespace": "https://docs.openstack.org/ext/securitygroups/api/v1.1", - "alias": "security_groups", - "description": "Security group support" - }, { - "updated": "2011-06-16T00:00:00+00:00", - "name": "Floating_ips", - "links": [], - "namespace": "https://docs.openstack.org/ext/floating_ips/api/v1.1", - "alias": "os-floating-ips", - "description": "Floating IPs support" - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json deleted file mode 100644 index b2a3556077..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_details.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "flavor" : { - "id" : "52415800-8b69-11e0-9b19-734f1195ff37", - "name" : "256 MB Server", - "ram" : 256, - "disk" : 10, - "vcpus" : 1, - "links": [ - { - "rel" : "self", - "href" : "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" - }, - { - "rel" : "bookmark", - "href" : "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" - } - ] - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json deleted file mode 100644 index e810b48368..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail.json +++ /dev/null @@ -1 +0,0 @@ -{"flavors": [{"rxtx_quota": 0, "name": "standard.xsmall", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/100", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", "rel": "bookmark"}], "ram": 1024, "vcpus": 1, "rxtx_cap": 0, "swap": 0, "disk": 30, "id": 100}, {"rxtx_quota": 0, "name": "standard.small", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/101", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/101", "rel": "bookmark"}], "ram": 2048, "vcpus": 2, "rxtx_cap": 0, "swap": 0, "disk": 60, "id": 101}, {"rxtx_quota": 0, "name": "standard.2xlarge", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/105", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/105", "rel": "bookmark"}], "ram": 32768, "vcpus": 8, "rxtx_cap": 0, "swap": 0, "disk": 960, "id": 105}, {"rxtx_quota": 0, "name": "standard.large", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/103", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/103", "rel": "bookmark"}], "ram": 8192, "vcpus": 4, "rxtx_cap": 0, "swap": 0, "disk": 240, "id": 103}, {"rxtx_quota": 0, "name": "standard.medium", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/102", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/102", "rel": "bookmark"}], "ram": 4096, "vcpus": 2, "rxtx_cap": 0, "swap": 0, "disk": 120, "id": 102}, {"rxtx_quota": 0, "name": "standard.xlarge", "links": [{"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/flavors/104", "rel": "self"}, {"href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/104", "rel": "bookmark"}], "ram": 16384, "vcpus": 4, "rxtx_cap": 0, "swap": 0, "disk": 480, "id": 104}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json deleted file mode 100644 index 4725d8be02..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list_detail_openstack.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "flavors": [{ - "rxtx_quota": 0, - "name": "m1.medium", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/3", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/flavors/3", - "rel": "bookmark" - }], - "ram": 4096, - "vcpus": 2, - "rxtx_cap": 0, - "swap": 0, - "disk": 40, - "id": 3 - }, { - "rxtx_quota": 0, - "name": "m1.large", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/4", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/flavors/4", - "rel": "bookmark" - }], - "ram": 8192, - "vcpus": 4, - "rxtx_cap": 0, - "swap": 0, - "disk": 80, - "id": 4 - }, { - "rxtx_quota": 0, - "name": "m1.tiny", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/1", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/flavors/1", - "rel": "bookmark" - }], - "ram": 512, - "vcpus": 1, - "rxtx_cap": 0, - "swap": 0, - "disk": 0, - "id": 1 - }, { - "rxtx_quota": 0, - "name": "m1.xlarge", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/5", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/flavors/5", - "rel": "bookmark" - }], - "ram": 16384, - "vcpus": 8, - "rxtx_cap": 0, - "swap": 0, - "disk": 160, - "id": 5 - }, { - "rxtx_quota": 0, - "name": "m1.small", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/flavors/2", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/flavors/2", - "rel": "bookmark" - }], - "ram": 2048, - "vcpus": 1, - "rxtx_cap": 0, - "swap": 0, - "disk": 20, - "id": 2 - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json deleted file mode 100644 index 5356f8c824..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_new.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "flavor" : { - "id" : "1cb47a44-9b84-4da4-bf81-c1976e8414ab", - "name" : "128 MB Server", - "ram" : 128, - "disk" : 10, - "vcpus" : 1, - "links" : [] - } -} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json deleted file mode 100644 index c2411fd65f..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_details.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "floating_ip" : - { - "id" : 1, - "ip" : "10.0.0.3", - "fixed_ip" : "10.0.0.2", - "instance_id" : 123 - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json deleted file mode 100644 index 27d251926a..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/floatingip_list.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "floating_ips" : [ - { - "instance_id": 12, - "ip" : "10.0.0.3", - "fixed_ip": "11.0.0.1", - "id" : 1 - }, - { - "instance_id": null, - "ip": "10.0.0.5", - "fixed_ip": null, - "id": 2 - } - ] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host.json deleted file mode 100644 index ad2e217e24..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host.json +++ /dev/null @@ -1 +0,0 @@ -{"host": [{"resource": {"project": "(total)", "memory_mb": 16083, "host": "ubuntu", "cpu": 4, "disk_gb": 181}}, {"resource": {"project": "(used_now)", "memory_mb": 3396, "host": "ubuntu", "cpu": 3, "disk_gb": 5}}, {"resource": {"project": "(used_max)", "memory_mb": 6144, "host": "ubuntu", "cpu": 3, "disk_gb": 80}}, {"resource": {"project": "f8535069c3fb404cb61c873b1a0b4921", "memory_mb": 6144, "host": "ubuntu", "cpu": 3, "disk_gb": 80}}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json deleted file mode 100644 index 5e939ddab0..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_details.json +++ /dev/null @@ -1 +0,0 @@ -{"aggregate": {"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": [], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json deleted file mode 100644 index 92dfd383f1..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_list.json +++ /dev/null @@ -1 +0,0 @@ -{"aggregates": [{"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": [], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json deleted file mode 100644 index 2d132f4698..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/host_aggregate_with_host_details.json +++ /dev/null @@ -1 +0,0 @@ -{"aggregate": {"name": "jclouds-test-a", "availability_zone": "nova", "deleted": false, "created_at": "2012-05-11 11:40:17", "updated_at": "2012-05-11 11:46:44", "operational_state": "created", "hosts": ["ubuntu"], "deleted_at": null, "id": 1, "metadata": {"somekey": "somevalue", "anotherkey": "another val"}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json deleted file mode 100644 index 30d377016b..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/hosts_list.json +++ /dev/null @@ -1 +0,0 @@ -{"hosts": [{"host_name": "ubuntu", "service": "compute"}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json deleted file mode 100644 index 4b778e417f..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_active.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "image" : { - "id" : "52415800-8b69-11e0-9b19-734f5736d2a2", - "name" : "My Server Backup", - "updated" : "2010-10-10T12:00:00Z", - "created" : "2010-08-10T12:00:00Z", - "tenant_id" : "12345", - "user_id" : "joe", - "status" : "ACTIVE", - "progress" : 80, - "minDisk" : 5, - "minRam" : 256, - "metadata" : { - "ImageType" : "Gold", - "ImageVersion" : "1.5" - }, - "server" : { - "id": "52415800-8b69-11e0-9b19-734f335aa7b3", - "links": [ - { - "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" - }, - { - "rel": "bookmark", - "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" - } - ] - }, - "links": [ - { - "rel" : "self", - "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" - }, - { - "rel" : "bookmark", - "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" - } - ] - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json deleted file mode 100644 index b75d94c8db..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_details.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "image" : { - "id" : "52415800-8b69-11e0-9b19-734f5736d2a2", - "name" : "My Server Backup", - "updated" : "2010-10-10T12:00:00Z", - "created" : "2010-08-10T12:00:00Z", - "tenant_id" : "12345", - "user_id" : "joe", - "status" : "SAVING", - "progress" : 80, - "minDisk" : 5, - "minRam" : 256, - "metadata" : { - "ImageType" : "Gold", - "ImageVersion" : "1.5" - }, - "server" : { - "id": "52415800-8b69-11e0-9b19-734f335aa7b3", - "links": [ - { - "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" - }, - { - "rel": "bookmark", - "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" - } - ] - }, - "links": [ - { - "rel" : "self", - "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" - }, - { - "rel" : "bookmark", - "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" - } - ] - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json deleted file mode 100644 index 0b4dcc043d..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail.json +++ /dev/null @@ -1 +0,0 @@ -{"images": [{"status": "ACTIVE", "updated": "2012-03-12T07:52:30Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1361", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1361", "rel": "bookmark"}], "created": "2012-02-21T14:13:55Z", "progress": 100, "id": "1361", "metadata": {"hp_image_type": "machine", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "kernel_id": "1359", "min_ram": 0, "ramdisk_id": "1360", "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:52:17Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1360", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1360", "rel": "bookmark"}], "created": "2012-02-21T14:13:53Z", "progress": 100, "id": "1360", "metadata": {"hp_image_type": "ramdisk", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:52:09Z", "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1359", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1359", "rel": "bookmark"}], "created": "2012-02-21T14:13:52Z", "progress": 100, "id": "1359", "metadata": {"hp_image_type": "kernel", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", "owner": null, "hp_image_builddate": "20120123", "architecture": "amd64", "min_disk": 0, "hp_image_version": "1hp1.1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:52Z", "name": "CentOS 6.2 Server 64-bit 20120125", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1358", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1358", "rel": "bookmark"}], "created": "2012-02-21T13:58:51Z", "progress": 100, "id": "1358", "metadata": {"hp_image_type": "machine", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "kernel_id": "1356", "min_ram": 0, "ramdisk_id": "1357", "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:37Z", "name": "CentOS 6.2 Server 64-bit 20120125 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1357", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1357", "rel": "bookmark"}], "created": "2012-02-21T13:58:49Z", "progress": 100, "id": "1357", "metadata": {"hp_image_type": "ramdisk", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:28Z", "name": "CentOS 6.2 Server 64-bit 20120125 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1356", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1356", "rel": "bookmark"}], "created": "2012-02-21T13:58:47Z", "progress": 100, "id": "1356", "metadata": {"hp_image_type": "kernel", "image_location": "local", "image_state": "available", "project_id": "None", "hp_md_version": "1", "min_ram": 0, "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", "owner": null, "hp_image_builddate": "20120125", "architecture": "x86_64", "min_disk": 0, "hp_image_version": "1hp1"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:51:04Z", "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1242", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1242", "rel": "bookmark"}], "created": "2011-12-21T11:57:15Z", "progress": 100, "id": "1242", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1241", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:58Z", "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1241", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", "rel": "bookmark"}], "created": "2011-12-21T11:57:07Z", "progress": 100, "id": "1241", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:52Z", "name": "Ubuntu Natty 11.04 Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1240", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1240", "rel": "bookmark"}], "created": "2011-12-21T11:55:03Z", "progress": 100, "id": "1240", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1239", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:45Z", "name": "Ubuntu Natty 11.04 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1239", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1239", "rel": "bookmark"}], "created": "2011-12-21T11:55:02Z", "progress": 100, "id": "1239", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:32Z", "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1238", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1238", "rel": "bookmark"}], "created": "2011-12-21T11:52:34Z", "progress": 100, "id": "1238", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1237", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:50:24Z", "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1237", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1237", "rel": "bookmark"}], "created": "2011-12-21T11:52:27Z", "progress": 100, "id": "1237", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:30Z", "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1236", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1236", "rel": "bookmark"}], "created": "2011-12-21T11:40:17Z", "progress": 100, "id": "1236", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1235", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:23Z", "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1235", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1235", "rel": "bookmark"}], "created": "2011-12-21T11:39:58Z", "progress": 100, "id": "1235", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "amd64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:49:05Z", "name": "CentOS 5.6 Server 64-bit 20111207", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1234", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1234", "rel": "bookmark"}], "created": "2011-12-21T11:07:09Z", "progress": 100, "id": "1234", "metadata": {"image_location": "local", "image_state": "available", "kernel_id": "1232", "min_ram": 0, "ramdisk_id": "1233", "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:48:59Z", "name": "CentOS 5.6 Server 64-bit 20111207 (Ramdisk)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1233", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1233", "rel": "bookmark"}], "created": "2011-12-21T11:07:08Z", "progress": 100, "id": "1233", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}, {"status": "ACTIVE", "updated": "2012-03-12T07:48:39Z", "name": "CentOS 5.6 Server 64-bit 20111207 (Kernel)", "links": [{"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/images/1232", "rel": "self"}, {"href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1232", "rel": "bookmark"}], "created": "2011-12-21T11:07:07Z", "progress": 100, "id": "1232", "metadata": {"image_location": "local", "image_state": "available", "min_ram": 0, "min_disk": 0, "architecture": "x86_64", "owner": null, "project_id": "None"}}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json deleted file mode 100644 index 396d1f4f72..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_imageextension.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "images": [{ - "status": "UNRECOGNIZED", - "updated": "2012-02-02T19:11:00Z", - "name": "oneiric-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/15", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/15", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:52Z", - "progress": 100, - "id": "15", - "metadata": { - "kernel_id": "14", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }, { - "status": "UNKNOWN", - "updated": "2012-02-02T19:10:51Z", - "name": "oneiric-server-cloudimg-amd64-kernel", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/14", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/14", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:50Z", - "progress": 100, - "id": "14", - "metadata": { - "min_disk": 0, - "owner": "1", - "min_ram": 0 - } - }, { - "status": "ACTIVE", - "updated": "2012-02-02T19:10:41Z", - "name": "natty-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/13", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/13", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:33Z", - "progress": 100, - "id": "13", - "metadata": { - "kernel_id": "12", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }, { - "status": "SAVING", - "updated": "2012-02-02T19:10:33Z", - "name": "natty-server-cloudimg-amd64-kernel", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/12", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/12", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:32Z", - "progress": 100, - "id": "12", - "metadata": { - "min_disk": 0, - "owner": "1", - "min_ram": 0 - } - }, { - "status": "ERROR", - "updated": "2012-02-02T19:10:41Z", - "name": "natty-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/11", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/11", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:33Z", - "progress": 100, - "id": "11", - "metadata": { - "kernel_id": "12", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }, { - "status": "ERROR", - "updated": "2012-02-02T19:10:41Z", - "name": "natty-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/10", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/10", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:33Z", - "progress": 100, - "id": "10", - "metadata": { - "kernel_id": "12", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json deleted file mode 100644 index f0575db1ef..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list_detail_openstack.json +++ /dev/null @@ -1,81 +0,0 @@ -{ - "images": [{ - "status": "ACTIVE", - "updated": "2012-02-02T19:11:00Z", - "name": "oneiric-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/15", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/15", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:52Z", - "progress": 100, - "id": "15", - "metadata": { - "kernel_id": "14", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }, { - "status": "ACTIVE", - "updated": "2012-02-02T19:10:51Z", - "name": "oneiric-server-cloudimg-amd64-kernel", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/14", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/14", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:50Z", - "progress": 100, - "id": "14", - "metadata": { - "min_disk": 0, - "owner": "1", - "min_ram": 0 - } - }, { - "status": "ACTIVE", - "updated": "2012-02-02T19:10:41Z", - "name": "natty-server-cloudimg-amd64", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/13", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/13", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:33Z", - "progress": 100, - "id": "13", - "metadata": { - "kernel_id": "12", - "min_disk": 0, - "min_ram": 0, - "owner": "1" - } - }, { - "status": "ACTIVE", - "updated": "2012-02-02T19:10:33Z", - "name": "natty-server-cloudimg-amd64-kernel", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/images/12", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/images/12", - "rel": "bookmark" - }], - "created": "2012-02-02T19:10:32Z", - "progress": 100, - "id": "12", - "metadata": { - "min_disk": 0, - "owner": "1", - "min_ram": 0 - } - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json deleted file mode 100644 index 837b9cc967..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quota_class.json +++ /dev/null @@ -1,15 +0,0 @@ -{"quota_class_set": { - "metadata_items": 128, - "injected_file_content_bytes": 10240, - "injected_files": 5, - "gigabytes": 1000, - "ram": 4096, - "floating_ips": 10, - "security_group_rules": 20, - "instances": 5, - "key_pairs": 100, - "volumes": 5, - "cores": 10, - "id": "jcloudstestquotas", - "security_groups": 10 -}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json deleted file mode 100644 index dcf2869d8c..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/quotas.json +++ /dev/null @@ -1,15 +0,0 @@ -{"quota_set": { - "metadata_items": 128, - "injected_file_content_bytes": 10240, - "injected_files": 5, - "gigabytes": 1000, - "ram": 51200, - "floating_ips": 10, - "security_group_rules": 20, - "instances": 10, - "key_pairs": 100, - "volumes": 10, - "cores": 20, - "id": "demo", - "security_groups": 10 -}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json deleted file mode 100644 index 840de6ce54..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "security_group": - { - "rules": [ - { - "from_port": 22, - "group": {}, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 28, - "ip_range": { - "cidr": "10.2.6.0/24" - }, - "id": 108 - }, - { - "from_port": 22, - "group": { - "tenant_id": "admin", - "name": "11111" - }, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 28, - "ip_range": {}, - "id": 109 - } - ], - "tenant_id": "tenant0", - "id": 0, - "name": "name0", - "description": "description0" - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json deleted file mode 100644 index 0da190235f..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_computeservice_typical.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "security_group": { - "rules": [{ - "from_port": 22, - "group": {}, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 2769, - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": 10331 - }, { - "from_port": 22, - "group": { - "tenant_id": "37936628937291", - "name": "jclouds_mygroup" - }, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 2769, - "ip_range": {}, - "id": 10332 - }, { - "from_port": 8080, - "group": {}, - "ip_protocol": "tcp", - "to_port": 8080, - "parent_group_id": 2769, - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": 10333 - }, { - "from_port": 8080, - "group": { - "tenant_id": "37936628937291", - "name": "jclouds_mygroup" - }, - "ip_protocol": "tcp", - "to_port": 8080, - "parent_group_id": 2769, - "ip_range": {}, - "id": 10334 - }], - "tenant_id": "37936628937291", - "id": 2769, - "name": "jclouds_mygroup", - "description": "jclouds_mygroup" - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json deleted file mode 100644 index 0c5b316bb0..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "security_group": - { - "rules": [ - { - "from_port": 22, - "group": {}, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 160, - "ip_range": { - "cidr": "10.2.6.0/24" - }, - "id": 108 - }, - { - "from_port": 22, - "group": { - "tenant_id": "tenant0", - "name": "name0" - }, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 160, - "ip_range": {}, - "id": 109 - } - ], - "tenant_id": "tenant0", - "id": 160, - "name": "name0", - "description": "description0" - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json deleted file mode 100644 index 27aca88759..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_extension_norules.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "security_group": - { - "rules": [], - "tenant_id": "tenant0", - "id": 160, - "name": "name0", - "description": "description0" - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json deleted file mode 100644 index 5ee82bccbe..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_details_port22.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "security_group": { - "rules": [{ - "from_port": 22, - "group": {}, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 2769, - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": 10331 - }], - "tenant_id": "37936628937291", - "id": 2769, - "name": "jclouds-test", - "description": "jclouds-test" - } -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json deleted file mode 100644 index b5a1ed1bfc..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "security_groups":[ - { - "rules":[ - { - "from_port":22, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":22, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":107 - }, - { - "from_port":7600, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":7600, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":118 - }, - { - "from_port":8084, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":8084, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":119 - } - ], - "tenant_id":"tenant1", - "id":1, - "name":"name1", - "description":"description1" - } - ] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json deleted file mode 100644 index 7e58c5164f..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "security_groups":[ - { - "rules": [{ - "from_port": 22, - "group": {}, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 2769, - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": 10331 - }, { - "from_port": 22, - "group": { - "tenant_id": "37936628937291", - "name": "jclouds_mygroup" - }, - "ip_protocol": "tcp", - "to_port": 22, - "parent_group_id": 2769, - "ip_range": {}, - "id": 10332 - }, { - "from_port": 8080, - "group": {}, - "ip_protocol": "tcp", - "to_port": 8080, - "parent_group_id": 2769, - "ip_range": { - "cidr": "0.0.0.0/0" - }, - "id": 10333 - }, { - "from_port": 8080, - "group": { - "tenant_id": "37936628937291", - "name": "jclouds_mygroup" - }, - "ip_protocol": "tcp", - "to_port": 8080, - "parent_group_id": 2769, - "ip_range": {}, - "id": 10334 - }], - "tenant_id": "37936628937291", - "id": 2769, - "name": "jclouds_mygroup", - "description": "jclouds_mygroup" - } - ] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json deleted file mode 100644 index 4a19a36f27..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_list_extension.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "security_groups":[ - { - "rules":[ - { - "from_port":22, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":22, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":107 - }, - { - "from_port":7600, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":7600, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":118 - }, - { - "from_port":8084, - "group":{ - - }, - "ip_protocol":"tcp", - "to_port":8084, - "parent_group_id":3, - "ip_range":{ - "cidr":"0.0.0.0/0" - }, - "id":119 - } - ], - "tenant_id": "tenant0", - "id": 160, - "name": "name0", - "description": "description0" - } - ] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json deleted file mode 100644 index e41095f7af..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_devstack.json +++ /dev/null @@ -1,44 +0,0 @@ -{"server": { - "OS-EXT-STS:task_state": null, - "addresses": { - "private": [{"version": 4, "addr": "10.0.0.8"}] - }, - "links": - [ - { - "href": "http://172.16.89.149:8774/v2/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", "rel": "self" - }, - { - "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", "rel": "bookmark" - } - ], - "image": { - "id": "8e6f5bc4-a210-45b2-841f-c510eae14300", "links": [ - { - "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/images/8e6f5bc4-a210-45b2-841f-c510eae14300", "rel": "bookmark" - }] - }, - "OS-EXT-STS:vm_state": "paused", - "OS-EXT-SRV-ATTR:instance_name": "instance-00000014", - "flavor": { - "id": "1", - "links": [{"href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/flavors/1", "rel": "bookmark"}] - }, - "id": "141b775f-7ac1-45f0-9a95-146260f33a53", - "user_id": "89c01b67395d4bea945f7f5bfd7f344a", - "OS-DCF:diskConfig": "MANUAL", - "accessIPv4": "", - "accessIPv6": "", - "OS-EXT-STS:power_state": 3, - "config_drive": "", - "status": "PAUSED", - "updated": "2012-05-04T15:07:48Z", - "hostId": "eab9a77d1c44b8833e4a3dc6d2d9d50de556e780a319f184d8c82d9b", - "OS-EXT-SRV-ATTR:host": "ubuntu", - "key_name": "", - "OS-EXT-SRV-ATTR:hypervisor_hostname": null, - "name": "test", - "created": "2012-05-04T15:07:36Z", - "tenant_id": "7f312675f9b84c97bff8f5054e181419", - "metadata": {} -}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json deleted file mode 100644 index d35988dfa4..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_diagnostics.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "vnet0_tx_errors": 0, - "vda_read": 77364736, - "vda_write": 415446016, - "vnet0_tx_packets": 9701, - "vda_write_req": 47278, - "cpu0_time": 143150000000, - "vnet0_tx": 1691221, - "vnet0_rx_drop": 0, - "vda_errors": -1, - "vnet0_rx_errors": 0, - "memory": 524288, - "vnet0_rx_packets": 11271, - "vda_read_req": 9551, - "vnet0_rx": 1805288, - "vnet0_tx_drop": 0 -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json deleted file mode 100644 index 9ca9445f18..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details_essex.json +++ /dev/null @@ -1,152 +0,0 @@ -{ - "servers": [{ - "OS-EXT-STS:task_state": null, - "addresses": { - "Net TenantA Front-Middle": [{ - "version": 4, - "addr": "172.16.11.5" - }], - "Public network": [{ - "version": 4, - "addr": "172.16.1.13" - }, { - "version": 4, - "addr": "10.193.112.119" - }] - }, - "links": [{ - "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", - "rel": "self" - }, { - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", - "rel": "bookmark" - }], - "image": { - "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", - "rel": "bookmark" - }] - }, - "OS-EXT-STS:vm_state": "active", - "flavor": { - "id": "1", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", - "rel": "bookmark" - }] - }, - "id": "0c80b392-db30-4736-ae02-4480090f1207", - "user_id": "df13814f6c354d00a8acf66502836323", - "OS-DCF:diskConfig": "MANUAL", - "accessIPv4": "", - "accessIPv6": "", - "progress": 0, - "OS-EXT-STS:power_state": 1, - "config_drive": "", - "status": "ACTIVE", - "updated": "2012-04-12T11:21:33Z", - "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", - "key_name": "", - "name": "VM proxy", - "created": "2012-04-12T11:21:23Z", - "tenant_id": "8d10e6646d5d4585937395b04839a353", - "metadata": {} - }, { - "OS-EXT-STS:task_state": null, - "addresses": { - "Net TenantA Front-Middle": [{ - "version": 4, - "addr": "172.16.11.4" - }], - "Net TenantA Middle-Back": [{ - "version": 4, - "addr": "172.16.12.5" - }] - }, - "links": [{ - "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", - "rel": "self" - }, { - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", - "rel": "bookmark" - }], - "image": { - "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", - "rel": "bookmark" - }] - }, - "OS-EXT-STS:vm_state": "active", - "flavor": { - "id": "1", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", - "rel": "bookmark" - }] - }, - "id": "b332b5cd-535e-4677-b68e-fc8badc13236", - "user_id": "df13814f6c354d00a8acf66502836323", - "OS-DCF:diskConfig": "MANUAL", - "accessIPv4": "", - "accessIPv6": "", - "progress": 0, - "OS-EXT-STS:power_state": 1, - "config_drive": "", - "status": "ACTIVE", - "updated": "2012-04-12T11:18:58Z", - "hostId": "e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc", - "key_name": "", - "name": "VM blog", - "created": "2012-04-12T11:18:48Z", - "tenant_id": "8d10e6646d5d4585937395b04839a353", - "metadata": {} - }, { - "OS-EXT-STS:task_state": null, - "addresses": { - "Net TenantA Middle-Back": [{ - "version": 4, - "addr": "172.16.12.4" - }] - }, - "links": [{ - "href": "http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", - "rel": "self" - }, { - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", - "rel": "bookmark" - }], - "image": { - "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", - "rel": "bookmark" - }] - }, - "OS-EXT-STS:vm_state": "active", - "flavor": { - "id": "1", - "links": [{ - "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", - "rel": "bookmark" - }] - }, - "id": "f9d43436-4572-4c9b-9b74-5fa6890a2f21", - "user_id": "df13814f6c354d00a8acf66502836323", - "OS-DCF:diskConfig": "MANUAL", - "accessIPv4": "", - "accessIPv6": "", - "progress": 0, - "OS-EXT-STS:power_state": 1, - "config_drive": "", - "status": "ACTIVE", - "updated": "2012-04-12T11:15:09Z", - "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", - "key_name": "", - "name": "VM MySQL", - "created": "2012-04-12T11:14:56Z", - "tenant_id": "8d10e6646d5d4585937395b04839a353", - "metadata": {} - }] -} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json deleted file mode 100644 index 16e03fe9e1..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups.json +++ /dev/null @@ -1 +0,0 @@ -{"server": {"status": "ACTIVE", "updated": "2012-05-04T12:15:01Z", "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", "name": "test", "links": [{"href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "self"}, {"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "bookmark"}], "created": "2012-05-04T12:14:57Z", "tenant_id": "4287930c796741aa898425f40832cb3c", "image": {"id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "rel": "bookmark"}]}, "addresses": {"private": [{"version": 4, "addr": "10.0.0.8"}]}, "accessIPv4": "", "accessIPv6": "", "key_name": "", "progress": 0, "flavor": {"id": "1", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/flavors/1", "rel": "bookmark"}]}, "config_drive": "", "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "security_groups": [{"name": "default"},{"name": "group1"}], "metadata": {}}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json deleted file mode 100644 index 7a3c4b2adc..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_with_security_groups_extension.json +++ /dev/null @@ -1 +0,0 @@ -{"server": {"status": "ACTIVE", "updated": "2012-05-04T12:15:01Z", "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", "name": "test", "links": [{"href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "self"}, {"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "rel": "bookmark"}], "created": "2012-05-04T12:14:57Z", "tenant_id": "4287930c796741aa898425f40832cb3c", "image": {"id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", "rel": "bookmark"}]}, "addresses": {"private": [{"version": 4, "addr": "10.0.0.8"}]}, "accessIPv4": "", "accessIPv6": "", "key_name": "", "progress": 0, "flavor": {"id": "1", "links": [{"href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/flavors/1", "rel": "bookmark"}]}, "config_drive": "", "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", "security_groups": [{"name": "name1"}], "metadata": {}}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json deleted file mode 100644 index de07dc4f7c..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usage.json +++ /dev/null @@ -1 +0,0 @@ -{"tenant_usage": {"total_memory_mb_usage": 0.0014847999999999999, "total_vcpus_usage": 7.249999999999999e-07, "total_hours": 4.833333333333333e-07, "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "stop": "2012-04-18 13:32:07.255830", "server_usages": [{"hours": 2.4166666666666665e-07, "uptime": 91149, "local_gb": 50, "ended_at": null, "name": "test1", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "vcpus": 2, "memory_mb": 4096, "state": "active", "flavor": "m1.medium", "started_at": "2012-04-17 12:12:58"}, {"hours": 2.4166666666666665e-07, "uptime": 84710, "local_gb": 30, "ended_at": null, "name": "mish_test", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "vcpus": 1, "memory_mb": 2048, "state": "active", "flavor": "m1.small", "started_at": "2012-04-17 14:00:17"}], "start": "2012-04-18 13:32:07.255743", "total_local_gb_usage": 1.933333333333333e-05}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json deleted file mode 100644 index 6f3c0d74f6..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/simple_tenant_usages.json +++ /dev/null @@ -1 +0,0 @@ -{"tenant_usages": [{"total_memory_mb_usage": 0.0015018666666666667, "total_vcpus_usage": 7.333333333333333e-07, "start": "2012-04-18 12:18:39.702411", "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", "stop": "2012-04-18 12:18:39.702499", "total_hours": 4.888888888888889e-07, "total_local_gb_usage": 1.9555555555555557e-05}] \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json deleted file mode 100644 index 375127b705..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_details.json +++ /dev/null @@ -1 +0,0 @@ -{"snapshot": {"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json deleted file mode 100644 index 03980b1697..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list.json +++ /dev/null @@ -1 +0,0 @@ -{"snapshots": [{"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json deleted file mode 100644 index 03980b1697..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/snapshot_list_detail.json +++ /dev/null @@ -1 +0,0 @@ -{"snapshots": [{"status": "available", "displayDescription": "jclouds live test snapshot", "displayName": "jclouds-live-test", "volumeId": 9, "id": 7, "createdAt": "2012-04-24 13:34:42", "size": 1}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json deleted file mode 100644 index 7df0182f03..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/virtual_interfaces_list.json +++ /dev/null @@ -1 +0,0 @@ -{"virtual_interfaces": [{"id": "02315827-b05c-4668-9c05-75c68838074a", "mac_address": "fa:16:3e:09:71:34"}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json deleted file mode 100644 index 8dd11dc4e6..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_details.json +++ /dev/null @@ -1 +0,0 @@ -{"volume": {"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json deleted file mode 100644 index d2179e799d..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list.json +++ /dev/null @@ -1 +0,0 @@ -{"volumes": [{"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json deleted file mode 100644 index d2179e799d..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_list_detail.json +++ /dev/null @@ -1 +0,0 @@ -{"volumes": [{"status": "in-use", "displayDescription": "This is a test volume", "availabilityZone": "nova", "displayName": "test", "attachments": [{"device": "/dev/vdc", "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", "id": 1, "volumeId": 1}], "volumeType": null, "snapshotId": null, "size": 1, "id": 1, "createdAt": "2012-04-23 12:16:45", "metadata": {}}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json deleted file mode 100644 index 8739d09cdc..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type.json +++ /dev/null @@ -1,9 +0,0 @@ -{"volume_type": { - "name": "jclouds-test-1", - "deleted": false, - "created_at": "2012-05-10 12:33:06", - "updated_at": null, - "extra_specs": {"test": "value1", "test1": "wibble"}, - "deleted_at": null, - "id": 8 -}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json deleted file mode 100644 index 6e71d5d3fd..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_extra_specs.json +++ /dev/null @@ -1 +0,0 @@ -{"extra_specs": {"test": "value1"}} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json b/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json deleted file mode 100644 index 3e613a30cd..0000000000 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/volume_type_list.json +++ /dev/null @@ -1 +0,0 @@ -{"volume_types": [{"name": "jclouds-test-1", "deleted": false, "created_at": "2012-05-10 12:33:06", "updated_at": null, "extra_specs": {"test": "value1", "test1": "wibble"}, "deleted_at": null, "id": 8}]} \ No newline at end of file diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/README.txt b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/README.txt similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/README.txt rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/README.txt diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/pom.xml b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml similarity index 91% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/pom.xml rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml index a3a04e736a..b6964b9fe7 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/pom.xml +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/pom.xml @@ -22,17 +22,17 @@ org.apache.jclouds jclouds-project - 1.7.1 + 1.8.0 org.apache.stratos openstack-nova - 1.7.1-stratos + 1.8.0-stratos jclouds openstack-nova api jclouds components to access an implementation of OpenStack Nova bundle - 1.7.1 + 1.8.0 http://localhost:5000/v2.0/ @@ -102,6 +102,18 @@ logback-classic test + + com.squareup.okhttp + mockwebserver + test + + + + org.bouncycastle + bcprov-jdk15on + + + diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java similarity index 79% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java index b03727eede..9f8d30203b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApi.java @@ -18,17 +18,18 @@ import java.io.Closeable; import java.util.Set; + import org.jclouds.javax.annotation.Nullable; import org.jclouds.location.Zone; import org.jclouds.location.functions.ZoneToEndpoint; -import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI; +import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi; +import org.jclouds.openstack.nova.v2_0.extensions.ConsolesApi; import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi; import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi; import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi; import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi; import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi; import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi; import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi; import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi; import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi; @@ -48,13 +49,9 @@ import com.google.inject.Provides; /** - * Provides synchronous access to Nova. + * Provides access to the OpenStack Compute (Nova) API. *

* - * @see NovaAsyncApi - * @see - * @author Adrian Cole */ public interface NovaApi extends Closeable { /** @@ -66,143 +63,142 @@ public interface NovaApi extends Closeable { Set getConfiguredZones(); /** - * Provides synchronous access to availability zone features + * Provides access to Server features. */ @Delegate - AvailabilityZoneAPI getAvailabilityZoneApi( + ServerApi getServerApiForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Server features. + * Provides access to Flavor features. */ @Delegate - ServerApi getServerApiForZone( + FlavorApi getFlavorApiForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Flavor features. + * Provides access to Extension features. */ @Delegate - FlavorApi getFlavorApiForZone( + ExtensionApi getExtensionApiForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Extension features. + * Provides access to Image features. */ @Delegate - ExtensionApi getExtensionApiForZone( + ImageApi getImageApiForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Image features. + * Provides access to availability zone features */ @Delegate - ImageApi getImageApiForZone( + Optional getAvailabilityZoneApi( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Floating IP features. + * Provides access to Floating IP features. */ @Delegate Optional getFloatingIPExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Security Group features. + * Provides access to Security Group features. */ @Delegate Optional getSecurityGroupExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Key Pair features. + * Provides access to Key Pair features. */ @Delegate Optional getKeyPairExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Host Administration features. + * Provides access to Host Administration features. */ @Delegate Optional getHostAdministrationExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Simple Tenant Usage features. + * Provides access to Simple Tenant Usage features. */ @Delegate Optional getSimpleTenantUsageExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Virtual Interface features. + * Provides access to Virtual Interface features. */ @Delegate Optional getVirtualInterfaceExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Server Extra Data features. + * Provides access to Server Extra Data features. */ @Delegate Optional getServerWithSecurityGroupsExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Server Admin Actions features. + * Provides access to Server Admin Actions features. */ @Delegate Optional getServerAdminExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Aggregate features. + * Provides access to Aggregate features. */ @Delegate Optional getHostAggregateExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Flavor extra specs features. + * Provides access to Flavor extra specs features. */ @Delegate Optional getFlavorExtraSpecsExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Quota features. + * Provides access to Quota features. */ @Delegate Optional getQuotaExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Quota Classes features. + * Provides access to Volume features. */ @Delegate - Optional getQuotaClassExtensionForZone( + Optional getVolumeExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Volume features. + * Provides access to Volume Attachment features. */ @Delegate - Optional getVolumeExtensionForZone( + Optional getVolumeAttachmentExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Volume Attachment features. + * Provides access to Volume Type features. */ @Delegate - Optional getVolumeAttachmentExtensionForZone( + Optional getVolumeTypeExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); /** - * Provides synchronous access to Volume Type features. + * Provides synchronous access to Console features. */ @Delegate - Optional getVolumeTypeExtensionForZone( + Optional getConsolesExtensionForZone( @EndpointParam(parser = ZoneToEndpoint.class) @Nullable String zone); - } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java similarity index 76% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java index ff87858ed4..4dfd4010f5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadata.java @@ -28,35 +28,23 @@ import java.util.Properties; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.openstack.keystone.v2_0.config.AuthenticationApiModule; import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; -import org.jclouds.openstack.keystone.v2_0.config.MappedAuthenticationApiModule; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule; import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextModule; +import org.jclouds.openstack.nova.v2_0.config.NovaHttpApiModule; import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; -import org.jclouds.openstack.nova.v2_0.config.NovaRestClientModule; import org.jclouds.openstack.v2_0.ServiceType; -import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rest.internal.BaseHttpApiMetadata; import com.google.common.collect.ImmutableSet; -import com.google.common.reflect.TypeToken; import com.google.inject.Module; /** - * Implementation of {@link ApiMetadata} for Nova 2.0 API - * - * @author Adrian Cole + * Implementation of {@link org.jclouds.apis.ApiMetadata} for Nova 2.0 API */ -public class NovaApiMetadata extends BaseRestApiMetadata { - - /** - * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as - * {@link NovaAsyncApi} interface will be removed in jclouds 1.7. - */ - @Deprecated - public static final TypeToken> CONTEXT_TOKEN = new TypeToken>() { - private static final long serialVersionUID = 1L; - }; +public class NovaApiMetadata extends BaseHttpApiMetadata { @Override public Builder toBuilder() { @@ -72,7 +60,7 @@ protected NovaApiMetadata(Builder builder) { } public static Properties defaultProperties() { - Properties properties = BaseRestApiMetadata.defaultProperties(); + Properties properties = BaseHttpApiMetadata.defaultProperties(); // auth fail can happen while cloud-init applies keypair updates properties.setProperty("jclouds.ssh.max-retries", "7"); properties.setProperty("jclouds.ssh.retry-auth", "true"); @@ -88,30 +76,28 @@ public static Properties defaultProperties() { return properties; } - public static class Builder extends BaseRestApiMetadata.Builder { + public static class Builder extends BaseHttpApiMetadata.Builder { - @SuppressWarnings("deprecation") protected Builder() { - super(NovaApi.class, NovaAsyncApi.class); id("openstack-nova") .name("OpenStack Nova Diablo+ API") .identityName("${tenantName}:${userName} or ${userName}, if your keystone supports a default tenant") .credentialName("${password}") - .endpointName("KeyStone base url ending in /v2.0/") + .endpointName("Keystone base url ending in /v2.0/") .documentation(URI.create("http://api.openstack.org/")) - .version("1.1") + .version("2") .defaultEndpoint("http://localhost:5000/v2.0/") .defaultProperties(NovaApiMetadata.defaultProperties()) .view(typeToken(ComputeServiceContext.class)) .defaultModules(ImmutableSet.>builder() - .add(MappedAuthenticationApiModule.class) + .add(AuthenticationApiModule.class) .add(KeystoneAuthenticationModule.class) .add(ZoneModule.class) .add(NovaParserModule.class) - .add(NovaRestClientModule.class) + .add(NovaHttpApiModule.class) .add(NovaComputeServiceContextModule.class).build()); } - + @Override public NovaApiMetadata build() { return new NovaApiMetadata(this); diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java new file mode 100644 index 0000000000..82f69f3d07 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindConsoleToJsonPayload.java @@ -0,0 +1,63 @@ +/* + * 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.jclouds.openstack.nova.v2_0.binders; + +import java.util.Map; + +import javax.inject.Inject; +import javax.inject.Singleton; + +import org.jclouds.http.HttpRequest; +import org.jclouds.json.Json; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.rest.binders.BindToJsonPayload; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedMap; + +@Singleton +public class BindConsoleToJsonPayload extends BindToJsonPayload { + + @Inject + public BindConsoleToJsonPayload(Json jsonBinder) { + super(jsonBinder); + } + + @Override + public R bindToRequest(R request, Map postParams) { + String action; + + Console.Type type = (Console.Type) postParams.get("type"); + + switch (type) { + case NOVNC: + case XVPVNC: + action = "os-getVNCConsole"; + break; + case SPICE_HTML5: + action = "os-getSPICEConsole"; + break; + case RDP_HTML5: + action = "os-getRDPConsole"; + break; + default: + throw new IllegalArgumentException("Invalid type: " + type); + } + + return bindToRequest(request, ImmutableMap.of(action, ImmutableSortedMap.copyOf(postParams))); + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java index 882eac64be..509de12634 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindKeyPairToJsonPayload.java @@ -28,10 +28,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSortedMap; -/** - * - * @author Adrian Cole - */ @Singleton public class BindKeyPairToJsonPayload extends BindToJsonPayload { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java index 3cf29d7458..c0fa3bbed6 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindMetadataToJsonPayload.java @@ -27,10 +27,6 @@ import com.google.common.collect.ImmutableMap; -/** - * - * @author Adrian Cole - */ @Singleton public class BindMetadataToJsonPayload extends BindToJsonPayload { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java index cdd3df5a16..022ce6c726 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/binders/BindSecurityGroupRuleToJsonPayload.java @@ -36,11 +36,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindSecurityGroupRuleToJsonPayload extends BindToJsonPayload implements MapBinder { @Inject diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java index 7a1094272d..163bbe47b3 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeService.java @@ -78,9 +78,6 @@ import com.google.common.collect.Multimap; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * @author Adrian Cole - */ @Singleton public class NovaComputeService extends BaseComputeService { protected final NovaApi novaApi; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java index 0e249960ee..7a7cb7de03 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapter.java @@ -65,8 +65,6 @@ /** * The adapter used by the NovaComputeServiceContextModule to interface the nova-specific domain * model to the computeService generic domain model. - * - * @author Matt Stephenson, Adrian Cole */ public class NovaComputeServiceAdapter implements ComputeServiceAdapter { @@ -88,7 +86,7 @@ public NovaComputeServiceAdapter(NovaApi novaApi, @Zone Supplier> zo this.zoneIds = checkNotNull(zoneIds, "zoneIds"); this.removeFloatingIpFromNodeAndDeallocate = checkNotNull(removeFloatingIpFromNodeAndDeallocate, "removeFloatingIpFromNodeAndDeallocate"); - this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache"); + this.keyPairCache = checkNotNull(keyPairCache, "keyPairCache"); } /** @@ -111,7 +109,6 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoNam options.diskConfig(templateOptions.getDiskConfig()); options.configDrive(templateOptions.getConfigDrive()); options.availabilityZone(templateOptions.getAvailabilityZone()); - if (templateOptions.getNovaNetworks() != null) { options.novaNetworks(templateOptions.getNovaNetworks()); } @@ -121,7 +118,7 @@ public NodeAndInitialCredentials createNodeWithGroupEncodedIntoNam Optional privateKey = Optional.absent(); if (templateOptions.getKeyPairName() != null) { - options.keyPairName(templateOptions.getKeyPairName()); + options.keyPairName(templateOptions.getKeyPairName()); KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName())); if (keyPair != null && keyPair.getPrivateKey() != null) { privateKey = Optional.of(keyPair.getPrivateKey()); @@ -272,8 +269,9 @@ public void resumeNode(String id) { ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id); if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) { novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().resume(zoneAndId.getId()); + } else { + throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension"); } - throw new UnsupportedOperationException("resume requires installation of the Admin Actions extension"); } @Override @@ -281,8 +279,9 @@ public void suspendNode(String id) { ZoneAndId zoneAndId = ZoneAndId.fromSlashEncoded(id); if (novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).isPresent()) { novaApi.getServerAdminExtensionForZone(zoneAndId.getZone()).get().suspend(zoneAndId.getId()); + } else { + throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension"); } - throw new UnsupportedOperationException("suspend requires installation of the Admin Actions extension"); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java index 311d4abf24..e070bdb11f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/config/NovaComputeServiceContextModule.java @@ -98,8 +98,6 @@ /** * Module for building a compute service context for Nova - * - * @author Matt Stephenson */ public class NovaComputeServiceContextModule extends ComputeServiceAdapterContextModule { @@ -236,21 +234,30 @@ public String apply(Location arg0) { @VisibleForTesting public static final Map toPortableNodeStatus = ImmutableMap - . builder().put(Server.Status.ACTIVE, NodeMetadata.Status.RUNNING)// - .put(Server.Status.SUSPENDED, NodeMetadata.Status.SUSPENDED)// - .put(Server.Status.DELETED, NodeMetadata.Status.TERMINATED)// - .put(Server.Status.PAUSED, NodeMetadata.Status.SUSPENDED)// - .put(Server.Status.RESIZE, NodeMetadata.Status.PENDING)// - .put(Server.Status.VERIFY_RESIZE, NodeMetadata.Status.PENDING)// - .put(Server.Status.REVERT_RESIZE, NodeMetadata.Status.PENDING)// - .put(Server.Status.BUILD, NodeMetadata.Status.PENDING)// - .put(Server.Status.PASSWORD, NodeMetadata.Status.PENDING)// - .put(Server.Status.REBUILD, NodeMetadata.Status.PENDING)// - .put(Server.Status.ERROR, NodeMetadata.Status.ERROR)// - .put(Server.Status.REBOOT, NodeMetadata.Status.PENDING)// - .put(Server.Status.HARD_REBOOT, NodeMetadata.Status.PENDING)// - .put(Server.Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED)// - .put(Server.Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED).build(); + . builder() + .put(Server.Status.ACTIVE, NodeMetadata.Status.RUNNING) + .put(Server.Status.BUILD, NodeMetadata.Status.PENDING) + .put(Server.Status.DELETED, NodeMetadata.Status.TERMINATED) + .put(Server.Status.ERROR, NodeMetadata.Status.ERROR) + .put(Server.Status.HARD_REBOOT, NodeMetadata.Status.PENDING) + .put(Server.Status.MIGRATING, NodeMetadata.Status.PENDING) + .put(Server.Status.PASSWORD, NodeMetadata.Status.PENDING) + .put(Server.Status.PAUSED, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.REBOOT, NodeMetadata.Status.PENDING) + .put(Server.Status.REBUILD, NodeMetadata.Status.PENDING) + .put(Server.Status.RESCUE, NodeMetadata.Status.PENDING) + .put(Server.Status.RESIZE, NodeMetadata.Status.PENDING) + .put(Server.Status.REVERT_RESIZE, NodeMetadata.Status.PENDING) + .put(Server.Status.SHELVED, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.SHELVED_OFFLOADED, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.SHUTOFF, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.SOFT_DELETED, NodeMetadata.Status.TERMINATED) + .put(Server.Status.STOPPED, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.SUSPENDED, NodeMetadata.Status.SUSPENDED) + .put(Server.Status.UNKNOWN, NodeMetadata.Status.UNRECOGNIZED) + .put(Server.Status.UNRECOGNIZED, NodeMetadata.Status.UNRECOGNIZED) + .put(Server.Status.VERIFY_RESIZE, NodeMetadata.Status.PENDING) + .build(); @Singleton @Provides diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java index f8fd4d9374..dfee4d1d26 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtension.java @@ -57,9 +57,6 @@ /** * Nova implementation of {@link ImageExtension} - * - * @author David Alves - * */ @Singleton public class NovaImageExtension implements ImageExtension { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java index 8b36fc96ee..e808ed366b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtension.java @@ -65,8 +65,6 @@ /** * An extension to compute service to allow for the manipulation of {@link org.jclouds.compute.domain.SecurityGroup}s. Implementation * is optional by providers. - * - * @author Andrew Bayer */ public class NovaSecurityGroupExtension implements SecurityGroupExtension { @@ -173,7 +171,7 @@ public SecurityGroup createSecurityGroup(String name, String zone) { String markerGroup = namingConvention.create().sharedNameForGroup(name); ZoneSecurityGroupNameAndPorts zoneAndName = new ZoneSecurityGroupNameAndPorts(zone, markerGroup, ImmutableSet. of()); - SecurityGroupInZone rawGroup = groupCreator.apply(zoneAndName); + SecurityGroupInZone rawGroup = groupCreator.getUnchecked(zoneAndName); return groupConverter.apply(rawGroup); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java similarity index 51% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java index f7c18ee037..347510c62c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNode.java @@ -19,8 +19,9 @@ import static com.google.common.base.Preconditions.checkState; import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import java.util.ArrayList; import java.util.Collections; +import java.util.List; +import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import javax.annotation.Resource; @@ -32,6 +33,7 @@ import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.logging.Logger; import org.jclouds.openstack.nova.v2_0.NovaApi; +import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.domain.FloatingIP; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndId; import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi; @@ -39,6 +41,7 @@ import com.google.common.base.Function; import com.google.common.base.Objects; +import com.google.common.base.Optional; import com.google.common.base.Predicate; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; @@ -47,11 +50,9 @@ /** * A function for adding and allocating an ip to a node - * - * @author Adrian Cole */ public class AllocateAndAddFloatingIpToNode implements - Function, AtomicReference> { + Function, AtomicReference> { @Resource @Named(ComputeServiceConstants.COMPUTE_LOGGER) @@ -70,39 +71,77 @@ public AllocateAndAddFloatingIpToNode(@Named(TIMEOUT_NODE_RUNNING) Predicate apply(AtomicReference input) { - checkState(nodeRunning.apply(input), "node never achieved state running %s", input.get()); - NodeMetadata node = input.get(); + public AtomicReference apply(AtomicReference input) { + checkState(nodeRunning.apply(input.get().getNodeMetadata()), "node never achieved state running %s", input.get().getNodeMetadata()); + NodeMetadata node = input.get().getNodeMetadata().get(); // node's location is a host String zoneId = node.getLocation().getParent().getId(); FloatingIPApi floatingIpApi = novaApi.getFloatingIPExtensionForZone(zoneId).get(); + Optional> poolNames = input.get().getNovaTemplateOptions().get().getFloatingIpPoolNames(); + + Optional ip = allocateFloatingIPForNode(floatingIpApi, poolNames, node.getId()); + if (!ip.isPresent()) { + throw new InsufficientResourcesException("Failed to allocate a FloatingIP for node(" + node.getId() + ")"); + } + logger.debug(">> adding floatingIp(%s) to node(%s)", ip.get().getIp(), node.getId()); + + floatingIpApi.addToServer(ip.get().getIp(), node.getProviderId()); + input.get().getNodeMetadata().set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.get().getIp())).build()); + floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId())); + return input.get().getNodeMetadata(); + } + + /** + * Allocates a FloatingIP for a given Node + * + * @param floatingIpApi FloatingIPApi to create or query for a valid FloatingIP + * @param poolNames optional set of pool names from which we will attempt to allocate an IP from. Most cases this is null + * @param nodeID optional id of the Node we are trying to allocate a FloatingIP for. Used here only for logging purposes + * @return Optional + */ + private Optional allocateFloatingIPForNode(FloatingIPApi floatingIpApi, Optional> poolNames, String nodeID) { FloatingIP ip = null; + + // 1.) Attempt to allocate from optionally passed poolNames + if (poolNames.isPresent()) { + for (String poolName : poolNames.get()) { + try { + logger.debug(">> allocating floating IP from pool %s for node(%s)", poolName, nodeID); + ip = floatingIpApi.allocateFromPool(poolName); + if (ip != null) + return Optional.of(ip); + } catch (InsufficientResourcesException ire){ + logger.trace("<< [%s] failed to allocate floating IP from pool %s for node(%s)", ire.getMessage(), poolName, nodeID); + } + } + } + + // 2.) Attempt to allocate, if necessary, via 'create()' call try { - logger.debug(">> allocating or reassigning floating ip for node(%s)", node.getId()); + logger.debug(">> creating floating IP for node(%s)", nodeID); ip = floatingIpApi.create(); - } catch (InsufficientResourcesException e) { - logger.trace("<< [%s] allocating a new floating ip for node(%s)", e.getMessage(), node.getId()); - logger.trace(">> searching for existing, unassigned floating ip for node(%s)", node.getId()); - ArrayList unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpApi.list(), - new Predicate() { - - @Override - public boolean apply(FloatingIP arg0) { - return arg0.getFixedIp() == null; - } - - })); - // try to prevent multiple parallel launches from choosing the same ip. - Collections.shuffle(unassignedIps); - ip = Iterables.getLast(unassignedIps); + if (ip != null) + return Optional.of(ip); + } catch (InsufficientResourcesException ire) { + logger.trace("<< [%s] failed to create floating IP for node(%s)", ire.getMessage(), nodeID); } - logger.debug(">> adding floatingIp(%s) to node(%s)", ip.getIp(), node.getId()); - floatingIpApi.addToServer(ip.getIp(), node.getProviderId()); - input.set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.getIp())).build()); - floatingIpCache.invalidate(ZoneAndId.fromSlashEncoded(node.getId())); - return input; + // 3.) If no IP was found make final attempt by searching through list of available IP's + logger.trace(">> searching for existing, unassigned floating IP for node(%s)", nodeID); + List unassignedIps = Lists.newArrayList(Iterables.filter(floatingIpApi.list(), + new Predicate() { + + @Override + public boolean apply(FloatingIP arg0) { + return arg0.getFixedIp() == null; + } + + })); + // try to prevent multiple parallel launches from choosing the same ip. + Collections.shuffle(unassignedIps); + ip = Iterables.getLast(unassignedIps); + return Optional.fromNullable(ip); } @Override diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java index 6b5d519080..5a87105137 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/CreateSecurityGroupIfNeeded.java @@ -39,10 +39,6 @@ import com.google.common.base.Function; import com.google.common.base.Optional; -/** - * - * @author Adrian Cole - */ @Singleton public class CreateSecurityGroupIfNeeded implements Function { @Resource diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java index 160944bdb5..4e8a776023 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardware.java @@ -36,8 +36,6 @@ /** * A function for transforming the nova specific FlavorInZone object to the generic Hardware object. - * - * @author Matt Stephenson */ public class FlavorInZoneToHardware implements Function { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java index 109da29690..0655c21cd0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImage.java @@ -36,8 +36,6 @@ /** * A function for transforming a nova-specific Image into a generic Image object. - * - * @author Matt Stephenson */ public class ImageInZoneToImage implements Function { private final Map toPortableImageStatus; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java index f26c4e0085..2781942c1f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystem.java @@ -47,8 +47,6 @@ /** * A function for transforming a nova specific Image into a generic OperatingSystem object. - * - * @author Matt Stephenson */ public class ImageToOperatingSystem implements Function { public static final Pattern DEFAULT_PATTERN = Pattern.compile("(([^ ]*) ([0-9.]+) ?.*)"); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java index fc772df7fc..1991e775c5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroup.java @@ -40,8 +40,6 @@ /** * A function for transforming a Nova-specific SecurityGroup into a generic * SecurityGroup object. - * - * @author Andrew Bayer */ @Singleton public class NovaSecurityGroupInZoneToSecurityGroup implements Function { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java index d39f849182..6bd2e64fff 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroup.java @@ -36,8 +36,6 @@ /** * A function for transforming a Nova-specific SecurityGroup into a generic * SecurityGroup object. - * - * @author Andrew Bayer */ @Singleton public class NovaSecurityGroupToSecurityGroup implements Function { @@ -45,10 +43,10 @@ public class NovaSecurityGroupToSecurityGroup implements Function ruleToPermission; + protected Function ruleToPermission; @Inject - public NovaSecurityGroupToSecurityGroup(Function ruleToPermission) { + public NovaSecurityGroupToSecurityGroup(Function ruleToPermission) { this.ruleToPermission = ruleToPermission; } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java index 4993f0c357..f49330fbf7 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneId.java @@ -39,10 +39,6 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; -/** - * - * @author Adrian Cole - */ public class OrphanedGroupsByZoneId implements Function, Multimap> { private final Predicate allNodesInGroupTerminated; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java index 269a3334e3..cee1305563 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/RemoveFloatingIpFromNodeAndDeallocate.java @@ -35,8 +35,6 @@ /** * A function for removing and deallocating an ip address from a node - * - * @author Adrian Cole */ public class RemoveFloatingIpFromNodeAndDeallocate implements Function { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java index a98a62b001..46d4679e27 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermission.java @@ -45,8 +45,6 @@ /** * A function for transforming a nova-specific SecurityGroupRule into a generic * IpPermission object. - * - * @author Andrew Bayer */ public class SecurityGroupRuleToIpPermission implements Function { @Resource diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java index 23035c2939..57d66c270d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadata.java @@ -66,8 +66,6 @@ /** * A function for transforming a nova-specific Server into a generic * NodeMetadata object. - * - * @author Matt Stephenson, Adam Lowe, Adrian Cole */ public class ServerInZoneToNodeMetadata implements Function { @Resource @@ -106,7 +104,11 @@ public NodeMetadata apply(ServerInZone serverInZone) { .description(from.getHostId()).parent(zone).build() : zone); builder.group(groupFromMapOrName(from.getMetadata(), from.getName(), nodeNamingConvention)); addMetadataAndParseTagsFromCommaDelimitedValue(builder, from.getMetadata()); - builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode()); + + if (from.getImage() != null) { + builder.imageId(ZoneAndId.fromZoneAndId(serverInZone.getZone(), from.getImage().getId()).slashEncode()); + } + builder.operatingSystem(findOperatingSystemForServerOrNull(serverInZone)); builder.hardware(findHardwareForServerOrNull(serverInZone)); builder.status(toPortableNodeStatus.get(from.getStatus())); @@ -133,7 +135,7 @@ public NodeMetadata apply(ServerInZone serverInZone) { AddressToStringTransformationFunction.INSTANCE), isInet4Address)); - for (Link link: from.getLinks()) { + for (Link link : from.getLinks()) { if (link.getRelation().equals(Link.Relation.SELF)) { builder.uri(link.getHref()); } @@ -176,9 +178,15 @@ protected Hardware findHardwareForServerOrNull(ServerInZone serverInZone) { } protected OperatingSystem findOperatingSystemForServerOrNull(ServerInZone serverInZone) { - Image image = findObjectOfTypeForServerOrNull(images.get(), "image", serverInZone.getServer().getImage().getId(), - serverInZone); - return (image != null) ? image.getOperatingSystem() : null; + if (serverInZone.getServer().getImage() != null) { + Image image = findObjectOfTypeForServerOrNull( + images.get(), "image", serverInZone.getServer().getImage().getId(), serverInZone); + + return (image != null) ? image.getOperatingSystem() : null; + } else { + return null; + } + } public T findObjectOfTypeForServerOrNull(Set supply, String type, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java index 18096fe466..71852dce0f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPair.java @@ -35,9 +35,6 @@ import com.google.common.cache.CacheLoader; import com.google.inject.Inject; -/** - * @author Adam Lowe - */ @Singleton public class CreateUniqueKeyPair extends CacheLoader { @Resource diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java index 71951cd8bf..d072e3704e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreate.java @@ -32,10 +32,6 @@ import com.google.common.cache.CacheLoader; import com.google.common.util.concurrent.Atomics; -/** - * - * @author Adrian Cole - */ public class FindSecurityGroupOrCreate extends CacheLoader { protected final Predicate> returnSecurityGroupExistsInZone; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java index 1c0ae8a7e5..e4a9caa523 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstance.java @@ -33,8 +33,6 @@ * Each zone may or may not have the floating ip function present. In order to safely proceed, we * must allow the user to determine if a zone has floating ip services before attempting to use * them. - * - * @author Adam Lowe */ @Singleton public class LoadFloatingIpsForInstance extends CacheLoader> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NodeAndNovaTemplateOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NodeAndNovaTemplateOptions.java new file mode 100644 index 0000000000..b971cfc616 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NodeAndNovaTemplateOptions.java @@ -0,0 +1,54 @@ +/* + * 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.jclouds.openstack.nova.v2_0.compute.options; + +import java.util.concurrent.atomic.AtomicReference; + +import org.jclouds.compute.domain.NodeMetadata; + +import com.google.common.util.concurrent.Atomics; + +/** + * Simple data-structure for holding a NodeMetadata object along with a + * corresponding NovaTemplateOptions object. + */ +public class NodeAndNovaTemplateOptions { + + private final AtomicReference nodeMetadata; + private final AtomicReference novaTemplateOptions; + + protected NodeAndNovaTemplateOptions(AtomicReference nodeMetadata, AtomicReference novaTemplateOptions) { + this.nodeMetadata = nodeMetadata; + this.novaTemplateOptions = novaTemplateOptions; + } + + public AtomicReference getNodeMetadata() { + return nodeMetadata; + } + + public AtomicReference getNovaTemplateOptions() { + return novaTemplateOptions; + } + + public static NodeAndNovaTemplateOptions newReference(AtomicReference node, AtomicReference options) { + return new NodeAndNovaTemplateOptions(node, options); + } + + public static AtomicReference newAtomicReference(AtomicReference node, AtomicReference options) { + return Atomics.newReference(NodeAndNovaTemplateOptions.newReference(node, options)); + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java similarity index 85% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java index b85dfd430b..896fbec208 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptions.java @@ -28,7 +28,6 @@ import org.jclouds.compute.options.TemplateOptions; import org.jclouds.domain.LoginCredentials; import org.jclouds.openstack.nova.v2_0.domain.Network; -import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; import org.jclouds.scriptbuilder.domain.Statement; import com.google.common.base.Objects; @@ -49,8 +48,6 @@ * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * Set set = api.createNodesInGroup(tag, 2, templateBuilder.build()); * - * - * @author Adam Lowe */ public class NovaTemplateOptions extends TemplateOptions implements Cloneable { @Override @@ -66,13 +63,15 @@ public void copyTo(TemplateOptions to) { if (to instanceof NovaTemplateOptions) { NovaTemplateOptions eTo = NovaTemplateOptions.class.cast(to); eTo.autoAssignFloatingIp(shouldAutoAssignFloatingIp()); + if (getFloatingIpPoolNames().isPresent()) + eTo.floatingIpPoolNames(getFloatingIpPoolNames().get()); if (getSecurityGroupNames().isPresent()) eTo.securityGroupNames(getSecurityGroupNames().get()); eTo.generateKeyPair(shouldGenerateKeyPair()); eTo.keyPairName(getKeyPairName()); - eTo.availabilityZone(getAvailabilityZone()); + eTo.availabilityZone(getAvailabilityZone()); if (getUserData() != null) { - eTo.userData(getUserData()); + eTo.userData(getUserData()); } if (getDiskConfig() != null) { eTo.diskConfig(getDiskConfig()); @@ -84,14 +83,16 @@ public void copyTo(TemplateOptions to) { } protected boolean autoAssignFloatingIp = false; + protected Optional> floatingIpPoolNames = Optional.absent(); protected Optional> securityGroupNames = Optional.absent(); protected boolean generateKeyPair = false; protected String keyPairName; protected byte[] userData; protected String diskConfig; protected boolean configDrive; - protected String availabilityZone; protected Set novaNetworks; + protected String availabilityZone; + @Override public boolean equals(Object o) { @@ -101,6 +102,7 @@ public boolean equals(Object o) { return false; NovaTemplateOptions that = NovaTemplateOptions.class.cast(o); return super.equals(that) && equal(this.autoAssignFloatingIp, that.autoAssignFloatingIp) + && equal(this.floatingIpPoolNames, that.floatingIpPoolNames) && equal(this.securityGroupNames, that.securityGroupNames) && equal(this.generateKeyPair, that.generateKeyPair) && equal(this.keyPairName, that.keyPairName) @@ -113,7 +115,7 @@ && equal(this.availabilityZone, that.availabilityZone) @Override public int hashCode() { - return Objects.hashCode(super.hashCode(), autoAssignFloatingIp, securityGroupNames, generateKeyPair, keyPairName, userData, diskConfig, configDrive,availabilityZone, novaNetworks); + return Objects.hashCode(super.hashCode(), autoAssignFloatingIp, floatingIpPoolNames, securityGroupNames, generateKeyPair, keyPairName, userData, diskConfig, configDrive, availabilityZone, novaNetworks); } @Override @@ -121,6 +123,8 @@ public ToStringHelper string() { ToStringHelper toString = super.string(); if (!autoAssignFloatingIp) toString.add("autoAssignFloatingIp", autoAssignFloatingIp); + if (floatingIpPoolNames.isPresent()) + toString.add("floatingIpPoolNames", floatingIpPoolNames.get()); if (securityGroupNames.isPresent()) toString.add("securityGroupNames", securityGroupNames.get()); if (generateKeyPair) @@ -137,13 +141,30 @@ public ToStringHelper string() { public static final NovaTemplateOptions NONE = new NovaTemplateOptions(); /** - * @see #shouldAutoAssignFloatingIp() + * @see #getFloatingIpPoolNames() */ public NovaTemplateOptions autoAssignFloatingIp(boolean enable) { this.autoAssignFloatingIp = enable; return this; } + /** + * @see #getFloatingIpPoolNames() + */ + public NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames) { + return floatingIpPoolNames(ImmutableSet.copyOf(checkNotNull(floatingIpPoolNames, "floatingIpPoolNames"))); + } + + /** + * @see #getFloatingIpPoolNames() + */ + public NovaTemplateOptions floatingIpPoolNames(Iterable floatingIpPoolNames) { + for (String groupName : checkNotNull(floatingIpPoolNames, "floatingIpPoolNames")) + checkNotNull(emptyToNull(groupName), "all floating-ip-pool-names must be non-empty"); + this.floatingIpPoolNames = Optional.> of(ImmutableSet.copyOf(floatingIpPoolNames)); + return this; + } + /** * @see #shouldGenerateKeyPair() */ @@ -168,7 +189,6 @@ public NovaTemplateOptions availabilityZone(String zone) { return this; } - /** * * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames @@ -190,7 +210,7 @@ public NovaTemplateOptions securityGroupNames(Iterable securityGroupName /** *

Note

* - * This requires that {@link NovaApi#getExtensionForZone(String)} to return + * This requires that {@link org.jclouds.openstack.nova.v2_0.NovaApi#getExtensionApiForZone(String)} to return * {@link Optional#isPresent present} * * @return true if auto assignment of a floating ip to each vm is enabled @@ -199,6 +219,18 @@ public boolean shouldAutoAssignFloatingIp() { return autoAssignFloatingIp; } + /** + * The floating IP pool name(s) to use when allocating a FloatingIP. Applicable + * only if #shouldAutoAssignFloatingIp() returns true. If not set will attempt to + * use whatever FloatingIP(s) can be found regardless of which pool they originated + * from + * + * @return floating-ip-pool names to use + */ + public Optional> getFloatingIpPoolNames() { + return floatingIpPoolNames; + } + /** * Specifies the keypair used to run instances with * @return the keypair to be used @@ -215,11 +247,10 @@ public String getAvailabilityZone() { return availabilityZone; } - /** *

Note

* - * This requires that {@link NovaApi#getKeyPairExtensionForZone(String)} to return + * This requires that {@link org.jclouds.openstack.nova.v2_0.NovaApi#getKeyPairExtensionForZone(String)} to return * {@link Optional#isPresent present} * * @return true if auto generation of keypairs is enabled @@ -227,7 +258,7 @@ public String getAvailabilityZone() { public boolean shouldGenerateKeyPair() { return generateKeyPair; } - + /** * if unset, generate a default group prefixed with {@link jclouds#} according * to {@link #getInboundPorts()} @@ -239,25 +270,25 @@ public Optional> getSecurityGroupNames() { } public byte[] getUserData() { - return userData; - } + return userData; + } /** - * @see CreateServerOptions#getDiskConfig() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig() */ public String getDiskConfig() { - return diskConfig; - } + return diskConfig; + } /** - * @see CreateServerOptions#getConfigDrive() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive() */ public boolean getConfigDrive() { return configDrive; } /** - * @see CreateServerOptions#getNetworks() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks() */ public Set getNovaNetworks() { return novaNetworks; @@ -272,6 +303,22 @@ public static NovaTemplateOptions autoAssignFloatingIp(boolean enable) { return new NovaTemplateOptions().autoAssignFloatingIp(enable); } + /** + * @see #getFloatingIpPoolNames() + */ + public NovaTemplateOptions floatingIpPoolNames(String... floatingIpPoolNames) { + NovaTemplateOptions options = new NovaTemplateOptions(); + return NovaTemplateOptions.class.cast(options.floatingIpPoolNames(floatingIpPoolNames)); + } + + /** + * @see #getFloatingIpPoolNames() + */ + public NovaTemplateOptions floatingIpPoolNames(Iterable floatingIpPoolNames) { + NovaTemplateOptions options = new NovaTemplateOptions(); + return NovaTemplateOptions.class.cast(options.floatingIpPoolNames(floatingIpPoolNames)); + } + /** * @see NovaTemplateOptions#shouldGenerateKeyPair() */ @@ -292,7 +339,7 @@ public static NovaTemplateOptions keyPairName(String keyPairName) { public static NovaTemplateOptions availabilityZone(String zone) { return new NovaTemplateOptions().availabilityZone(zone); } - + /** * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getSecurityGroupNames */ @@ -406,7 +453,7 @@ public static NovaTemplateOptions overrideLoginCredentials(LoginCredentials cred NovaTemplateOptions options = new NovaTemplateOptions(); return options.overrideLoginCredentials(credentials); } - + /** * @see TemplateOptions#blockUntilRunning */ @@ -414,7 +461,7 @@ public static NovaTemplateOptions blockUntilRunning(boolean blockUntilRunning) { NovaTemplateOptions options = new NovaTemplateOptions(); return options.blockUntilRunning(blockUntilRunning); } - + /** * @see NovaTemplateOptions#userData */ @@ -422,7 +469,7 @@ public static NovaTemplateOptions userData(byte[] userData) { NovaTemplateOptions options = new NovaTemplateOptions(); return NovaTemplateOptions.class.cast(options.userData(userData)); } - + /** * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig() */ @@ -608,15 +655,15 @@ public NovaTemplateOptions networks(String... networks) { * User data as bytes (not base64-encoded) */ public NovaTemplateOptions userData(byte[] userData) { - // This limit may not be needed for nova - checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, - "userData cannot be larger than 16kb"); - this.userData = userData; - return this; + // This limit may not be needed for nova + checkArgument(checkNotNull(userData, "userData").length <= 16 * 1024, + "userData cannot be larger than 16kb"); + this.userData = userData; + return this; } /** - * @see CreateServerOptions#getDiskConfig() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getDiskConfig() */ public NovaTemplateOptions diskConfig(String diskConfig) { this.diskConfig = diskConfig; @@ -629,7 +676,7 @@ public NovaTemplateOptions diskConfig(String diskConfig) { * normally be available through the metadata service by mounting this disk and reading files from it. * To enable the config drive, set this parameter to "true". * This has to be enabled for user data cases. - * @see CreateServerOptions#getConfigDrive() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getConfigDrive() */ public NovaTemplateOptions configDrive(boolean configDrive) { this.configDrive = configDrive; @@ -640,7 +687,7 @@ public NovaTemplateOptions configDrive(boolean configDrive) { * @param novaNetworks The list of network declarations. * Nova-specific network declarations allow for specifying network UUIDs, port UUIDs, and fixed IPs. * Unline {@link #networks(Iterable)} this supports setting additional network parameters and not just network UUIDs. - * @see CreateServerOptions#getNetworks() + * @see org.jclouds.openstack.nova.v2_0.options.CreateServerOptions#getNetworks() */ public NovaTemplateOptions novaNetworks(Set novaNetworks) { this.novaNetworks = novaNetworks; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java index 680a82c21b..a4b63e9a8b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/predicates/AllNodesInGroupTerminated.java @@ -33,9 +33,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; -/** - * @author Adrian Cole - */ public class AllNodesInGroupTerminated implements Predicate { private final ComputeService computeService; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java similarity index 89% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java index e3ea4ccb7a..58f7af55b3 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/compute/strategy/ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet.java @@ -42,24 +42,23 @@ import org.jclouds.compute.strategy.impl.CreateNodesWithGroupEncodedIntoNameThenAddToSet; import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.compute.functions.AllocateAndAddFloatingIpToNode; +import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.domain.KeyPair; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.SecurityGroupInZone; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneAndName; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ZoneSecurityGroupNameAndPorts; +import com.google.common.base.Function; import com.google.common.base.Throwables; import com.google.common.cache.LoadingCache; import com.google.common.collect.Multimap; import com.google.common.primitives.Ints; +import com.google.common.util.concurrent.Atomics; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * - * @author Adrian Cole - */ @Singleton public class ApplyNovaTemplateOptionsCreateNodesWithGroupEncodedIntoNameThenAddToSet extends CreateNodesWithGroupEncodedIntoNameThenAddToSet { @@ -153,13 +152,21 @@ protected ListenableFuture> createNodeInGroupWithN final String name, Template template) { ListenableFuture> future = super.createNodeInGroupWithNameAndTemplate(group, name, template); - NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions()); - + final NovaTemplateOptions templateOptions = NovaTemplateOptions.class.cast(template.getOptions()); if (templateOptions.shouldAutoAssignFloatingIp()) { - return Futures.transform(future, createAndAddFloatingIpToNode, userExecutor); + + ListenableFuture> nodeAndNovaTemplateOptions = Futures.transform(future, + new Function, AtomicReference>() { + + @Override + public AtomicReference apply(AtomicReference input) { + return NodeAndNovaTemplateOptions.newAtomicReference(input, Atomics.newReference(templateOptions)); + } + } + ); + return Futures.transform(nodeAndNovaTemplateOptions, createAndAddFloatingIpToNode, userExecutor); } else { return future; } } - } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaHttpApiModule.java similarity index 50% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaHttpApiModule.java index 556ec60b3a..d763406bdc 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaRestClientModule.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaHttpApiModule.java @@ -15,10 +15,8 @@ * limitations under the License. */ package org.jclouds.openstack.nova.v2_0.config; -import static org.jclouds.reflect.Reflection2.typeToken; import java.net.URI; -import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -30,103 +28,30 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.openstack.nova.v2_0.NovaApi; -import org.jclouds.openstack.nova.v2_0.NovaAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAPI; -import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneAsyncApi; import org.jclouds.openstack.nova.v2_0.extensions.ExtensionNamespaces; -import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsApi; -import org.jclouds.openstack.nova.v2_0.extensions.FlavorExtraSpecsAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi; -import org.jclouds.openstack.nova.v2_0.extensions.FloatingIPAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAdministrationAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateApi; -import org.jclouds.openstack.nova.v2_0.extensions.HostAggregateAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.KeyPairApi; -import org.jclouds.openstack.nova.v2_0.extensions.KeyPairAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassApi; -import org.jclouds.openstack.nova.v2_0.extensions.QuotaClassAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupApi; -import org.jclouds.openstack.nova.v2_0.extensions.SecurityGroupAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerAdminAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsApi; -import org.jclouds.openstack.nova.v2_0.extensions.ServerWithSecurityGroupsAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageApi; -import org.jclouds.openstack.nova.v2_0.extensions.SimpleTenantUsageAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi; -import org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeAttachmentAsyncApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeApi; -import org.jclouds.openstack.nova.v2_0.extensions.VolumeTypeAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.FlavorApi; -import org.jclouds.openstack.nova.v2_0.features.FlavorAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.ImageApi; -import org.jclouds.openstack.nova.v2_0.features.ImageAsyncApi; -import org.jclouds.openstack.nova.v2_0.features.ServerApi; -import org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi; import org.jclouds.openstack.nova.v2_0.handlers.NovaErrorHandler; import org.jclouds.openstack.v2_0.domain.Extension; -import org.jclouds.openstack.v2_0.features.ExtensionApi; -import org.jclouds.openstack.v2_0.features.ExtensionAsyncApi; import org.jclouds.openstack.v2_0.functions.PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet; import org.jclouds.rest.ConfiguresRestClient; -import org.jclouds.rest.config.RestClientModule; +import org.jclouds.rest.config.HttpApiModule; import org.jclouds.rest.functions.ImplicitOptionalConverter; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.Multimap; -import com.google.common.reflect.TypeToken; import com.google.inject.Provides; /** * Configures the Nova connection. - * - * @author Adrian Cole + * */ @ConfiguresRestClient -public class NovaRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() - .put(ServerApi.class, ServerAsyncApi.class) - .put(FlavorApi.class, FlavorAsyncApi.class) - .put(ImageApi.class, ImageAsyncApi.class) - .put(ExtensionApi.class, ExtensionAsyncApi.class) - .put(FloatingIPApi.class, FloatingIPAsyncApi.class) - .put(AvailabilityZoneAPI.class, AvailabilityZoneAsyncApi.class) - .put(SecurityGroupApi.class, SecurityGroupAsyncApi.class) - .put(KeyPairApi.class, KeyPairAsyncApi.class) - .put(HostAdministrationApi.class, HostAdministrationAsyncApi.class) - .put(SimpleTenantUsageApi.class, SimpleTenantUsageAsyncApi.class) - .put(VirtualInterfaceApi.class, VirtualInterfaceAsyncApi.class) - .put(ServerWithSecurityGroupsApi.class, ServerWithSecurityGroupsAsyncApi.class) - .put(ServerAdminApi.class, ServerAdminAsyncApi.class) - .put(HostAggregateApi.class, HostAggregateAsyncApi.class) - .put(FlavorExtraSpecsApi.class, FlavorExtraSpecsAsyncApi.class) - .put(QuotaApi.class, QuotaAsyncApi.class) - .put(QuotaClassApi.class, QuotaClassAsyncApi.class) - .put(VolumeApi.class, VolumeAsyncApi.class) - .put(VolumeAttachmentApi.class, VolumeAttachmentAsyncApi.class) - .put(VolumeTypeApi.class, VolumeTypeAsyncApi.class) - .build(); - - @SuppressWarnings("unchecked") - public NovaRestClientModule() { - super(TypeToken.class.cast(typeToken(NovaApi.class)), TypeToken.class.cast(typeToken(NovaAsyncApi.class)), DELEGATE_MAP); - } +public class NovaHttpApiModule extends HttpApiModule { - protected NovaRestClientModule(TypeToken syncClientType, TypeToken
asyncClientType, - Map, Class> sync2Async) { - super(syncClientType, asyncClientType, sync2Async); + public NovaHttpApiModule() { } @Override @@ -134,7 +59,7 @@ protected void configure() { bind(ImplicitOptionalConverter.class).to(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); super.configure(); } - + @Provides @Singleton public Multimap aliases() { @@ -163,10 +88,10 @@ public Multimap aliases() { URI.create("http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1")) .put(URI.create(ExtensionNamespaces.QUOTAS), URI.create("http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1")) - .put(URI.create(ExtensionNamespaces.QUOTA_CLASSES), - URI.create("http://docs.openstack.org/compute/ext/quota-classes-sets/api/v1.1")) .put(URI.create(ExtensionNamespaces.VOLUME_TYPES), URI.create("http://docs.openstack.org/compute/ext/volume_types/api/v1.1")) + .put(URI.create(ExtensionNamespaces.AVAILABILITY_ZONE), + URI.create("http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1")) .build(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java similarity index 79% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java index 7f31c27876..f35dba88e3 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaParserModule.java @@ -50,10 +50,6 @@ import com.google.inject.AbstractModule; import com.google.inject.Provides; -/** - * @author Adrian Cole - * @author Adam Lowe - */ public class NovaParserModule extends AbstractModule { @Provides @@ -126,7 +122,15 @@ public static class ServerAdapter implements JsonDeserializer { @Override public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { - Server serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); + Server serverBase; + + // Servers can be created without an image so test if an image object is returned + if (jsonElement.getAsJsonObject().get("image").isJsonObject()) { + serverBase = apply((ServerInternal) context.deserialize(jsonElement, ServerInternal.class)); + } else { + serverBase = apply((ServerInternalWithoutImage) context.deserialize(jsonElement, ServerInternalWithoutImage.class)); + } + Server.Builder result = Server.builder().fromServer(serverBase); ServerExtendedStatus extendedStatus = context.deserialize(jsonElement, ServerExtendedStatus.class); if (!Objects.equal(extendedStatus, ServerExtendedStatus.builder().build())) { @@ -139,7 +143,7 @@ public Server deserialize(JsonElement jsonElement, Type type, JsonDeserializatio return result.build(); } - public Server apply(ServerInternal in) { + public Server apply(Server in) { return in.toBuilder().build(); } @@ -155,5 +159,18 @@ protected ServerInternal(String id, @Nullable String name, java.util.Set l super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, image, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig); } } + + private static class ServerInternalWithoutImage extends Server { + @ConstructorProperties({ + "id", "name", "links", "uuid", "tenant_id", "user_id", "updated", "created", "hostId", "accessIPv4", "accessIPv6", "status", "flavor", "key_name", "config_drive", "addresses", "metadata", "extendedStatus", "extendedAttributes", "OS-DCF:diskConfig" + }) + protected ServerInternalWithoutImage(String id, @Nullable String name, java.util.Set links, @Nullable String uuid, String tenantId, + String userId, Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4, + @Nullable String accessIPv6, Server.Status status, Resource flavor, @Nullable String keyName, + @Nullable String configDrive, Multimap addresses, Map metadata, + @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) { + super(id, name, links, uuid, tenantId, userId, updated, created, hostId, accessIPv4, accessIPv6, status, null, flavor, keyName, configDrive, addresses, metadata, extendedStatus, extendedAttributes, diskConfig); + } + } } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java index 9b5543980a..57eb8f8b05 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/config/NovaProperties.java @@ -18,8 +18,6 @@ /** * Configuration properties and constants used in openstack Nova connections. - * - * @author Adam Lowe */ public class NovaProperties { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java index 38c744dfea..c57136c1b5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Address.java @@ -26,7 +26,6 @@ /** * IP address * - * @author AdrianCole */ public class Address { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java index 97460d8fcb..70fe2e4d7e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/BackupType.java @@ -20,9 +20,6 @@ import com.google.common.base.CaseFormat; -/** - * @author Adam Lowe - */ public enum BackupType { DAILY, WEEKLY; diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Console.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Console.java new file mode 100644 index 0000000000..1c51fbf539 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Console.java @@ -0,0 +1,161 @@ +/* + * 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.jclouds.openstack.nova.v2_0.domain; + +import static com.google.common.base.Objects.toStringHelper; +import static com.google.common.base.Preconditions.checkNotNull; + +import java.beans.ConstructorProperties; +import java.net.URI; + +import com.google.common.base.Objects.ToStringHelper; +import com.google.common.base.Objects; + +/** + * Represents an Openstack Console. + */ +public class Console { + public enum Type { + NOVNC("novnc"), + XVPVNC("xvpvnc"), + SPICE_HTML5("spice-html5"), + RDP_HTML5("rdp-html5"), + UNRECOGNIZED("unrecognized"); + + private final String type; + + Type(String type) { + this.type = type; + } + + public String type() { + return type; + } + + /** + * Used from jclouds builtin deserializer. + */ + public static Type fromValue(String type) { + if (type != null) { + for (Type value : Type.values()) { + if (type.equals(value.type)) { + return value; + } + } + return UNRECOGNIZED; + } + return null; + } + + @Override + public String toString() { + return type(); + } + } + + public static Builder builder() { + return new ConcreteBuilder(); + } + + public Builder toBuilder() { + return new ConcreteBuilder().fromConsole(this); + } + + public abstract static class Builder> { + protected abstract T self(); + + protected URI url; + protected Type type; + + /** + * @see Console#getUrl() + */ + public T url(URI url) { + this.url = checkNotNull(url, "url"); + return self(); + } + + /** + * @see Console#getType() + */ + public T type(Type type) { + this.type = type; + return self(); + } + + public Console build() { + return new Console(url, type); + } + + public T fromConsole(Console in) { + return this.url(in.getUrl()).type(in.getType()); + } + } + + private static class ConcreteBuilder extends Builder { + @Override + protected ConcreteBuilder self() { + return this; + } + } + + private final URI url; + private final Type type; + + @ConstructorProperties({ "url", "type" }) + protected Console(URI url, Type type) { + this.url = checkNotNull(url, "url"); + this.type = checkNotNull(type, "type"); + } + + /** + * @return the url to use to connect to the server. + */ + public URI getUrl() { + return this.url; + } + + /** + * @return the type of the url + */ + public Type getType() { + return this.type; + } + + @Override + public int hashCode() { + return Objects.hashCode(url, type); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null || getClass() != obj.getClass()) return false; + Console that = Console.class.cast(obj); + return Objects.equal(this.url, that.url) + && Objects.equal(this.type, that.type); + } + + protected ToStringHelper string() { + return toStringHelper(this).add("url", url).add("type", type); + } + + @Override + public String toString() { + return string().toString(); + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java index c353ab05b7..ce40d5106b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Flavor.java @@ -35,7 +35,6 @@ * A flavor is an available hardware configuration for a server. Each flavor has * a unique combination of disk space and memory capacity. * - * @author Jeremy Daggett, Ilja Bobkevic * @see diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java similarity index 83% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java index 203b2da02e..76e1c26ed0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/FloatingIP.java @@ -31,28 +31,26 @@ * A Floating IP is an IP address that can be created and associated with a * Server instance. Floating IPs can also be disassociated and deleted from a * Server instance. - * - * @author Jeremy Daggett - * @author chamerling -*/ + */ public class FloatingIP implements Comparable { - public static Builder builder() { + public static Builder builder() { return new ConcreteBuilder(); } - + public Builder toBuilder() { return new ConcreteBuilder().fromFloatingIP(this); } - public abstract static class Builder> { + public abstract static class Builder> { protected abstract T self(); protected String id; protected String ip; protected String fixedIp; protected String instanceId; - + protected String pool; + /** * @see FloatingIP#getId() */ @@ -85,8 +83,16 @@ public T instanceId(String instanceId) { return self(); } + /** + * @see FloatingIP#getPool() + */ + public T pool(String pool) { + this.pool = pool; + return self(); + } + public FloatingIP build() { - return new FloatingIP(id, ip, fixedIp, instanceId); + return new FloatingIP(id, ip, fixedIp, instanceId, pool); } public T fromFloatingIP(FloatingIP in) { @@ -94,7 +100,8 @@ public T fromFloatingIP(FloatingIP in) { .id(in.getId()) .ip(in.getIp()) .fixedIp(in.getFixedIp()) - .instanceId(in.getInstanceId()); + .instanceId(in.getInstanceId()) + .pool(in.getPool()); } } @@ -111,15 +118,17 @@ protected ConcreteBuilder self() { private final String fixedIp; @Named("instance_id") private final String instanceId; + private final String pool; @ConstructorProperties({ - "id", "ip", "fixed_ip", "instance_id" + "id", "ip", "fixed_ip", "instance_id", "pool" }) - protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId) { + protected FloatingIP(String id, String ip, @Nullable String fixedIp, @Nullable String instanceId, @Nullable String pool) { this.id = checkNotNull(id, "id"); this.ip = checkNotNull(ip, "ip"); this.fixedIp = fixedIp; this.instanceId = instanceId; + this.pool = pool; } public String getId() { @@ -140,9 +149,14 @@ public String getInstanceId() { return this.instanceId; } + @Nullable + public String getPool() { + return this.pool; + } + @Override public int hashCode() { - return Objects.hashCode(id, ip, fixedIp, instanceId); + return Objects.hashCode(id, ip, fixedIp, instanceId, pool); } @Override @@ -153,14 +167,15 @@ public boolean equals(Object obj) { return Objects.equal(this.id, that.id) && Objects.equal(this.ip, that.ip) && Objects.equal(this.fixedIp, that.fixedIp) - && Objects.equal(this.instanceId, that.instanceId); + && Objects.equal(this.instanceId, that.instanceId) + && Objects.equal(this.pool, that.pool); } - + protected ToStringHelper string() { return Objects.toStringHelper(this) - .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId); + .add("id", id).add("ip", ip).add("fixedIp", fixedIp).add("instanceId", instanceId).add("pool", pool); } - + @Override public String toString() { return string().toString(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Host.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java index fc6744c033..75d3b706a8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostAggregate.java @@ -177,7 +177,7 @@ protected HostAggregate(String id, String name, String availabilityZone, @Nullab this.state = checkNotNull(state, "state"); this.created = checkNotNull(created, "created"); this.updated = Optional.fromNullable(updated); - this.metadata = metadata == null ? ImmutableMap.of() : ImmutableMap.copyOf(metadata); + this.metadata = metadata == null ? ImmutableMap.of() : ImmutableMap.copyOf(metadata); } public String getId() { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/HostResourceUsage.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java index 65cc81d406..7a73154c7a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Image.java @@ -36,7 +36,6 @@ * An image is a collection of files you use to create or rebuild a server. Operators provide * pre-built OS images by default. You may also create custom images. * - * @author Jeremy Daggett * @see */ @@ -49,7 +48,6 @@ public class Image extends Resource { * are available for install. The optional minDisk and minRam attributes set the minimum disk and * RAM requirements needed to create a server with the image. * - * @author Adrian Cole */ public static enum Status { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java index 3a9322df3b..38f4e90823 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Ingress.java @@ -30,7 +30,6 @@ /** * Ingress access to a destination protocol on particular ports * - * @author Adrian Cole */ @Beta public class Ingress { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/KeyPair.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java index 516f6e1b0c..482ae0ebc5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Network.java @@ -28,7 +28,6 @@ * Used to provide support for network, port, and fixed_ip when booting Nova servers. * OpenStack will support either a Nova Network or Neutron, but not both at the same time. * Specifying a port is only possible with Neutron. - * @author Zack Shoylev */ public class Network implements Comparable { private final String networkUuid; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Quota.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java index 453dd77ff2..e4bcb4dc34 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/RebootType.java @@ -16,10 +16,6 @@ */ package org.jclouds.openstack.nova.v2_0.domain; -/** - * - * @author Adrian Cole - */ public enum RebootType { HARD, SOFT; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroup.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SecurityGroupRule.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java index a7b316aeba..220ff62416 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Server.java @@ -39,7 +39,6 @@ * A server is a virtual machine instance in the compute system. Flavor and image are requisite * elements when creating a server. * - * @author Adrian Cole * @see @@ -55,11 +54,18 @@ public class Server extends Resource { * Other possible values for the status attribute include: BUILD, REBUILD, SUSPENDED, RESIZE, * VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, and ERROR. * - * @author Adrian Cole */ public static enum Status { - ACTIVE, BUILD, REBUILD, SUSPENDED, PAUSED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, DELETED, UNKNOWN, ERROR, STOPPED, UNRECOGNIZED; + ACTIVE, BUILD, REBUILD, SUSPENDED, PAUSED, RESIZE, VERIFY_RESIZE, REVERT_RESIZE, PASSWORD, REBOOT, HARD_REBOOT, + DELETED, UNKNOWN, ERROR, + + /** + * @deprecated please use {@code Status.SHUTOFF} instead + */ + @Deprecated STOPPED, + + UNRECOGNIZED, MIGRATING, SHUTOFF, RESCUE, SOFT_DELETED, SHELVED, SHELVED_OFFLOADED; public String value() { return name(); @@ -311,7 +317,7 @@ protected ConcreteBuilder self() { }) protected Server(String id, @Nullable String name, java.util.Set links, @Nullable String uuid, String tenantId, String userId, @Nullable Date updated, Date created, @Nullable String hostId, @Nullable String accessIPv4, - @Nullable String accessIPv6, Server.Status status, Resource image, Resource flavor, @Nullable String keyName, + @Nullable String accessIPv6, Server.Status status, @Nullable Resource image, Resource flavor, @Nullable String keyName, @Nullable String configDrive, Multimap addresses, Map metadata, @Nullable ServerExtendedStatus extendedStatus, @Nullable ServerExtendedAttributes extendedAttributes, @Nullable String diskConfig) { @@ -325,7 +331,7 @@ protected Server(String id, @Nullable String name, java.util.Set links, @N this.accessIPv4 = Strings.emptyToNull(accessIPv4); this.accessIPv6 = Strings.emptyToNull(accessIPv6); this.status = checkNotNull(status, "status"); - this.image = checkNotNull(image, "image"); + this.image = image; this.flavor = checkNotNull(flavor, "flavor"); this.keyName = Strings.emptyToNull(keyName); this.configDrive = Strings.emptyToNull(configDrive); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java index dcaf6fcf76..8b13ec8cc2 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerCreated.java @@ -30,7 +30,6 @@ /** * Server Resource with administrative password returned by ServerApi#CreateServer calls * - * @author Adam Lowe * @see diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java index 139066058a..1dea7a5f12 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedAttributes.java @@ -28,7 +28,6 @@ /** * Additional attributes delivered by Extended Server Attributes extension (alias "OS-EXT-SRV-ATTR") * - * @author Adam Lowe * @see diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java index 33dcb7562e..31164705dc 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerExtendedStatus.java @@ -28,7 +28,6 @@ /** * Additional attributes delivered by Extended Server Status extension (alias "OS-EXT-STS") * - * @author Adam Lowe * @see diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java index 3d7a9b9a97..64c01af629 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/ServerWithSecurityGroups.java @@ -37,7 +37,6 @@ /** * Extended server returned by ServerWithSecurityGroupsApi * - * @author Adam Lowe * @see diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java index eba8531ba1..f790d67f9e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleServerUsage.java @@ -31,7 +31,6 @@ /** * Information the SimpleTenantUsage extension return data about each Server * - * @author Adam Lowe */ public class SimpleServerUsage { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java index 61cec18d29..4b127431e7 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/SimpleTenantUsage.java @@ -33,7 +33,6 @@ /** * Information the SimpleTenantUsage extension returns data about each tenant * - * @author Adam Lowe */ public class SimpleTenantUsage { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java index c90f40e0e5..b0b216457e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/TenantIdAndName.java @@ -28,7 +28,6 @@ /** * Class TenantIdAndName * - * @author Adrian Cole */ public class TenantIdAndName { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java index b77f242b5d..42b2fba4fa 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VirtualInterface.java @@ -28,7 +28,6 @@ /** * Represents a Virtual Interface (VIF) * - * @author Adam Lowe * @see org.jclouds.openstack.nova.v2_0.extensions.VirtualInterfaceApi */ public class VirtualInterface { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/Volume.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeAttachment.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeSnapshot.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/VolumeType.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java similarity index 60% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java index 69469611f2..ca83af7bc4 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/AvailabilityZone.java @@ -1,20 +1,18 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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 +/* + * 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 + * 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. + * 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.jclouds.openstack.nova.v2_0.domain.zonescoped; @@ -23,9 +21,6 @@ import java.beans.ConstructorProperties; -/** - * @author Inbar Stolberg - */ public class AvailabilityZone { @SerializedName("zoneName") diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java index 5836ac22b3..3f412d42e5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/FlavorInZone.java @@ -20,9 +20,6 @@ import org.jclouds.openstack.nova.v2_0.domain.Flavor; -/** - * @author Adrian Cole - */ public class FlavorInZone extends ZoneAndId { protected final Flavor image; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java index b7d03f43cd..86581ba2dc 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ImageInZone.java @@ -20,9 +20,6 @@ import org.jclouds.openstack.nova.v2_0.domain.Image; -/** - * @author Adrian Cole - */ public class ImageInZone extends ZoneAndId { protected final Image image; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java index 28e2b0f3d3..17535cd45d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/SecurityGroupInZone.java @@ -20,9 +20,6 @@ import org.jclouds.openstack.nova.v2_0.domain.SecurityGroup; -/** - * @author Adrian Cole - */ public class SecurityGroupInZone extends ZoneAndName { protected final SecurityGroup securityGroup; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java index 2249cf7ae8..158f052ba1 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ServerInZone.java @@ -20,9 +20,6 @@ import org.jclouds.openstack.nova.v2_0.domain.Server; -/** - * @author Adrian Cole - */ public class ServerInZone extends ZoneAndId { protected final Server server; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java index 6c6f0c6bbc..e77286e5eb 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndId.java @@ -23,9 +23,6 @@ import com.google.common.base.Splitter; import com.google.common.collect.Iterables; -/** - * @author Adam Lowe - */ public class ZoneAndId { public static ZoneAndId fromSlashEncoded(String id) { Iterable parts = Splitter.on('/').split(checkNotNull(id, "id")); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java index fdb49e1b12..ef12fd9822 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneAndName.java @@ -28,8 +28,6 @@ /** * Helpful when looking for resources by zone and name - * - * @author Adrian Cole */ public class ZoneAndName { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java index 4182d917b6..a5c1c65efb 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneSecurityGroupNameAndPorts.java @@ -25,9 +25,6 @@ import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ public class ZoneSecurityGroupNameAndPorts extends ZoneAndName { protected final Set ports; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java similarity index 52% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java index c786095c0d..d32c368805 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/domain/zonescoped/ZoneState.java @@ -1,28 +1,23 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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 +/* + * 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 + * 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. + * 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.jclouds.openstack.nova.v2_0.domain.zonescoped; import com.google.common.base.Objects; -/** - * @author Inbar Stolberg - */ public class ZoneState { private final boolean available; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java similarity index 54% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java index 08a1852165..7b894fb115 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApi.java @@ -16,35 +16,39 @@ */ package org.jclouds.openstack.nova.v2_0.extensions; -import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; /** - * Provides asynchronous access to Simple Tenant Usage via the REST API. - *

- * - * @author Adam Lowe - * @see SimpleTenantUsageAsyncApi + * Provides access to the OpenStack Compute (Nova) Availability Zone Extension API. */ @Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SIMPLE_TENANT_USAGE) -public interface SimpleTenantUsageApi { - - /** - * Retrieve tenant_usage for all tenants - * - * @return the set of TenantUsage reports - */ - FluentIterable list(); - +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.AVAILABILITY_ZONE) +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/os-availability-zone") +public interface AvailabilityZoneApi { /** - * Retrieve tenant_usage for a specified tenant - * - * @return the requested tenant usage + * @return all availability zones */ - SimpleTenantUsage get(String tenantId); + @Named("availabilityZone:list") + @GET + @SelectJson("availabilityZoneInfo") + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) + FluentIterable list(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java similarity index 59% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java index f07148f3f3..715ce52473 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaClassAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApi.java @@ -18,16 +18,16 @@ import javax.inject.Named; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; -import org.jclouds.openstack.nova.v2_0.domain.QuotaClass; +import org.jclouds.openstack.nova.v2_0.binders.BindConsoleToJsonPayload; +import org.jclouds.openstack.nova.v2_0.domain.Console; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; import org.jclouds.rest.annotations.Fallback; @@ -35,44 +35,32 @@ import org.jclouds.rest.annotations.PayloadParam; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.SelectJson; -import org.jclouds.rest.binders.BindToJsonPayload; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Quota Classes via the REST API. + * Provides access to the OpenStack Compute (Nova) Consoles Extension API. + *

* - * @author Adam Lowe - * @see QuotaClassApi - * @see - * @see */ @Beta -@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTA_CLASSES) +@Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.CONSOLES) @RequestFilters(AuthenticateRequest.class) -@Path("/os-quota-class-sets") -public interface QuotaClassAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +public interface ConsolesApi { /** - * @see QuotaClassApi#get + * Gets the specified server Console. + * + * @param serverId Server id + * @param type see {@link Console.Type} + * @return a Console object containing the console url and type. */ - @Named("quotaclass:get") - @GET - @SelectJson("quota_class_set") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{id}") - @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); - - /** - * @see QuotaClassApi#update - */ - @Named("quotaclass:update") - @PUT - @Path("/{id}") + @Named("consoles:getConsole") + @POST + @Path("/servers/{serverId}/action") + @SelectJson("console") @Produces(MediaType.APPLICATION_JSON) - @MapBinder(BindToJsonPayload.class) - ListenableFuture update(@PathParam("id") String id, @PayloadParam("quota_class_set") QuotaClass quotas); - + @Fallback(MapHttp4xxCodesToExceptions.class) + @MapBinder(BindConsoleToJsonPayload.class) + Console getConsole(@PathParam("serverId") String serverId, @PayloadParam("type") Console.Type type); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java similarity index 92% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java index a249190882..503f32e186 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ExtensionNamespaces.java @@ -19,7 +19,6 @@ /** * Extension namespaces * - * @author Adrian Cole * @see */ public interface ExtensionNamespaces { @@ -67,6 +66,10 @@ public interface ExtensionNamespaces { * Virtual interface support */ public static final String VIRTUAL_INTERFACES = "http://docs.openstack.org/ext/virtual_interfaces/api/v1.1"; + /** + * Availability zone extensions + */ + public static final String AVAILABILITY_ZONE = "http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1"; /** * Extended support to the Create Server v1.1 API */ @@ -93,11 +96,6 @@ public interface ExtensionNamespaces { */ public static final String EXTENDED_STATUS = "http://docs.openstack.org/compute/ext/extended_status/api/v1.1"; - /** - * Quota Classes extension - */ - public static final String QUOTA_CLASSES = "http://docs.openstack.org/ext/quota-classes-sets/api/v1.1"; - /** * Disk Config extension */ @@ -107,4 +105,9 @@ public interface ExtensionNamespaces { * Aggregates extension */ public static final String AGGREGATES = "http://docs.openstack.org/ext/aggregates/api/v1.1"; + + /** + * Consoles extension + */ + public static final String CONSOLES = "http://docs.openstack.org/compute/ext/os-consoles/api/v2"; } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java similarity index 57% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java index f788e6ed54..5856cd668f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApi.java @@ -32,6 +32,7 @@ import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; @@ -45,74 +46,85 @@ import org.jclouds.rest.binders.BindToJsonPayload; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provide access to extra metadata for Nova flavors. + * Provides access to the OpenStack Compute (Nova) Flavor Extra Specs Extension API. * - * @author Adam Lowe - * @see * @see org.jclouds.openstack.nova.v2_0.features.FlavorApi - * @see FlavorExtraSpecsApi */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLAVOR_EXTRA_SPECS) @RequestFilters(AuthenticateRequest.class) @Consumes(MediaType.APPLICATION_JSON) -public interface FlavorExtraSpecsAsyncApi { - +@Path("/flavors") +public interface FlavorExtraSpecsApi { /** - * @see FlavorExtraSpecsApi#getMetadata(String) + * Retrieves all extra specs for a flavor + * + * @return the set of extra metadata for the flavor */ - @Named("flavor:getmetadata") + @Named("flavorExtraSpecs:getMetadata") @GET + @Path("/{id}/os-extra_specs") @SelectJson("extra_specs") - @Path("/flavors/{flavor_id}/os-extra_specs") @Fallback(EmptyMapOnNotFoundOr404.class) - ListenableFuture> getMetadata(@PathParam("flavor_id") String flavorId); + Map getMetadata(@PathParam("id") String flavorId); /** - * @see FlavorExtraSpecsApi#updateMetadataEntry(String, String, String) + * Creates or updates the extra specs for a given flavor + * + * @param flavorId the id of the flavor to modify + * @param specs the extra specs to apply */ - @Named("flavor:updatemetadata") + @Named("flavorExtraSpecs:updateMetadata") @POST - @Path("/flavors/{flavor_id}/os-extra_specs") + @Path("/{id}/os-extra_specs") @Produces(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) @MapBinder(BindToJsonPayload.class) - ListenableFuture updateMetadata(@PathParam("flavor_id") String flavorId, @PayloadParam("extra_specs") Map specs); + @Fallback(FalseOnNotFoundOr404.class) + Boolean updateMetadata(@PathParam("id") String flavorId, + @PayloadParam("extra_specs") Map specs); /** - * @see FlavorExtraSpecsApi#getMetadataKey(String, String) + * Return a single extra spec value + * + * @param id the id of the flavor to modify + * @param key the extra spec key to retrieve */ - @Named("flavor:getmetadata") + @Named("flavorExtraSpecs:getMetadataKey") @GET - @Path("/flavors/{flavor_id}/os-extra_specs/{key}") + @Path("/{id}/os-extra_specs/{key}") @Unwrap @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMetadataKey(@PathParam("flavor_id") String flavorId, @PathParam("key") String key); + @Nullable + String getMetadataKey(@PathParam("id") String flavorId, @PathParam("key") String key); /** - * @see FlavorExtraSpecsApi#updateMetadataEntry(String, String, String) + * Creates or updates a single extra spec value + * + * @param id the id of the flavor to modify + * @param key the extra spec key (when creating ensure this does not include whitespace or + * other difficult characters) + * @param value the value to associate with the key */ - @Named("flavor:updatemetadata") + @Named("flavorExtraSpecs:updateMetadataEntry") @PUT - @Path("/flavors/{flavor_id}/os-extra_specs/{key}") + @Path("/{id}/os-extra_specs/{key}") @Produces(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) @Payload("%7B\"{key}\":\"{value}\"%7D") - ListenableFuture updateMetadataEntry(@PathParam("flavor_id") String flavorId, - @PathParam("key") @PayloadParam("key") String key, - @PayloadParam("value") String value); + @Fallback(FalseOnNotFoundOr404.class) + Boolean updateMetadataEntry(@PathParam("id") String flavorId, + @PathParam("key") @PayloadParam("key") String key, @PayloadParam("value") String value); /** - * @see FlavorExtraSpecsApi#deleteMetadataKey(String, String) + * Deletes an extra spec + * + * @param id the id of the flavor to modify + * @param key the extra spec key to delete */ - @Named("flavor:deletemetadata") + @Named("flavorExtraSpecs:deleteMetadataKey") @DELETE - @Path("/flavors/{flavor_id}/os-extra_specs/{key}") + @Path("/{id}/os-extra_specs/{key}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture deleteMetadataKey(@PathParam("flavor_id") String flavorId, - @PathParam("key") String key); - + Boolean deleteMetadataKey(@PathParam("id") String flavorId, @PathParam("key") String key); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java similarity index 59% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java index f6cc543f1e..6160364935 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApi.java @@ -28,6 +28,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.FloatingIP; import org.jclouds.openstack.v2_0.ServiceType; @@ -40,106 +41,114 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Floating IPs via the REST API. - *

- * - * @see FloatingIPApi - * @author Jeremy Daggett - * @see ExtensionAsyncApi - * @see - * @see - * @see + * Provides access to the OpenStack Compute (Nova) Floating IP extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.FLOATING_IPS) @RequestFilters(AuthenticateRequest.class) -public interface FloatingIPAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +public interface FloatingIPApi { /** - * @see FloatingIPApi#list + * Lists all Floating IP addresses + * + * @return all Floating IPs */ - @Named("floatingip:list") + @Named("floatingIP:list") @GET @Path("/os-floating-ips") @SelectJson("floating_ips") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** - * @see FloatingIPApi#get + * Gets a specific Floating IP address + * + * @return all Floating IPs */ - @Named("floatingip:get") + @Named("floatingIP:get") @GET @Path("/os-floating-ips/{id}") @SelectJson("floating_ip") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + FloatingIP get(@PathParam("id") String id); /** - * @see FloatingIPApi#create + * Allocates a Floating IP address + * + * @return a newly created FloatingIP */ - @Named("floatingip:create") + @Named("floatingIP:create") @POST @Path("/os-floating-ips") @SelectJson("floating_ip") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) @Payload("{}") - ListenableFuture create(); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FloatingIP create(); /** - * @see org.jclouds.openstack.nova.v2_0.extensions.FloatingIPApi#allocateFromPool + * Allocates a Floating IP address from a pool + * + * @param pool + * Pool to allocate IP address from + * @return a newly created FloatingIP */ - @Named("floatingip:create") + @Named("floatingIP:allocateFromPool") @POST @Path("/os-floating-ips") @SelectJson("floating_ip") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) @Payload("%7B\"pool\":\"{pool}\"%7D") - ListenableFuture allocateFromPool(@PayloadParam("pool") String pool); - + @Fallback(NullOnNotFoundOr404.class) + @Nullable + FloatingIP allocateFromPool(@PayloadParam("pool") String pool); /** - * @see FloatingIPApi#delete + * Deletes a Floating IP address + * + * @param id + * the Floating IP id */ - @Named("floatingip:delete") + @Named("floatingIP:delete") @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Fallback(NullOnNotFoundOr404.class) @Path("/os-floating-ips/{id}") - ListenableFuture delete(@PathParam("id") String id); + void delete(@PathParam("id") String id); /** - * @see FloatingIPApi#addToServer + * Adds a Floating IP address to a Server + * + * @param id + * the server id + * @param address + * the IP address to add + * + * NOTE: Possibly move this to ServerApi? */ - @Named("floatingip:add") + @Named("floatingIP:add") @POST - @Path("/servers/{server}/action") - @Consumes + @Path("/servers/{id}/action") @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"addFloatingIp\":%7B\"address\":\"{address}\"%7D%7D") - ListenableFuture addToServer(@PayloadParam("address") String address, - @PathParam("server") String serverId); + void addToServer(@PayloadParam("address") String address, @PathParam("id") String serverId); /** - * @see FloatingIPApi#removeFromServer + * Removes a Floating IP address from a Server + * + * @param id + * the server id + * @param address + * the IP address to remove + * + * NOTE: Possibly move this to ServerApi? */ - @Named("floatingip:remove") + @Named("floatingIP:remove") @POST - @Path("/servers/{server}/action") - @Consumes + @Path("/servers/{id}/action") @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"removeFloatingIp\":%7B\"address\":\"{address}\"%7D%7D") - ListenableFuture removeFromServer(@PayloadParam("address") String address, - @PathParam("server") String serverId); - + void removeFromServer(@PayloadParam("address") String address, @PathParam("id") String serverId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java similarity index 67% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java index cf066c21ac..5836507555 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApi.java @@ -46,112 +46,123 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Host Administration features via the REST API. - *

- * - * @author Adam Lowe - * @see HostAdministrationApi - * @see - * @see - * @see + * Provides access to OpenStack Compute (Nova) Host Administration extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.HOSTS) @RequestFilters(AuthenticateRequest.class) -@Path("/os-hosts") @Consumes(MediaType.APPLICATION_JSON) -public interface HostAdministrationAsyncApi { - +@Path("/os-hosts") +public interface HostAdministrationApi { /** - * @see HostAdministrationApi#list() + * Returns the list of hosts + * + * @return the usage information */ - @Named("hostadmin:list") + @Named("hostAdmin:list") @GET @SelectJson("hosts") @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** - * @see HostAdministrationApi#listResourceUsage(String) + * Retrieves the physical/usage resource on a specific host + * + * @return the usage information */ - @Named("hostadmin:listresource") + @Named("hostAdmin:listResourceUsage") @GET @Path("/{id}") @SelectJson("host") @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listResourceUsage(@PathParam("id") String hostId); + FluentIterable listResourceUsage(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#enable(String) + * Allow the specified host to accept new instances. + * + * @return true if successful */ - @Named("hostadmin:enable") + @Named("hostAdmin:enable") @PUT - @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") + @Produces(MediaType.APPLICATION_JSON) @Payload("{\"status\":\"enable\"}") @ResponseParser(StatusEnabledResponseParser.class) - ListenableFuture enable(@PathParam("id") String hostId); + boolean enable(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#disable(String) + * Prevent the specified host from accepting new instances. + * + * @return true if successful */ - @Named("hostadmin:disable") + @Named("hostAdmin:disable") @PUT - @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") + @Produces(MediaType.APPLICATION_JSON) @Payload("{\"status\":\"disable\"}") @ResponseParser(StatusDisabledResponseParser.class) - ListenableFuture disable(@PathParam("id") String hostId); + boolean disable(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#startMaintenance(String) + * Start host maintenance window. + *

+ * Note: this triggers guest VMs evacuation. + * + * @return true if successful */ - @Named("hostadmin:startmaintenance") + @Named("hostAdmin:startMaintenance") @PUT - @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") + @Produces(MediaType.APPLICATION_JSON) @Payload("{\"maintenance_mode\":\"enable\"}") @ResponseParser(MaintenanceModeEnabledResponseParser.class) - ListenableFuture startMaintenance(@PathParam("id") String hostId); + boolean startMaintenance(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#stopMaintenance(String) + * Stop host maintenance window. + * + * @return true if successful */ - @Named("hostadmin:stopmaintenance") + @Named("hostAdmin:stopMaintenance") @PUT - @Produces(MediaType.APPLICATION_JSON) @Path("/{id}") + @Produces(MediaType.APPLICATION_JSON) @Payload("{\"maintenance_mode\":\"disable\"}") @ResponseParser(MaintenanceModeDisabledResponseParser.class) - ListenableFuture stopMaintenance(@PathParam("id") String hostId); + boolean stopMaintenance(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#startup(String) + * Startup a host. + * + * @return true if successful */ - @Named("hostadmin:startup") + @Named("hostAdmin:startup") @GET @Path("/{id}/startup") @ResponseParser(PowerIsStartupResponseParser.class) - ListenableFuture startup(@PathParam("id") String hostId); + boolean startup(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#shutdown(String) + * Shutdown a host. + * + * @return true if successful */ - @Named("hostadmin:shutdown") + @Named("hostAdmin:shutdown") @GET @Path("/{id}/shutdown") @ResponseParser(PowerIsShutdownResponseParser.class) - ListenableFuture shutdown(@PathParam("id") String hostId); + boolean shutdown(@PathParam("id") String hostId); /** - * @see HostAdministrationApi#reboot(String) + * Reboot a host. + * + * @return true if successful */ - @Named("hostadmin:reboot") + @Named("hostAdmin:reboot") @GET @Path("/{id}/reboot") @ResponseParser(PowerIsRebootResponseParser.class) - ListenableFuture reboot(@PathParam("id") String hostId); + boolean reboot(@PathParam("id") String hostId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java similarity index 56% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java index 1ee3dc72cc..b291ca011f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApi.java @@ -31,6 +31,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.HostAggregate; import org.jclouds.openstack.v2_0.ServiceType; @@ -43,119 +44,114 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provide access to Aggregates in Nova. - * - * @author Adam Lowe - * @see HostAggregateApi + * Provide access to the OpenStack Compute (Nova) Host Aggregates extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.AGGREGATES) @RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) @Path("/os-aggregates") -public interface HostAggregateAsyncApi { - +public interface HostAggregateApi { /** - * @see HostAggregateApi#list() + * Lists all host aggregates. + * + * @return the set of host aggregates. */ - @Named("hostaggregate:list") + @Named("hostAggregate:list") @GET @SelectJson("aggregates") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** - * @see HostAggregateApi#get(String) + * Retrieves the details of an aggregate, hosts and metadata included. + * + * @return the details of the aggregate requested. */ - @Named("hostaggregate:get") + @Named("hostAggregate:get") @GET @Path("/{id}") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + HostAggregate get(@PathParam("id") String id); /** - * @see HostAggregateApi#createInAvailabilityZone(String, String) + * Creates an aggregate, given its name and availability zone. + * + * @return the newly created Aggregate */ - @Named("hostaggregate:create") + @Named("hostAggregate:create") @POST @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @WrapWith("aggregate") - ListenableFuture createInAvailabilityZone(@PayloadParam("name") String name, - @PayloadParam("availability_zone") String availabilityZone); + HostAggregate createInAvailabilityZone(@PayloadParam("name") String name, + @PayloadParam("availability_zone") String availabilityZone); /** - * @see HostAggregateApi#updateName + * Updates the name of an aggregate. */ - @Named("hostaggregate:update") + @Named("hostAggregate:update") @POST @Path("/{id}") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @WrapWith("aggregate") - ListenableFuture updateName(@PathParam("id") String id, @PayloadParam("name") String name); + HostAggregate updateName(@PathParam("id") String id, @PayloadParam("name") String name); /** - * @see HostAggregateApi#updateAvailabilityZone + * Updates the availability zone for an aggregate. */ - @Named("hostaggregate:update") + @Named("hostAggregate:update") @POST @Path("/{id}") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @WrapWith("aggregate") - ListenableFuture updateAvailabilityZone(@PathParam("id") String id, @PayloadParam("availability_zone") String availabilityZone); - + HostAggregate updateAvailabilityZone(@PathParam("id") String id, + @PayloadParam("availability_zone") String availabilityZone); + /** - * @see HostAggregateApi#delete(String) + * Removes an aggregate. */ - @Named("hostaggregate:delete") + @Named("hostAggregate:delete") @DELETE @Path("/{id}") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String id); + Boolean delete(@PathParam("id") String id); /** - * @see HostAggregateApi#addHost(String,String) + * Adds a host to an aggregate */ - @Named("hostaggregate:addhost") + @Named("hostAggregate:addHost") @POST @Path("/{id}/action") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @WrapWith("add_host") - ListenableFuture addHost(@PathParam("id") String id, @PayloadParam("host") String host); - + HostAggregate addHost(@PathParam("id") String id, @PayloadParam("host") String host); /** - * @see HostAggregateApi#removeHost(String,String) + * Removes a host from an aggregate */ - @Named("hostaggregate:removehost") + @Named("hostAggregate:removeHost") @POST @Path("/{id}/action") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @WrapWith("remove_host") - ListenableFuture removeHost(@PathParam("id") String id, @PayloadParam("host") String host); + HostAggregate removeHost(@PathParam("id") String id, @PayloadParam("host") String host); /** - * @see HostAggregateApi#setMetadata + * Adds metadata to an aggregate */ - @Named("hostaggregate:setmetadata") + @Named("hostAggregate:setMetadata") @POST @Path("/{id}/action") @SelectJson("aggregate") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @WrapWith("set_metadata") - ListenableFuture setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map metadata); + HostAggregate setMetadata(@PathParam("id") String id, + @PayloadParam("metadata") Map metadata); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java similarity index 67% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java index 246aec818d..cdc1d17f54 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApi.java @@ -28,6 +28,8 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindKeyPairToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.KeyPair; @@ -44,58 +46,81 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Key Pairs via the REST API. - *

- * - * @see KeyPairApi - * @author Jeremy Daggett - * @see ExtensionAsyncApi - * @see - * @see - * @see + * Provides access to the OpenStack Compute (Nova) Key Pair Extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.KEYPAIRS) @RequestFilters(AuthenticateRequest.class) -public interface KeyPairAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +@Path("/os-keypairs") +public interface KeyPairApi { + /** + * Lists all Key Pairs. + * + * @return all Key Pairs + */ @Named("keypair:list") @GET - @Path("/os-keypairs") @ResponseParser(ParseKeyPairs.class) - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); + /** + * Creates a {@link KeyPair}. + * + * @return the created {@link KeyPair}. + */ @Named("keypair:create") @POST - @Path("/os-keypairs") @SelectJson("keypair") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"keypair\":%7B\"name\":\"{name}\"%7D%7D") - ListenableFuture create(@PayloadParam("name") String name); + KeyPair create(@PayloadParam("name") String name); + + /** + * Creates a {@link KeyPair} with a public key. + * + * @return the created {@link KeyPair}. + */ @Named("keypair:create") @POST - @Path("/os-keypairs") @SelectJson("keypair") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @MapBinder(BindKeyPairToJsonPayload.class) - ListenableFuture createWithPublicKey(@PayloadParam("name") String name, + KeyPair createWithPublicKey(@PayloadParam("name") String name, @PayloadParam("public_key") String publicKey); + /** + * Gets a specific {@link KeyPair} by name. + * + * @param name + * the name of the {@link KeyPair} + * + * @return the specified {@link KeyPair}, otherwise null. + */ + @Named("keypair:get") + @GET + @Path("/{name}") + @SelectJson("keypair") + @Consumes(MediaType.APPLICATION_JSON) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + KeyPair get(@PathParam("name") String name); + + /** + * Deletes a {@link KeyPair}. + * + * @param name + * the name of the {@link KeyPair} + * + * @return {@code true} if the {@link KeyPair} was deleted, otherwise {@code false}. + */ @Named("keypair:delete") @DELETE - @Path("/os-keypairs/{name}") + @Path("/{name}") @Fallback(FalseOnNotFoundOr404.class) - @Consumes - ListenableFuture delete(@PathParam("name") String name); - + boolean delete(@PathParam("name") String name); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java similarity index 65% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java index b364fcb8bd..ce7aeb84ec 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApi.java @@ -26,6 +26,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Quota; import org.jclouds.openstack.v2_0.ServiceType; @@ -38,52 +39,55 @@ import org.jclouds.rest.binders.BindToJsonPayload; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provide access to Quota information for Nova tenants. - * - * @author Adam Lowe - * @see QuotaApi - * @see + * Provide access to OpenStack Compute (Nova) Quota Extension API. + *

+ * The quotas extension enables limiters placed on the resources used per tenant (project) for virtual instances. It is + * used with the OpenStack Compute API 1.1 for administrators who need to control the amount of volumes, memory, floating + * IP addresses, instances, or cores allowed within a defined tenant or project. + *

+ * To use this extension, you need to have administrative rights to the tenants upon which you are placing quotas. + * */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.QUOTAS) @RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) @Path("/os-quota-sets") -public interface QuotaAsyncApi { - +public interface QuotaApi { /** - * @see QuotaApi#getDefaultsForTenant(String) + * @return the quota settings for the tenant */ @Named("quota:get") @GET @SelectJson("quota_set") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{tenant_id}") + @Path("/{id}") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getByTenant(@PathParam("tenant_id") String tenantId); + @Nullable + Quota getByTenant(@PathParam("id") String tenantId); /** - * @see QuotaApi#updateQuotaOfTenant + * Update the quotas for a given tenant + * + * @return true if successful */ @Named("quota:update") @PUT - @Path("/{tenant_id}") + @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @MapBinder(BindToJsonPayload.class) - ListenableFuture updateQuotaOfTenant(@PayloadParam("quota_set") Quota quota, - @PathParam("tenant_id") String tenantId); + boolean updateQuotaOfTenant(@PayloadParam("quota_set") Quota quota, + @PathParam("id") String tenantId); /** - * @see QuotaApi#getDefaultsForTenant(String) + * @return the set of default quotas for the tenant */ @Named("quota:get") @GET @SelectJson("quota_set") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/{tenant_id}/defaults") + @Path("/{id}/defaults") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getDefaultsForTenant(@PathParam("tenant_id") String tenantId); - + @Nullable + Quota getDefaultsForTenant(@PathParam("id") String tenantId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java similarity index 60% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java index 5e5a2def9e..ec37d65005 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApi.java @@ -29,6 +29,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindSecurityGroupRuleToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.Ingress; @@ -45,108 +46,109 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Security Groups via the REST API. - *

- * - * @see SecurityGroupApi - * @author Jeremy Daggett - * @see - * @see - * @see + * Provides access to the OpenStack Compute (Nova) Security Group extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SECURITY_GROUPS) @RequestFilters(AuthenticateRequest.class) -public interface SecurityGroupAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +public interface SecurityGroupApi { /** - * @see SecurityGroupApi#list + * List all Security Groups. + * + * @return all Security Groups */ - @Named("securitygroup:list") + @Named("securityGroup:list") @GET - @SelectJson("security_groups") - @Consumes(MediaType.APPLICATION_JSON) @Path("/os-security-groups") + @SelectJson("security_groups") @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** - * @see SecurityGroupApi#get + * Get a specific Security Group + * + * @return a specific Security Group */ - @Named("securitygroup:get") + @Named("securityGroup:get") @GET @Path("/os-security-groups/{id}") @SelectJson("security_group") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + SecurityGroup get(@PathParam("id") String id); /** - * @see SecurityGroupApi#createWithDescription + * Create a Security Group + * + * @return a new Security Group */ - @Named("securitygroup:create") + @Named("securityGroup:create") @POST @Path("/os-security-groups") @SelectJson("security_group") - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"security_group\":%7B\"name\":\"{name}\",\"description\":\"{description}\"%7D%7D") - ListenableFuture createWithDescription(@PayloadParam("name") String name, - @PayloadParam("description") String description); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + SecurityGroup createWithDescription(@PayloadParam("name") String name, + @PayloadParam("description") String description); /** - * @see SecurityGroupApi#delete + * Delete a Security Group. + * + * @return */ - @Named("securitygroup:delete") + @Named("securityGroup:delete") @DELETE @Path("/os-security-groups/{id}") @Fallback(FalseOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_JSON) - ListenableFuture delete(@PathParam("id") String id); + boolean delete(@PathParam("id") String id); /** - * @see SecurityGroupApi#createRuleAllowingCidrBlock + * Create a Security Group Rule. + * + * @return a new Security Group Rule */ - @Named("securitygroup:create") + @Named("securityGroup:create") @POST @Path("/os-security-group-rules") @SelectJson("security_group_rule") - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @MapBinder(BindSecurityGroupRuleToJsonPayload.class) - ListenableFuture createRuleAllowingCidrBlock( - @PayloadParam("parent_group_id") String parent_group_id, Ingress ip_protocol, - @PayloadParam("cidr") String cidr); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + SecurityGroupRule createRuleAllowingCidrBlock( + @PayloadParam("parent_group_id") String parentGroup, Ingress ip_protocol, + @PayloadParam("cidr") String sourceCidr); /** - * @see SecurityGroupApi#createRuleOnSecurityGroupToCidrBlock + * Create a Security Group Rule. + * + * @return a new Security Group Rule */ - @Named("securitygroup:create") + @Named("securityGroup:create") @POST @Path("/os-security-group-rules") @SelectJson("security_group_rule") - @Fallback(NullOnNotFoundOr404.class) - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @MapBinder(BindSecurityGroupRuleToJsonPayload.class) - ListenableFuture createRuleAllowingSecurityGroupId( - @PayloadParam("parent_group_id") String parent_group_id, Ingress ip_protocol, - @PayloadParam("group_id") String group_id); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + SecurityGroupRule createRuleAllowingSecurityGroupId( + @PayloadParam("parent_group_id") String parentGroup, Ingress ip_protocol, + @PayloadParam("group_id") String groupId); /** - * @see SecurityGroupApi#deleteRule + * Delete a Security Group Rule. + * + * @return */ - @Named("securitygroup:delete") + @Named("securityGroup:delete") @DELETE - @Path("/os-security-group-rules/{security_group_rule_ID}") + @Path("/os-security-group-rules/{id}") @Fallback(FalseOnNotFoundOr404.class) - @Consumes - ListenableFuture deleteRule(@PathParam("security_group_rule_ID") String security_group_rule_ID); - + boolean deleteRule(@PathParam("id") String ruleId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java similarity index 58% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java index 1797a9d141..bf22f407f1 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerAdminApi.java @@ -40,136 +40,160 @@ import org.jclouds.rest.annotations.WrapWith; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provide access to Admin Server Actions via REST API + * Provide access to the OpenStack Compute (Nova) Admin Server Actions Extension API. + * + * Provide additional actions for servers: + * 'suspend', 'resume', 'migrate', 'lock', 'unlock', 'resetNetwork', 'createBackup', 'pause', 'migrateLive', + * 'injectNetworkInfo', 'unpause' * - * @author Adam Lowe - * @see org.jclouds.openstack.nova.v2_0.extensions.ServerAdminApi */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.ADMIN_ACTIONS) @RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) @Path("/servers/{id}/action") -public interface ServerAdminAsyncApi { - +public interface ServerAdminApi { /** - * @see ServerAdminApi#suspend(String) + * Suspend a server. + * + * @param id id of the server */ - @Named("serveradmin:suspend") + @Named("serverAdmin:suspend") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"suspend\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture suspend(@PathParam("id") String id); + Boolean suspend(@PathParam("id") String id); /** - * @see ServerAdminApi#resume(String) + * Resume a server. + * + * @param id id of the server */ - @Named("serveradmin:resume") + @Named("serverAdmin:resume") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"resume\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture resume(@PathParam("id") String id); + Boolean resume(@PathParam("id") String id); /** - * @see ServerAdminApi#migrate(String) + * Migrate a server. + * + * @param id id of the server */ - @Named("serveradmin:migrate") + @Named("serverAdmin:migrate") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"migrate\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture migrate(@PathParam("id") String id); + Boolean migrate(@PathParam("id") String id); /** - * @see ServerAdminApi#lock(String) + * Lock a server. + * + * @param id id of the server */ - @Named("serveradmin:lock") + @Named("serverAdmin:lock") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"lock\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture lock(@PathParam("id") String id); + Boolean lock(@PathParam("id") String id); /** - * @see ServerAdminApi#unlock(String) + * Unlock a server. + * + * @param id id of the server */ - @Named("serveradmin:unlock") + @Named("serverAdmin:unlock") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"unlock\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture unlock(@PathParam("id") String id); + Boolean unlock(@PathParam("id") String id); /** - * @see ServerAdminApi#resetNetwork(String) + * Reset network of a server. + * + * @param id id of the server */ - @Named("serveradmin:resetnetwork") + @Named("serverAdmin:resetNetwork") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"resetNetwork\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture resetNetwork(@PathParam("id") String id); + Boolean resetNetwork(@PathParam("id") String id); /** - * @see ServerAdminApi#createBackup + * Create backup of a server. + * + * @param id id of the server + * @param imageName the name of the image to create + * @param backupType the type of backup + * @param rotation the number of images to retain (0 to simply overwrite) + * @param options optional rotation and/or metadata parameters + * @return the id of the newly created image */ - @Named("serveradmin:createbackup") + @Named("serverAdmin:createBackup") @POST - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @WrapWith("createBackup") - @Fallback(MapHttp4xxCodesToExceptions.class) @ResponseParser(ParseImageIdFromLocationHeader.class) - ListenableFuture createBackup(@PathParam("id") String id, - @PayloadParam("name") String imageName, - @PayloadParam("backup_type") BackupType backupType, - @PayloadParam("rotation") int rotation, - CreateBackupOfServerOptions... options); + @Fallback(MapHttp4xxCodesToExceptions.class) + String createBackup(@PathParam("id") String id, @PayloadParam("name") String imageName, + @PayloadParam("backup_type") BackupType backupType, @PayloadParam("rotation") int rotation, + CreateBackupOfServerOptions... options); /** - * @see ServerAdminApi#pause(String) + * Pause a server. + * + * @param id id of the server */ - @Named("serveradmin:pause") + @Named("serverAdmin:pause") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"pause\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture pause(@PathParam("id") String id); + Boolean pause(@PathParam("id") String id); /** - * @see ServerAdminApi#unpause(String) + * Unpause a server. + * + * @param id id of the server */ - @Named("serveradmin:unpause") + @Named("serverAdmin:unpause") @POST @Produces(MediaType.APPLICATION_JSON) @Payload("{\"unpause\":null}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture unpause(@PathParam("id") String id); + Boolean unpause(@PathParam("id") String id); /** - * @see ServerAdminApi#injectNetworkInfo(String) + * Live migrate a server. + * + * @param id id of the server */ - @Named("serveradmin:injectnetwork") + @Named("serverAdmin:liveMigrate") @POST @Produces(MediaType.APPLICATION_JSON) - @Payload("{\"injectNetworkInfo\":null}") + @WrapWith("os-migrateLive") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture injectNetworkInfo(@PathParam("id") String id); + Boolean liveMigrate(@PathParam("id") String id, @PayloadParam("host") String host, + @PayloadParam("block_migration") boolean blockMigration, + @PayloadParam("disk_over_commit") boolean diskOverCommit); /** - * @see ServerAdminApi#liveMigrate(String) + * Inject network info into a server. + * + * @param id id of the server */ - @Named("serveradmin:livemigrate") + @Named("serverAdmin:injectNetwork") @POST @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"injectNetworkInfo\":null}") @Fallback(FalseOnNotFoundOr404.class) - @WrapWith("os-migrateLive") - ListenableFuture liveMigrate(@PathParam("id") String id, - @PayloadParam("host") String host, - @PayloadParam("block_migration") boolean blockMigration, - @PayloadParam("disk_over_commit") boolean diskOverCommit); + Boolean injectNetworkInfo(@PathParam("id") String id); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java similarity index 69% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java index 069d39b28a..02bebd59b8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApi.java @@ -24,6 +24,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.ServerWithSecurityGroups; import org.jclouds.openstack.v2_0.ServiceType; @@ -33,30 +34,35 @@ import org.jclouds.rest.annotations.SelectJson; import com.google.common.annotations.Beta; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides synchronous access to Servers with Security Groups. + * Provides access to the OpenStack Compute (Nova) Create Server extension API. * - * @author Adam Lowe - * @see org.jclouds.openstack.nova.v2_0.features.ServerAsyncApi - * @see ServerWithSecurityGroupsApi - * @see + * This provides details including the security groups associated with a Server. + *

+ * + * NOTE: the equivalent to listServersInDetail() isn't available at the other end, so not + * extending ServerApi at this time. + * + * @see org.jclouds.openstack.nova.v2_0.features.ServerApi */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.CREATESERVEREXT) @RequestFilters(AuthenticateRequest.class) -public interface ServerWithSecurityGroupsAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +@Path("/os-create-server-ext") +public interface ServerWithSecurityGroupsApi { /** - * @see ServerWithSecurityGroupsApi#get(String) + * Retrieve details of the specified server, including security groups + * + * @param id id of the server + * @return server or null if not found */ @Named("server:get") @GET @SelectJson("server") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/os-create-server-ext/{id}") + @Path("/{id}") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); - + @Nullable + ServerWithSecurityGroups get(@PathParam("id") String id); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java similarity index 66% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java index 550d40492b..46dff34c5f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApi.java @@ -25,6 +25,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.SimpleTenantUsage; import org.jclouds.openstack.v2_0.ServiceType; @@ -35,43 +36,37 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Simple Tenant Usage via the REST API. - *

- * - * @author Adam Lowe - * @see SimpleTenantUsageApi - * @see - * @see - * @see + * Provides access to the OpenStack Compute (Nova) Simple Tenant Usage extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.SIMPLE_TENANT_USAGE) @RequestFilters(AuthenticateRequest.class) -public interface SimpleTenantUsageAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +@Path("/os-simple-tenant-usage") +public interface SimpleTenantUsageApi { /** - * @see SimpleTenantUsageApi#list() + * Retrieve tenant usage for all tenants. + * + * @return the set of TenantUsage reports */ - @Named("tenantusage:list") + @Named("tenantUsage:list") @GET - @Path("/os-simple-tenant-usage") @SelectJson("tenant_usages") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** - * @see SimpleTenantUsageApi#get(String) + * Retrieve tenant_usage for a specified tenant + * + * @return the requested tenant usage */ - @Named("tenantusage:get") + @Named("tenantUsage:get") @GET - @Path("/os-simple-tenant-usage/{id}") + @Path("/{id}") @SelectJson("tenant_usage") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String tenantId); - + @Nullable + SimpleTenantUsage get(@PathParam("id") String tenantId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java similarity index 79% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java index c23228c6cb..a0f8833a91 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApi.java @@ -34,26 +34,26 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Virtual Interface features (VIFs). - * - * @see VirtualInterfaceApi - * @author Adam Lowe + * Provides access to the OpenStack Compute (Nova) Virtual Interface (VIFs) extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VIRTUAL_INTERFACES) @RequestFilters(AuthenticateRequest.class) -public interface VirtualInterfaceAsyncApi { +@Consumes(MediaType.APPLICATION_JSON) +@Path("/servers") +public interface VirtualInterfaceApi { /** - * @see VirtualInterfaceApi#listOnServer(String) + * Returns the list of Virtual Interfaces for a given instance. + * + * @return the list of virtual interfaces */ - @Named("virtualinterface:list") + @Named("virtualInterface:list") @GET + @Path("/{id}/os-virtual-interfaces") @SelectJson("virtual_interfaces") @Consumes(MediaType.APPLICATION_JSON) - @Path("/servers/{server_id}/os-virtual-interfaces") @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listOnServer(@PathParam("server_id") String serverId); + FluentIterable listOnServer(@PathParam("id") String serverId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java similarity index 64% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java index 0e84604a2f..485fb09ab9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApi.java @@ -29,6 +29,7 @@ import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Volume; import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; @@ -46,31 +47,26 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides synchronous access to Volumes. - *

- * - * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeAsyncApi - * @author Adam Lowe + * Provides access to the OpenStack Compute (Nova) Volume extension API. */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES) @RequestFilters(AuthenticateRequest.class) -public interface VolumeAsyncApi { +@Consumes(MediaType.APPLICATION_JSON) +public interface VolumeApi { /** - * Returns a summary list of volumes. + * Returns a summary list of snapshots. * - * @return the list of volumes + * @return the list of snapshots */ @Named("volume:list") @GET @Path("/os-volumes") @SelectJson("volumes") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); + FluentIterable list(); /** * Returns a detailed list of volumes. @@ -81,25 +77,24 @@ public interface VolumeAsyncApi { @GET @Path("/os-volumes/detail") @SelectJson("volumes") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listInDetail(); + FluentIterable listInDetail(); /** * Return data about the given volume. * - * @return details of a specific volume. + * @return details of a specific snapshot. */ @Named("volume:get") @GET @Path("/os-volumes/{id}") @SelectJson("volume") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String volumeId); + @Nullable + Volume get(@PathParam("id") String volumeId); /** - * Creates a new volume + * Creates a new Snapshot * * @return the new Snapshot */ @@ -107,148 +102,146 @@ public interface VolumeAsyncApi { @POST @Path("/os-volumes") @SelectJson("volume") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @MapBinder(CreateVolumeOptions.class) - ListenableFuture create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options); + Volume create(@PayloadParam("size") int sizeGB, CreateVolumeOptions... options); /** - * Delete a volume. + * Delete a snapshot. * * @return true if successful */ @Named("volume:delete") @DELETE - @Path("/os-volumes/{id}") + @Path("/os-volumes/{volumeId}") @Consumes(MediaType.APPLICATION_JSON) @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String volumeId); - + boolean delete(@PathParam("volumeId") String volumeId); + /** * List volume attachments for a given instance. - * + * * @return all Floating IPs * @deprecated To be removed in jclouds 1.7 * @see VolumeAttachmentApi#listAttachmentsOnServer(String) */ - @Named("volume:listattachments") + @Deprecated + @Named("volume:listAttachments") @GET - @Path("/servers/{server_id}/os-volume_attachments") + @Path("/servers/{id}/os-volume_attachments") @SelectJson("volumeAttachments") @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - @Deprecated ListenableFuture> listAttachmentsOnServer(@PathParam("server_id") String serverId); + FluentIterable listAttachmentsOnServer(@PathParam("id") String serverId); /** * Get a specific attached volume. - * + * * @return data about the given volume attachment. * @deprecated To be removed in jclouds 1.7 * @see VolumeAttachmentApi#getAttachmentForVolumeOnServer(String, String) */ - @Named("volume:getattachments") + @Deprecated + @Named("volume:getAttachments") @GET - @Path("/servers/{server_id}/os-volume_attachments/{id}") + @Path("/servers/{serverId}/os-volume_attachments/{id}") @SelectJson("volumeAttachment") @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - @Deprecated ListenableFuture getAttachmentForVolumeOnServer(@PathParam("id") String volumeId, - @PathParam("server_id") String serverId); + @Nullable + VolumeAttachment getAttachmentForVolumeOnServer(@PathParam("id") String volumeId, + @PathParam("serverId") String serverId); /** * Attach a volume to an instance * - * @return the new Attachment + * @return data about the new volume attachment * @deprecated To be removed in jclouds 1.7 * @see VolumeAttachmentApi#attachVolumeToServerAsDevice(String, String, String) */ + @Deprecated @Named("volume:attach") @POST - @Path("/servers/{server_id}/os-volume_attachments") + @Path("/servers/{serverId}/os-volume_attachments") @SelectJson("volumeAttachment") @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) @WrapWith("volumeAttachment") - @Deprecated ListenableFuture attachVolumeToServerAsDevice(@PayloadParam("volumeId") String volumeId, - @PathParam("server_id") String serverId, @PayloadParam("device") String device); + VolumeAttachment attachVolumeToServerAsDevice(@PayloadParam("volumeId") String volumeId, + @PathParam("serverId") String serverId, @PayloadParam("device") String device); /** * Detach a Volume from an instance. - * + * * @return true if successful * @deprecated To be removed in jclouds 1.7 * @see VolumeAttachmentApi#detachVolumeFromServer(String, String) */ + @Deprecated @Named("volume:detach") @DELETE - @Path("/servers/{server_id}/os-volume_attachments/{id}") - @Consumes(MediaType.APPLICATION_JSON) + @Path("/servers/{serverId}/os-volume_attachments/{id}") @Fallback(FalseOnNotFoundOr404.class) - @Deprecated ListenableFuture detachVolumeFromServer(@PathParam("id") String volumeId, @PathParam("server_id") String serverId); + Boolean detachVolumeFromServer(@PathParam("id") String volumeId, + @PathParam("serverId") String serverId); /** * Returns a summary list of snapshots. * * @return the list of snapshots */ - @Named("volume:listsnapshots") + @Named("volume:listSnapshots") @GET @Path("/os-snapshots") @SelectJson("snapshots") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listSnapshots(); + FluentIterable listSnapshots(); /** * Returns a summary list of snapshots. * * @return the list of snapshots */ - @Named("volume:listsnapshot") + @Named("volume:listSnapshots") @GET @Path("/os-snapshots/detail") @SelectJson("snapshots") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> listSnapshotsInDetail(); + FluentIterable listSnapshotsInDetail(); /** * Return data about the given snapshot. * * @return details of a specific snapshot. */ - @Named("volume:getsnapshot") + @Named("volume:getSnapshot") @GET @Path("/os-snapshots/{id}") @SelectJson("snapshot") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getSnapshot(@PathParam("id") String snapshotId); + @Nullable + VolumeSnapshot getSnapshot(@PathParam("id") String snapshotId); /** - * Creates a new Snapshot + * Creates a new Snapshot. * * @return the new Snapshot */ - @Named("volume:createsnapshot") + @Named("volume:createSnapshot") @POST @Path("/os-snapshots") @SelectJson("snapshot") @Produces(MediaType.APPLICATION_JSON) - @Consumes(MediaType.APPLICATION_JSON) @MapBinder(CreateVolumeSnapshotOptions.class) - ListenableFuture createSnapshot(@PayloadParam("volume_id") String volumeId, CreateVolumeSnapshotOptions... options); + VolumeSnapshot createSnapshot(@PayloadParam("volume_id") String volumeId, CreateVolumeSnapshotOptions... options); /** * Delete a snapshot. * * @return true if successful */ - @Named("volume:deletesnapshot") + @Named("volume:deleteSnapshot") @DELETE @Path("/os-snapshots/{id}") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture deleteSnapshot(@PathParam("id") String snapshotId); - + boolean deleteSnapshot(@PathParam("id") String snapshotId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java similarity index 55% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java index 273815e96b..c280fa9d71 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApi.java @@ -16,72 +16,117 @@ */ package org.jclouds.openstack.nova.v2_0.extensions; +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.EmptyFluentIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; import org.jclouds.openstack.v2_0.ServiceType; import org.jclouds.openstack.v2_0.services.Extension; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.WrapWith; import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; /** - * Provides synchronous access to Volume Attachments. - * - * This API strictly handles attaching Volumes to Servers. To create and manage Volumes you need to use one of the + * Provides access to the OpenStack Compute (Nova) Volume Attachments Extension API. + * + * This API strictly handles attaching Volumes to Servers. To create and manage Volumes you need to use one of the * following APIs: - * + * * 1. The Cinder API * If your OpenStack deployment is Folsom or later and it supports the Cinder block storage service, use this API. * @see org.jclouds.openstack.cinder.v1.features.VolumeApi - * + * * 2. The nova-volume API * If your OpenStack deployment is Essex or earlier and it supports the nova-volume extension, use this API. * @see org.jclouds.openstack.nova.v2_0.extensions.VolumeApi - * - * @see VolumeAttachmentAsyncApi - * @author Everett Toews + * */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUMES) +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/servers") public interface VolumeAttachmentApi { /** * List Volume Attachments for a given Server. - * + * * @param serverId The ID of the Server * @return All VolumeAttachments for the Server */ - FluentIterable listAttachmentsOnServer(String serverId); + @Named("volumeAttachment:list") + @GET + @Path("/{serverId}/os-volume_attachments") + @SelectJson("volumeAttachments") + @Fallback(EmptyFluentIterableOnNotFoundOr404.class) + FluentIterable listAttachmentsOnServer(@PathParam("serverId") String serverId); /** * Get a specific Volume Attachment for a Volume and Server. - * + * * @param volumeId The ID of the Volume * @param serverId The ID of the Server * @return The Volume Attachment. */ - VolumeAttachment getAttachmentForVolumeOnServer(String volumeId, String serverId); + @Named("volumeAttachment:get") + @GET + @Path("/{serverId}/os-volume_attachments/{id}") + @SelectJson("volumeAttachment") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + VolumeAttachment getAttachmentForVolumeOnServer(@PathParam("id") String volumeId, + @PathParam("serverId") String serverId); /** * Attach a Volume to a Server. - * - * Note: If you are using KVM as your hypervisor then the actual device name in the Server will be different than + * + * Note: If you are using KVM as your hypervisor then the actual device name in the Server will be different than * the one specified. When the Server sees a new device, it picks the next available name (which in most cases is * /dev/vdc) and the disk shows up there on the Server. - * + * * @param serverId The ID of the Server * @param volumeId The ID of the Volume - * @param device The name of the device this Volume will be identified as in the Server (e.g. /dev/vdc) + * @param device The name of the device this Volume will be identified as in the Server (e.g. /dev/vdc) * @return The Volume Attachment. */ - VolumeAttachment attachVolumeToServerAsDevice(String volumeId, String serverId, String device); + @Named("volumeAttachment:attach") + @POST + @Path("/{serverId}/os-volume_attachments") + @SelectJson("volumeAttachment") + @Produces(MediaType.APPLICATION_JSON) + @WrapWith("volumeAttachment") + VolumeAttachment attachVolumeToServerAsDevice(@PayloadParam("volumeId") String volumeId, + @PathParam("serverId") String serverId, @PayloadParam("device") String device); /** * Detach a Volume from a server. - * + * * Note: Make sure you've unmounted the volume first. Failure to do so could result in failure or data loss. - * + * * @param volumeId The ID of the Volume * @param serverId The ID of the Server * @return true if successful */ - boolean detachVolumeFromServer(String volumeId, String serverId); + @Named("volumeAttachment:detach") + @DELETE + @Path("/{serverId}/os-volume_attachments/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean detachVolumeFromServer(@PathParam("id") String volumeId, + @PathParam("serverId") String serverId); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java similarity index 58% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java index 4312258190..943fe4b4bb 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApi.java @@ -33,6 +33,7 @@ import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; import org.jclouds.Fallbacks.FalseOnNotFoundOr404; import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.VolumeType; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeTypeOptions; @@ -50,112 +51,130 @@ import com.google.common.annotations.Beta; import com.google.common.collect.FluentIterable; -import com.google.common.util.concurrent.ListenableFuture; /** - * Provides asynchronous access to Volume Type features + * Provides access to the OpenStack Compute (Nova) Volume Type extension API. * - * @author Adam Lowe - * @see VolumeTypeApi + * @see VolumeApi */ @Beta @Extension(of = ServiceType.COMPUTE, namespace = ExtensionNamespaces.VOLUME_TYPES) @RequestFilters(AuthenticateRequest.class) -@Path("/os-volume-types") @Consumes(MediaType.APPLICATION_JSON) -public interface VolumeTypeAsyncApi { - +@Path("/os-volume-types") +public interface VolumeTypeApi { /** - * @see VolumeTypeApi#list + * @return set of all volume types */ - @Named("volumetype:list") + @Named("volumeType:list") @GET @SelectJson("volume_types") @Fallback(EmptyFluentIterableOnNotFoundOr404.class) - ListenableFuture> list(); - + FluentIterable list(); /** - * @see VolumeTypeApi#get + * Gets a volume type + * + * @param id the id of the volume type to retrieve + * @return the requested volume type */ - @Named("volumetype:get") + @Named("volumeType:get") @GET @Path("/{id}") @SelectJson("volume_type") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + VolumeType get(@PathParam("id") String id); /** - * @see VolumeTypeApi#create + * Creates a new volume type + * + * @param name the name of the new volume type + * @param options optional settings for the new volume type + * @return the new volume type */ - @Named("volumetype:create") + @Named("volumeType:create") @POST @SelectJson("volume_type") @Produces(MediaType.APPLICATION_JSON) @WrapWith("volume_type") - ListenableFuture create(@PayloadParam("name") String name, CreateVolumeTypeOptions... options); + VolumeType create(@PayloadParam("name") String name, CreateVolumeTypeOptions... options); /** - * @see VolumeTypeApi#delete + * Deletes a volume type + * + * @param id the id of the volume type to delete */ - @Named("volumetype:delete") + @Named("volumeType:delete") @DELETE @Path("/{id}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String id); + boolean delete(@PathParam("id") String id); /** - * @see VolumeTypeApi#getExtraSpecs(String) + * Gets the extra specs for a volume type + * + * @param id the id of the volume type + * @return the set of extra metadata for the flavor */ - @Named("volumetype:getextraspecs") + @Named("volumeType:getExtraSpecs") @GET - @SelectJson("extra_specs") @Path("/{id}/extra_specs") + @SelectJson("extra_specs") @Fallback(EmptyMapOnNotFoundOr404.class) - ListenableFuture> getExtraSpecs(@PathParam("id") String id); + Map getExtraSpecs(@PathParam("id") String id); /** - * @see VolumeTypeApi#updateExtraSpecs(String, java.util.Map) + * Creates or updates the extra metadata for a given flavor */ - @Named("volumetype:udpateextraspecs") + @Named("volumeType:updateExtraSpecs") @POST @Path("/{id}/extra_specs") @Produces(MediaType.APPLICATION_JSON) - @Fallback(FalseOnNotFoundOr404.class) @MapBinder(BindToJsonPayload.class) - ListenableFuture updateExtraSpecs(@PathParam("id") String id, @PayloadParam("extra_specs") Map specs); + @Fallback(FalseOnNotFoundOr404.class) + boolean updateExtraSpecs(@PathParam("id") String id, @PayloadParam("extra_specs") Map specs); /** - * @see VolumeTypeApi#getExtraSpec(String, String) + * Retrieve a single extra spec value + * + * @param id the id of the volume type + * @param key the key of the extra spec item to retrieve */ - @Named("volumetype:getextraspec") + @Named("volumeType:getExtraSpec") @GET @Path("/{id}/extra_specs/{key}") @Unwrap @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getExtraSpec(@PathParam("id") String id, @PathParam("key") String key); + @Nullable + String getExtraSpec(@PathParam("id") String id, @PathParam("key") String key); /** - * @see VolumeTypeApi#updateExtraSpec(String, String, String) + * Creates or updates a single extra spec value + * + * @param id the id of the volume type + * @param key the extra spec key (when creating ensure this does not include whitespace or other difficult characters) + * @param value the new value to store associate with the key */ - @Named("volumetype:updateextraspec") + @Named("volumeType:updateExtraSpec") @PUT @Path("/{id}/extra_specs/{key}") @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"{key}\":\"{value}\"%7D") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture updateExtraSpec(@PathParam("id") String id, - @PathParam("key") @PayloadParam("key") String key, - @PayloadParam("value") String value); + boolean updateExtraSpec(@PathParam("id") String id, + @PathParam("key") @PayloadParam("key") String key, + @PayloadParam("value") String value); /** - * @see VolumeTypeApi#deleteExtraSpec(String, String) + * Deletes an existing extra spec + * + * @param id the id of the volume type + * @param key the key of the extra spec to delete */ - @Named("volumetype:deleteextraspec") + @Named("volumeType:deleteExtraSpec") @DELETE @Path("/{id}/extra_specs/{key}") @Fallback(FalseOnNotFoundOr404.class) - ListenableFuture deleteExtraSpec(@PathParam("id") String id, - @PathParam("key") String key); - + boolean deleteExtraSpec(@PathParam("id") String id, @PathParam("key") String key); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java similarity index 62% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java index 7c1552ed76..6d151a69a0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/FlavorApi.java @@ -30,12 +30,13 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; -import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.domain.Flavor; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavorDetails; import org.jclouds.openstack.nova.v2_0.functions.internal.ParseFlavors; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; import org.jclouds.openstack.v2_0.domain.Resource; import org.jclouds.openstack.v2_0.options.PaginationOptions; import org.jclouds.rest.annotations.Fallback; @@ -46,99 +47,90 @@ import org.jclouds.rest.annotations.Unwrap; import org.jclouds.rest.annotations.WrapWith; -import com.google.common.util.concurrent.ListenableFuture; - /** - * Provides asynchronous access to Flavors via their REST API. + * Provides access to the OpenStack Compute (Nova) Flavor API. *

- * - * @see FlavorApi - * @see docs - * @author Jeremy Daggett TODO: Need a ListFlavorOptions class minDisk=minDiskInGB& - * minRam=minRamInMB& marker=markerID&limit=int - * @author Ilja Bobkevic + * */ @RequestFilters(AuthenticateRequest.class) -public interface FlavorAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +@Path("/flavors") +public interface FlavorApi { /** - * @see FlavorApi#list() + * List all flavors (IDs, names, links) + * + * @return all flavors (IDs, names, links) */ @Named("flavor:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/flavors") - @RequestFilters(AuthenticateRequest.class) @ResponseParser(ParseFlavors.class) @Transform(ParseFlavors.ToPagedIterable.class) @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); + PagedIterable list(); - /** @see FlavorApi#list(PaginationOptions) */ @Named("flavor:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/flavors") - @RequestFilters(AuthenticateRequest.class) @ResponseParser(ParseFlavors.class) @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> list(PaginationOptions options); + PaginatedCollection list(PaginationOptions options); /** - * @see FlavorApi#listInDetail() + * List all flavors (all details) + * + * @return all flavors (all details) */ @Named("flavor:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/flavors/detail") - @RequestFilters(AuthenticateRequest.class) + @Path("/detail") @ResponseParser(ParseFlavorDetails.class) @Transform(ParseFlavorDetails.ToPagedIterable.class) @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> listInDetail(); + PagedIterable listInDetail(); - /** @see FlavorApi#listInDetail(PaginationOptions) */ @Named("flavor:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/flavors/detail") - @RequestFilters(AuthenticateRequest.class) + @Path("/detail") @ResponseParser(ParseFlavorDetails.class) @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> listInDetail(PaginationOptions options); + PaginatedCollection listInDetail(PaginationOptions options); /** - * @see FlavorApi#get + * List details of the specified flavor + * + * @param id + * id of the flavor + * @return flavor or null if not found */ @Named("flavor:get") @GET + @Path("/{id}") @SelectJson("flavor") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/flavors/{id}") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + Flavor get(@PathParam("id") String id); - /** - * @see FlavorApi#create + * Create flavor according to the provided object + * + * @param flavor - flavor object + * @return newly created flavor */ @Named("flavor:create") @POST @Unwrap - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Path("/flavors") - ListenableFuture create(@WrapWith("flavor") Flavor flavor); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Flavor create(@WrapWith("flavor") Flavor flavor); /** - * @see FlavorApi#delete + * Delete flavor with a given id + * + * @param id - flavor id */ @Named("flavor:delete") @DELETE - @Consumes - @Path("/flavors/{id}") + @Path("/{id}") @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String id); + void delete(@PathParam("id") String id); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java similarity index 55% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java index f45826cdd4..025af01c63 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageAsyncApi.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ImageApi.java @@ -34,8 +34,9 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404; import org.jclouds.Fallbacks.VoidOnNotFoundOr404; import org.jclouds.collect.PagedIterable; -import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; +import org.jclouds.javax.annotation.Nullable; import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload; import org.jclouds.openstack.nova.v2_0.domain.Image; @@ -53,154 +54,178 @@ import org.jclouds.rest.annotations.Transform; import org.jclouds.rest.binders.BindToJsonPayload; -import com.google.common.util.concurrent.ListenableFuture; - /** - * Provides asynchronous access to Images via the REST API. - *

- * - * @see ImageApi - * @author Jeremy Daggett + * Provides access to the OpenStack Compute (Nova) Image API. */ @RequestFilters(AuthenticateRequest.class) -public interface ImageAsyncApi { - +@Consumes(MediaType.APPLICATION_JSON) +@Path("/images") +public interface ImageApi { /** - * @see ImageApi#list() + * List all images (IDs, names, links) + * + * @return all images (IDs, names, links) */ @Named("image:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @RequestFilters(AuthenticateRequest.class) @ResponseParser(ParseImages.class) @Transform(ParseImages.ToPagedIterable.class) @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> list(); + PagedIterable list(); - /** @see ImageApi#list(PaginationOptions) */ @Named("image:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images") - @RequestFilters(AuthenticateRequest.class) @ResponseParser(ParseImages.class) @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> list(PaginationOptions options); + PaginatedCollection list(PaginationOptions options); /** - * @see ImageApi#listInDetail() + * List all images (all details) + * + * @return all images (all details) */ @Named("image:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/detail") - @RequestFilters(AuthenticateRequest.class) + @Path("/detail") @ResponseParser(ParseImageDetails.class) @Transform(ParseImageDetails.ToPagedIterable.class) @Fallback(EmptyPagedIterableOnNotFoundOr404.class) - ListenableFuture> listInDetail(); + PagedIterable listInDetail(); - /** @see ImageApi#listInDetail(PaginationOptions) */ @Named("image:list") @GET - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/detail") - @RequestFilters(AuthenticateRequest.class) + @Path("/detail") @ResponseParser(ParseImageDetails.class) @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) - ListenableFuture> listInDetail(PaginationOptions options); + PaginatedCollection listInDetail(PaginationOptions options); /** - * @see ImageApi#get + * List details of the specified image + * + * @param id + * id of the server + * @return server or null if not found */ @Named("image:get") @GET + @Path("/{id}") @SelectJson("image") - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/{id}") @Fallback(NullOnNotFoundOr404.class) - ListenableFuture get(@PathParam("id") String id); + @Nullable + Image get(@PathParam("id") String id); /** - * @see ImageApi#delete + * Delete the specified image + * + * @param id + * id of the image + * @return server or null if not found */ @Named("image:delete") @DELETE - @Consumes(MediaType.APPLICATION_JSON) - @Path("/images/{id}") + @Path("/{id}") @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture delete(@PathParam("id") String id); - + void delete(@PathParam("id") String id); + /** - * @see ImageApi#getMetadata + * List all metadata for an image. + * + * @param id + * id of the image + * @return the metadata as a Map */ - @Named("image:getmetadata") + @Named("image:getMetadata") @GET + @Path("/{id}/metadata") @SelectJson("metadata") - @Path("/images/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) @Fallback(EmptyMapOnNotFoundOr404.class) - ListenableFuture> getMetadata(@PathParam("id") String id); + Map getMetadata(@PathParam("id") String id); /** - * @see ImageApi#setMetadata + * Sets the metadata for an image. + * + * @param id + * id of the image + * @param metadata + * a Map containing the metadata + * @return the metadata as a Map */ - @Named("image:setmetadata") + @Named("image:setMetadata") @PUT + @Path("/{id}/metadata") @SelectJson("metadata") - @Path("/images/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) @MapBinder(BindToJsonPayload.class) - ListenableFuture> setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map metadata); + @Fallback(EmptyMapOnNotFoundOr404.class) + Map setMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map metadata); /** - * @see ImageApi#updateMetadata + * Update the metadata for a server. + * + * @param id + * id of the image + * @param metadata + * a Map containing the metadata + * @return the metadata as a Map */ - @Named("image:updatemetadata") + @Named("image:updateMetadata") @POST + @Path("/{id}/metadata") @SelectJson("metadata") - @Path("/images/{id}/metadata") - @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - @Fallback(EmptyMapOnNotFoundOr404.class) @MapBinder(BindToJsonPayload.class) - ListenableFuture> updateMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map metadata); + @Fallback(EmptyMapOnNotFoundOr404.class) + Map updateMetadata(@PathParam("id") String id, @PayloadParam("metadata") Map metadata); /** - * @see ImageApi#getMetadata + * Update the metadata for an image. + * + * @param id + * id of the image + * @param metadata + * a Map containing the metadata + * @return the value or null if not present */ - @Named("image:getmetadata") + @Named("image:getMetadata") @GET - @Path("/images/{id}/metadata/{key}") - @Consumes(MediaType.APPLICATION_JSON) + @Path("/{id}/metadata/{key}") @ResponseParser(OnlyMetadataValueOrNull.class) @Fallback(NullOnNotFoundOr404.class) - ListenableFuture getMetadata(@PathParam("id") String id, @PathParam("key") String key); - + @Nullable + String getMetadata(@PathParam("id") String id, @PathParam("key") String key); + /** - * @see ImageApi#updateMetadata + * Set a metadata item for an image. + * + * @param id + * id of the image + * @param key + * the name of the metadata item + * @param value + * the value of the metadata item + * @return the value you updated */ - @Named("image:updatemetadata") + @Named("image:updateMetadata") @PUT - @Path("/images/{id}/metadata/{key}") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) + @Path("/{id}/metadata/{key}") @ResponseParser(OnlyMetadataValueOrNull.class) @MapBinder(BindMetadataToJsonPayload.class) - ListenableFuture updateMetadata(@PathParam("id") String id, - @PathParam("key") @PayloadParam("key") String key, @PathParam("value") @PayloadParam("value") String value); + @Fallback(NullOnNotFoundOr404.class) + @Nullable + String updateMetadata(@PathParam("id") String id, @PathParam("key") @PayloadParam("key") String key, + @PathParam("value") @PayloadParam("value") String value); - /** - * @see ImageApi#deleteMetadata + * Delete a metadata item from an image. + * + * @param id + * id of the image + * @param key + * the name of the metadata item */ - @Named("image:deletemetadata") + @Named("image:deleteMetadata") @DELETE - @Consumes - @Path("/images/{id}/metadata/{key}") + @Path("/{id}/metadata/{key}") @Fallback(VoidOnNotFoundOr404.class) - ListenableFuture deleteMetadata(@PathParam("id") String id, @PathParam("key") String key); + void deleteMetadata(@PathParam("id") String id, @PathParam("key") String key); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java new file mode 100644 index 0000000000..80f1d9e05e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/features/ServerApi.java @@ -0,0 +1,433 @@ +/* + * 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.jclouds.openstack.nova.v2_0.features; + +import com.google.common.base.Optional; + +import java.util.Map; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks.AbsentOn403Or404Or500; +import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404; +import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404; +import org.jclouds.Fallbacks.FalseOnNotFoundOr404; +import org.jclouds.Fallbacks.NullOnNotFoundOr404; +import org.jclouds.Fallbacks.VoidOnNotFoundOr404; +import org.jclouds.collect.PagedIterable; +import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.openstack.v2_0.domain.PaginatedCollection; +import org.jclouds.openstack.keystone.v2_0.KeystoneFallbacks.EmptyPaginatedCollectionOnNotFoundOr404; +import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest; +import org.jclouds.openstack.nova.v2_0.binders.BindMetadataToJsonPayload; +import org.jclouds.openstack.nova.v2_0.domain.RebootType; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.domain.ServerCreated; +import org.jclouds.openstack.nova.v2_0.functions.ParseImageIdFromLocationHeader; +import org.jclouds.openstack.nova.v2_0.functions.internal.OnlyMetadataValueOrNull; +import org.jclouds.openstack.nova.v2_0.functions.internal.ParseDiagnostics; +import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServerDetails; +import org.jclouds.openstack.nova.v2_0.functions.internal.ParseServers; +import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; +import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.openstack.v2_0.options.PaginationOptions; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.Payload; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.annotations.Transform; +import org.jclouds.rest.annotations.Unwrap; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * Provides access to the OpenStack Compute (Nova) Server API. + */ +@RequestFilters(AuthenticateRequest.class) +@Consumes(MediaType.APPLICATION_JSON) +@Path("/servers") +public interface ServerApi { + /** + * List all servers (IDs, names, links) + * + * @return all servers (IDs, names, links) + */ + @Named("server:list") + @GET + @ResponseParser(ParseServers.class) + @Transform(ParseServers.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable list(); + + @Named("server:list") + @GET + @ResponseParser(ParseServers.class) + @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) + PaginatedCollection list(PaginationOptions options); + + /** + * List all servers (all details) + * + * @return all servers (all details) + */ + @Named("server:list") + @GET + @Path("/detail") + @ResponseParser(ParseServerDetails.class) + @Transform(ParseServerDetails.ToPagedIterable.class) + @Fallback(EmptyPagedIterableOnNotFoundOr404.class) + PagedIterable listInDetail(); + + @Named("server:list") + @GET + @Path("/detail") + @ResponseParser(ParseServerDetails.class) + @Fallback(EmptyPaginatedCollectionOnNotFoundOr404.class) + PaginatedCollection listInDetail(PaginationOptions options); + + /** + * List details of the specified server + * + * @param id + * id of the server + * @return server or null if not found + */ + @Named("server:get") + @GET + @Path("/{id}") + @SelectJson("server") + @Fallback(NullOnNotFoundOr404.class) + @Nullable + Server get(@PathParam("id") String id); + + /** + * Create a new server + * + * @param name + * name of the server to create + * @param imageRef + * reference to the image for the server to use + * @param flavorRef + * reference to the flavor to use when creating the server + * @param options + * optional parameters to be passed into the server creation + * request + * @return the newly created server + */ + @Named("server:create") + @POST + @Unwrap + @MapBinder(CreateServerOptions.class) + ServerCreated create(@PayloadParam("name") String name, @PayloadParam("imageRef") String imageRef, + @PayloadParam("flavorRef") String flavorRef, CreateServerOptions... options); + + /** + * Terminate and delete a server. + * + * @param id + * id of the server + * @return True if successful, False otherwise + */ + @Named("server:delete") + @DELETE + @Path("/{id}") + @Fallback(FalseOnNotFoundOr404.class) + boolean delete(@PathParam("id") String id); + + /** + * Start a server + * + * @param id + * id of the server + */ + @Named("server:start") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"os-start\":null}") + void start(@PathParam("id") String id); + + /** + * Stop a server + * + * @param id + * id of the server + */ + @Named("server:stop") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"os-stop\":null}") + void stop(@PathParam("id") String id); + + /** + * Reboot a server. + * + * @param id + * id of the server + * @param rebootType + * The type of reboot to perform (Hard/Soft) + */ + @Named("server:reboot") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") + void reboot(@PathParam("id") String id, @PayloadParam("type") RebootType rebootType); + + /** + * Resize a server to a new flavor size. + * + * @param id + * id of the server + * @param flavorId + * id of the new flavor to use + */ + @Named("server:resize") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"resize\":%7B\"flavorRef\":{flavorId}%7D%7D") + void resize(@PathParam("id") String id, @PayloadParam("flavorId") String flavorId); + + /** + * Confirm a resize operation. + * + * @param id + * id of the server + */ + @Named("server:confirmResize") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"confirmResize\":null}") + void confirmResize(@PathParam("id") String id); + + /** + * Revert a resize operation. + * + * @param id + * id of the server + */ + @Named("server:revertResize") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("{\"revertResize\":null}") + void revertResize(@PathParam("id") String id); + + /** + * Rebuild a server. + * + * @param id + * id of the server + * @param options + * Optional parameters to the rebuilding operation. + */ + @Named("server:rebuild") + @POST + @Path("/{id}/action") + @MapBinder(RebuildServerOptions.class) + void rebuild(@PathParam("id") String id, RebuildServerOptions... options); + + /** + * Change the administrative password to a server. + * + * @param id + * id of the server + * @param adminPass + * The new administrative password to use + */ + @Named("server:changeAdminPass") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") + void changeAdminPass(@PathParam("id") String id, @PayloadParam("adminPass") String adminPass); + + /** + * Rename a server. + * + * @param id + * id of the server + * @param newName + * The new name for the server + */ + @Named("server:rename") + @PUT + @Path("/{id}") + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") + void rename(@PathParam("id") String id, @PayloadParam("name") String newName); + + /** + * Create an image from a server. + * + * @param name + * The name of the new image + * @param id + * id of the server + * + * @return ID of the new / updated image + */ + @Named("server:createImageFromServer") + @POST + @Path("/{id}/action") + @Produces(MediaType.APPLICATION_JSON) + @Payload("%7B\"createImage\":%7B\"name\":\"{name}\", \"metadata\": %7B%7D%7D%7D") + @ResponseParser(ParseImageIdFromLocationHeader.class) + @Fallback(MapHttp4xxCodesToExceptions.class) + String createImageFromServer(@PayloadParam("name") String name, @PathParam("id") String id); + + /** + * List all metadata for a server. + * + * @param id + * id of the server + * + * @return the metadata as a Map + */ + @Named("server:getMetadata") + @GET + @Path("/{id}/metadata") + @SelectJson("metadata") + @Fallback(EmptyMapOnNotFoundOr404.class) + Map getMetadata(@PathParam("id") String id); + + /** + * Set the metadata for a server. + * + * @param id + * id of the server + * @param metadata + * a Map containing the metadata + * @return the metadata as a Map + */ + @Named("server:setMetadata") + @PUT + @Path("/{id}/metadata") + @SelectJson("metadata") + @Produces(MediaType.APPLICATION_JSON) + @Fallback(EmptyMapOnNotFoundOr404.class) + @MapBinder(BindToJsonPayload.class) + Map setMetadata(@PathParam("id") String id, + @PayloadParam("metadata") Map metadata); + + /** + * Update the metadata for a server. + * + * @param id + * id of the server + * @param metadata + * a Map containing the metadata + * @return the metadata as a Map + */ + @Named("server:updateMetadata") + @POST + @Path("/{id}/metadata") + @Produces(MediaType.APPLICATION_JSON) + @SelectJson("metadata") + @MapBinder(BindToJsonPayload.class) + @Fallback(EmptyMapOnNotFoundOr404.class) + Map updateMetadata(@PathParam("id") String id, + @PayloadParam("metadata") Map metadata); + + /** + * Update the metadata for a server. + * + * @param id + * id of the image + * @param metadata + * a Map containing the metadata + * @return the value or null if not present + */ + @Named("server:getMetadata") + @GET + @Path("/{id}/metadata/{key}") + @ResponseParser(OnlyMetadataValueOrNull.class) + @Fallback(NullOnNotFoundOr404.class) + @Nullable + String getMetadata(@PathParam("id") String id, @PathParam("key") String key); + + /** + * Set a metadata item for a server. + * + * @param id + * id of the image + * @param key + * the name of the metadata item + * @param value + * the value of the metadata item + * @return the value you updated + */ + @Named("server:updateMetadata") + @PUT + @Path("/{id}/metadata/{key}") + @Produces(MediaType.APPLICATION_JSON) + @ResponseParser(OnlyMetadataValueOrNull.class) + @MapBinder(BindMetadataToJsonPayload.class) + String updateMetadata(@PathParam("id") String id, @PathParam("key") @PayloadParam("key") String key, + @PathParam("value") @PayloadParam("value") String value); + + /** + * Delete a metadata item from a server. + * + * @param id + * id of the image + * @param key + * the name of the metadata item + */ + @Named("server:deleteMetadata") + @DELETE + @Path("/{id}/metadata/{key}") + @Fallback(VoidOnNotFoundOr404.class) + void deleteMetadata(@PathParam("id") String id, @PathParam("key") String key); + + /** + * Get usage information about the server such as CPU usage, Memory and IO. + * The information returned by this method is dependent on the hypervisor + * in use by the OpenStack installation and whether that hypervisor supports + * this method. More information can be found in the + * OpenStack API + * reference.
+ * At the moment the returned response is a generic map. In future versions + * of OpenStack this might be subject to change. + * + * @param id + * id of the server + * @return A Map containing the collected values organized by key - value. + */ + @Named("server:getDiagnostics") + @GET + @Path("/{id}/diagnostics") + @ResponseParser(ParseDiagnostics.class) + @Fallback(AbsentOn403Or404Or500.class) + Optional> getDiagnostics(@PathParam("id") String id); +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/FieldValueResponseParsers.java diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java index 9627ece28d..a52a0d2211 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/OverLimitParser.java @@ -56,9 +56,6 @@ * } * } * - * - * @author Adrian Cole, Steve Loughran - * */ public class OverLimitParser implements Function> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java index 1ca6f6843a..ec7f005634 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/ParseImageIdFromLocationHeader.java @@ -17,16 +17,14 @@ package org.jclouds.openstack.nova.v2_0.functions; import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpResponse; import com.google.common.base.Function; +import com.google.common.net.HttpHeaders; /** * This parses {@link Image} from the body of the link in the Location header of the HTTPResponse. - * - * @author Tim Miller */ @Singleton public class ParseImageIdFromLocationHeader implements Function { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java index 8183f84f97..ba9ad1f1e0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/OnlyMetadataValueOrNull.java @@ -32,10 +32,6 @@ import com.google.inject.Inject; import com.google.inject.TypeLiteral; -/** - * - * @author Adrian Cole - */ @Singleton public class OnlyMetadataValueOrNull implements Function { private final ParseJson parser; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java similarity index 82% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java index 366aa4c0ea..85ee0414fd 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseDiagnostics.java @@ -25,21 +25,18 @@ import com.google.inject.Inject; import java.util.Map; -/** - * @author Leander Beernaert - */ -public class ParseDiagnostics implements Function>> { +public class ParseDiagnostics implements Function>> { - private final ParseJson>> parser; + private final ParseJson>> parser; @Inject - public ParseDiagnostics(ParseJson>> parser) { + public ParseDiagnostics(ParseJson>> parser) { this.parser = parser; } @Override - public Optional > apply(HttpResponse response) { + public Optional > apply(HttpResponse response) { checkNotNull(response, "response"); return parser.apply(response); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java index 7e15016cb1..260c6c9b51 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavorDetails.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java index 5d183f4f1f..9b1b21c7ea 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseFlavors.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java index c69103ab1c..39b3984cee 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImageDetails.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java index a9391341b2..d4e1944544 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseImages.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java index 96566ff805..ad84f9ab51 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseKeyPairs.java @@ -32,10 +32,6 @@ import com.google.inject.Inject; import com.google.inject.TypeLiteral; -/** - * - * @author Adrian Cole - */ @Singleton public class ParseKeyPairs implements Function> { private final ParseFirstJsonValueNamed> parser; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java index 4af2ceaecf..e9389cabad 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServerDetails.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java index 2de8c767eb..15a932e696 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/functions/internal/ParseServers.java @@ -42,8 +42,6 @@ /** * boiler plate until we determine a better way - * - * @author Adrian Cole */ @Beta @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java index 4bfb51b282..487ce0b248 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandler.java @@ -47,9 +47,6 @@ /** * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole, Steve Loughran - * */ // TODO: is there error spec someplace? let's type errors, etc. @Singleton diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java index e6002e5f52..c2d38090e0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateBackupOfServerOptions.java @@ -32,9 +32,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * @author Adam Lowe - */ public class CreateBackupOfServerOptions implements MapBinder { public static final CreateBackupOfServerOptions NONE = new CreateBackupOfServerOptions(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java index b135e19d8e..8a8bd2cfd1 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateServerOptions.java @@ -33,26 +33,18 @@ import javax.inject.Named; import org.jclouds.http.HttpRequest; -import org.jclouds.openstack.nova.v2_0.NovaApi; import org.jclouds.openstack.nova.v2_0.domain.Network; -import org.jclouds.openstack.nova.v2_0.domain.Server; import org.jclouds.rest.MapBinder; import org.jclouds.rest.binders.BindToJsonPayload; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; -import com.google.common.base.Optional; import com.google.common.collect.ForwardingObject; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -/** - * @author Adrian Cole - * @author Inbar Stolberg - * @author Zack Shoylev - */ public class CreateServerOptions implements MapBinder { @Inject private BindToJsonPayload jsonBinder; @@ -128,7 +120,8 @@ public boolean equals(Object object) { && equal(metadata, other.metadata) && equal(personality, other.personality) && equal(adminPass, other.adminPass) && equal(diskConfig, other.diskConfig) && equal(adminPass, other.adminPass) && equal(networks, other.networks) - && equal(availabilityZone, other.availabilityZone); + && equal(availabilityZone, other.availabilityZone) + && equal(configDrive, other.configDrive); } else { return false; } @@ -136,7 +129,7 @@ && equal(adminPass, other.adminPass) && equal(networks, other.networks) @Override public int hashCode() { - return Objects.hashCode(keyName, securityGroupNames, metadata, personality, adminPass, networks, availabilityZone); + return Objects.hashCode(keyName, securityGroupNames, metadata, personality, adminPass, networks, availabilityZone, configDrive); } protected ToStringHelper string() { @@ -156,6 +149,7 @@ protected ToStringHelper string() { if (!networks.isEmpty()) toString.add("networks", networks); toString.add("availability_zone", availabilityZone == null ? null : availabilityZone); + toString.add("configDrive", configDrive); return toString; } @@ -180,6 +174,8 @@ static class ServerRequest { @Named("OS-DCF:diskConfig") String diskConfig; Set> networks; + @Named("config_drive") + String configDrive; private ServerRequest(String name, String imageRef, String flavorRef) { this.name = name; @@ -204,6 +200,8 @@ public R bindToRequest(R request, Map po server.availabilityZone = availabilityZone; if (userData != null) server.user_data = base64().encode(userData); + if (configDrive) + server.configDrive = "true"; if (securityGroupNames.size() > 0) { server.securityGroupNames = Sets.newLinkedHashSet(); for (String groupName : securityGroupNames) { @@ -223,13 +221,13 @@ public R bindToRequest(R request, Map po for (Network network : novaNetworks) { // Avoid serializing null values, which are common here. ImmutableMap.Builder networkMap = new ImmutableMap.Builder(); - if(network.getNetworkUuid() != null) { + if (network.getNetworkUuid() != null) { networkMap.put("uuid", network.getNetworkUuid()); } - if(network.getPortUuid() != null) { + if (network.getPortUuid() != null) { networkMap.put("port", network.getPortUuid()); } - if(network.getFixedIp() != null) { + if (network.getFixedIp() != null) { networkMap.put("fixed_ip", network.getFixedIp()); } server.networks.add(networkMap.build()); @@ -289,13 +287,10 @@ public CreateServerOptions adminPass(String adminPass) { * Custom cloud server metadata can also be supplied at launch time. This * metadata is stored in the API system where it is retrievable by querying * the API for server status. The maximum size of the metadata key and value - * is each 255 bytes and the maximum number of key-value pairs that can be - * supplied per server is 5. + * is each 255 bytes. */ public CreateServerOptions metadata(Map metadata) { checkNotNull(metadata, "metadata"); - checkArgument(metadata.size() <= 5, - "you cannot have more then 5 metadata values. You specified: " + metadata.size()); for (Entry entry : metadata.entrySet()) { checkArgument( entry.getKey().getBytes().length < 255, @@ -313,6 +308,7 @@ public CreateServerOptions metadata(Map metadata) { * Custom user-data can be also be supplied at launch time. * It is retrievable by the instance and is often used for launch-time configuration * by instance scripts. + * Pass userData unencdoed, as the value will be base64 encoded automatically. */ public CreateServerOptions userData(byte[] userData) { this.userData = userData; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java index 921a4c82f0..df9a879f0b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeOptions.java @@ -35,9 +35,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * @author Adam Lowe - */ public class CreateVolumeOptions implements MapBinder { public static final CreateVolumeOptions NONE = new CreateVolumeOptions(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java index b159367cbc..c8a2fdddd8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeSnapshotOptions.java @@ -32,9 +32,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * @author Adam Lowe - */ public class CreateVolumeSnapshotOptions implements MapBinder { public static final CreateVolumeSnapshotOptions NONE = new CreateVolumeSnapshotOptions(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java index 7ab646047c..a5b72e471f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/CreateVolumeTypeOptions.java @@ -32,9 +32,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * @author Adam Lowe - */ public class CreateVolumeTypeOptions implements MapBinder { public static final CreateVolumeTypeOptions NONE = new CreateVolumeTypeOptions(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java index 23eb5f3504..848f3c3069 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/ListOptions.java @@ -25,7 +25,6 @@ * * @see PaginationOptions * @see - * @author Adrian Cole */ public class ListOptions extends PaginationOptions { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java index e1f0d08c75..1e269fc60c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/options/RebuildServerOptions.java @@ -30,10 +30,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * @author Adrian Cole - * @author Inbar Stolberg - */ public class RebuildServerOptions implements MapBinder { @Inject private BindToJsonPayload jsonBinder; diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java index a44b502c4b..0899e8802e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/FindSecurityGroupWithNameAndReturnTrue.java @@ -40,8 +40,6 @@ /** * AtomicReference is so that we can return the securityGroup that matched. - * - * @author Adrian Cole */ @Singleton public class FindSecurityGroupWithNameAndReturnTrue implements Predicate> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java index aa8cad71b3..421a22a665 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicates.java @@ -25,8 +25,6 @@ /** * Predicates handy when working with Images - * - * @author Adrian Cole */ public class ImagePredicates { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java index ec511bb2ca..d442fcd6d8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/KeyPairPredicates.java @@ -24,8 +24,6 @@ /** * Predicates handy when working with KeyPairs - * - * @author Adam Lowe */ public class KeyPairPredicates { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java index 412e37f48e..ff81842ccb 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicates.java @@ -29,8 +29,6 @@ /** * Predicates handy when working with SecurityGroups - * - * @author Adrian Cole */ public class SecurityGroupPredicates { diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java new file mode 100644 index 0000000000..18461d28ce --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java @@ -0,0 +1,117 @@ +/* + * 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.jclouds.openstack.nova.v2_0.predicates; + +import com.google.common.base.Predicate; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.features.ServerApi; + +import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status; +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE; +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF; +import static org.jclouds.util.Predicates2.retry; + +/** + * This class tests to see if a Server or ServerCreated has reached a desired status. This class is most useful when + * paired with a RetryablePredicate as in the code below. Together these classes can be used to block execution until + * the Server or ServerCreated has reached that desired status. This is useful when your Server needs to be 100% ready + * before you can continue with execution. + *

+ * For example, you can use the factory methods like so. + *

+ *

+ * {@code
+ * ServerCreated serverCreated = serverApi.create("my-server", image.getId(), flavor.getId());
+ *
+ * if (!ServerPredicates.awaitActive(serverApi).apply(serverCreated.getId())) {
+ *     throw new TimeoutException("Timeout on server: " + serverCreated);
+ * }
+ * 
+ * + *
+ * {@code
+ * if (!ServerPredicates.awaitStatus(serverApi, ACTIVE, 300, 2).apply(server.getId())) {
+ *   throw new TimeoutException("Timeout on server: " + serverCreated);
+ * }
+ * 
+ */ +public class ServerPredicates { + private static final int TEN_MINUTES = 600; + private static final int FIVE_SECONDS = 5; + + /** + * Waits until a Server is ACTIVE. + * + * @param serverApi The ServerApi in the zone where your Server resides. + * @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes. + */ + public static Predicate awaitActive(ServerApi serverApi) { + return awaitStatus(serverApi, ACTIVE, TEN_MINUTES, FIVE_SECONDS); + } + + /** + * Waits until a Server is SHUTOFF. + * + * @param serverApi The ServerApi in the zone where your Server resides. + * @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes. + */ + public static Predicate awaitShutoff(ServerApi serverApi) { + return awaitStatus(serverApi, SHUTOFF, TEN_MINUTES, FIVE_SECONDS); + } + + /** + * Waits until a Server reaches Status. + * + * @param serverApi The ServerApi in the zone where your Server resides. + * @return Predicate that will check the status every periodInSec seconds for a maximum of maxWaitInSec minutes. + */ + public static Predicate awaitStatus( + ServerApi serverApi, Status status, long maxWaitInSec, long periodInSec) { + ServerStatusPredicate statusPredicate = new ServerStatusPredicate(serverApi, status); + + return retry(statusPredicate, maxWaitInSec, periodInSec, periodInSec, SECONDS); + } + + public static class ServerStatusPredicate implements Predicate { + private final ServerApi serverApi; + private final Status status; + + public ServerStatusPredicate(ServerApi serverApi, Status status) { + this.serverApi = checkNotNull(serverApi, "serverApi must be defined"); + this.status = checkNotNull(status, "status must be defined"); + } + + /** + * @return boolean Return true when the Server reaches the Status, false otherwise + * @throws IllegalStateException if the Server associated with serverId does not exist + */ + @Override + public boolean apply(String serverId) { + checkNotNull(serverId, "server must be defined"); + + Server server = serverApi.get(serverId); + + if (server == null) { + throw new IllegalStateException(String.format("Server %s not found.", serverId)); + } + + return status.equals(server.getStatus()); + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java index 9e6c46bf55..7cafdd5c40 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest.java @@ -32,7 +32,6 @@ /** * * @see KeystoneProperties#CREDENTIAL_TYPE - * @author Adrian Cole */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest") public class AccessKeyAndSecretKeyAndTenantIdAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -55,7 +54,7 @@ public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java index 740c5e8540..a013889a9b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest.java @@ -32,7 +32,6 @@ /** * * @see KeystoneProperties#CREDENTIAL_TYPE - * @author Adrian Cole */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest") public class AccessKeyAndSecretKeyAndTenantNamePropertyAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -55,7 +54,7 @@ public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java index 0784a7b054..8cc0539127 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/AccessKeyAndSecretKeyAuthenticationExpectTest.java @@ -31,7 +31,6 @@ /** * * @see KeystoneProperties#CREDENTIAL_TYPE - * @author Adrian Cole */ @Test(groups = "unit", testName = "AccessKeyAndSecretKeyAuthenticationExpectTest") public class AccessKeyAndSecretKeyAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -50,7 +49,7 @@ public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java index a1588756d0..59723b66c6 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/EndpointIdIsRandomExpectTest.java @@ -30,8 +30,6 @@ /** * Tests to ensure that we can pick the only endpoint of a service - * - * @author Adrian Cole */ @Test(groups = "unit", testName = "EndpointIdIsRandomExpectTest") public class EndpointIdIsRandomExpectTest extends BaseNovaApiExpectTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java index fbca40468b..970b6f7e6a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/NovaApiMetadataTest.java @@ -19,10 +19,6 @@ import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "NovaApiMetadataTest") public class NovaApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java index ad7bf9a117..22b446ec22 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationExpectTest.java @@ -29,7 +29,6 @@ /** * * @see KeystoneProperties#CREDENTIAL_TYPE - * @author Adrian Cole */ @Test(groups = "unit", testName = "PasswordAuthenticationExpectTest") public class PasswordAuthenticationExpectTest extends BaseNovaApiExpectTest { @@ -41,7 +40,7 @@ public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java index 06b6f85eb5..b6cb8812bf 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/PasswordAuthenticationWithTenantNameExpectTest.java @@ -31,7 +31,6 @@ /** * * @see KeystoneProperties#CREDENTIAL_TYPE - * @author Adrian Cole */ @Test(groups = "unit", testName = "PasswordAuthenticationWithTenantNameExpectTest") public class PasswordAuthenticationWithTenantNameExpectTest extends BaseNovaApiExpectTest { @@ -50,7 +49,7 @@ public void testListServersWhenResponseIs2xx() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java similarity index 72% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java index edf5a56efc..0a9aa06dba 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceAdapterExpectTest.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Properties; +import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.Template; @@ -48,15 +49,13 @@ /** * Tests the compute service abstraction of the nova api. - * - * @author Adrian Cole */ @Test(groups = "unit", testName = "NovaComputeServiceAdapterExpectTest") public class NovaComputeServiceAdapterExpectTest extends BaseNovaComputeServiceContextExpectTest { HttpRequest serverDetail = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -68,15 +67,15 @@ public void testCreateNodeWithGroupEncodedIntoNameWithNetworks() throws Exceptio HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\": [{\"uuid\": \"4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a\"}]}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\": [{\"uuid\": \"4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a\"}]}}", "application/json")) .build(); HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_networks_response.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_networks_response.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -90,28 +89,28 @@ public void testCreateNodeWithGroupEncodedIntoNameWithNetworks() throws Exceptio Template template = forNetworks.getInstance(TemplateBuilder.class).build(); template.getOptions().as(NovaTemplateOptions.class).networks("4ebd35cf-bfe7-4d93-b0d8-eb468ce2245a"); - + NovaComputeServiceAdapter adapter = forNetworks.getInstance(NovaComputeServiceAdapter.class); NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); // Response irrelevant in this expect test - just verifying the request. } - + public void testCreateNodeWithGroupEncodedIntoNameWithDiskConfig() throws Exception { HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"AUTO\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"AUTO\"}}", "application/json")) .build(); HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_disk_config_auto.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_disk_config_auto.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -125,7 +124,7 @@ public void testCreateNodeWithGroupEncodedIntoNameWithDiskConfig() throws Except Template template = forDiskConfig.getInstance(TemplateBuilder.class).build(); template.getOptions().as(NovaTemplateOptions.class).diskConfig(Server.DISK_CONFIG_AUTO); - + NovaComputeServiceAdapter adapter = forDiskConfig.getInstance(NovaComputeServiceAdapter.class); NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); @@ -133,20 +132,54 @@ public void testCreateNodeWithGroupEncodedIntoNameWithDiskConfig() throws Except assertEquals(server.getNode().getServer().getDiskConfig().orNull(), Server.DISK_CONFIG_AUTO); } + public void testCreateNodeWithGroupEncodedIntoNameWithConfigDrive() throws Exception { + + HttpRequest createServer = HttpRequest + .builder() + .method("POST") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken) + .payload(payloadFromStringWithContentType( + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"config_drive\":\"true\"}}", "application/json")) + .build(); + + HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") + .payload(payloadFromResourceWithContentType("/new_server_config_drive.json", "application/json; charset=UTF-8")).build(); + + Map requestResponseMap = ImmutableMap. builder() + .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) + .put(extensionsOfNovaRequest, extensionsOfNovaResponse) + .put(listDetail, listDetailResponse) + .put(listFlavorsDetail, listFlavorsDetailResponse) + .put(createServer, createServerResponse) + .put(serverDetail, serverDetailResponse).build(); + + Injector forConfigDrive = requestsSendResponses(requestResponseMap); + + Template template = forConfigDrive.getInstance(TemplateBuilder.class).build(); + template.getOptions().as(NovaTemplateOptions.class).configDrive(true); + + NovaComputeServiceAdapter adapter = forConfigDrive.getInstance(NovaComputeServiceAdapter.class); + + NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); + assertNotNull(server); + } + public void testCreateNodeWithGroupEncodedIntoNameWithNovaNetworks() throws Exception { HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\":[{\"uuid\":\"12345\", \"port\":\"67890\", \"fixed_ip\":\"192.168.0.1\"},{\"uuid\":\"54321\", \"port\":\"09876\", \"fixed_ip\":\"192.168.0.2\"},{\"uuid\":\"non-nova-uuid\"}]}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\":[{\"uuid\":\"12345\", \"port\":\"67890\", \"fixed_ip\":\"192.168.0.1\"},{\"uuid\":\"54321\", \"port\":\"09876\", \"fixed_ip\":\"192.168.0.2\"},{\"uuid\":\"non-nova-uuid\"}]}}", "application/json")) .build(); HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_nova_networks.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_nova_networks.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -185,15 +218,15 @@ public void testCreateNodeWithGroupEncodedIntoNameWhenSecurityGroupsArePresent() HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"}, {\"name\":\"group2\"}]}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"}, {\"name\":\"group2\"}]}}", "application/json")) .build(); HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -207,7 +240,7 @@ public void testCreateNodeWithGroupEncodedIntoNameWhenSecurityGroupsArePresent() Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build(); template.getOptions().as(NovaTemplateOptions.class).securityGroupNames("group1", "group2"); - + NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", @@ -222,20 +255,20 @@ public void testCreateNodeWithGroupEncodedIntoNameWhenSecurityGroupsArePresent() * authentication even be available. */ public void testWhenKeyPairPresentWeUsePrivateKeyAsCredentialNotPassword() throws Exception { - + HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"key_name\":\"foo\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"key_name\":\"foo\"}}", "application/json")) .build(); - + HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -249,16 +282,16 @@ public void testWhenKeyPairPresentWeUsePrivateKeyAsCredentialNotPassword() throw Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build(); template.getOptions().as(NovaTemplateOptions.class).keyPairName("foo"); - + NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); - + // we expect to have already an entry in the cache for the key LoadingCache keyPairCache = forSecurityGroups.getInstance(Key .get(new TypeLiteral>() { })); keyPairCache.put(ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "foo"), KeyPair.builder().name("foo") .privateKey("privateKey").build()); - + NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); @@ -272,19 +305,19 @@ public void testWhenKeyPairPresentWeUsePrivateKeyAsCredentialNotPassword() throw * inject, then you simply cannot log in to the server. */ public void testNoKeyPairOrAdminPass() throws Exception { - + HttpRequest createServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\"}}", "application/json")) .build(); - + HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_no_adminpass.json", "application/json; charset=UTF-8")).build(); Map requestResponseMap = ImmutableMap. builder() .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) @@ -297,20 +330,90 @@ public void testNoKeyPairOrAdminPass() throws Exception { Injector forSecurityGroups = requestsSendResponses(requestResponseMap); Template template = forSecurityGroups.getInstance(TemplateBuilder.class).build(); - + NovaComputeServiceAdapter adapter = forSecurityGroups.getInstance(NovaComputeServiceAdapter.class); - + NodeAndInitialCredentials server = adapter.createNodeWithGroupEncodedIntoName("test", "test-e92", template); assertNotNull(server); assertNull(server.getCredentials()); } - + + /** + * Test successful suspend/resume via ComputeService which depends on + * Admin extension being installed in OpenStack + */ + public void testSuspendWithAdminExtensionSucceeds() throws Exception { + + HttpRequest suspendServer = HttpRequest + .builder() + .method("POST") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752/action") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken) + .payload(payloadFromStringWithContentType( + "{\"suspend\":null}", "application/json")) + .build(); + + HttpResponse suspendServerResponse = HttpResponse.builder() + .statusCode(202) + .build(); + + Map requestResponseMap = ImmutableMap. builder() + .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) + .put(extensionsOfNovaRequest, extensionsOfNovaResponse) + .put(listDetail, listDetailResponse) + .put(listFlavorsDetail, listFlavorsDetailResponse) + .put(suspendServer, suspendServerResponse) + .put(serverDetail, serverDetailResponse).build(); + + Injector forAdminExtension = requestsSendResponses(requestResponseMap); + + ComputeService computeService = forAdminExtension.getInstance(ComputeService.class); + + computeService.suspendNode("az-1.region-a.geo-1/71752"); + } + + /** + * Test failed suspend/resume via ComputeService which depends on + * Admin extension being installed in OpenStack. Throws UOE if extension is missing. + */ + @Test(expectedExceptions = UnsupportedOperationException.class) + public void testSuspendWithoutAdminExtensionThrowsUOE() throws Exception { + + HttpRequest suspendServer = HttpRequest + .builder() + .method("POST") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752/action") + .addHeader("X-Auth-Token", authToken) + .payload(payloadFromStringWithContentType( + "{\"suspend\":null}", "application/json")) + .build(); + + HttpResponse suspendServerResponse = HttpResponse.builder() + .statusCode(202) + .build(); + + Map requestResponseMap = ImmutableMap. builder() + .put(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess) + .put(extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse) + .put(listDetail, listDetailResponse) + .put(listFlavorsDetail, listFlavorsDetailResponse) + .put(suspendServer, suspendServerResponse) + .put(serverDetail, serverDetailResponse).build(); + + Injector forAdminExtension = requestsSendResponses(requestResponseMap); + + ComputeService compute = forAdminExtension.getInstance(ComputeService.class); + + compute.suspendNode("az-1.region-a.geo-1/71752"); + } + @Override public Injector apply(ComputeServiceContext input) { return input.utils().injector(); } - + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java similarity index 91% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java index 188896390e..f62e97e04f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceExpectTest.java @@ -20,6 +20,7 @@ import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.blockUntilRunning; import static org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions.Builder.keyPairName; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -46,8 +47,6 @@ /** * Tests the compute service abstraction of the nova api. - * - * @author Matt Stephenson */ @Test(groups = "unit", testName = "NovaComputeServiceExpectTest") public class NovaComputeServiceExpectTest extends BaseNovaComputeServiceExpectTest { @@ -79,7 +78,7 @@ public void testListLocationsWhenResponseIs2xx() throws Exception { assertNotNull(apiWhenServersExist.listNodes()); assertEquals(apiWhenServersExist.listNodes().size(), 1); assertEquals(apiWhenServersExist.listNodes().iterator().next().getId(), - "az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f000004d2"); + "az-1.region-a.geo-1/71752"); assertEquals(apiWhenServersExist.listNodes().iterator().next().getName(), "sample-server"); } @@ -94,18 +93,18 @@ public void testListLocationsWhenResponseIs2xx() throws Exception { payloadFromResourceWithContentType("/keystoneAuthResponse_openstack.json", "application/json")) .build()) .put(extensionsOfNovaRequest.toBuilder() - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/extensions").build(), + .endpoint("https://nova-api.openstack.org:9774/v2/3456/extensions").build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/extension_list_openstack.json")) .build()) .put(listDetail.toBuilder() - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/images/detail").build(), + .endpoint("https://nova-api.openstack.org:9774/v2/3456/images/detail").build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/image_list_detail_openstack.json")) .build()) .put(listServers.toBuilder() - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers/detail").build(), + .endpoint("https://nova-api.openstack.org:9774/v2/3456/servers/detail").build(), listServersResponse) .put(listFlavorsDetail.toBuilder() - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/flavors/detail").build(), + .endpoint("https://nova-api.openstack.org:9774/v2/3456/flavors/detail").build(), HttpResponse.builder().statusCode(200).payload(payloadFromResource("/flavor_list_detail_openstack.json")) .build()).build(); @@ -132,7 +131,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest listServers = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/detail") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -147,7 +146,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/os-security-groups") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -156,7 +155,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest createWithPrefixOnGroup = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/os-security-groups") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -170,7 +169,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest createRuleForDefaultPort22 = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-group-rules") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -184,7 +183,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest getSecurityGroup = HttpRequest .builder() .method("GET") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-security-groups/160") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/os-security-groups/160") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -194,7 +193,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest create = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/os-keypairs") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -208,7 +207,7 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { HttpRequest serverDetail = HttpRequest .builder() .method("GET") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers/71752") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/servers/71752") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -234,7 +233,7 @@ public void testCreateNodeWithGeneratedKeyPair() throws Exception { HttpRequest createServerWithGeneratedKeyPair = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -269,7 +268,7 @@ public String get() { NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, blockUntilRunning(false).generateKeyPair(true))); - assertNotNull(node.getCredentials().getPrivateKey()); + assertTrue(node.getCredentials().getOptionalPrivateKey().isPresent()); } @Test @@ -289,7 +288,7 @@ public void testCreateNodeWhileUserSpecifiesKeyPair() throws Exception { HttpRequest createServerWithSuppliedKeyPair = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -325,7 +324,7 @@ public String get() { NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, keyPairName("fooPair").blockUntilRunning(false))); // we don't have access to this private key - assertEquals(node.getCredentials().getPrivateKey(), null); + assertFalse(node.getCredentials().getOptionalPrivateKey().isPresent()); } @@ -340,7 +339,7 @@ public void testCreateNodeWhileUserSpecifiesKeyPairAndUserSpecifiedGroups() thro HttpRequest createServerWithSuppliedKeyPairAndGroup = HttpRequest .builder() .method("POST") - .endpoint("https://nova-api.openstack.org:9774/v1.1/3456/servers") + .endpoint("https://nova-api.openstack.org:9774/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -376,7 +375,7 @@ public String get() { NodeMetadata node = Iterables.getOnlyElement(apiThatCreatesNode.createNodesInGroup("test", 1, keyPairName("fooPair").securityGroupNames("mygroup").blockUntilRunning(false))); // we don't have access to this private key - assertEquals(node.getCredentials().getPrivateKey(), null); + assertFalse(node.getCredentials().getOptionalPrivateKey().isPresent()); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java index d20126ce52..f5e33ddb12 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/NovaComputeServiceLiveTest.java @@ -29,10 +29,6 @@ import com.google.inject.Module; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", singleThreaded = true, testName = "NovaComputeServiceLiveTest") public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java index afd289fd12..8021cb9cf0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionExpectTest.java @@ -32,10 +32,6 @@ import com.google.common.collect.ImmutableMap.Builder; import com.google.common.util.concurrent.Futures; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "NovaImageExtensionExpectTest") public class NovaImageExtensionExpectTest extends BaseNovaComputeServiceExpectTest { @@ -47,7 +43,7 @@ protected Properties setupProperties() { } HttpRequest serverDetail = HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -55,7 +51,7 @@ protected Properties setupProperties() { .payload(payloadFromResource("/server_details.json")).build(); HttpRequest createImage = HttpRequest.builder().method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71752/action") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71752/action") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -64,11 +60,11 @@ protected Properties setupProperties() { "application/json")).build(); HttpResponse createImageResponse = HttpResponse.builder().statusCode(202) - .addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") + .addHeader("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .build(); HttpRequest getImage = HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java index 463ff55d05..3e9cdf0520 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaImageExtensionLiveTest.java @@ -24,9 +24,6 @@ /** * Live test for openstack-nova {@link ImageExtension} implementation. - * - * @author David Alves - * */ @Test(groups = "live", singleThreaded = true, testName = "NovaImageExtensionLiveTest") public class NovaImageExtensionLiveTest extends BaseImageExtensionLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java index 809b4da28e..775490a9f8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionExpectTest.java @@ -44,16 +44,12 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; -/** - * - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "NovaSecurityGroupExtensionExpectTest") public class NovaSecurityGroupExtensionExpectTest extends BaseNovaComputeServiceExpectTest { protected String zone = "az-1.region-a.geo-1"; protected HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -83,7 +79,7 @@ public void testListSecurityGroups() { public void testListSecurityGroupsInLocation() { HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -108,7 +104,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testListSecurityGroupsForNode() { HttpRequest serverReq = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb")) + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb")) .headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -117,7 +113,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/server_with_security_groups_extension.json")).build(); HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -139,7 +135,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testGetSecurityGroupById() { HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -160,7 +156,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testCreateSecurityGroup() { HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -168,7 +164,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/securitygroup_details_extension.json")).build(); HttpRequest create = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()) .payload( @@ -180,7 +176,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/securitygroup_created.json")).build(); HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap.builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -206,7 +202,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testRemoveSecurityGroup() { HttpRequest delete = HttpRequest.builder().method("DELETE").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")) + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")) .headers( ImmutableMultimap.builder().put("Accept", "application/json") .put("X-Auth-Token", authToken).build()).build(); @@ -214,7 +210,7 @@ public void testRemoveSecurityGroup() { HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build(); HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -236,7 +232,7 @@ public void testAddIpPermissionCidrFromIpPermission() { HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -248,7 +244,7 @@ public void testAddIpPermissionCidrFromIpPermission() { payloadFromResource("/securitygrouprule_created_cidr.json")).build(); HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -285,7 +281,7 @@ public void testAddIpPermissionCidrFromParams() { HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -297,7 +293,7 @@ public void testAddIpPermissionCidrFromParams() { payloadFromResource("/securitygrouprule_created_cidr.json")).build(); HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -331,7 +327,7 @@ public void testAddIpPermissionGroupFromIpPermission() { HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -343,7 +339,7 @@ public void testAddIpPermissionGroupFromIpPermission() { payloadFromResource("/securitygrouprule_created_group.json")).build(); HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -380,7 +376,7 @@ public void testAddIpPermissionGroupFromParams() { HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -392,7 +388,7 @@ public void testAddIpPermissionGroupFromParams() { payloadFromResource("/securitygrouprule_created_group.json")).build(); HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java index 4a7dbed215..804d546abc 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/extensions/NovaSecurityGroupExtensionLiveTest.java @@ -21,9 +21,6 @@ /** * Live test for openstack-nova {@link org.jclouds.compute.extensions.SecurityGroupExtension} implementation. - * - * @author Andrew Bayer - * */ @Test(groups = "live", singleThreaded = true, testName = "NovaSecurityGroupExtensionLiveTest") public class NovaSecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java similarity index 66% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java index a5631caf5f..28cc5334a9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/AllocateAndAddFloatingIpToNodeExpectTest.java @@ -31,6 +31,8 @@ import org.jclouds.domain.LoginCredentials; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; +import org.jclouds.openstack.nova.v2_0.compute.options.NodeAndNovaTemplateOptions; +import org.jclouds.openstack.nova.v2_0.compute.options.NovaTemplateOptions; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaComputeServiceExpectTest; import org.testng.annotations.Test; @@ -41,8 +43,6 @@ /** * Tests the compute service abstraction of the nova api. - * - * @author Matt Stephenson */ @Test(groups = "unit", testName = "AllocateAndAddFloatingIpToNodeTest") public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeServiceExpectTest { @@ -55,9 +55,10 @@ public class AllocateAndAddFloatingIpToNodeExpectTest extends BaseNovaComputeSer final NodeMetadata node = new NodeMetadataBuilder().id("az-1.region-a.geo-1/71592").providerId("71592").location( host).name("Server 71592").status(Status.RUNNING).privateAddresses(ImmutableSet.of("10.4.27.237")) .credentials(LoginCredentials.builder().password("foo").build()).build(); + final NovaTemplateOptions options = NovaTemplateOptions.Builder.autoAssignFloatingIp(false); HttpRequest createFloatingIP = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).payload(payloadFromStringWithContentType("{}", "application/json")).build(); @@ -77,9 +78,13 @@ ImmutableMap. builder().put(keystoneAuthWithUsernameA .getInstance(AllocateAndAddFloatingIpToNode.class); AtomicReference nodeRef = Atomics.newReference(node); - fn.apply(nodeRef); + AtomicReference optionsRef = Atomics.newReference(options); + AtomicReference nodeNovaRef = NodeAndNovaTemplateOptions.newAtomicReference(nodeRef, optionsRef); + + fn.apply(nodeNovaRef); NodeMetadata node1 = nodeRef.get(); assertNotNull(node1); + assertNotNull(optionsRef.get()); assertEquals(node1.getPublicAddresses(), ImmutableSet.of("10.0.0.3")); assertEquals(node1.getCredentials(), node.getCredentials()); @@ -87,16 +92,16 @@ ImmutableMap. builder().put(keystoneAuthWithUsernameA private HttpRequest addFloatingIPForAddress(String address) { HttpRequest addFloatingIPRequest = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/71592/action")) + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/71592/action")) .headers( - ImmutableMultimap. builder().put("Accept", "*/*") + ImmutableMultimap. builder().put("Accept", "application/json") .put("X-Auth-Token", authToken).build()).payload( payloadFromStringWithContentType("{\"addFloatingIp\":{\"address\":\"" + address + "\"}}", "application/json")).build(); return addFloatingIPRequest; } - public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception { + public void testAllocateWhenAllocationFailsOn400LookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception { HttpResponse createFloatingIPResponse = HttpResponse .builder() .statusCode(400) @@ -106,7 +111,7 @@ public void testAllocateWhenAllocationFailsLookupUnusedIpAddToServerAndUpdatesNo "application/json")).build(); HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -124,10 +129,51 @@ ImmutableMap. builder().put(keystoneAuthWithUsernameA .getInstance(AllocateAndAddFloatingIpToNode.class); AtomicReference nodeRef = Atomics.newReference(node); - fn.apply(nodeRef); + AtomicReference optionsRef = Atomics.newReference(options); + AtomicReference nodeNovaRef = NodeAndNovaTemplateOptions.newAtomicReference(nodeRef, optionsRef); + + fn.apply(nodeNovaRef); NodeMetadata node1 = nodeRef.get(); assertNotNull(node1); + assertNotNull(optionsRef.get()); assertEquals(node1.getPublicAddresses(), ImmutableSet.of("10.0.0.5")); + } + + public void testAllocateWhenAllocationFailsOn404LookupUnusedIpAddToServerAndUpdatesNodeMetadata() throws Exception { + HttpResponse createFloatingIPResponse = HttpResponse + .builder() + .statusCode(404) + .payload( + payloadFromStringWithContentType( + "{\"badRequest\": {\"message\": \"AddressLimitExceeded: Address quota exceeded. You cannot create any more addresses\", \"code\": 404}}", + "application/json")).build(); + + HttpRequest list = HttpRequest.builder().method("GET").endpoint( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")).headers( + ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", + authToken).build()).build(); + + HttpResponse listResponseForUnassigned = HttpResponse.builder().statusCode(200).payload( + payloadFromResource("/floatingip_list.json")).build(); + HttpRequest addFloatingIPRequest = addFloatingIPForAddress("10.0.0.5"); + + AllocateAndAddFloatingIpToNode fn = requestsSendResponses( + ImmutableMap. builder().put(keystoneAuthWithUsernameAndPasswordAndTenantName, + responseWithKeystoneAccess).put(extensionsOfNovaRequest, extensionsOfNovaResponse).put( + createFloatingIP, createFloatingIPResponse) + .put(addFloatingIPRequest, addFloatingIPResponse).put(list, + listResponseForUnassigned).build()).getContext().utils().injector() + .getInstance(AllocateAndAddFloatingIpToNode.class); + + AtomicReference nodeRef = Atomics.newReference(node); + AtomicReference optionsRef = Atomics.newReference(options); + AtomicReference nodeNovaRef = NodeAndNovaTemplateOptions.newAtomicReference(nodeRef, optionsRef); + + fn.apply(nodeNovaRef); + NodeMetadata node1 = nodeRef.get(); + assertNotNull(node1); + assertNotNull(optionsRef.get()); + assertEquals(node1.getPublicAddresses(), ImmutableSet.of("10.0.0.5")); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java index b3a0e30510..6e0e00157c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/FlavorInZoneToHardwareTest.java @@ -37,8 +37,6 @@ /** * Tests the function used to transform Flavor objects into Hardware objects - * - * @author Matt Stephenson, Adrian Cole */ @Test(testName = "FlavorInZoneToHardwareTest") public class FlavorInZoneToHardwareTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java index dfc15f47d4..98722424e9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageInZoneToImageTest.java @@ -39,8 +39,6 @@ /** * Tests the function that transforms nova-specific images to generic images. - * - * @author Matt Stephenson, Adrian Cole */ @Test(testName = "ImageInZoneToHardwareTest") public class ImageInZoneToImageTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java index 2fdc0a4263..cc91b6012a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ImageToOperatingSystemTest.java @@ -38,8 +38,6 @@ /** * Tests for the function for transforming a nova specific Image into a generic * OperatingSystem object. - * - * @author Matt Stephenson */ public class ImageToOperatingSystemTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java index c884987452..dceba6c072 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupInZoneToSecurityGroupTest.java @@ -35,9 +35,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "NovaSecurityGroupInZoneToSecurityGroupTest") public class NovaSecurityGroupInZoneToSecurityGroupTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java index 675408778e..1a964b66df 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/NovaSecurityGroupToSecurityGroupTest.java @@ -44,9 +44,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "NovaSecurityGroupToSecurityGroupTest") public class NovaSecurityGroupToSecurityGroupTest { @@ -65,7 +62,7 @@ public class NovaSecurityGroupToSecurityGroupTest { ZoneAndName.fromZoneAndName("az-1.region-a.geo-1", "some-other-group"), new SecurityGroupInZone(securityGroupWithCidr(), "az-1.region-a.geo-1")); // weird compilation error means have to declare extra generics for call to build() - see https://bugs.eclipse.org/bugs/show_bug.cgi?id=365818 - private static final Supplier > groupCache = Suppliers.> ofInstance( + private static final Supplier > groupCache = Suppliers.> ofInstance( CacheBuilder.newBuilder().build(CacheLoader.from(Functions.forMap(groupMap)))); public static final SecurityGroupRuleToIpPermission ruleConverter = new SecurityGroupRuleToIpPermission(returnSecurityGroupExistsInZone, locationIndex, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java index 1f520dc99b..b6ae064c5d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/OrphanedGroupsByZoneIdTest.java @@ -42,11 +42,6 @@ import com.google.common.collect.ImmutableSet; import com.google.inject.Guice; -/** - * - * - * @author Adrian Cole - */ @Test(testName = "OrphanedGroupsByZoneIdTest") public class OrphanedGroupsByZoneIdTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java index 59c59d0356..dedf100bfe 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/SecurityGroupRuleToIpPermissionTest.java @@ -31,8 +31,6 @@ /** * Tests for the function for transforming a nova specific SecurityGroupRule into a generic * IpPermission object. - * - * @author Andrew Bayer */ public class SecurityGroupRuleToIpPermissionTest { @@ -56,7 +54,7 @@ public void testApplyWithGroup() { assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort()); assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort()); assertTrue(convertedPerm.getGroupIds().contains("az-1.region-a.geo-1/some-id")); - assertTrue(convertedPerm.getCidrBlocks().size() == 0); + assertEquals(convertedPerm.getCidrBlocks().size(), 0); } @Test @@ -76,6 +74,6 @@ public void testApplyWithCidr() { assertEquals(convertedPerm.getFromPort(), ruleToConvert.getFromPort()); assertEquals(convertedPerm.getToPort(), ruleToConvert.getToPort()); assertEquals(convertedPerm.getCidrBlocks(), ImmutableSet.of("0.0.0.0/0")); - assertTrue(convertedPerm.getTenantIdGroupNamePairs().size() == 0); + assertEquals(convertedPerm.getTenantIdGroupNamePairs().size(), 0); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java similarity index 89% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java index 7ef9fa7047..b5c16464e2 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/functions/ServerInZoneToNodeMetadataTest.java @@ -18,6 +18,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertNull; import java.net.URI; import java.util.Map; @@ -39,6 +40,7 @@ import org.jclouds.openstack.nova.v2_0.domain.Server; import org.jclouds.openstack.nova.v2_0.domain.zonescoped.ServerInZone; import org.jclouds.openstack.nova.v2_0.parse.ParseServerTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseServerWithoutImageTest; import org.jclouds.openstack.v2_0.domain.Link; import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.Test; @@ -52,8 +54,6 @@ /** * Tests for the function for transforming a nova specific Server into a generic * NodeMetadata object. - * - * @author Matt Stephenson, Adam Lowe, Adrian Cole */ @Test(testName = "ServerInZoneToNodeMetadataTest") public class ServerInZoneToNodeMetadataTest { @@ -196,7 +196,37 @@ public void testAlternateAccessIPs() { assertEquals(convertedNodeMetadata.getPublicAddresses(), ImmutableSet.of("67.23.10.132", "67.23.10.131", "76.32.1.231")); } - // TODO: clean up this syntax + @Test + public void testPortableNodeStatusNotNull() { + for (Server.Status serverStatus : Server.Status.values()) { + assertNotNull(NovaComputeServiceContextModule.toPortableNodeStatus.get(serverStatus)); + } + } + + @Test + public void testServerWithoutImage() { + Hardware existingHardware = new HardwareBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f216543fd") + .providerId("52415800-8b69-11e0-9b19-734f216543fd").location(zone).build(); + Image existingImage = new ImageBuilder().id("az-1.region-a.geo-1/52415800-8b69-11e0-9b19-734f6f006e54") + .operatingSystem(OperatingSystem.builder().family(OsFamily.LINUX).description("foobuntu").build()) + .providerId("52415800-8b69-11e0-9b19-734f6f006e54").description("foobuntu").status(Image.Status.AVAILABLE) + .location(zone).build(); + + Server serverToConvert = new ParseServerWithoutImageTest().expected(); + ServerInZone serverInZoneToConvert = new ServerInZone(serverToConvert, "az-1.region-a.geo-1"); + + ServerInZoneToNodeMetadata converter = new ServerInZoneToNodeMetadata( + NovaComputeServiceContextModule.toPortableNodeStatus, locationIndex, + Suppliers.> ofInstance(ImmutableSet.of(existingImage)), + Suppliers.> ofInstance(ImmutableSet.of(existingHardware)), + namingConvention); + + NodeMetadata convertedNodeMetadata = converter.apply(serverInZoneToConvert); + + assertNull(convertedNodeMetadata.getImageId()); + } + + // TODO: clean up this syntax private void checkHardwareAndImageStatus(Hardware expectedHardware, Hardware existingHardware, String expectedImageId, OperatingSystem expectedOs, Image existingImage) { @@ -243,8 +273,8 @@ private void checkHardwareAndImageStatus(Hardware expectedHardware, Hardware exi assertNotNull(convertedNodeMetadata.getUserMetadata()); assertEquals(convertedNodeMetadata.getUserMetadata(), ImmutableMap. of("Server Label", "Web Head 1", "Image Version", "2.1")); - - URI expectedURI = URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"); + + URI expectedURI = URI.create("http://servers.api.openstack.org/v2/1234/servers/71752"); assertEquals(convertedNodeMetadata.getUri(), expectedURI); } @@ -270,7 +300,7 @@ public void testNewServerWithoutHostIdSetsZoneAsLocation() { assertEquals(convertedNodeMetadata.getLocation(), zone); - URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752"); + URI expectedURI = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752"); assertEquals(convertedNodeMetadata.getUri(), expectedURI); } @@ -304,7 +334,7 @@ public Server expectedServer() { URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100"))) .build()) .links( - Link.create(Link.Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")), + Link.create(Link.Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752")), Link.create(Link.Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java index 9bca8e13df..269864341a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/CreateUniqueKeyPairTest.java @@ -37,9 +37,6 @@ import com.google.inject.Guice; import com.google.inject.TypeLiteral; -/** - * @author Adam Lowe - */ @Test(groups = "unit", testName = "CreateUniqueKeyPairTest") public class CreateUniqueKeyPairTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java index 62f45fd4a4..81bf3b0688 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/FindSecurityGroupOrCreateTest.java @@ -34,9 +34,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "FindSecurityGroupOrCreateTest") public class FindSecurityGroupOrCreateTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java index 771d63fe04..c31e684002 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/loaders/LoadFloatingIpsForInstanceTest.java @@ -34,9 +34,6 @@ import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableSet; -/** - * @author Adam Lowe - */ @Test(groups = "unit", singleThreaded = true, testName = "LoadFloatingIpsForInstanceTest") public class LoadFloatingIpsForInstanceTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java index 106da5bf5b..94c9919308 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/compute/options/NovaTemplateOptionsTest.java @@ -36,8 +36,6 @@ /** * Tests possible uses of NovaTemplateOptions and NovaTemplateOptions.Builder.* - * - * @author Adrian Cole */ @Test(testName = "NovaTemplateOptionsTest") public class NovaTemplateOptionsTest { @@ -203,7 +201,7 @@ public void testDiskConfig() { options.diskConfig(Server.DISK_CONFIG_AUTO); assertEquals(options.getDiskConfig(), Server.DISK_CONFIG_AUTO); } - + @Test(expectedExceptions = IllegalArgumentException.class) public void testblockOnPortBadFormat() { NovaTemplateOptions options = new NovaTemplateOptions(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java index 32c4617e94..b3a80a79ac 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiExpectTest.java @@ -37,14 +37,12 @@ /** * Tests parsing and guice wiring of AdminActionsApi - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "AdminActionsApiExpectTest") public class AdminActionsApiExpectTest extends BaseNovaApiExpectTest { public void testSuspend() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -56,7 +54,7 @@ public void testSuspend() { } public void testSuspendFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -69,7 +67,7 @@ public void testSuspendFailsNotFound() { @Test(expectedExceptions = AuthorizationException.class) public void testSuspendFailsNotAuthorized() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -81,7 +79,7 @@ public void testSuspendFailsNotAuthorized() { } public void testResume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -93,7 +91,7 @@ public void testResume() { } public void testResumeFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -106,7 +104,7 @@ public void testResumeFailsNotFound() { @Test(expectedExceptions = AuthorizationException.class) public void testResumeFailsNotAuthorized() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -118,7 +116,7 @@ public void testResumeFailsNotAuthorized() { } public void testLock() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -130,7 +128,7 @@ public void testLock() { } public void testLockFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -142,7 +140,7 @@ public void testLockFailsNotFound() { } public void testUnlock() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -154,7 +152,7 @@ public void testUnlock() { } public void testUnlockFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -166,7 +164,7 @@ public void testUnlockFailsNotFound() { } public void testPause() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -178,7 +176,7 @@ public void testPause() { } public void testPauseFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -190,7 +188,7 @@ public void testPauseFailsNotFound() { } public void testUnpause() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -202,7 +200,7 @@ public void testUnpause() { } public void testUnpauseFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -214,7 +212,7 @@ public void testUnpauseFailsNotFound() { } public void testMigrateServer() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -227,7 +225,7 @@ public void testMigrateServer() { public void testMigrateServerFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -239,7 +237,7 @@ public void testMigrateServerFailsNotFound() { } public void testResetNetworkOfServer() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -251,7 +249,7 @@ public void testResetNetworkOfServer() { } public void testResetNetworkOfServerFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -263,7 +261,7 @@ public void testResetNetworkOfServerFailsNotFound() { } public void testInjectNetworkInfoIntoServer() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -275,7 +273,7 @@ public void testInjectNetworkInfoIntoServer() { } public void testInjectNetworkInfoIntoServerFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -290,7 +288,7 @@ public void testBackupServer() { ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, - authenticatedGET().endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action").method("POST") + authenticatedGET().endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action").method("POST") .payload(payloadFromStringWithContentType("{\"createBackup\":{\"backup_type\":\"weekly\",\"rotation\":3,\"name\":\"mybackup\",\"metadata\":{\"some\":\"data or other\"}}}", MediaType.APPLICATION_JSON)).build(), HttpResponse.builder().statusCode(202).addHeader("Location", "http://172.16.89.149:8774/v2/images/1976b3b3-409a-468d-b16c-a9172c341b46").build() ).getServerAdminExtensionForZone("az-1.region-a.geo-1").get(); @@ -301,7 +299,7 @@ public void testBackupServer() { @Test(expectedExceptions = ResourceNotFoundException.class) public void testBackupServerFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -314,7 +312,7 @@ public void testBackupServerFailNotFound() { } public void testLiveMigrateServer() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -327,7 +325,7 @@ public void testLiveMigrateServer() { } public void testLiveMigrateServerFailsNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/action"); ServerAdminApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -343,6 +341,7 @@ protected HttpRequest.Builder standardActionRequestBuilderVoidResponse(URI en return HttpRequest.builder() .method("POST") .addHeader("X-Auth-Token", authToken) + .addHeader("Accept", "application/json") .payload(payloadFromStringWithContentType("{\"" + actionName + "\":null}", MediaType.APPLICATION_JSON)) .endpoint(endpoint); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java index 1d150583c2..37f6f376e9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AdminActionsApiLiveTest.java @@ -44,8 +44,6 @@ * Tests behavior of HostAdministrationApi * * TODO test migration methods - * - * @author Adam Lowe */ @Test(groups = "live", testName = "AdminActionsApiLiveTest", singleThreaded = true) public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java similarity index 58% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java index f033a1b266..bc2eba4ef9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZoneApiExpectTest.java @@ -1,20 +1,18 @@ -/** - * Licensed to jclouds, Inc. (jclouds) under one or more - * contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. jclouds 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 +/* + * 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 + * 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. + * 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.jclouds.openstack.nova.v2_0.extensions; @@ -31,17 +29,14 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; -/** - * @author Inbar Stolberg - */ @Test(groups = "unit", testName = "AvailabilityZoneApiExpectTest") public class AvailabilityZoneApiExpectTest extends BaseNovaApiExpectTest { - public void testLAvailabilityZonesList() throws Exception { + public void testAvailabilityZonesList() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-availability-zone") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-availability-zone") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -53,12 +48,12 @@ public void testLAvailabilityZonesList() throws Exception { assertEquals(availabilityZonesApi.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); - FluentIterable zones = availabilityZonesApi.getAvailabilityZoneApi("az-1.region-a.geo-1").list(); + FluentIterable zones = availabilityZonesApi.getAvailabilityZoneApi("az-1.region-a.geo-1").get().list(); Optional zone = zones.first(); assertTrue(zone.isPresent(), "Couldn't find zone"); - assertTrue(zone.get().getName().equals("nova"), "Expected zone name to be nova but it was: " + zone.get().getName()); - assertTrue(zone.get().getState().available(), "Zone: "+ zone.get().getName() + " is not available."); + assertEquals(zone.get().getName(), "nova", "Expected zone name to be nova but it was: " + zone.get().getName()); + assertTrue(zone.get().getState().available(), "Zone: " + zone.get().getName() + " is not available."); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java new file mode 100644 index 0000000000..3cadf68910 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/AvailabilityZonesApiLiveTest.java @@ -0,0 +1,43 @@ +/* + * 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.jclouds.openstack.nova.v2_0.extensions; + +import com.google.common.base.Optional; +import com.google.common.collect.FluentIterable; +import org.jclouds.openstack.nova.v2_0.domain.zonescoped.AvailabilityZone; +import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; +import org.testng.annotations.Test; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +@Test(groups = "live", testName = "AvailabilityZonesApiLiveTest") +public class AvailabilityZonesApiLiveTest extends BaseNovaApiLiveTest { + + @Test + public void testListAvailabilityZones() throws Exception { + + Optional availabilityZoneApi = api.getAvailabilityZoneApi("RegionOne"); + if (availabilityZoneApi.isPresent()) { + FluentIterable zones = availabilityZoneApi.get().list(); + + for (AvailabilityZone zone : zones) { + assertNotNull(zone.getName()); + assertTrue(zone.getState().available(), "zone: " + zone.getName() + " is not available."); + } + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiLiveTest.java new file mode 100644 index 0000000000..c74dbad49a --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiLiveTest.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.jclouds.openstack.nova.v2_0.extensions; + +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.features.ServerApi; +import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; +import org.testng.annotations.Test; + +import com.google.common.base.Optional; + +/** + * Tests behavior of {@code ConsolesApi} + */ +@Test(groups = "live", testName = "ConsolesApiLiveTest") +public class ConsolesApiLiveTest extends BaseNovaApiLiveTest { + + public void testGetNOVNCConsole() { + testGetConsole(Console.Type.NOVNC); + } + + public void testGetXVPVNCConsole() { + testGetConsole(Console.Type.XVPVNC); + } + + private void testGetConsole(Console.Type consoleType) { + for (String zoneId : api.getConfiguredZones()) { + Optional apiOption = api.getConsolesExtensionForZone(zoneId); + if (!apiOption.isPresent()) { + System.err.println("Consoles extension not present in server."); + continue; + } + + ConsolesApi api = apiOption.get(); + ServerApi serverApi = this.api.getServerApiForZone(zoneId); + Server server = createServerInZone(zoneId); + Console console = api.getConsole(server.getId(), consoleType); + assertNotNull(console.getType()); + assertTrue(consoleType.equals(console.getType())); + assertNotNull(console.getUrl()); + assertTrue(console.getUrl().toString().startsWith("http")); + serverApi.delete(server.getId()); + } + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiMockTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiMockTest.java new file mode 100644 index 0000000000..c636603d85 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ConsolesApiMockTest.java @@ -0,0 +1,144 @@ +/* + * 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.jclouds.openstack.nova.v2_0.extensions; + +import static com.google.common.collect.Iterables.getFirst; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNull; +import static org.testng.Assert.fail; + +import org.jclouds.openstack.nova.v2_0.NovaApi; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.openstack.nova.v2_0.parse.ParseNOVNCConsoleTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseRDPConsoleTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseSPICEConsoleTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseXVPVNCConsoleTest; +import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest; +import org.testng.annotations.Test; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; + +/** + * Tests ConsolesApi Guice wiring and parsing + */ +@Test(groups = "unit", testName = "ConsolesApiMockTest", enabled = false) +public class ConsolesApiMockTest extends BaseOpenStackMockTest { + + public void testNullConsoleType() { + assertNull(Console.Type.fromValue(null)); + } + + public void testUnrecognizedConsoleType() { + assertEquals(Console.Type.UNRECOGNIZED, Console.Type.fromValue("invalid type")); + } + + public void getNOVNCConsole() throws Exception { + getConsole(Console.Type.NOVNC, "/novnc_console.json", new ParseNOVNCConsoleTest().expected()); + } + + public void getNOVNCConsoleWhenResponseIs404NotFound() throws Exception { + getConsoleWhenResponseIs404NotFound(Console.Type.NOVNC); + } + + public void getXVPVNCConsole() throws Exception { + getConsole(Console.Type.XVPVNC, "/xvpvnc_console.json", new ParseXVPVNCConsoleTest().expected()); + } + + public void getXVPVNCConsoleWhenResponseIs404NotFound() throws Exception { + getConsoleWhenResponseIs404NotFound(Console.Type.XVPVNC); + } + + public void getSPICEConsole() throws Exception { + getConsole(Console.Type.SPICE_HTML5, "/spice_console.json", new ParseSPICEConsoleTest().expected()); + } + + public void getSPICEConsoleWhenResponseIs404NotFound() throws Exception { + getConsoleWhenResponseIs404NotFound(Console.Type.SPICE_HTML5); + } + + public void getRDPConsole() throws Exception { + getConsole(Console.Type.RDP_HTML5, "/rdp_console.json", new ParseRDPConsoleTest().expected()); + } + + public void getRDPConsoleWhenResponseIs404NotFound() throws Exception { + getConsoleWhenResponseIs404NotFound(Console.Type.RDP_HTML5); + } + + private void getConsole(Console.Type consoleType, String responseResource, Console expected) throws Exception { + String serverId = "5f64fca7-879b-4173-bf9c-8fa88330a4dc"; + + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/keystoneAuthResponse.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource(responseResource)))); + + try { + NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova"); + + String zoneId = getFirst(novaApi.getConfiguredZones(), "RegionTwo"); + + ConsolesApi consolesApi = novaApi.getConsolesExtensionForZone(zoneId).get(); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertEquals(server.takeRequest().getRequestLine(), + "GET /v2/da0d12be20394afb851716e10a49e4a7/extensions HTTP/1.1"); + assertEquals(consolesApi.getConsole(serverId, consoleType), expected); + + } finally { + server.shutdown(); + } + } + + private void getConsoleWhenResponseIs404NotFound(Console.Type consoleType) throws Exception { + String serverId = "5f64fca7-879b-4173-bf9c-8fa88330a4dc"; + + MockWebServer server = mockOpenStackServer(); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/access.json")))); + server.enqueue(addCommonHeaders(new MockResponse().setBody(stringFromResource("/extension_list_full.json")))); + server.enqueue(addCommonHeaders(new MockResponse() + .setStatus("HTTP/1.1 404 Not Found") + .setBody("{\"itemNotFound\":" + "{\"message\":\"Instance " + serverId + + " could not be found.\",\"code\":404}}") + .setHeader("Content-Type", "application/json; charset=UTF-8"))); + + try { + NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova"); + + String zoneId = getFirst(novaApi.getConfiguredZones(), "RegionTwo"); + + ConsolesApi consolesApi = novaApi.getConsolesExtensionForZone(zoneId).get(); + + assertEquals(server.getRequestCount(), 2); + assertAuthentication(server); + assertEquals(server.takeRequest().getRequestLine(), + "GET /v2/da0d12be20394afb851716e10a49e4a7/extensions HTTP/1.1"); + + try { + consolesApi.getConsole(serverId, consoleType); + fail("expected a ResourceNotFoundException"); + } catch (org.jclouds.rest.ResourceNotFoundException e) { + // expected + } + + } finally { + server.shutdown(); + } + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java similarity index 92% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java index b04b5f2228..eb1009af82 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiExpectTest.java @@ -33,14 +33,12 @@ /** * Tests guice wiring and parsing of FlavorExtraSpecsApi - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "FlavorExtraSpecsApiExpectTest") public class FlavorExtraSpecsApiExpectTest extends BaseNovaApiExpectTest { public void testGetAllExtraSpecs() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/9/os-extra_specs"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -52,7 +50,7 @@ public void testGetAllExtraSpecs() { } public void testGetAllExtraSpecsFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/9/os-extra_specs"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -64,7 +62,7 @@ public void testGetAllExtraSpecsFailNotFound() { } public void testSetAllExtraSpecs() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/9/os-extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/9/os-extra_specs"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -78,7 +76,7 @@ public void testSetAllExtraSpecs() { } public void testSetExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -92,7 +90,7 @@ public void testSetExtraSpec() { } public void testGetExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -104,7 +102,7 @@ public void testGetExtraSpec() { } public void testGetExtraSpecFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -116,7 +114,7 @@ public void testGetExtraSpecFailNotFound() { } public void testDeleteExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -128,7 +126,7 @@ public void testDeleteExtraSpec() { } public void testDeleteExtraSpecFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/5/os-extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/5/os-extra_specs/test1"); FlavorExtraSpecsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java index d95832433f..b7a6d9ca6b 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FlavorExtraSpecsApiLiveTest.java @@ -36,8 +36,6 @@ /** * Tests behavior of FlavorExtraSpecsApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "FlavorExtraSpecsApiLiveTest", singleThreaded = true) public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java index 65cf1d495a..4647c4183d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiExpectTest.java @@ -32,9 +32,7 @@ import com.google.common.collect.ImmutableSet; /** - * Tests annotation parsing of {@code FloatingIPAsyncApi} - * - * @author Michael Arnold + * Tests annotation parsing of {@code FloatingIPApi} */ @Test(groups = "unit", testName = "FloatingIPApiExpectTest") public class FloatingIPApiExpectTest extends BaseNovaApiExpectTest { @@ -64,7 +62,7 @@ public void testListFloatingIPsWhenResponseIs2xx() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -84,7 +82,7 @@ public void testListFloatingIPsWhenResponseIs404() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -100,7 +98,7 @@ public void testGetFloatingIPWhenResponseIs2xx() throws Exception { HttpRequest get = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips/1") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -118,7 +116,7 @@ public void testGetFloatingIPWhenResponseIs404() throws Exception { HttpRequest get = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips/1") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -134,7 +132,7 @@ public void testAllocateWhenResponseIs2xx() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{}", "application/json")).build(); @@ -155,7 +153,7 @@ public void testAllocateWhenResponseIs404() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{}", "application/json")).build(); @@ -173,7 +171,7 @@ public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception { HttpRequest createFloatingIP = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{\"pool\":\"myPool\"}", "application/json")).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java index d85604c2ef..f65914f0d2 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/FloatingIPApiLiveTest.java @@ -34,9 +34,7 @@ import com.google.common.collect.Multimap; /** - * Tests behavior of {@code ServerApi} - * - * @author Adrian Cole + * Tests the behavior of the {@link FloatingIPApi} */ @Test(groups = "live", testName = "FloatingIPApiLiveTest") public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest { @@ -60,7 +58,7 @@ public void testListFloatingIPs() throws Exception { assertEquals(newDetails.getIp(), ip.getIp()); assertEquals(newDetails.getFixedIp(), ip.getFixedIp()); assertEquals(newDetails.getInstanceId(), ip.getInstanceId()); - + assertEquals(newDetails.getPool(), ip.getPool()); } } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java index 97861e364c..3b3f01f81c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiExpectTest.java @@ -38,15 +38,13 @@ /** * Tests HostAdministrationApi guice wiring and parsing (including the Response parsers in FieldValueResponseParsers) - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "HostAdministrationApiExpectTest") public class HostAdministrationApiExpectTest extends BaseNovaApiExpectTest { public void testList() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") @@ -66,7 +64,7 @@ public void testList() { } public void testGet() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/xyz"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/xyz"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") @@ -86,7 +84,7 @@ public void testGet() { } public void testEnableHost() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -102,7 +100,7 @@ public void testEnableHost() { @Test(expectedExceptions = ResourceNotFoundException.class) public void testEnableHostFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -116,7 +114,7 @@ public void testEnableHostFailNotFound() { } public void testEnableHostFailNotEnabled() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -131,7 +129,7 @@ public void testEnableHostFailNotEnabled() { } public void testDisableHost() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -146,7 +144,7 @@ public void testDisableHost() { } public void testStartMaintenance() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -161,7 +159,7 @@ public void testStartMaintenance() { } public void testStopMaintenance() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu"); HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("PUT") @@ -179,7 +177,7 @@ public void testStartupHost() { HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(), HttpResponse.builder().statusCode(200) @@ -193,7 +191,7 @@ public void testStartupHostFailNotFound() { HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(), HttpResponse.builder().statusCode(404).build()).getHostAdministrationExtensionForZone("az-1.region-a.geo-1").get(); @@ -204,7 +202,7 @@ public void testStartupHostFailWrongActionInProgress() { HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/startup") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/startup") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(), HttpResponse.builder().statusCode(200) @@ -217,7 +215,7 @@ public void testShutdownHost() { HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/shutdown") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/shutdown") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(), HttpResponse.builder().statusCode(200) @@ -230,7 +228,7 @@ public void testRebootHost() { HostAdministrationApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-hosts/ubuntu/reboot") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-hosts/ubuntu/reboot") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(), HttpResponse.builder().statusCode(200) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java index 814cd7dfa1..ab5ace0205 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAdministrationApiLiveTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of HostAdministrationApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "HostAdministrationApiLiveTest", singleThreaded = true) public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java index 4f0ac08ed4..8e192c190a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiExpectTest.java @@ -37,15 +37,13 @@ /** * Tests HostAggregateApi guice wiring and parsing - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "HostAggregateApiExpectTest") public class HostAggregateApiExpectTest extends BaseNovaApiExpectTest { private DateService dateService = new SimpleDateFormatDateService(); public void testList() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -57,7 +55,7 @@ public void testList() { } public void testGet() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -68,7 +66,7 @@ public void testGet() { } public void testGetFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -78,7 +76,7 @@ public void testGetFailNotFound() { } public void testCreateAggregate() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") @@ -91,7 +89,7 @@ public void testCreateAggregate() { } public void testDeleteAggregate() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("DELETE").build(), @@ -101,7 +99,7 @@ public void testDeleteAggregate() { } public void testDeleteAggregateFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("DELETE").build(), @@ -111,7 +109,7 @@ public void testDeleteAggregateFailNotFound() { } public void testUpdateName() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") @@ -122,7 +120,7 @@ public void testUpdateName() { } public void testUpdateAvailabilityZone() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") @@ -133,7 +131,7 @@ public void testUpdateAvailabilityZone() { } public void testAddHost() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") @@ -144,7 +142,7 @@ public void testAddHost() { } public void testRemoveHost() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") @@ -156,7 +154,7 @@ public void testRemoveHost() { public void testSetMetadata() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-aggregates/1/action"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-aggregates/1/action"); HostAggregateApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).method("POST") diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java index 5a237dbb34..49940a02ea 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/HostAggregateApiLiveTest.java @@ -37,8 +37,6 @@ /** * Tests behavior of AggregateApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "AggregateApiLiveTest", singleThreaded = true) public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java similarity index 75% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java index 55f0d58601..ea04fbea25 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiExpectTest.java @@ -18,6 +18,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertNull; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -30,9 +31,7 @@ import com.google.common.collect.ImmutableSet; /** - * Tests annotation parsing of {@code KeyPairAsyncApi} - * - * @author Michael Arnold + * Tests annotation parsing of {@code KeyPairApi} */ @Test(groups = "unit", testName = "KeyPairApiExpectTest") public class KeyPairApiExpectTest extends BaseNovaApiExpectTest { @@ -41,7 +40,7 @@ public void testListKeyPairsWhenResponseIs2xx() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -62,7 +61,7 @@ public void testListKeyPairsWhenResponseIs404() throws Exception { HttpRequest list = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -79,14 +78,14 @@ public void testCreateKeyPair() throws Exception { HttpRequest create = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}", "application/json")) .build(); HttpResponse createResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/keypair_created.json")).build(); + .payload(payloadFromResource("/keypair_details.json")).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse); @@ -100,7 +99,7 @@ public void testCreateKeyPairWithPublicKey() throws Exception { HttpRequest create = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -109,7 +108,7 @@ public void testCreateKeyPairWithPublicKey() throws Exception { "application/json")).build(); HttpResponse createResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/keypair_created.json")).build(); + .payload(payloadFromResource("/keypair_details.json")).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse); @@ -128,8 +127,8 @@ public void testDeleteKeyPair() throws Exception { HttpRequest delete = HttpRequest .builder() .method("DELETE") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs/testkeypair") - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair") + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); HttpResponse deleteResponse = HttpResponse.builder().statusCode(202).build(); @@ -139,4 +138,38 @@ public void testDeleteKeyPair() throws Exception { assertTrue(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().delete("testkeypair")); } + + public void testGetKeyPairWhenResponseIs2xx() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken).build(); + + HttpResponse getResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/keypair_details.json")).build(); + + NovaApi apiWhenKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, + responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse); + + assertEquals(apiWhenKeyPairExists.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().get("testkeypair"), + new ParseKeyPairTest().expected()); + } + + public void testGetKeyPairWhenResponseIs404() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs/testkeypair") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken).build(); + + HttpResponse getResponse = HttpResponse.builder().statusCode(404).build(); + + NovaApi apiWhenNoKeyPairExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, + responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse); + + assertNull(apiWhenNoKeyPairExists.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().get("testkeypair")); + } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java similarity index 59% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java index da2e1e499a..4edfed83a9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/KeyPairApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.openstack.nova.v2_0.extensions; +import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import org.jclouds.openstack.nova.v2_0.domain.KeyPair; @@ -25,13 +26,14 @@ import com.google.common.collect.FluentIterable; /** - * Tests behavior of {@code KeyPairApi} - * - * @author Michael Arnold + * Tests live behavior of {@code KeyPairApi} */ @Test(groups = "live", testName = "KeyPairApiLiveTest") public class KeyPairApiLiveTest extends BaseNovaApiLiveTest { + final String KEYPAIR_NAME = "testkp"; + final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002"; + public void testListKeyPairs() throws Exception { for (String zoneId : api.getConfiguredZones()) { KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get(); @@ -40,16 +42,20 @@ public void testListKeyPairs() throws Exception { } } - public void testCreateAndDeleteKeyPair() throws Exception { - final String KEYPAIR_NAME = "testkp"; + public void testCreateAndGetAndDeleteKeyPair() throws Exception { for (String zoneId : api.getConfiguredZones()) { KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get(); - KeyPair keyPair = null; + KeyPair createdKeyPair = null; try { - keyPair = keyPairApi.create(KEYPAIR_NAME); - assertNotNull(keyPair); + createdKeyPair = keyPairApi.create(KEYPAIR_NAME); + assertNotNull(createdKeyPair); + + KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); + assertEquals(keyPair.getName(), createdKeyPair.getName()); + assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); + assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { - if (keyPair != null) { + if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } @@ -57,17 +63,19 @@ public void testCreateAndDeleteKeyPair() throws Exception { } public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception { - final String KEYPAIR_NAME = "testkp"; - final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002"; - for (String zoneId : api.getConfiguredZones()) { KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get(); - KeyPair keyPair = null; + KeyPair createdKeyPair = null; try { - keyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); - assertNotNull(keyPair); + createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); + assertNotNull(createdKeyPair); + + KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); + assertEquals(keyPair.getName(), createdKeyPair.getName()); + assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); + assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { - if (keyPair != null) { + if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java index 79e6747645..fe876aa118 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiExpectTest.java @@ -33,14 +33,12 @@ /** * Tests HostAdministrationApi guice wiring and parsing - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "QuotaApiExpectTest") public class QuotaApiExpectTest extends BaseNovaApiExpectTest { public void testGetQuotas() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -50,7 +48,7 @@ public void testGetQuotas() throws Exception { } public void testGetQuotasFailsTenantNotFound() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -59,7 +57,7 @@ public void testGetQuotasFailsTenantNotFound() throws Exception { } public void testGetDefaultQuotas() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo/defaults"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -69,7 +67,7 @@ public void testGetDefaultQuotas() throws Exception { } public void testGetDefaultQuotasFailsTenantNotFound() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo/defaults"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo/defaults"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, authenticatedGET().endpoint(endpoint).build(), @@ -79,11 +77,12 @@ public void testGetDefaultQuotasFailsTenantNotFound() throws Exception { public void testUpdateQuotas() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().endpoint(endpoint).method("PUT") .addHeader("X-Auth-Token", authToken) + .addHeader("Accept", "application/json") .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON)) .build(), HttpResponse.builder().statusCode(200).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); @@ -93,11 +92,12 @@ public void testUpdateQuotas() throws Exception { @Test(expectedExceptions = ResourceNotFoundException.class) public void testUpdateQuotasFailsNotFound() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-quota-sets/demo"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-quota-sets/demo"); QuotaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().endpoint(endpoint).method("PUT") .addHeader("X-Auth-Token", authToken) + .addHeader("Accept", "application/json") .payload(payloadFromResourceWithContentType("/quotas.json", MediaType.APPLICATION_JSON)) .build(), HttpResponse.builder().statusCode(404).build()).getQuotaExtensionForZone("az-1.region-a.geo-1").get(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java index 140822314b..d0190dcc96 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/QuotaApiLiveTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of QuotaApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "QuotaApiLiveTest", singleThreaded = true) public class QuotaApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java index 1fa8416ae7..fe692ba3c6 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiExpectTest.java @@ -38,15 +38,13 @@ import com.google.common.collect.ImmutableSet; /** - * Tests annotation parsing of {@code SecurityGroupAsyncApi} - * - * @author Michael Arnold + * Tests annotation parsing of {@code SecurityGroupApi} */ @Test(groups = "unit", testName = "SecurityGroupApiExpectTest") public class SecurityGroupApiExpectTest extends BaseNovaApiExpectTest { public void testListSecurityGroupsWhenResponseIs2xx() throws Exception { HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -65,7 +63,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testListSecurityGroupsWhenReponseIs404IsEmpty() throws Exception { HttpRequest listListSecurityGroups = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -82,7 +80,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testGetSecurityGroupWhenResponseIs2xx() throws Exception { HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/0")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/0")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -99,7 +97,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testGetSecurityGroupWhenResponseIs404() throws Exception { HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/0")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/0")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -116,7 +114,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testCreateSecurityGroupWhenResponseIs2xx() throws Exception { HttpRequest create = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()) .payload( @@ -138,7 +136,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testDeleteSecurityGroupWhenResponseIs2xx() throws Exception { HttpRequest delete = HttpRequest.builder().method("DELETE").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/160")) + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/160")) .headers( ImmutableMultimap. builder().put("Accept", "application/json") .put("X-Auth-Token", authToken).build()).build(); @@ -158,7 +156,7 @@ public void testCreateSecurityGroupRuleForCidrBlockWhenResponseIs2xx() throws Ex HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -183,7 +181,7 @@ public void testCreateSecurityGroupRuleForSecurityGroupIdWhenResponseIs2xx() thr HttpRequest createRule = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload( @@ -206,9 +204,9 @@ public void testCreateSecurityGroupRuleForSecurityGroupIdWhenResponseIs2xx() thr public void testDeleteSecurityGroupRuleWhenResponseIs2xx() throws Exception { HttpRequest deleteRule = HttpRequest.builder().method("DELETE").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules/161")) + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules/161")) .headers( - ImmutableMultimap. builder().put("Accept", "*/*") + ImmutableMultimap. builder().put("Accept", "application/json") .put("X-Auth-Token", authToken).build()).build(); HttpResponse deleteRuleResponse = HttpResponse.builder().statusCode(202).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java index c0fb2df181..eaf9c0fe49 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SecurityGroupApiLiveTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code SecurityGroupApi} - * - * @author Michael Arnold */ @Test(groups = "live", testName = "SecurityGroupApiLiveTest", singleThreaded = true) public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java index 3eb95245f2..d770a05e53 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiExpectTest.java @@ -30,14 +30,12 @@ /** * Tests parsing and guice wiring of ServerWithSecurityGroupsApi - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "ServerWithSecurityGroupsApiExpectTest") public class ServerWithSecurityGroupsApiExpectTest extends BaseNovaApiExpectTest { public void testGetServerWithSecurityGroups() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); ServerWithSecurityGroupsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -51,7 +49,7 @@ public void testGetServerWithSecurityGroups() { } public void testGetServerWithSecurityGroupsFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-create-server-ext/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb"); ServerWithSecurityGroupsApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java index a4482535da..8be4f9a832 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/ServerWithSecurityGroupsApiLiveTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of ServerWithSecurityGroupsApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "ServerWithSecurityGroupsApiLiveTest", singleThreaded = true) public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java index cfb2393e08..d04dd8efa3 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiExpectTest.java @@ -37,15 +37,13 @@ /** * Tests SimpleTenantUsageApi guice wiring and parsing - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "SimpleTenantUsageApiExpectTest") public class SimpleTenantUsageApiExpectTest extends BaseNovaApiExpectTest { private DateService dateService = new SimpleDateFormatDateService(); public void testList() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-simple-tenant-usage"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-simple-tenant-usage"); SimpleTenantUsageApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") @@ -71,7 +69,7 @@ public void testList() throws Exception { } public void testGet() throws Exception { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-simple-tenant-usage/test-1234"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-simple-tenant-usage/test-1234"); SimpleTenantUsageApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, HttpRequest.builder().method("GET") diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java index f658d2615a..58b958129c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/SimpleTenantUsageApiLiveTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of SimpleTenantUsageApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "SimpleTenantUsageApiLiveTest") public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java index ab9be8d4fc..1e68dbab73 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiExpectTest.java @@ -30,14 +30,12 @@ /** * Tests parsing and guice wiring of VirtualInterfaceApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "VirtualInterfaceApiLiveTest") public class VirtualInterfaceApiExpectTest extends BaseNovaApiExpectTest { public void testListVirtualInterfaces() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/os-virtual-interfaces"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/os-virtual-interfaces"); VirtualInterfaceApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -51,7 +49,7 @@ public void testListVirtualInterfaces() { } public void testListVirtualInterfacesFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/1/os-virtual-interfaces"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/1/os-virtual-interfaces"); VirtualInterfaceApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java index 4f360352c4..c27d17c83e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VirtualInterfaceApiLiveTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of VirtualInterfaceApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "VirtualInterfaceApiLiveTest", singleThreaded = true) public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java index c177ce2d93..e2ba73dd05 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiExpectTest.java @@ -44,15 +44,13 @@ /** * Tests VolumeApi guice wiring and parsing - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "VolumeApiExpectTest") public class VolumeApiExpectTest extends BaseNovaApiExpectTest { private DateService dateService = new SimpleDateFormatDateService(); public void testListVolumes() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -65,7 +63,7 @@ public void testListVolumes() { } public void testListVolumesFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -78,7 +76,7 @@ public void testListVolumesFail() { } public void testListVolumesInDetail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/detail"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/detail"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -91,7 +89,7 @@ public void testListVolumesInDetail() { } public void testListVolumesInDetailFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/detail"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/detail"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -104,7 +102,7 @@ public void testListVolumesInDetailFail() { } public void testCreateVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -121,7 +119,7 @@ public void testCreateVolume() { @Test(expectedExceptions = ResourceNotFoundException.class) public void testCreateVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -137,7 +135,7 @@ public void testCreateVolumeFail() { } public void testGetVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -157,7 +155,7 @@ public void testGetVolume() { } public void testGetVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -169,7 +167,7 @@ public void testGetVolumeFail() { } public void testDeleteVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -181,7 +179,7 @@ public void testDeleteVolume() { } public void testDeleteVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volumes/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volumes/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -193,7 +191,7 @@ public void testDeleteVolumeFail() { } public void testListAttachments() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -213,7 +211,7 @@ public void testListAttachments() { @Test(expectedExceptions = AuthorizationException.class) public void testListAttachmentsFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-2/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-2/os-volume_attachments"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -225,7 +223,7 @@ public void testListAttachmentsFail() { } public void testGetAttachment() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -238,7 +236,7 @@ public void testGetAttachment() { } public void testGetAttachmentFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -250,7 +248,7 @@ public void testGetAttachmentFail() { } public void testAttachVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -265,7 +263,7 @@ public void testAttachVolume() { @Test(expectedExceptions = ResourceNotFoundException.class) public void testAttachVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -274,11 +272,11 @@ public void testAttachVolumeFail() { HttpResponse.builder().statusCode(404).build() ).getVolumeExtensionForZone("az-1.region-a.geo-1").get(); - api.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc"); + api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc"); } public void testDetachVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -290,7 +288,7 @@ public void testDetachVolume() { } public void testDetachVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -302,7 +300,7 @@ public void testDetachVolumeFail() { } public void testListSnapshots() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -315,7 +313,7 @@ public void testListSnapshots() { } public void testListSnapshotsFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -328,7 +326,7 @@ public void testListSnapshotsFail() { } public void testGetSnapshot() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -341,7 +339,7 @@ public void testGetSnapshot() { } public void testGetSnapshotFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -353,7 +351,7 @@ public void testGetSnapshotFail() { } public void testListSnapshotsInDetail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/detail"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/detail"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -375,7 +373,7 @@ public void testListSnapshotsInDetail() { } public void testListSnapshotsInDetailFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/detail"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/detail"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -388,7 +386,7 @@ public void testListSnapshotsInDetailFail() { } public void testCreateSnapshot() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -405,7 +403,7 @@ public void testCreateSnapshot() { @Test(expectedExceptions = AuthorizationException.class) public void testCreateSnapshotFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -420,7 +418,7 @@ public void testCreateSnapshotFail() { } public void testDeleteSnapshot() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -433,7 +431,7 @@ public void testDeleteSnapshot() { @Test(expectedExceptions = AuthorizationException.class) public void testDeleteSnapshotFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-snapshots/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-snapshots/1"); VolumeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java similarity index 92% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java index a7f14ad216..930cecd87e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeApiLiveTest.java @@ -27,6 +27,7 @@ import org.jclouds.openstack.nova.v2_0.domain.VolumeAttachment; import org.jclouds.openstack.nova.v2_0.domain.VolumeSnapshot; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; +import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeOptions; import org.jclouds.openstack.nova.v2_0.options.CreateVolumeSnapshotOptions; import org.testng.annotations.AfterClass; @@ -40,14 +41,13 @@ /** * Tests behavior of VolumeApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "VolumeApiLiveTest", singleThreaded = true) public class VolumeApiLiveTest extends BaseNovaApiLiveTest { private Optional volumeOption; private String zone; + private String availabilityZone; private Volume testVolume; private VolumeSnapshot testSnapshot; @@ -58,6 +58,9 @@ public void setup() { super.setup(); zone = Iterables.getLast(api.getConfiguredZones(), "nova"); volumeOption = api.getVolumeExtensionForZone(zone); + + Optional availabilityZoneApi = api.getAvailabilityZoneApi(zone); + availabilityZone = availabilityZoneApi.isPresent() ? Iterables.getLast(availabilityZoneApi.get().list()).getName() : zone; } @AfterClass(groups = { "integration", "live" }) @@ -91,7 +94,7 @@ public void testCreateVolume() { testVolume = volumeOption.get().create( 1, CreateVolumeOptions.Builder.name("jclouds-test-volume").description("description of test volume") - .availabilityZone(zone)); + .availabilityZone(availabilityZone)); assertTrue(retry(new Predicate() { public boolean apply(VolumeApi volumeApi) { return volumeOption.get().get(testVolume.getId()).getStatus() == Volume.Status.AVAILABLE; @@ -217,7 +220,8 @@ public void testAttachments() { if (volumeOption.isPresent()) { String server_id = null; try { - final String serverId = server_id = createServerInZone(zone).getId(); + CreateServerOptions createServerOptions = CreateServerOptions.Builder.availabilityZone(availabilityZone); + final String serverId = server_id = createServerInZone(zone, createServerOptions).getId(); Set attachments = volumeOption.get().listAttachmentsOnServer(serverId).toSet(); assertNotNull(attachments); @@ -238,7 +242,11 @@ public boolean apply(VolumeApi volumeApi) { assertNotNull(attachments); assertEquals(attachments.size(), before + 1); - assertEquals(volumeOption.get().get(testVolume.getId()).getStatus(), Volume.Status.IN_USE); + assertTrue(retry(new Predicate() { + public boolean apply(VolumeApi volumeApi) { + return volumeApi.get(testVolume.getId()).getStatus() == Volume.Status.IN_USE; + } + }, 30 * 1000L).apply(volumeOption.get()), "Volume status did not show in-use after 30 seconds"); boolean foundIt = false; for (VolumeAttachment att : attachments) { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java similarity index 92% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java index 1b4857d060..57be07c673 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiExpectTest.java @@ -41,15 +41,13 @@ /** * Tests VolumeAttachmentApi Guice wiring and parsing - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "VolumeAttachmentApiExpectTest") public class VolumeAttachmentApiExpectTest extends BaseNovaApiExpectTest { private DateService dateService = new SimpleDateFormatDateService(); public void testListAttachments() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -69,7 +67,7 @@ public void testListAttachments() { @Test(expectedExceptions = AuthorizationException.class) public void testListAttachmentsFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-2/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-2/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -81,7 +79,7 @@ public void testListAttachmentsFail() { } public void testGetAttachment() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -94,7 +92,7 @@ public void testGetAttachment() { } public void testGetAttachmentFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -106,7 +104,7 @@ public void testGetAttachmentFail() { } public void testAttachVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -121,7 +119,7 @@ public void testAttachVolume() { @Test(expectedExceptions = ResourceNotFoundException.class) public void testAttachVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -130,11 +128,11 @@ public void testAttachVolumeFail() { HttpResponse.builder().statusCode(404).build() ).getVolumeAttachmentExtensionForZone("az-1.region-a.geo-1").get(); - api.attachVolumeToServerAsDevice("1", "instance-1","/dev/vdc"); + api.attachVolumeToServerAsDevice("1", "instance-1", "/dev/vdc"); } public void testDetachVolume() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -146,7 +144,7 @@ public void testDetachVolume() { } public void testDetachVolumeFail() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/instance-1/os-volume_attachments/1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/instance-1/os-volume_attachments/1"); VolumeAttachmentApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java index cc853d838f..473e5c7cd2 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeAttachmentApiLiveTest.java @@ -38,8 +38,6 @@ /** * Tests behavior of Volume Attachment API - * - * @author Everett Toews */ @Test(groups = "live", testName = "VolumeAttachmentApiLiveTest", singleThreaded = true) public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java index 36d8d0f6bf..2e84833709 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiExpectTest.java @@ -39,15 +39,13 @@ /** * Tests guice wiring and parsing of VolumeTypeApi - * - * @author Adam Lowe */ @Test(groups = "unit", testName = "VolumeTypeApiExpectTest") public class VolumeTypeApiExpectTest extends BaseNovaApiExpectTest { private DateService dateService = new SimpleDateFormatDateService(); public void testListVolumeTypes() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -60,7 +58,7 @@ public void testListVolumeTypes() { } public void testGetVolumeType() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -73,7 +71,7 @@ public void testGetVolumeType() { } public void testGetVolumeTypeFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -85,7 +83,7 @@ public void testGetVolumeTypeFailNotFound() { } public void testCreateVolumeType() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -100,7 +98,7 @@ public void testCreateVolumeType() { } public void testCreateVolumeTypeWithOptsNONE() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -115,7 +113,7 @@ public void testCreateVolumeTypeWithOptsNONE() { } public void testCreateVolumeTypeWithOptsSet() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -130,7 +128,7 @@ public void testCreateVolumeTypeWithOptsSet() { } public void testDeleteVolumeType() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -142,7 +140,7 @@ public void testDeleteVolumeType() { } public void testDeleteVolumeTypeFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/8"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/8"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -154,7 +152,7 @@ public void testDeleteVolumeTypeFailNotFound() { } public void testGetAllExtraSpecs() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -166,7 +164,7 @@ public void testGetAllExtraSpecs() { } public void testGetAllExtraSpecsFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -178,7 +176,7 @@ public void testGetAllExtraSpecsFailNotFound() { } public void testSetAllExtraSpecs() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/9/extra_specs"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/9/extra_specs"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -192,7 +190,7 @@ public void testSetAllExtraSpecs() { } public void testSetExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -206,7 +204,7 @@ public void testSetExtraSpec() { } public void testGetExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -218,7 +216,7 @@ public void testGetExtraSpec() { } public void testGetExtraSpecFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -230,7 +228,7 @@ public void testGetExtraSpecFailNotFound() { } public void testDeleteExtraSpec() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, @@ -242,7 +240,7 @@ public void testDeleteExtraSpec() { } public void testDeleteExtraSpecFailNotFound() { - URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-volume-types/5/extra_specs/test1"); + URI endpoint = URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-volume-types/5/extra_specs/test1"); VolumeTypeApi api = requestsSendResponses( keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java index 02b0f50dea..4dda6bbc3f 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/extensions/VolumeTypeApiLiveTest.java @@ -38,8 +38,6 @@ /** * Tests behavior of VolumeTypeApi - * - * @author Adam Lowe */ @Test(groups = "live", testName = "VolumeTypeApiLiveTest", singleThreaded = true) public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java similarity index 85% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java index 4c91ec2a7a..8c58fa398a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiExpectTest.java @@ -31,20 +31,18 @@ import com.google.common.collect.ImmutableSet; /** - * Tests annotation parsing of {@code ExtensionAsyncApi} - * - * @author Adrian Cole + * Tests annotation parsing of {@code ExtensionApi} */ @Test(groups = "unit", testName = "ExtensionApiExpectTest") public class ExtensionApiExpectTest extends BaseNovaApiExpectTest { public void testListExtensionsWhenResponseIs2xx() throws Exception { - HttpRequest listExtensions = HttpRequest - .builder() + HttpRequest listExtensions = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/extension_list.json")).build(); @@ -59,12 +57,12 @@ public void testListExtensionsWhenResponseIs2xx() throws Exception { } public void testListExtensionsWhenReponseIs404IsEmpty() throws Exception { - HttpRequest listExtensions = HttpRequest - .builder() + HttpRequest listExtensions = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listExtensionsResponse = HttpResponse.builder().statusCode(404).build(); @@ -76,13 +74,12 @@ public void testListExtensionsWhenReponseIs404IsEmpty() throws Exception { // TODO: gson deserializer for Multimap public void testGetExtensionByAliasWhenResponseIs2xx() throws Exception { - - HttpRequest getExtension = HttpRequest - .builder() + HttpRequest getExtension = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions/RS-PIE") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions/RS-PIE") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/extension_details.json")).build(); @@ -95,12 +92,12 @@ public void testGetExtensionByAliasWhenResponseIs2xx() throws Exception { } public void testGetExtensionByAliasWhenResponseIs404() throws Exception { - HttpRequest getExtension = HttpRequest - .builder() + HttpRequest getExtension = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions/RS-PIE") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions/RS-PIE") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse getExtensionResponse = HttpResponse.builder().statusCode(404) .payload(payloadFromResource("/extension_details.json")).build(); @@ -109,7 +106,5 @@ public void testGetExtensionByAliasWhenResponseIs404() throws Exception { responseWithKeystoneAccess, getExtension, getExtensionResponse); assertNull(apiWhenNoExtensionsExist.getExtensionApiForZone("az-1.region-a.geo-1").get("RS-PIE")); - } - } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java index b81a761709..153603ad4c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ExtensionApiLiveTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@link ExtensionApi} - * - * @author Adrian Cole */ @Test(groups = "live", testName = "ExtensionApiLiveTest") public class ExtensionApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java similarity index 83% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java index 22af220abb..c52e9b57de 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiExpectTest.java @@ -21,7 +21,6 @@ import static org.testng.Assert.assertTrue; import javax.ws.rs.HttpMethod; -import javax.ws.rs.core.HttpHeaders; import javax.ws.rs.core.MediaType; import org.jclouds.http.HttpRequest; @@ -35,22 +34,21 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableSet; +import com.google.common.net.HttpHeaders; /** - * Tests annotation parsing of {@code FlavorAsyncApi} - * - * @author Jeremy Daggett, Ilja Bobkevic + * Tests annotation parsing of {@code FlavorApi} */ @Test(groups = "unit", testName = "FlavorApiExpectTest") public class FlavorApiExpectTest extends BaseNovaApiExpectTest { public void testListFlavorsWhenResponseIs2xx() throws Exception { - HttpRequest listFlavors = HttpRequest - .builder() + HttpRequest listFlavors = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/flavor_list.json")).build(); @@ -65,12 +63,12 @@ public void testListFlavorsWhenResponseIs2xx() throws Exception { } public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception { - HttpRequest listFlavors = HttpRequest - .builder() + HttpRequest listFlavors = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(404).build(); @@ -82,13 +80,12 @@ public void testListFlavorsWhenReponseIs404IsEmpty() throws Exception { // TODO: gson deserializer for Multimap public void testGetFlavorWhenResponseIs2xx() throws Exception { - - HttpRequest getFlavor = HttpRequest - .builder() + HttpRequest getFlavor = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/52415800-8b69-11e0-9b19-734f1195ff37") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse getFlavorResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/flavor_details.json")).build(); @@ -102,10 +99,9 @@ public void testGetFlavorWhenResponseIs2xx() throws Exception { } public void testGetFlavorWhenResponseIs404() throws Exception { - HttpRequest getFlavor = HttpRequest - .builder() + HttpRequest getFlavor = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/123") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/123") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -116,19 +112,17 @@ public void testGetFlavorWhenResponseIs404() throws Exception { responseWithKeystoneAccess, getFlavor, getFlavorResponse); assertNull(apiWhenNoFlavorsExist.getFlavorApiForZone("az-1.region-a.geo-1").get("123")); - } - + public void testCreateFlavor200() throws Exception { - ParseCreateFlavorTest parser = new ParseCreateFlavorTest(); - HttpRequest listFlavors = HttpRequest - .builder() + ParseCreateFlavorTest parser = new ParseCreateFlavorTest(); + HttpRequest listFlavors = HttpRequest.builder() .method(HttpMethod.POST) - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors") .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .addHeader("X-Auth-Token", authToken) .payload(payloadFromResource(parser.resource())).build(); - + HttpResponse listFlavorsResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource(parser.resource())).build(); @@ -137,25 +131,23 @@ public void testCreateFlavor200() throws Exception { assertEquals( api.getFlavorApiForZone("az-1.region-a.geo-1").create(Flavor.builder() - .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab") - .name("128 MB Server").ram(128).vcpus(1) - .disk(10).build()) + .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab") + .name("128 MB Server").ram(128).vcpus(1) + .disk(10).build()) .toString(), parser.expected().toString()); } public void testDeleteFlavor202() throws Exception { String flavorId = "1cb47a44-9b84-4da4-bf81-c1976e8414ab"; - - HttpRequest updateMetadata = HttpRequest - .builder() + HttpRequest updateMetadata = HttpRequest.builder() .method(HttpMethod.DELETE) - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/" + flavorId) - .addHeader(HttpHeaders.ACCEPT, MediaType.WILDCARD) + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/" + flavorId) + .addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON) .addHeader("X-Auth-Token", authToken) .build(); HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(204).build(); - + NovaApi api = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, updateMetadata, updateMetadataResponse); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java index 2af0d542c4..bd10bea8ee 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/FlavorApiLiveTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@link FlavorApi} - * - * @author Jeremy Daggett */ @Test(groups = "live", testName = "FlavorApiLiveTest") public class FlavorApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java similarity index 81% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java index 85407d15fa..d3a5231852 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiExpectTest.java @@ -35,19 +35,18 @@ import com.google.common.collect.ImmutableSet; /** - * Tests annotation parsing of {@code ImageAsyncApi} - * - * @author Michael Arnold + * Tests annotation parsing of {@code ImageApi} */ -@Test(groups = "unit", testName = "ImageAsyncApiTest") +@Test(groups = "unit", testName = "ImageApiExpectTest") public class ImageApiExpectTest extends BaseNovaApiExpectTest { + public void testListImagesWhenResponseIs2xx() throws Exception { - HttpRequest list = HttpRequest - .builder() + HttpRequest list = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/image_list.json")).build(); @@ -62,12 +61,12 @@ public void testListImagesWhenResponseIs2xx() throws Exception { } public void testListImagesWhenReponseIs404IsEmpty() throws Exception { - HttpRequest list = HttpRequest - .builder() + HttpRequest list = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse listResponse = HttpResponse.builder().statusCode(404).build(); @@ -79,12 +78,12 @@ public void testListImagesWhenReponseIs404IsEmpty() throws Exception { public void testGetImageWhenResponseIs2xx() throws Exception { - HttpRequest getImage = HttpRequest - .builder() + HttpRequest getImage = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse getImageResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/image_details.json")).build(); @@ -98,48 +97,45 @@ public void testGetImageWhenResponseIs2xx() throws Exception { } public void testGetImageWhenResponseIs404() throws Exception { - HttpRequest getImage = HttpRequest - .builder() + HttpRequest getImage = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/52415800-8b69-11e0-9b19-734f5736d2a2") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); + .addHeader("X-Auth-Token", authToken) + .build(); HttpResponse getImageResponse = HttpResponse.builder().statusCode(404).build(); NovaApi apiWhenNoImagesExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getImage, getImageResponse); - assertNull(apiWhenNoImagesExist.getImageApiForZone("az-1.region-a.geo-1").get( - "52415800-8b69-11e0-9b19-734f5736d2a2")); - + assertNull(apiWhenNoImagesExist.getImageApiForZone("az-1.region-a.geo-1").get("52415800-8b69-11e0-9b19-734f5736d2a2")); } public void testListMetadataWhenResponseIs2xx() throws Exception { - String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; - HttpRequest getMetadata = HttpRequest - .builder() + String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); - + .addHeader("X-Auth-Token", authToken) + .build(); + HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_list.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getMetadata, getMetadataResponse); - assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId).toString(), + assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId).toString(), new ParseMetadataListTest().expected().toString()); } - + public void testListMetadataWhenResponseIs404() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; - HttpRequest getMetadata = HttpRequest - .builder() + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken) .build(); @@ -164,22 +160,22 @@ public void testSetMetadataWhenResponseIs2xx() throws Exception { .put("Image Version", "2.1") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("PUT") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_list.json")).build(); - + NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, setMetadata, setMetadataResponse); - assertEquals(apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata).toString(), + assertEquals(apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata).toString(), new ParseMetadataListTest().expected().toString()); } @@ -189,14 +185,14 @@ public void testSetMetadataWhenResponseIs404() throws Exception { .put("Server Label", "Web Head 1") .put("Image Version", "2.1") .build(); - - HttpRequest setMetadata = HttpRequest - .builder() + + HttpRequest setMetadata = HttpRequest.builder() .method("PUT") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" +imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build(); @@ -219,22 +215,22 @@ public void testUpdateMetadataWhenResponseIs2xx() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_updated.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, setMetadata, setMetadataResponse); - assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, metadata).toString(), + assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, metadata).toString(), new ParseMetadataUpdateTest().expected().toString()); } @@ -245,13 +241,12 @@ public void testUpdateMetadataWhenResponseIs404() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + imageId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + imageId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404) @@ -261,7 +256,7 @@ public void testUpdateMetadataWhenResponseIs404() throws Exception { responseWithKeystoneAccess, setMetadata, setMetadataResponse); try { - apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata); + apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").setMetadata(imageId, metadata); fail("Expected an exception."); } catch (Exception e) { // expected @@ -272,21 +267,20 @@ public void testGetMetadataItemWhenResponseIs2xx() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; String key = "Image%20Version"; - HttpRequest getMetadata = HttpRequest - .builder() + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key) + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" + key) .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromString("{\"metadata\":{\"Image Version\":\"2.5\"}}")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getMetadata, getMetadataResponse); - assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId, "Image Version").toString(), + assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").getMetadata(imageId, "Image Version").toString(), "2.5"); } @@ -294,10 +288,9 @@ public void testGetMetadataItemWhenResponseIs404() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; String key = "Image%20Version"; - HttpRequest getMetadata = HttpRequest - .builder() + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key) + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" + key) .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); @@ -315,10 +308,9 @@ public void testSetMetadataItemWhenResponseIs2xx() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; String key = "Image Version"; - HttpRequest updateMetadata = HttpRequest - .builder() + HttpRequest updateMetadata = HttpRequest.builder() .method("PUT") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + "Image%20Version") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" + "Image%20Version") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json")) @@ -326,28 +318,27 @@ public void testSetMetadataItemWhenResponseIs2xx() throws Exception { HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromStringWithContentType("{\"metadata\":{\"Image Version\":\"2.5\"}}", "application/json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, updateMetadata, updateMetadataResponse); - - assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, key, "2.5").toString(), + + assertEquals(apiWhenServerExists.getImageApiForZone("az-1.region-a.geo-1").updateMetadata(imageId, key, "2.5").toString(), "2.5"); } public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; String key = "Image%20Version"; - - HttpRequest deleteMetadata = HttpRequest - .builder() + + HttpRequest deleteMetadata = HttpRequest.builder() .method("DELETE") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key) - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" + key) + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); HttpResponse deleteMetadataResponse = HttpResponse.builder().statusCode(204).build(); - + NovaApi apiWhenImageExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse); @@ -358,11 +349,10 @@ public void testDeleteMetadataItemWhenResponseIs404() throws Exception { String imageId = "52415800-8b69-11e0-9b19-734f5736d2a2"; String key = "Image%20Version"; - HttpRequest deleteMetadata = HttpRequest - .builder() + HttpRequest deleteMetadata = HttpRequest.builder() .method("DELETE") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId + "/metadata/" + key) - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId + "/metadata/" + key) + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); @@ -372,6 +362,5 @@ public void testDeleteMetadataItemWhenResponseIs404() throws Exception { responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse); apiWhenImageExists.getImageApiForZone("az-1.region-a.geo-1").deleteMetadata(imageId, key); - } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java index 83d0b62677..076201761a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ImageApiLiveTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@link ImageApi} - * - * @author Michael Arnold */ @Test(groups = "live", testName = "ImageApiLiveTest") public class ImageApiLiveTest extends BaseNovaApiLiveTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java similarity index 75% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java index 070dcf6d19..cfee8a6bc6 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiExpectTest.java @@ -30,27 +30,25 @@ import org.jclouds.openstack.nova.v2_0.parse.ParseCreatedServerTest; import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataListTest; import org.jclouds.openstack.nova.v2_0.parse.ParseMetadataUpdateTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseServerDetailsStatesTest; +import org.jclouds.openstack.nova.v2_0.parse.ParseServerDiagnostics; import org.jclouds.openstack.nova.v2_0.parse.ParseServerListTest; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -import org.jclouds.openstack.nova.v2_0.parse.ParseServerDiagnostics; /** - * Tests annotation parsing of {@code ServerAsyncApi} - * - * @author Adrian Cole + * Tests annotation parsing of {@code ServerApi} */ -@Test(groups = "unit", testName = "ServerAsyncApiTest") +@Test(groups = "unit", testName = "ServerApiExpectTest") public class ServerApiExpectTest extends BaseNovaApiExpectTest { public void testListServersWhenResponseIs2xx() throws Exception { - HttpRequest listServers = HttpRequest - .builder() + HttpRequest listServers = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -67,10 +65,9 @@ public void testListServersWhenResponseIs2xx() throws Exception { } public void testListServersWhenReponseIs404IsEmpty() throws Exception { - HttpRequest listServers = HttpRequest - .builder() + HttpRequest listServers = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); @@ -82,20 +79,54 @@ public void testListServersWhenReponseIs404IsEmpty() throws Exception { assertTrue(apiWhenNoServersExist.getServerApiForZone("az-1.region-a.geo-1").list().concat().isEmpty()); } + public void testListInDetailServersWhenResponseIs2xx() throws Exception { + HttpRequest listServers = HttpRequest + .builder() + .method("GET") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken).build(); + + HttpResponse listInDetailServersResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/server_list_details_states.json")).build(); + + NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, + responseWithKeystoneAccess, listServers, listInDetailServersResponse); + + assertEquals(apiWhenServersExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1")); + + assertEquals(apiWhenServersExist.getServerApiForZone("az-1.region-a.geo-1").listInDetail().concat().toString(), + new ParseServerDetailsStatesTest().expected().toString()); + } + + public void testListInDetailServersWhenReponseIs404IsEmpty() throws Exception { + HttpRequest listServers = HttpRequest + .builder() + .method("GET") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken).build(); + + HttpResponse listInDetailServersResponse = HttpResponse.builder().statusCode(404).build(); + + NovaApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, + responseWithKeystoneAccess, listServers, listInDetailServersResponse); + + assertTrue(apiWhenNoServersExist.getServerApiForZone("az-1.region-a.geo-1").listInDetail().concat().isEmpty()); + } + public void testCreateServerWhenResponseIs202() throws Exception { - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\"}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); @@ -105,19 +136,17 @@ public void testCreateServerWhenResponseIs202() throws Exception { } public void testCreateServerInAvailabilityZoneWhenResponseIs202() throws Exception { - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"availability_zone\":\"nova\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"availability_zone\":\"nova\"}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_in_zone.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/new_server_in_zone.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); @@ -129,21 +158,17 @@ public void testCreateServerInAvailabilityZoneWhenResponseIs202() throws Excepti } public void testCreateServerWithSecurityGroupsWhenResponseIs202() throws Exception { - - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"},{\"name\":\"group2\"}]}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"security_groups\":[{\"name\":\"group1\"},{\"name\":\"group2\"}]}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build(); - + .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); @@ -154,21 +179,17 @@ public void testCreateServerWithSecurityGroupsWhenResponseIs202() throws Excepti } public void testCreateServerWithNetworksWhenResponseIs202() throws Exception { - - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\":[{\"uuid\":\"b3856ac0-f481-11e2-b778-0800200c9a66\"},{\"uuid\":\"bf0f0f90-f481-11e2-b778-0800200c9a66\"}]}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"networks\":[{\"uuid\":\"b3856ac0-f481-11e2-b778-0800200c9a66\"},{\"uuid\":\"bf0f0f90-f481-11e2-b778-0800200c9a66\"}]}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server.json","application/json; charset=UTF-8")).build(); - + .payload(payloadFromResourceWithContentType("/new_server.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); @@ -179,24 +200,20 @@ public void testCreateServerWithNetworksWhenResponseIs202() throws Exception { } public void testCreateServerWithDiskConfigAuto() throws Exception { - - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"AUTO\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"AUTO\"}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_disk_config_auto.json","application/json; charset=UTF-8")).build(); - + .payload(payloadFromResourceWithContentType("/new_server_disk_config_auto.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses( - keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, + keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241", @@ -205,24 +222,20 @@ public void testCreateServerWithDiskConfigAuto() throws Exception { } public void testCreateServerWithDiskConfigManual() throws Exception { - - HttpRequest createServer = HttpRequest - .builder() + HttpRequest createServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"MANUAL\"}}","application/json")) + "{\"server\":{\"name\":\"test-e92\",\"imageRef\":\"1241\",\"flavorRef\":\"100\",\"OS-DCF:diskConfig\":\"MANUAL\"}}", "application/json")) .build(); - HttpResponse createServerResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/new_server_disk_config_manual.json","application/json; charset=UTF-8")).build(); - + .payload(payloadFromResourceWithContentType("/new_server_disk_config_manual.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses( - keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, + keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createServer, createServerResponse); assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").create("test-e92", "1241", @@ -232,14 +245,13 @@ public void testCreateServerWithDiskConfigManual() throws Exception { public void testRebuildServerWhenResponseIs202() throws Exception { String serverId = "52415800-8b69-11e0-9b19-734f565bc83b"; - HttpRequest rebuildServer = HttpRequest - .builder() + HttpRequest rebuildServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId +"/action") - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"rebuild\":{\"adminPass\":\"password\",\"imageRef\":\"1234\",\"name\":\"newName\",\"accessIPv4\":\"1.1.1.1\",\"accessIPv6\":\"fe80::100\"}}","application/json")) + "{\"rebuild\":{\"adminPass\":\"password\",\"imageRef\":\"1234\",\"name\":\"newName\",\"accessIPv4\":\"1.1.1.1\",\"accessIPv6\":\"fe80::100\"}}", "application/json")) .build(); HttpResponse rebuildServerResponse = HttpResponse.builder().statusCode(202).build(); @@ -257,21 +269,19 @@ public void testCreateImageWhenResponseIs2xx() throws Exception { String imageId = "456"; String imageName = "foo"; - HttpRequest createImage = HttpRequest - .builder() + HttpRequest createImage = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") - .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken) + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( "{\"createImage\":{\"name\":\"" + imageName + "\", \"metadata\": {}}}", "application/json")) - .build(); + .build(); HttpResponse createImageResponse = HttpResponse.builder() .statusCode(200) - .headers( - ImmutableMultimap. builder() - .put("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/" + imageId).build()).build(); + .headers(ImmutableMultimap. builder() + .put("Location", "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/" + imageId).build()).build(); NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createImage, createImageResponse); @@ -284,17 +294,17 @@ public void testCreateImageWhenResponseIs404IsEmpty() throws Exception { String serverId = "123"; String imageName = "foo"; - HttpRequest createImage = HttpRequest - .builder() + HttpRequest createImage = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") - .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken) + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") + .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( "{\"createImage\":{\"name\":\"" + imageName + "\", \"metadata\": {}}}", "application/json")) - .build(); + .build(); HttpResponse createImageResponse = HttpResponse.builder().statusCode(404).build(); + NovaApi apiWhenServerDoesNotExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, createImage, createImageResponse); @@ -305,18 +315,17 @@ public void testCreateImageWhenResponseIs404IsEmpty() throws Exception { // expected } } - + public void testStopServerWhenResponseIs2xx() throws Exception { String serverId = "123"; - HttpRequest stopServer = HttpRequest - .builder() + HttpRequest stopServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( "{\"os-stop\":null}", "application/json")) - .build(); + .build(); HttpResponse stopServerResponse = HttpResponse.builder().statusCode(202).build(); @@ -325,19 +334,17 @@ public void testStopServerWhenResponseIs2xx() throws Exception { apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").stop(serverId); } - + public void testStopServerWhenResponseIs404() throws Exception { String serverId = "123"; - HttpRequest stopServer = HttpRequest - .builder() + HttpRequest stopServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType( "{\"os-stop\":null}", "application/json")) - .build(); + .build(); HttpResponse stopServerResponse = HttpResponse.builder().statusCode(404).build(); @@ -351,19 +358,18 @@ public void testStopServerWhenResponseIs404() throws Exception { // expected } } - + public void testStartServerWhenResponseIs2xx() throws Exception { String serverId = "123"; HttpRequest startServer = HttpRequest .builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType( "{\"os-start\":null}", "application/json")) - .build(); + .build(); HttpResponse startServerResponse = HttpResponse.builder().statusCode(202).build(); @@ -372,18 +378,17 @@ public void testStartServerWhenResponseIs2xx() throws Exception { apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").start(serverId); } - + public void testStartServerWhenResponseIs404() throws Exception { String serverId = "123"; - HttpRequest startServer = HttpRequest - .builder() + HttpRequest startServer = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/action") - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/action") + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType( - "{\"os-startp\":null}", "application/json")) - .build(); + "{\"os-start\":null}", "application/json")) + .build(); HttpResponse startServerResponse = HttpResponse.builder().statusCode(404).build(); @@ -400,31 +405,28 @@ public void testStartServerWhenResponseIs404() throws Exception { public void testListMetadataWhenResponseIs2xx() throws Exception { String serverId = "123"; - - HttpRequest getMetadata = HttpRequest - .builder() + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") - .addHeader("X-Auth-Token", authToken).build(); - + .addHeader("X-Auth-Token", authToken) + .build(); + HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_list.json")).build(); - - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getMetadata, getMetadataResponse); - assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId).toString(), + assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId).toString(), new ParseMetadataListTest().expected().toString()); } - + public void testListMetadataWhenResponseIs404() throws Exception { String serverId = "123"; - HttpRequest getMetadata = HttpRequest - .builder() + HttpRequest getMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken) .build(); @@ -435,7 +437,7 @@ public void testListMetadataWhenResponseIs404() throws Exception { responseWithKeystoneAccess, getMetadata, getMetadataResponse); try { - apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId); + apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId); fail("Expected an exception."); } catch (Exception e) { // expected @@ -449,22 +451,22 @@ public void testSetMetadataWhenResponseIs2xx() throws Exception { .put("Image Version", "2.1") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("PUT") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_list.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, setMetadata, setMetadataResponse); - assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata).toString(), + assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata).toString(), new ParseMetadataListTest().expected().toString()); } @@ -474,14 +476,14 @@ public void testSetMetadataWhenResponseIs404() throws Exception { .put("Server Label", "Web Head 1") .put("Image Version", "2.1") .build(); - - HttpRequest setMetadata = HttpRequest - .builder() + + HttpRequest setMetadata = HttpRequest.builder() .method("PUT") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "*/*") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 1\",\"Image Version\":\"2.1\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build(); @@ -490,7 +492,7 @@ public void testSetMetadataWhenResponseIs404() throws Exception { responseWithKeystoneAccess, setMetadata, setMetadataResponse); try { - apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); + apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); fail("Expected an exception."); } catch (Exception e) { // expected @@ -504,22 +506,22 @@ public void testUpdateMetadataWhenResponseIs2xx() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_updated.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, setMetadata, setMetadataResponse); - assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(), + assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(), new ParseMetadataUpdateTest().expected().toString()); } @@ -530,13 +532,13 @@ public void testUpdateMetadataWhenResponseIs404() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404) @@ -546,7 +548,7 @@ public void testUpdateMetadataWhenResponseIs404() throws Exception { responseWithKeystoneAccess, setMetadata, setMetadataResponse); try { - apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); + apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); fail("Expected an exception."); } catch (Exception e) { // expected @@ -560,18 +562,18 @@ public void testGetMetadataItemWhenResponseIs2xx() throws Exception { HttpRequest getMetadata = HttpRequest .builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + "Server%20Label") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" + "Server%20Label") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); HttpResponse getMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_item.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getMetadata, getMetadataResponse); - assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId, key).toString(), + assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").getMetadata(serverId, key).toString(), "Web Head 1"); } @@ -581,13 +583,13 @@ public void testGetMetadataItemWhenResponseIs404() throws Exception { .put("Server Label", "Web Head 1") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("GET") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404) @@ -597,7 +599,7 @@ public void testGetMetadataItemWhenResponseIs404() throws Exception { responseWithKeystoneAccess, setMetadata, setMetadataResponse); try { - apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); + apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); fail("Expected an exception."); } catch (Exception e) { // expected @@ -611,22 +613,22 @@ public void testSetMetadataItemWhenResponseIs2xx() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/metadata_updated.json")).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, setMetadata, setMetadataResponse); - assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(), + assertEquals(apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").updateMetadata(serverId, metadata).toString(), new ParseMetadataUpdateTest().expected().toString()); } @@ -637,13 +639,13 @@ public void testSetMetadataItemWhenResponseIs404() throws Exception { .put("Server Description", "Simple Server") .build(); - HttpRequest setMetadata = HttpRequest - .builder() + HttpRequest setMetadata = HttpRequest.builder() .method("POST") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) - .payload(payloadFromStringWithContentType("{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}","application/json")) + .payload(payloadFromStringWithContentType( + "{\"metadata\":{\"Server Label\":\"Web Head 2\",\"Server Description\":\"Simple Server\"}}", "application/json")) .build(); HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404) @@ -653,7 +655,7 @@ public void testSetMetadataItemWhenResponseIs404() throws Exception { responseWithKeystoneAccess, setMetadata, setMetadataResponse); try { - apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); + apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").setMetadata(serverId, metadata); fail("Expected an exception."); } catch (Exception e) { // expected @@ -664,32 +666,29 @@ public void testDeleteMetadataItemWhenResponseIs2xx() throws Exception { String serverId = "123"; String key = "Server%20Label"; - HttpRequest updateMetadata = HttpRequest - .builder() + HttpRequest updateMetadata = HttpRequest.builder() .method("DELETE") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + key) - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" + key) + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); HttpResponse updateMetadataResponse = HttpResponse.builder().statusCode(204).build(); - + NovaApi apiWhenServerExists = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, updateMetadata, updateMetadataResponse); apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").deleteMetadata(serverId, key); - } public void testDeleteMetadataItemWhenResponseIs404() throws Exception { String serverId = "123"; String key = "Server%20Label"; - HttpRequest deleteMetadata = HttpRequest - .builder() + HttpRequest deleteMetadata = HttpRequest.builder() .method("DELETE") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/" + serverId + "/metadata/" + key) - .addHeader("Accept", "*/*") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/metadata/" + key) + .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .build(); @@ -699,39 +698,32 @@ public void testDeleteMetadataItemWhenResponseIs404() throws Exception { responseWithKeystoneAccess, deleteMetadata, deleteMetadataResponse); apiWhenServerExists.getServerApiForZone("az-1.region-a.geo-1").deleteMetadata(serverId, key); - } - + public void testGetDiagnosticsWhenResponseIs200() throws Exception { - String serverId = "123"; - HttpRequest getDiagnostics = HttpRequest - .builder() + HttpRequest getDiagnostics = HttpRequest.builder() .method("GET") .addHeader("Accept", "application/json") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/"+ serverId + "/diagnostics") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/diagnostics") .addHeader("X-Auth-Token", authToken) .build(); - HttpResponse serverDiagnosticsResponse = HttpResponse.builder().statusCode(202).message("HTTP/1.1 202 Accepted") - .payload(payloadFromResourceWithContentType("/server_diagnostics.json","application/json; charset=UTF-8")).build(); + .payload(payloadFromResourceWithContentType("/server_diagnostics.json", "application/json; charset=UTF-8")).build(); NovaApi apiWithNewServer = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, getDiagnostics, serverDiagnosticsResponse); assertEquals(apiWithNewServer.getServerApiForZone("az-1.region-a.geo-1").getDiagnostics(serverId), new ParseServerDiagnostics().expected()); } - - + public void testGetDiagnosticsWhenResponseIs403Or404Or500() throws Exception { - String serverId = "123"; - HttpRequest getDiagnostics = HttpRequest - .builder() + HttpRequest getDiagnostics = HttpRequest.builder() .method("GET") .addHeader("Accept", "application/json") - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/"+ serverId + "/diagnostics") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/" + serverId + "/diagnostics") .addHeader("X-Auth-Token", authToken) .build(); @@ -740,7 +732,4 @@ public void testGetDiagnosticsWhenResponseIs403Or404Or500() throws Exception { HttpResponse.builder().statusCode(statusCode).build()).getServerApiForZone("az-1.region-a.geo-1").getDiagnostics(serverId).isPresent()); } } - - - } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java similarity index 76% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java index 3553d1888b..691999b16d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/features/ServerApiLiveTest.java @@ -16,14 +16,19 @@ */ package org.jclouds.openstack.nova.v2_0.features; +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE; +import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitActive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; +import com.google.common.base.Optional; +import org.jclouds.http.HttpResponseException; import org.jclouds.openstack.nova.v2_0.domain.Network; import org.jclouds.openstack.nova.v2_0.domain.Server; import org.jclouds.openstack.nova.v2_0.domain.ServerCreated; +import org.jclouds.openstack.nova.v2_0.extensions.AvailabilityZoneApi; import org.jclouds.openstack.nova.v2_0.internal.BaseNovaApiLiveTest; import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; import org.jclouds.openstack.nova.v2_0.options.RebuildServerOptions; @@ -37,9 +42,6 @@ /** * Tests behavior of {@link ServerApi} - * - * @author Adrian Cole - * @author Inbar Stolberg */ @Test(groups = "live", testName = "ServerApiLiveTest") public class ServerApiLiveTest extends BaseNovaApiLiveTest { @@ -81,14 +83,20 @@ public void testGetServerById() throws Exception { @Test public void testCreateInAvailabilityZone() { String serverId = null; + String availabilityZone; + for (String zoneId : zones) { ServerApi serverApi = api.getServerApiForZone(zoneId); + Optional availabilityZoneApi = api.getAvailabilityZoneApi(zoneId); + availabilityZone = availabilityZoneApi.isPresent() ? Iterables.getLast(availabilityZoneApi.get().list()).getName() : "nova"; try { - serverId = createServer(zoneId, "nova", Server.Status.ACTIVE).getId(); + serverId = createServer(zoneId, availabilityZone).getId(); Server server = serverApi.get(serverId); - assertEquals(server.getStatus(), Server.Status.ACTIVE); + assertEquals(server.getStatus(), ACTIVE); } finally { - serverApi.delete(serverId); + if (serverId != null) { + serverApi.delete(serverId); + } } } } @@ -112,9 +120,10 @@ public void testCreateWithNetworkOptions() { ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), "1", options); serverId = server.getId(); - blockUntilServerInState(server.getId(), serverApi, Server.Status.ACTIVE); + awaitActive(serverApi).apply(server.getId()); + Server serverCheck = serverApi.get(serverId); - assertEquals(serverCheck.getStatus(), Server.Status.ACTIVE); + assertEquals(serverCheck.getStatus(), ACTIVE); } finally { if (serverId != null) { serverApi.delete(serverId); @@ -129,11 +138,16 @@ public void testCreateInWrongAvailabilityZone() { for (String zoneId : zones) { ServerApi serverApi = api.getServerApiForZone(zoneId); try { - serverId = createServer(zoneId, "err", Server.Status.ERROR).getId(); - Server server = serverApi.get(serverId); - assertEquals(server.getStatus(), Server.Status.ERROR); + serverId = createServer(zoneId, "err").getId(); + } catch (HttpResponseException e) { + // Here is an implementation detail difference between OpenStack and some providers. + // Some providers accept a bad availability zone and create the server in the zoneId. + // Vanilla OpenStack will error out with a 400 Bad Request + assertEquals(e.getResponse().getStatusCode(), 400); } finally { - serverApi.delete(serverId); + if (serverId != null) { + serverApi.delete(serverId); + } } } } @@ -146,11 +160,11 @@ public void testRebuildServer() { for (String zoneId : zones) { ServerApi serverApi = api.getServerApiForZone(zoneId); try { - serverId = createServer(zoneId, Server.Status.ACTIVE).getId(); + serverId = createServer(zoneId, null).getId(); Server server = serverApi.get(serverId); - assertEquals(server.getStatus(), Server.Status.ACTIVE); + assertEquals(server.getStatus(), ACTIVE); RebuildServerOptions options = new RebuildServerOptions(). withImage(server.getImage().getId()). @@ -168,27 +182,25 @@ public void testRebuildServer() { assertEquals("fe80::100", rebuiltServer.getAccessIPv6()); } finally { - serverApi.delete(serverId); + if (serverId != null) { + serverApi.delete(serverId); + } } } } - private Server createServer(String regionId, Server.Status serverStatus) { - ServerApi serverApi = api.getServerApiForZone(regionId); + private Server createServer(String zoneId, String availabilityZoneId) { + ServerApi serverApi = api.getServerApiForZone(zoneId); + CreateServerOptions options = new CreateServerOptions(); - ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options); + if (availabilityZoneId != null) { + options = options.availabilityZone(availabilityZoneId); + } - blockUntilServerInState(server.getId(), serverApi, serverStatus); + ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId), options); - return serverApi.get(server.getId()); - } + awaitActive(serverApi).apply(server.getId()); - private Server createServer(String regionId, String availabilityZoneId, Server.Status serverStatus) { - ServerApi serverApi = api.getServerApiForZone(regionId); - CreateServerOptions options = new CreateServerOptions(); - options = options.availabilityZone(availabilityZoneId); - ServerCreated server = serverApi.create(hostName, imageIdForZone(regionId), flavorRefForZone(regionId), options); - blockUntilServerInState(server.getId(), serverApi, serverStatus); return serverApi.get(server.getId()); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java index ba4be4df6a..fc15e92093 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/CreateSecurityGroupIfNeededTest.java @@ -36,14 +36,10 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "CreateSecurityGroupIfNeededTest") public class CreateSecurityGroupIfNeededTest extends BaseNovaApiExpectTest { HttpRequest create = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()) .payload( @@ -69,10 +65,10 @@ public void testCreateNewGroup() throws Exception { int ruleId = 10331; - for (int port : ImmutableList.of(22,8080)) { + for (int port : ImmutableList.of(22, 8080)) { HttpRequest createCidrRule = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()) .payload( @@ -89,7 +85,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p builder.put(createCidrRule, createCidrRuleResponse); HttpRequest createSelfRule = HttpRequest.builder().method("POST").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-group-rules")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-group-rules")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()) .payload( @@ -108,7 +104,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p } HttpRequest getSecurityGroup = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups/" + groupId)).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups/" + groupId)).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -145,7 +141,7 @@ public void testReturnExistingGroupOnAlreadyExists() throws Exception { builder.put(create, createResponse); HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java index c8e2639f4c..d9c467ef90 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/FindSecurityGroupWithNameAndReturnTrueExpectTest.java @@ -37,16 +37,12 @@ import com.google.common.collect.Iterables; import com.google.common.util.concurrent.Atomics; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "FindSecurityGroupWithNameAndReturnTrueExpectTest") public class FindSecurityGroupWithNameAndReturnTrueExpectTest extends BaseNovaApiExpectTest { public void testUpdateReferenceWhenSecurityGroupListContainsGroupName() throws Exception { HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -74,7 +70,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p public void testDoesNotUpdateReferenceWhenSecurityGroupListMissingGroupName() throws Exception { HttpRequest list = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-security-groups")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-security-groups")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java index d1656d7bc2..e313c34dc7 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/functions/InternalURLLiveTest.java @@ -32,7 +32,6 @@ * Simple live test to check the correct loading of the internal endpoint * services. * - * @author Ignacio Mulas * */ @Test(groups = "live", testName = "InternalURLLiveTest") diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java index fe302a7b28..0756c44a49 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/handlers/NovaErrorHandlerTest.java @@ -39,10 +39,6 @@ import com.google.common.base.Ticker; import com.google.gson.Gson; -/** - * - * @author Adrian Cole, Steve Loughran - */ @Test(groups = "unit", testName = "NovaErrorHandlerTest", singleThreaded = true) public class NovaErrorHandlerTest { @@ -59,7 +55,7 @@ public void test401MakesAuthorizationException() { assertEquals(command.getException().getClass(), AuthorizationException.class); assertEquals(command.getException().getMessage(), - "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 401 Unauthorized"); + "POST https://nova/v2/servers HTTP/1.1 -> HTTP/1.1 401 Unauthorized"); } @Test @@ -68,13 +64,13 @@ public void test404MakesResourceNotFoundException() { assertEquals(command.getException().getClass(), ResourceNotFoundException.class); assertEquals(command.getException().getMessage(), - "POST https://nova/v1.1/servers HTTP/1.1 -> HTTP/1.1 404 Not Found"); + "POST https://nova/v2/servers HTTP/1.1 -> HTTP/1.1 404 Not Found"); } // should wait until ips are associated w/the server HttpResponse noFixedIps = HttpResponse.builder().statusCode(400) .message("HTTP/1.1 400 Bad Request") - .payload("{\"badRequest\": {\"message\": "+ + .payload("{\"badRequest\": {\"message\": " + "\"instance |71554| has no fixed_ips. unable to associate floating ip\", \"code\": 400}}") .build(); @@ -219,7 +215,7 @@ public long read() { new OverLimitParser(new GsonWrapper(new Gson()))); private HttpCommand command() { - return new HttpCommand(HttpRequest.builder().method("POST").endpoint("https://nova/v1.1/servers").build()); + return new HttpCommand(HttpRequest.builder().method("POST").endpoint("https://nova/v2/servers").build()); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java index 6c63da5e3b..537a07dc9e 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiExpectTest.java @@ -20,8 +20,6 @@ /** * Base class for writing KeyStone Rest Api Expect tests - * - * @author Adrian Cole */ public class BaseNovaApiExpectTest extends BaseNovaExpectTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java similarity index 86% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java index da1847bbe2..acc830ebec 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaApiLiveTest.java @@ -19,6 +19,10 @@ import java.util.Properties; import java.util.Set; +import com.google.common.collect.ComparisonChain; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.Ordering; import org.jclouds.apis.BaseApiLiveTest; import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties; import org.jclouds.openstack.nova.v2_0.NovaApi; @@ -30,23 +34,19 @@ import org.jclouds.openstack.nova.v2_0.features.FlavorApi; import org.jclouds.openstack.nova.v2_0.features.ImageApi; import org.jclouds.openstack.nova.v2_0.features.ServerApi; +import org.jclouds.openstack.nova.v2_0.options.CreateServerOptions; import org.jclouds.openstack.v2_0.domain.Resource; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.common.base.Throwables; -import com.google.common.collect.ComparisonChain; -import com.google.common.collect.Iterables; -import com.google.common.collect.Ordering; /** * Tests behavior of {@code NovaApi} - * - * @author Adrian Cole */ @Test(groups = "live") public class BaseNovaApiLiveTest extends BaseApiLiveTest { - protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase(); + protected String hostName = System.getProperty("user.name").replace('.', '-').toLowerCase(); public BaseNovaApiLiveTest() { provider = "openstack-nova"; @@ -58,7 +58,15 @@ public BaseNovaApiLiveTest() { @Override public void setup() { super.setup(); - zones = api.getConfiguredZones(); + + String testZone = System.getProperty("test." + provider + ".zone"); + + if (testZone != null) { + zones = ImmutableSet.of(testZone); + } else { + zones = api.getConfiguredZones(); + } + for (String zone : zones) { ServerApi serverApi = api.getServerApiForZone(zone); for (Resource server : serverApi.list().concat()) { @@ -75,15 +83,19 @@ protected Properties setupProperties() { setIfTestSystemPropertyPresent(props, NovaProperties.AUTO_ALLOCATE_FLOATING_IPS); return props; } - + protected Server createServerInZone(String zoneId) { + return createServerInZone(zoneId, new CreateServerOptions()); + } + + protected Server createServerInZone(String zoneId, CreateServerOptions options) { ServerApi serverApi = api.getServerApiForZone(zoneId); - ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId)); + ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId), options); blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE); return serverApi.get(server.getId()); } - /** + /** * Will block until the requested server is in the correct state, if Extended Server Status extension is loaded * this will continue to block while any task is in progress. */ @@ -100,10 +112,12 @@ protected void blockUntilServerInState(String serverId, ServerApi api, Status st } } } - + protected String imageIdForZone(String zoneId) { ImageApi imageApi = api.getImageApiForZone(zoneId); - return Iterables.getLast(imageApi.list().concat()).getId(); + + // Get the first image from the list as it tends to be "lighter" and faster to start + return Iterables.get(imageApi.list().concat(), 0).getId(); } protected String flavorRefForZone(String zoneId) { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java index bd3b7315cd..df58ae0c42 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaComputeServiceContextExpectTest.java @@ -30,15 +30,15 @@ import com.google.inject.Module; /** - * Base class for writing KeyStone Expect tests with the ComputeService abstraction - * - * @author Matt Stephenson + + * Base class for writing Keystone Expect tests with the ComputeService abstraction + * */ public abstract class BaseNovaComputeServiceContextExpectTest extends BaseNovaExpectTest implements Function { - + protected final HttpRequest listDetail = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/images/detail")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/images/detail")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -46,7 +46,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/image_list_detail.json")).build(); protected final HttpRequest listFlavorsDetail = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/flavors/detail")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/flavors/detail")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -54,7 +54,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/flavor_list_detail.json")).build(); protected final HttpRequest listServers = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/servers/detail")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/servers/detail")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -62,7 +62,7 @@ ImmutableMultimap. builder().put("Accept", "application/json").p payloadFromResource("/server_list_details.json")).build(); protected final HttpRequest listFloatingIps = HttpRequest.builder().method("GET").endpoint( - URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")).headers( + URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-floating-ips")).headers( ImmutableMultimap. builder().put("Accept", "application/json").put("X-Auth-Token", authToken).build()).build(); @@ -78,7 +78,7 @@ private ComputeServiceContext createComputeServiceContext(Function { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java index 714930cd96..76460bcc09 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/internal/BaseNovaExpectTest.java @@ -25,8 +25,6 @@ /** * Base class for writing Nova Expect tests - * - * @author Adrian Cole */ public class BaseNovaExpectTest extends BaseRestApiExpectTest { protected HttpRequest keystoneAuthWithUsernameAndPassword; @@ -59,7 +57,7 @@ public BaseNovaExpectTest() { extensionsOfNovaRequest = HttpRequest.builder().method("GET") // NOTE THIS IS NOVA, NOT KEYSTONE - .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/extensions") + .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/extensions") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken).build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java index 9b056b9d22..a142b1ed31 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseComputeServiceTypicalSecurityGroupTest.java @@ -35,10 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseSecurityGroupTest") public class ParseComputeServiceTypicalSecurityGroupTest extends BaseItemParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java similarity index 75% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java index a125f9ffa6..0ad50b2fdb 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreateFlavorTest.java @@ -31,28 +31,25 @@ /** * @see FlavorApiExpectTest - * @author Ilja Bobkevic */ @Test(groups = "unit", testName = "ParseCreateFlavorTest") public class ParseCreateFlavorTest extends BaseItemParserTest { - @Override - public String resource() { - return "/flavor_new.json"; - } + @Override + public String resource() { + return "/flavor_new.json"; + } - @Override - @SelectJson("flavor") - @Consumes(MediaType.APPLICATION_JSON) - public Flavor expected() { - return Flavor.builder() - .id("1cb47a44-9b84-4da4-bf81-c1976e8414ab") - .name("128 MB Server").ram(128).vcpus(1) - .disk(10).build(); - } + @Override + @SelectJson("flavor") + @Consumes(MediaType.APPLICATION_JSON) + public Flavor expected() { + return Flavor.builder().id("1cb47a44-9b84-4da4-bf81-c1976e8414ab").name("128 MB Server") + .ram(128).vcpus(1).disk(10).build(); + } - @Override - protected Injector injector() { - return Guice.createInjector(new NovaParserModule(), new GsonModule()); - } + @Override + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java index 3b2a7745af..0cfda1a2b0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseCreatedServerTest.java @@ -33,9 +33,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseCreatedServerTest") public class ParseCreatedServerTest extends BaseItemParserTest { @@ -54,7 +51,7 @@ public ServerCreated expected() { .name("test-e92") .adminPass("ZWuHcmTMQ7eXoHeM") .links( - Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")), + Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752")), Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build(); } @@ -69,7 +66,7 @@ public ServerCreated expectedWithDiskConfig(String diskConfig) { .adminPass("ZWuHcmTMQ7eXoHeM") .diskConfig(diskConfig) .links( - Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752")), + Link.create(Relation.SELF, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752")), Link.create(Relation.BOOKMARK, URI.create("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752"))).build(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java index 4fec5c0e53..8bdef8a504 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListNormalTest.java @@ -34,10 +34,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseExtensionListNormalTest") public class ParseExtensionListNormalTest extends BaseSetParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java index ba83a850bc..e42b036f5d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionListTest.java @@ -36,10 +36,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseExtensionListTest") public class ParseExtensionListTest extends BaseSetParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java index 6ba9645914..cfef3075f1 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseExtensionTest.java @@ -35,9 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseExtensionTest") public class ParseExtensionTest extends BaseItemParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java index 27f54846e1..3351c64916 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorListTest.java @@ -35,10 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseFlavorListTest") public class ParseFlavorListTest extends BaseSetParserTest { @@ -59,7 +55,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")), + URI.create("http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37"))) @@ -71,7 +67,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), + URI.create("http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java index 9d2a0118ad..69b4ead151 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFlavorTest.java @@ -34,9 +34,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseFlavorTest") public class ParseFlavorTest extends BaseItemParserTest { @@ -57,7 +54,7 @@ public Flavor expected() { ImmutableSet.of( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")), + URI.create("http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37")))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java similarity index 80% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java index 705b6e6f40..80a85690fe 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPListTest.java @@ -33,8 +33,7 @@ import com.google.inject.Injector; /** - * - * @author Michael Arnold + * Tests parsing of {@link FloatingIP} JSON data. */ @Test(groups = "unit", testName = "ParseFloatingIPListTest") public class ParseFloatingIPListTest extends BaseSetParserTest { @@ -48,8 +47,11 @@ public String resource() { @SelectJson("floating_ips") @Consumes(MediaType.APPLICATION_JSON) public Set expected() { - return ImmutableSet.of(FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").build(), - FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).build()); + return ImmutableSet.of( + FloatingIP.builder().id("1").instanceId("12").ip("10.0.0.3").fixedIp("11.0.0.1").pool("nova").build(), + FloatingIP.builder().id("2").instanceId(null).ip("10.0.0.5").fixedIp(null).pool("nova").build(), + FloatingIP.builder().id("3").instanceId("13").ip("10.0.0.13").fixedIp("11.0.0.3").build(), + FloatingIP.builder().id("4").instanceId("14").ip("10.0.0.14").fixedIp("11.0.0.4").pool(null).build()); } protected Injector injector() { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java index a75167c5bd..fb1921a9bf 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseFloatingIPTest.java @@ -30,7 +30,7 @@ import com.google.inject.Injector; /** - * @author Michael Arnold + * Test to parse a {@link FloatingIP} */ @Test(groups = "unit", testName = "ParseFloatingIPTest") public class ParseFloatingIPTest extends BaseItemParserTest { @@ -44,7 +44,7 @@ public String resource() { @SelectJson("floating_ip") @Consumes(MediaType.APPLICATION_JSON) public FloatingIP expected() { - return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").build(); + return FloatingIP.builder().id("1").instanceId("123").fixedIp("10.0.0.2").ip("10.0.0.3").pool("nova").build(); } protected Injector injector() { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java index 2dd19b3af8..ef5d74584d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageListTest.java @@ -35,10 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseImageListTest") public class ParseImageListTest extends BaseSetParserTest { @@ -59,7 +55,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), + URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"))) @@ -71,7 +67,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), + URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2"))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java index 4d36a56798..3f93dd54a4 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseImageTest.java @@ -38,9 +38,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseImageTest") public class ParseImageTest extends BaseItemParserTest { @@ -76,7 +73,7 @@ public Image expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")), + URI.create("http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3"))) @@ -85,7 +82,7 @@ public Image expected() { ImmutableSet.of( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), + URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2")))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java index 9576b523a8..6d7a0c9aff 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairListTest.java @@ -32,10 +32,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Michael Arnold - */ @Test(groups = "unit", testName = "ParseKeyPairListTest") public class ParseKeyPairListTest extends BaseItemParserTest> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java index da1423de5d..02dac16a02 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseKeyPairTest.java @@ -30,15 +30,14 @@ import com.google.inject.Injector; /** - * - * @author Michael Arnold + * Tests parsing of a {@link KeyPair}. */ @Test(groups = "unit", testName = "ParseKeyPairTest") public class ParseKeyPairTest extends BaseItemParserTest { @Override public String resource() { - return "/keypair_created.json"; + return "/keypair_details.json"; } @Override diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java index a13d4841c4..613ca7d172 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataItemTest.java @@ -31,10 +31,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseMetadataItemTest") public class ParseMetadataItemTest extends BaseItemParserTest> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java index 5559b20f7b..730840ec53 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataListTest.java @@ -31,10 +31,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseMetadataListTest") public class ParseMetadataListTest extends BaseItemParserTest> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java index eb7a1e830e..a518dfe7ac 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseMetadataUpdateTest.java @@ -31,10 +31,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Jeremy Daggett - */ @Test(groups = "unit", testName = "ParseMetadataUpdateTest") public class ParseMetadataUpdateTest extends BaseItemParserTest> { diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseNOVNCConsoleTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseNOVNCConsoleTest.java new file mode 100644 index 0000000000..9f0d925b55 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseNOVNCConsoleTest.java @@ -0,0 +1,69 @@ +/* + * 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.jclouds.openstack.nova.v2_0.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.base.Throwables; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests parsing of vnc console response. + */ +@Test(groups = "unit", testName = "ParseNOVNCConsoleTest") +public class ParseNOVNCConsoleTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/novnc_console.json"; + } + + @Override + @SelectJson("console") + @Consumes(MediaType.APPLICATION_JSON) + public Console expected() { + Console console = null; + try { + console = Console + .builder() + .url(new URI("http://example.com:6080/vnc_auto.html?token=f9906a48-b71e-4f18" + + "-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)")) + .type(Console.Type.NOVNC) + .build(); + } catch (Exception e) { + Throwables.propagate(e); + } + + return console; + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseRDPConsoleTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseRDPConsoleTest.java new file mode 100644 index 0000000000..9c80a1c4a4 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseRDPConsoleTest.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.jclouds.openstack.nova.v2_0.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.base.Throwables; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests parsing of RDP console response. + */ +@Test(groups = "unit", testName = "ParseRDPConsoleTest") +public class ParseRDPConsoleTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/rdp_console.json"; + } + + @Override + @SelectJson("console") + @Consumes(MediaType.APPLICATION_JSON) + public Console expected() { + Console console = null; + + try { + console = Console + .builder() + .url(new URI("http://example.com:6083/?token=f9906a48-b71e-4f18-baca-" + + "c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)")) + .type(Console.Type.RDP_HTML5) + .build(); + } catch (Exception e) { + Throwables.propagate(e); + } + + return console; + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSPICEConsoleTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSPICEConsoleTest.java new file mode 100644 index 0000000000..f8eb47f978 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSPICEConsoleTest.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.jclouds.openstack.nova.v2_0.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.base.Throwables; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests parsing of spice console response. + */ +@Test(groups = "unit", testName = "ParseSPICEConsoleTest") +public class ParseSPICEConsoleTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/spice_console.json"; + } + + @Override + @SelectJson("console") + @Consumes(MediaType.APPLICATION_JSON) + public Console expected() { + Console console = null; + + try { + console = Console + .builder() + .url(new URI("http://example.com:6080/spice_auto.html?token=f9906a48-b71e" + + "-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)")) + .type(Console.Type.SPICE_HTML5) + .build(); + } catch (Exception e) { + Throwables.propagate(e); + } + + return console; + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java index 4e46ede804..ba5aa78179 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupListTest.java @@ -34,10 +34,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Michael Arnold - */ @Test(groups = "unit", testName = "ParseSecurityGroupListTest") public class ParseSecurityGroupListTest extends BaseSetParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java index 784a0bdb40..0854b28392 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseSecurityGroupTest.java @@ -35,10 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Michael Arnold - */ @Test(groups = "unit", testName = "ParseSecurityGroupTest") public class ParseSecurityGroupTest extends BaseItemParserTest { @Override diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java index afa6874006..4f151d9b86 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsEssexTest.java @@ -41,9 +41,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseServerDetailsEssexTest") public class ParseServerDetailsEssexTest extends BaseSetParserTest { @@ -64,7 +61,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207")), + URI.create("http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207")), Link.create( Relation.BOOKMARK, URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207"))) @@ -99,7 +96,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236")), + URI.create("http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236")), Link.create( Relation.BOOKMARK, URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236"))) @@ -133,7 +130,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://nova:8774/v1.1/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21")), + URI.create("http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21")), Link.create( Relation.BOOKMARK, URI.create("http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21"))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsStatesTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsStatesTest.java new file mode 100644 index 0000000000..65b15b44ce --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDetailsStatesTest.java @@ -0,0 +1,252 @@ +/* + * 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.jclouds.openstack.nova.v2_0.parse; + +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Guice; +import com.google.inject.Injector; +import java.net.URI; +import java.util.Set; +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseSetParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Address; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.domain.Server.Status; +import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedAttributes; +import org.jclouds.openstack.nova.v2_0.domain.ServerExtendedStatus; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ParseServerDetailsStatesTest") +public class ParseServerDetailsStatesTest extends BaseSetParserTest { + + @Override + public String resource() { + return "/server_list_details_states.json"; + } + + @Override + @SelectJson("servers") + @Consumes(MediaType.APPLICATION_JSON) + public Set expected() { + return ImmutableSet.of( + Server.builder() + .links( + Link.create( + Relation.SELF, + URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f")), + Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f"))) + .image(Resource.builder() + .id("e3f84189-964e-4dc3-8ac6-832c2b7553d4") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4"))) + .build()) + .flavor(Resource.builder() + .id("6") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6"))) + .build()) + .id("56d51a88-0066-4976-91b6-d1b453be603f") + .userId("08ba127f0d6842279f9db8e8bc6977e9") + .status(Status.BUILD) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:59Z")) + .hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8") + .name("machine_5") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:54:57Z")) + .tenantId("4e1900cf21924a098709c23480e157c0") + .extendedStatus(ServerExtendedStatus.builder().vmState("building").powerState(0).taskState("spawning") + .build()) + .diskConfig("MANUAL") + .extendedAttributes( + ServerExtendedAttributes.builder() + .instanceName("instance-0000000b") + .hostName("rdohavana.localdomain") + .hypervisorHostName("rdohavana.localdomain").build() + ).build(), + Server.builder() + .links( + Link.create( + Relation.SELF, + URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003")), + Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003"))) + .image(Resource.builder() + .id("e3f84189-964e-4dc3-8ac6-832c2b7553d4") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4"))) + .build()) + .flavor(Resource.builder() + .id("6") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6"))) + .build()) + .id("3bc8ab03-52e7-4d2b-ba88-73f9ecadf003") + .userId("08ba127f0d6842279f9db8e8bc6977e9") + .status(Status.ACTIVE) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:52:21Z")) + .hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8") + .name("machine_4") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:51:53Z")) + .tenantId("4e1900cf21924a098709c23480e157c0") + .extendedStatus(ServerExtendedStatus.builder().vmState("active").powerState(1).build()) + .diskConfig("MANUAL") + .extendedAttributes( + ServerExtendedAttributes.builder() + .instanceName("instance-00000009") + .hostName("rdohavana.localdomain") + .hypervisorHostName("rdohavana.localdomain").build() + ) + .addresses(ImmutableMultimap.builder() + .putAll("public", Address.createV4("172.24.4.232")).build() + ).build(), + Server.builder() + .links( + Link.create( + Relation.SELF, + URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769")), + Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769"))) + .image(Resource.builder() + .id("e3f84189-964e-4dc3-8ac6-832c2b7553d4") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4"))) + .build()) + .flavor(Resource.builder() + .id("6") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6"))) + .build()) + .id("cad76945-8851-489a-99e1-f1049e02c769") + .userId("08ba127f0d6842279f9db8e8bc6977e9") + .status(Status.SHELVED_OFFLOADED) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:38:05Z")) + .name("machine_3") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:33:27Z")) + .tenantId("4e1900cf21924a098709c23480e157c0") + .extendedStatus(ServerExtendedStatus.builder().vmState("shelved_offloaded").powerState(4).build()) + .diskConfig("MANUAL") + .extendedAttributes( + ServerExtendedAttributes.builder() + .instanceName("instance-00000006").build() + ) + .addresses(ImmutableMultimap.builder() + .putAll("public", Address.createV4("172.24.4.229")).build() + ).build(), + Server.builder() + .links( + Link.create( + Relation.SELF, + URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9")), + Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9"))) + .image(Resource.builder() + .id("e3f84189-964e-4dc3-8ac6-832c2b7553d4") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4"))) + .build()) + .flavor(Resource.builder() + .id("6") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6"))) + .build()) + .id("89142a4f-f58c-4205-8571-65f4a2be2bc9") + .userId("08ba127f0d6842279f9db8e8bc6977e9") + .status(Status.RESCUE) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:36:05Z")) + .hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8") + .name("machine_2") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:31:19Z")) + .tenantId("4e1900cf21924a098709c23480e157c0") + .extendedStatus(ServerExtendedStatus.builder().vmState("rescued").powerState(1).build()) + .diskConfig("MANUAL") + .extendedAttributes( + ServerExtendedAttributes.builder() + .instanceName("instance-00000005") + .hostName("rdohavana.localdomain") + .hypervisorHostName("rdohavana.localdomain").build() + ) + .addresses(ImmutableMultimap.builder() + .putAll("public", Address.createV4("172.24.4.227")).build() + ).build(), + Server.builder() + .links( + Link.create( + Relation.SELF, + URI.create("http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00")), + Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00"))) + .image(Resource.builder() + .id("e3f84189-964e-4dc3-8ac6-832c2b7553d4") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4"))) + .build()) + .flavor(Resource.builder() + .id("6") + .links(Link.create( + Relation.BOOKMARK, + URI.create("http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6"))) + .build()) + .id("fac50d26-bb38-455f-ad92-eba790187c00") + .userId("08ba127f0d6842279f9db8e8bc6977e9") + .status(Status.SHUTOFF) + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:35:26Z")) + .hostId("0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8") + .name("machine_1") + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2014-03-19T11:28:56Z")) + .tenantId("4e1900cf21924a098709c23480e157c0") + .extendedStatus(ServerExtendedStatus.builder().vmState("stopped").powerState(4).build()) + .diskConfig("MANUAL") + .extendedAttributes( + ServerExtendedAttributes.builder() + .instanceName("instance-00000004") + .hostName("rdohavana.localdomain") + .hypervisorHostName("rdohavana.localdomain").build() + ) + .addresses(ImmutableMultimap.builder() + .putAll("public", Address.createV4("172.24.4.228")).build() + ).build() + ); + } + + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java similarity index 59% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java index 8d4eb8bb58..391fc58a16 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerDiagnostics.java @@ -27,31 +27,27 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; -/** - * - * @author Leander Beernaert - */ -public class ParseServerDiagnostics extends BaseItemParserTest>> { +public class ParseServerDiagnostics extends BaseItemParserTest>> { @Override - public Optional> expected() { - return Optional.>of( - new ImmutableMap.Builder() + public Optional> expected() { + return Optional.>of( + new ImmutableMap.Builder() .put("vnet0_tx_errors", "0") - .put("vda_read","77364736") - .put("vda_write","415446016") - .put("vnet0_tx_packets","9701") - .put("vda_write_req","47278") - .put("cpu0_time","143150000000") - .put("vnet0_tx","1691221") - .put("vnet0_rx_drop","0") - .put("vda_errors","-1") - .put("vnet0_rx_errors","0") - .put("memory","524288") - .put("vnet0_rx_packets","11271") - .put("vda_read_req","9551") - .put("vnet0_rx","1805288") - .put("vnet0_tx_drop","0").build()); + .put("vda_read", "77364736") + .put("vda_write", "415446016") + .put("vnet0_tx_packets", "9701") + .put("vda_write_req", "47278") + .put("cpu0_time", "143150000000") + .put("vnet0_tx", "1691221") + .put("vnet0_rx_drop", "0") + .put("vda_errors", "-1") + .put("vnet0_rx_errors", "0") + .put("memory", "524288") + .put("vnet0_rx_packets", "11271") + .put("vda_read_req", "9551") + .put("vnet0_rx", "1805288") + .put("vnet0_tx_drop", "0").build()); } } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java similarity index 94% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java index 4ebbcf2a71..ad2811efbd 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerListTest.java @@ -35,10 +35,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseServerListTest") public class ParseServerListTest extends BaseSetParserTest { @@ -59,7 +55,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")), + URI.create("http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f6af67565")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6af67565"))) @@ -71,7 +67,7 @@ public Set expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")), + URI.create("http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5"))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java similarity index 92% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java index 1b53135933..019f21592a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerTest.java @@ -42,9 +42,6 @@ import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4; import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseServerTest") public class ParseServerTest extends BaseItemParserTest { @@ -59,7 +56,7 @@ public String resource() { public Server expected() { return Server .builder() - .id("52415800-8b69-11e0-9b19-734f000004d2") + .id("71752") .tenantId("1234") .userId("5678") .name("sample-f352") @@ -78,7 +75,7 @@ public Server expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), + URI.create("http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54"))) @@ -91,7 +88,7 @@ public Server expected() { .links( Link.create( Relation.SELF, - URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), + URI.create("http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), Link.create( Relation.BOOKMARK, URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"))) @@ -104,10 +101,10 @@ public Server expected() { .putAll("private", createV4("10.176.42.16"), createV6("::babe:10.176.42.16")) .build()) .links(Link.create( - Relation.SELF, URI.create("http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54")), + Relation.SELF, URI.create("http://servers.api.openstack.org/v2/1234/servers/71752")), Link.create( Relation.BOOKMARK, - URI.create("http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54"))) + URI.create("http://servers.api.openstack.org/1234/servers/71752"))) .build(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java index e5d37d0a08..013bf9b809 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithAllExtensionsTest.java @@ -40,9 +40,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adam Lowe - */ @Test(groups = "unit", testName = "ParseServerWithAllExtensionsTest") public class ParseServerWithAllExtensionsTest extends BaseItemParserTest { diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java similarity index 98% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java index 2065f20c34..77230aaac0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithInternetAddressesTest.java @@ -38,9 +38,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseServerTest") public class ParseServerWithInternetAddressesTest extends BaseItemParserTest { @@ -85,7 +82,7 @@ public Server expected() { .links( Link.create( Relation.SELF, - URI.create("https://nova-api.openstack.org:9774/v1.1/37/servers/1459")), + URI.create("https://nova-api.openstack.org:9774/v2/37/servers/1459")), Link.create( Relation.BOOKMARK, URI.create("https://nova-api.openstack.org:9774/37/servers/1459"))) diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithoutImageTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithoutImageTest.java new file mode 100644 index 0000000000..83c748b528 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseServerWithoutImageTest.java @@ -0,0 +1,99 @@ +/* + * 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.jclouds.openstack.nova.v2_0.parse; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.inject.Guice; +import com.google.inject.Injector; +import org.jclouds.date.internal.SimpleDateFormatDateService; +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Address; +import org.jclouds.openstack.nova.v2_0.domain.Server; +import org.jclouds.openstack.nova.v2_0.domain.Server.Status; +import org.jclouds.openstack.v2_0.domain.Link; +import org.jclouds.openstack.v2_0.domain.Link.Relation; +import org.jclouds.openstack.v2_0.domain.Resource; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; +import java.net.URI; + +import static org.jclouds.openstack.nova.v2_0.domain.Address.createV4; +import static org.jclouds.openstack.nova.v2_0.domain.Address.createV6; + +@Test(groups = "unit", testName = "ParseServerWithoutImageTest") +public class ParseServerWithoutImageTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/server_details_without_image.json"; + } + + @Override + @SelectJson("server") + @Consumes(MediaType.APPLICATION_JSON) + public Server expected() { + return Server + .builder() + .id("71752") + .tenantId("1234") + .userId("5678") + .name("sample-f352") + .updated(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-10-10T12:00:00Z")) + .created(new SimpleDateFormatDateService().iso8601SecondsDateParse("2010-08-10T12:00:00Z")) + .hostId("e4d909c290d0fb1ca068ffaddf22cbd0") + .accessIPv4("67.23.10.132") + .accessIPv6("::babe:67.23.10.132") + .status(Status.BUILD) + .diskConfig(Server.DISK_CONFIG_AUTO) + .flavor( + Resource + .builder() + .id("52415800-8b69-11e0-9b19-734f216543fd") + .name("null") + .links( + Link.create( + Relation.SELF, + URI.create("http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd"))) + .build()) + .metadata( + new ImmutableMap.Builder().put("Server Label", "Web Head 1") + .put("Image Version", "2.1").build()) + .addresses(ImmutableMultimap.builder() + .putAll("public", createV4("67.23.10.132"), createV6("::babe:67.23.10.132"), createV4("67.23.10.131"), createV6("::babe:4317:0A83")) + .putAll("private", createV4("10.176.42.16"), createV6("::babe:10.176.42.16")) + .build()) + .links(Link.create( + Relation.SELF, URI.create("http://servers.api.openstack.org/v2/1234/servers/71752")), + Link.create( + Relation.BOOKMARK, + URI.create("http://servers.api.openstack.org/1234/servers/71752"))) + .build(); + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseXVPVNCConsoleTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseXVPVNCConsoleTest.java new file mode 100644 index 0000000000..5a38829cf0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/ParseXVPVNCConsoleTest.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.jclouds.openstack.nova.v2_0.parse; + +import java.net.URI; + +import javax.ws.rs.Consumes; +import javax.ws.rs.core.MediaType; + +import org.jclouds.json.BaseItemParserTest; +import org.jclouds.json.config.GsonModule; +import org.jclouds.openstack.nova.v2_0.config.NovaParserModule; +import org.jclouds.openstack.nova.v2_0.domain.Console; +import org.jclouds.rest.annotations.SelectJson; +import org.testng.annotations.Test; + +import com.google.common.base.Throwables; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * Tests parsing of vnc console response. + */ +@Test(groups = "unit", testName = "ParseXVPVNCConsoleTest") +public class ParseXVPVNCConsoleTest extends BaseItemParserTest { + + @Override + public String resource() { + return "/xvpvnc_console.json"; + } + + @Override + @SelectJson("console") + @Consumes(MediaType.APPLICATION_JSON) + public Console expected() { + Console console = null; + try { + console = Console + .builder() + .url(new URI("http://example.com:6081/console?token=2abbe0b2-dcf1-479d-8d58-88e82b477865")) + .type(Console.Type.XVPVNC) + .build(); + } catch (Exception e) { + Throwables.propagate(e); + } + + return console; + } + + protected Injector injector() { + return Guice.createInjector(new NovaParserModule(), new GsonModule()); + } + +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java index 3b567662bd..ee55926e33 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/parse/PublicIpsInPrivateAddressBlockExpectTest.java @@ -39,9 +39,6 @@ import com.google.inject.Guice; import com.google.inject.Injector; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ParseCreatedServerTest") public class PublicIpsInPrivateAddressBlockExpectTest extends BaseItemParserTest { @@ -88,7 +85,7 @@ public Server expected() { .addresses(ImmutableMultimap.builder() .putAll("private", Address.createV4("10.6.39.189"), Address.createV4("15.185.181.94")).build()) .links( - Link.create(Relation.SELF, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662")), + Link.create(Relation.SELF, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/59662")), Link.create(Relation.BOOKMARK, URI.create("https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662"))).build(); } diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java index b4cad2bb56..8bc43e3817 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ImagePredicatesTest.java @@ -23,10 +23,6 @@ import org.jclouds.openstack.nova.v2_0.parse.ParseImageTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "ImagePredicatesTest") public class ImagePredicatesTest { Image ref = new ParseImageTest().expected(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java index 26e5ce2790..4a073ed3d2 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/SecurityGroupPredicatesTest.java @@ -33,10 +33,6 @@ import com.google.common.collect.ImmutableSet; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "SecurityGroupPredicatesTest") public class SecurityGroupPredicatesTest { SecurityGroup ref = SecurityGroup.builder().id("12345").name("jclouds").description("description").build(); diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicatesMockTest.java b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicatesMockTest.java new file mode 100644 index 0000000000..a636b152e5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicatesMockTest.java @@ -0,0 +1,105 @@ +/* + * 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.jclouds.openstack.nova.v2_0.predicates; + +import com.squareup.okhttp.mockwebserver.MockResponse; +import com.squareup.okhttp.mockwebserver.MockWebServer; +import org.jclouds.openstack.nova.v2_0.NovaApi; +import org.jclouds.openstack.nova.v2_0.features.ServerApi; +import org.jclouds.openstack.v2_0.internal.BaseOpenStackMockTest; +import org.testng.annotations.Test; + +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE; +import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF; +import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitActive; +import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitShutoff; +import static org.jclouds.openstack.nova.v2_0.predicates.ServerPredicates.awaitStatus; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +@Test(groups = "unit", testName = "ServerPredicatesMockTest") +public class ServerPredicatesMockTest extends BaseOpenStackMockTest { + public void testAwaitActive() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(new MockResponse().setBody(stringFromResource("/access.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + String serverDetailsActive = stringFromResource("/server_details.json").replace("BUILD(scheduling)", ACTIVE.value()); + server.enqueue(new MockResponse().setBody(serverDetailsActive)); + + try { + NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova"); + ServerApi serverApi = novaApi.getServerApiForZone("RegionOne"); + + boolean result = awaitActive(serverApi).apply("71752"); + + assertTrue(result); + assertEquals(server.getRequestCount(), 5); + assertAuthentication(server); + } finally { + server.shutdown(); + } + } + + public void testAwaitShutoff() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(new MockResponse().setBody(stringFromResource("/access.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + String serverDetailsShutoff = stringFromResource("/server_details.json").replace("BUILD(scheduling)", SHUTOFF.value()); + server.enqueue(new MockResponse().setBody(serverDetailsShutoff)); + + try { + NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova"); + ServerApi serverApi = novaApi.getServerApiForZone("RegionOne"); + + boolean result = awaitShutoff(serverApi).apply("71752"); + + assertTrue(result); + assertEquals(server.getRequestCount(), 7); + assertAuthentication(server); + } finally { + server.shutdown(); + } + } + + public void testAwaitTimeout() throws Exception { + MockWebServer server = mockOpenStackServer(); + server.enqueue(new MockResponse().setBody(stringFromResource("/access.json"))); + + for (int i = 0; i < 20; i++) { + server.enqueue(new MockResponse().setBody(stringFromResource("/server_details.json"))); + } + + try { + NovaApi novaApi = api(server.getUrl("/").toString(), "openstack-nova"); + ServerApi serverApi = novaApi.getServerApiForZone("RegionOne"); + + boolean result = awaitStatus(serverApi, ACTIVE, 3, 1).apply("71752"); + + assertFalse(result); + assertAuthentication(server); + } finally { + server.shutdown(); + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/access.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/access.json new file mode 100644 index 0000000000..fab16454bc --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/access.json @@ -0,0 +1,228 @@ +{ + "access": { + "metadata": { + "roles": [ + "9fe2ff9ee4384b1894a90878d3e92bab", + "b926cb0f4e2642678735f86c2b06205e", + "33484487e73d4da0918a19b9c7e1f8ae", + "f2e54c2105fb49e29479af047115cebc" + ], + "is_admin": 0 + }, + "user": { + "name": "joe", + "roles": [ + { + "name": "_member_" + }, + { + "name": "anotherrole" + }, + { + "name": "heat_stack_owner" + }, + { + "name": "Member" + } + ], + "id": "8fbf8e68d36e4ac7bcf912a26213bd49", + "roles_links": [], + "username": "joe" + }, + "serviceCatalog": [ + { + "name": "nova", + "type": "compute", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v2/da0d12be20394afb851716e10a49e4a7", + "id": "2122bcaa704343c19ad2578410d4961d", + "internalURL": "URL/v2/da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL/v2/da0d12be20394afb851716e10a49e4a7" + } + ] + }, + { + "name": "neutron", + "type": "network", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/", + "id": "65a4d3f13cfb49a6a57a04e205cc2158", + "internalURL": "URL/", + "region": "RegionOne", + "adminURL": "URL/" + } + ] + }, + { + "name": "cinderv2", + "type": "volumev2", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v2/da0d12be20394afb851716e10a49e4a7", + "id": "31fe4d92eac44044b05be21c6f44cebc", + "internalURL": "URL/v2/da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL/v2/da0d12be20394afb851716e10a49e4a7" + } + ] + }, + { + "name": "trove", + "type": "database", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7", + "id": "06b7a7dbd25c4a01819c879700a9712a", + "internalURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL/v1.0/da0d12be20394afb851716e10a49e4a7" + } + ] + }, + { + "name": "s3", + "type": "s3", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL", + "id": "93b0b67091324e8ba01b62ee0584994c", + "internalURL": "URL", + "region": "RegionOne", + "adminURL": "URL" + } + ] + }, + { + "name": "glance", + "type": "image", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL", + "id": "a542e91bcfa046bfa1bf2397356d1414", + "internalURL": "URL", + "region": "RegionOne", + "adminURL": "URL" + } + ] + }, + { + "name": "novav3", + "type": "computev3", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v3", + "id": "9c3e8abb576d483db93bcef70c67bc1d", + "internalURL": "URL/v3", + "region": "RegionOne", + "adminURL": "URL/v3" + } + ] + }, + { + "name": "heat", + "type": "cloudformation", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v1", + "id": "6f4ca5ca9698425b85c300b3fc176c39", + "internalURL": "URL/v1", + "region": "RegionOne", + "adminURL": "URL/v1" + } + ] + }, + { + "name": "cinder", + "type": "volume", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v1/da0d12be20394afb851716e10a49e4a7", + "id": "037039c676694a35aa28d34fce09e51d", + "internalURL": "URL/v1/da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL/v1/da0d12be20394afb851716e10a49e4a7" + } + ] + }, + { + "name": "ec2", + "type": "ec2", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/services/Cloud", + "id": "1d242631bccb4ff4ba7a395dbcb51648", + "internalURL": "URL/services/Cloud", + "region": "RegionOne", + "adminURL": "URL/services/Admin" + } + ] + }, + { + "name": "heat", + "type": "orchestration", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v1/da0d12be20394afb851716e10a49e4a7", + "id": "199d00075e4a40308a6ad2aa8980d0cd", + "internalURL": "URL/v1/da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL/v1/da0d12be20394afb851716e10a49e4a7" + } + ] + }, + { + "name": "swift", + "type": "object-store", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v1/AUTH_da0d12be20394afb851716e10a49e4a7", + "id": "26b2cb1efb044193b847fc3f2fb12e82", + "internalURL": "URL/v1/AUTH_da0d12be20394afb851716e10a49e4a7", + "region": "RegionOne", + "adminURL": "URL" + } + ] + }, + { + "name": "keystone", + "type": "identity", + "endpoints_links": [], + "endpoints": [ + { + "publicURL": "URL/v2.0", + "id": "1bbfe80b50df4c4a84040aa782e42140", + "internalURL": "URL/v2.0", + "region": "RegionOne", + "adminURL": "URL/v2.0" + } + ] + } + ], + "token": { + "tenant": { + "name": "jclouds", + "id": "da0d12be20394afb851716e10a49e4a7", + "enabled": true, + "description": null + }, + "id": "TOKEN", + "expires": "2014-04-28T22:48:24Z", + "issued_at": "2014-04-28T21:48:24.972896" + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_details.json new file mode 100644 index 0000000000..9b9eaf36a6 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_details.json @@ -0,0 +1,8 @@ +{ + "volumeAttachment": { + "device": "/dev/vdc", + "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", + "id": 1, + "volumeId": 1 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_list.json new file mode 100644 index 0000000000..03f5c53d90 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/attachment_list.json @@ -0,0 +1,10 @@ +{ + "volumeAttachments": [ + { + "device": "/dev/vdc", + "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", + "id": 1, + "volumeId": 1 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_details.json new file mode 100644 index 0000000000..98a0614130 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_details.json @@ -0,0 +1,21 @@ +{ + "extension": { + "name": "Public Image Extension", + "namespace": "http://docs.rackspacecloud.com/servers/api/ext/pie/v1.0", + "alias": "RS-PIE", + "updated": "2011-01-22T13:25:27-06:00", + "description": "Adds the capability to share an image with other users.", + "links": [ + { + "rel": "describedby", + "type": "application/pdf", + "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-pie-20111111.pdf" + }, + { + "rel": "describedby", + "type": "application/vnd.sun.wadl+xml", + "href": "http://docs.rackspacecloud.com/servers/api/ext/cs-pie.wadl" + } + ] + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list.json index 4f3faa50ef..3fd77fcdd5 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/extension_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list.json @@ -39,4 +39,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_full.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_full.json new file mode 100644 index 0000000000..c54a010129 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_full.json @@ -0,0 +1,284 @@ +{ + "extensions": [ + { + "updated": "2011-09-27T00:00:00+00:00", + "name": "DiskConfig", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/disk_config/api/v1.1", + "alias": "OS-DCF", + "description": "Disk Management Extension" + }, + { + "updated": "2011-06-29T00:00:00+00:00", + "name": "Hosts", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/hosts/api/v1.1", + "alias": "os-hosts", + "description": "Admin-only host administration" + }, + { + "updated": "2011-07-19T00:00:00+00:00", + "name": "SchedulerHints", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/scheduler-hints/api/v2", + "alias": "os-scheduler-hints", + "description": "Pass arbitrary key/value pairs to the scheduler" + }, + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Quotas", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/quotas-sets/api/v1.1", + "alias": "os-quota-sets", + "description": "Quotas management support" + }, + { + "updated": "2011-12-23T00:00:00+00:00", + "name": "Floating_ip_dns", + "links": [], + "namespace": "http://docs.openstack.org/ext/floating_ip_dns/api/v1.1", + "alias": "os-floating-ip-dns", + "description": "Floating IP DNS support" + }, + { + "updated": "2011-09-14T00:00:00+00:00", + "name": "FlavorExtraData", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_data/api/v1.1", + "alias": "OS-FLV-EXT-DATA", + "description": "Provide additional data for flavors" + }, + { + "updated": "2011-06-23T00:00:00+00:00", + "name": "FlavorExtraSpecs", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/flavor_extra_specs/api/v1.1", + "alias": "os-flavor-extra-specs", + "description": "Instance type (flavor) extra specs" + }, + { + "updated": "2011-08-17T00:00:00+00:00", + "name": "VirtualInterfaces", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/virtual_interfaces/api/v1.1", + "alias": "virtual_interfaces", + "description": "Virtual interface support" + }, + { + "updated": "2011-12-23T00:00:00+00:00", + "name": "Accounts", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/accounts/api/v1.1", + "alias": "os-accounts", + "description": "Admin-only access to accounts" + }, + { + "updated": "2011-03-25T00:00:00+00:00", + "name": "Volumes", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/volumes/api/v1.1", + "alias": "os-volumes", + "description": "Volumes support" + }, + { + "updated": "2011-11-03T00:00:00+00:00", + "name": "ExtendedStatus", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1", + "alias": "OS-EXT-STS", + "description": "Extended Status support" + }, + { + "updated": "2011-12-23T00:00:00+00:00", + "name": "Consoles", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/os-consoles/api/v2", + "alias": "os-consoles", + "description": "Interactive Console support." + }, + { + "updated": "2011-07-21T00:00:00+00:00", + "name": "SecurityGroups", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/securitygroups/api/v1.1", + "alias": "security_groups", + "description": "Security group support" + }, + { + "updated": "2012-01-12T00:00:00+00:00", + "name": "Aggregates", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/aggregates/api/v1.1", + "alias": "os-aggregates", + "description": "Admin-only aggregate administration" + }, + { + "updated": "2011-07-19T00:00:00+00:00", + "name": "Createserverext", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/createserverext/api/v1.1", + "alias": "os-create-server-ext", + "description": "Extended support to the Create Server v1.1 API" + }, + { + "updated": "2011-09-01T00:00:00+00:00", + "name": "DeferredDelete", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/deferred-delete/api/v1.1", + "alias": "os-deferred-delete", + "description": "Instance deferred delete" + }, + { + "updated": "2011-12-21T00:00:00+00:00", + "name": "ServerDiagnostics", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/server-diagnostics/api/v1.1", + "alias": "os-server-diagnostics", + "description": "Allow Admins to view server diagnostics through server action" + }, + { + "updated": "2011-12-23T00:00:00+00:00", + "name": "Networks", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/networks/api/v1.1", + "alias": "os-networks", + "description": "Admin-only Network Management Extension" + }, + { + "updated": "2011-11-03T00:00:00+00:00", + "name": "ExtendedServerAttributes", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/extended_status/api/v1.1", + "alias": "OS-EXT-SRV-ATTR", + "description": "Extended Server Attributes support." + }, + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Keypairs", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/keypairs/api/v1.1", + "alias": "os-keypairs", + "description": "Keypair Support" + }, + { + "updated": "2011-08-24T00:00:00+00:00", + "name": "VolumeTypes", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/volume_types/api/v1.1", + "alias": "os-volume-types", + "description": "Volume types support" + }, + { + "updated": "2011-08-19T00:00:00+00:00", + "name": "SimpleTenantUsage", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/os-simple-tenant-usage/api/v1.1", + "alias": "os-simple-tenant-usage", + "description": "Simple tenant usage extension" + }, + { + "updated": "2012-01-04T00:00:00+00:00", + "name": "Floating_ip_pools", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/floating_ip_pools/api/v1.1", + "alias": "os-floating-ip-pools", + "description": "Floating IPs support" + }, + { + "updated": "2012-01-23T00:00:00+00:00", + "name": "ServerStartStop", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/servers/api/v1.1", + "alias": "os-server-start-stop", + "description": "Start/Stop instance compute API support" + }, + { + "updated": "2012-01-19T00:00:00+00:00", + "name": "Certificates", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/certificates/api/v1.1", + "alias": "os-certificates", + "description": "Certificates support" + }, + { + "updated": "2011-08-18T00:00:00+00:00", + "name": "Rescue", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/rescue/api/v1.1", + "alias": "os-rescue", + "description": "Instance rescue mode" + }, + { + "updated": "2012-01-19T00:00:00+00:00", + "name": "FlavorManage", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/flavor_manage/api/v1.1", + "alias": "os-flavor-manage", + "description": "\n Flavor create/delete API support\n " + }, + { + "updated": "2011-12-16T00:00:00+00:00", + "name": "Cloudpipe", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/cloudpipe/api/v1.1", + "alias": "os-cloudpipe", + "description": "Adds actions to create cloudpipe instances.\n\n When running with the Vlan network mode, you need a mechanism to route\n from the public Internet to your vlans. This mechanism is known as a\n cloudpipe.\n\n At the time of creating this class, only OpenVPN is supported. Support for\n a SSH Bastion host is forthcoming.\n " + }, + { + "updated": "2011-06-09T00:00:00+00:00", + "name": "Multinic", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/multinic/api/v1.1", + "alias": "NMN", + "description": "Multiple network support" + }, + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Users", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/users/api/v1.1", + "alias": "os-users", + "description": "Allow admins to acces user information" + }, + { + "updated": "2011-09-20T00:00:00+00:00", + "name": "AdminActions", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/admin-actions/api/v1.1", + "alias": "os-admin-actions", + "description": "Enable admin-only server actions\n\n Actions include: pause,unpause, suspend, resume, migrate,\n resetNetwork, injectNetworkInfo, lock, unlock, createBackup\n " + }, + { + "updated": "2011-12-21T00:00:00+00:00", + "name": "ServerActionList", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/server-actions-list/api/v1.1", + "alias": "os-server-action-list", + "description": "Allow Admins to view pending server actions" + }, + { + "updated": "2011-12-08T00:00:00+00:00", + "name": "Console_output", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/os-console-output/api/v2", + "alias": "os-console-output", + "description": "Console log output support, with tailing ability." + }, + { + "updated": "2011-06-16T00:00:00+00:00", + "name": "Floating_ips", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/floating_ips/api/v1.1", + "alias": "os-floating-ips", + "description": "Floating IPs support" + }, + { + "updated": "2012-12-21T00:00:00+00:00", + "name": "AvailabilityZone", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1", + "alias": "os-availability-zone", + "description": "1. Add availability_zone to the Create Server v1.1 API.\n 2. Add availability zones describing.\n " + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_normal.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_normal.json new file mode 100644 index 0000000000..211338d14f --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_normal.json @@ -0,0 +1,36 @@ +{ + "extensions": [ + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Keypairs", + "links": [], + "namespace": "http://docs.openstack.org/ext/keypairs/api/v1.1", + "alias": "os-keypairs", + "description": "Keypair Support" + }, + { + "updated": "2011-03-25T00:00:00+00:00", + "name": "Volumes", + "links": [], + "namespace": "http://docs.openstack.org/ext/volumes/api/v1.1", + "alias": "os-volumes", + "description": "Volumes support" + }, + { + "updated": "2011-07-21T00:00:00+00:00", + "name": "SecurityGroups", + "links": [], + "namespace": "http://docs.openstack.org/ext/securitygroups/api/v1.1", + "alias": "security_groups", + "description": "Security group support" + }, + { + "updated": "2011-06-16T00:00:00+00:00", + "name": "Floating_ips", + "links": [], + "namespace": "http://docs.openstack.org/ext/floating_ips/api/v1.1", + "alias": "os-floating-ips", + "description": "Floating IPs support" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_openstack.json new file mode 100644 index 0000000000..fad15a79e5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/extension_list_openstack.json @@ -0,0 +1,140 @@ +{ + "extensions": [ + { + "updated": "2011-06-09T00:00:00+00:00", + "name": "Multinic", + "links": [], + "namespace": "https://docs.openstack.org/ext/multinic/api/v1.1", + "alias": "NMN", + "description": "Multiple network support" + }, + { + "updated": "2011-06-29T00:00:00+00:00", + "name": "Hosts", + "links": [], + "namespace": "https://docs.openstack.org/ext/hosts/api/v1.1", + "alias": "os-hosts", + "description": "Host administration" + }, + { + "updated": "2011-03-25T00:00:00+00:00", + "name": "Volumes", + "links": [], + "namespace": "https://docs.openstack.org/ext/volumes/api/v1.1", + "alias": "os-volumes", + "description": "Volumes support" + }, + { + "updated": "2011-05-25 16:12:21.656723", + "name": "Admin Controller", + "links": [], + "namespace": "https:TODO/", + "alias": "ADMIN", + "description": "The Admin API Extension" + }, + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Quotas", + "links": [], + "namespace": "https://docs.openstack.org/ext/quotas-sets/api/v1.1", + "alias": "os-quota-sets", + "description": "Quotas management support" + }, + { + "updated": "2011-08-24T00:00:00+00:00", + "name": "VolumeTypes", + "links": [], + "namespace": "https://docs.openstack.org/ext/volume_types/api/v1.1", + "alias": "os-volume-types", + "description": "Volume types support" + }, + { + "updated": "2011-06-23T00:00:00+00:00", + "name": "FlavorExtraSpecs", + "links": [], + "namespace": "https://docs.openstack.org/ext/flavor_extra_specs/api/v1.1", + "alias": "os-flavor-extra-specs", + "description": "Instance type (flavor) extra specs" + }, + { + "updated": "2011-09-14T00:00:00+00:00", + "name": "FlavorExtraData", + "links": [], + "namespace": "https://docs.openstack.org/ext/flavor_extra_data/api/v1.1", + "alias": "os-flavor-extra-data", + "description": "Provide additional data for flavors" + }, + { + "updated": "2011-08-17T00:00:00+00:00", + "name": "VirtualInterfaces", + "links": [], + "namespace": "https://docs.openstack.org/ext/virtual_interfaces/api/v1.1", + "alias": "virtual_interfaces", + "description": "Virtual interface support" + }, + { + "updated": "2011-07-19T00:00:00+00:00", + "name": "Createserverext", + "links": [], + "namespace": "https://docs.openstack.org/ext/createserverext/api/v1.1", + "alias": "os-create-server-ext", + "description": "Extended support to the Create Server v1.1 API" + }, + { + "updated": "2011-08-08T00:00:00+00:00", + "name": "Keypairs", + "links": [], + "namespace": "https://docs.openstack.org/ext/keypairs/api/v1.1", + "alias": "os-keypairs", + "description": "Keypair Support" + }, + { + "updated": "2011-08-25T00:00:00+00:00", + "name": "VSAs", + "links": [], + "namespace": "https://docs.openstack.org/ext/vsa/api/v1.1", + "alias": "zadr-vsa", + "description": "Virtual Storage Arrays support" + }, + { + "updated": "2011-08-19T00:00:00+00:00", + "name": "SimpleTenantUsage", + "links": [], + "namespace": "https://docs.openstack.org/ext/os-simple-tenant-usage/api/v1.1", + "alias": "os-simple-tenant-usage", + "description": "Simple tenant usage extension" + }, + { + "updated": "2011-08-18T00:00:00+00:00", + "name": "Rescue", + "links": [], + "namespace": "https://docs.openstack.org/ext/rescue/api/v1.1", + "alias": "os-rescue", + "description": "Instance rescue mode" + }, + { + "updated": "2011-07-21T00:00:00+00:00", + "name": "SecurityGroups", + "links": [], + "namespace": "https://docs.openstack.org/ext/securitygroups/api/v1.1", + "alias": "security_groups", + "description": "Security group support" + }, + { + "updated": "2011-06-16T00:00:00+00:00", + "name": "Floating_ips", + "links": [], + "namespace": "https://docs.openstack.org/ext/floating_ips/api/v1.1", + "alias": "os-floating-ips", + "description": "Floating IPs support" + }, + { + "updated": "2012-12-21T00:00:00+00:00", + "name": "AvailabilityZone", + "links": [], + "namespace": "http://docs.openstack.org/compute/ext/availabilityzone/api/v1.1", + "alias": "os-availability-zone", + "description": "1. Add availability_zone to the Create Server v1.1 API.\n 2. Add availability zones describing.\n " + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_details.json new file mode 100644 index 0000000000..5acfd71e02 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_details.json @@ -0,0 +1,19 @@ +{ + "flavor": { + "id": "52415800-8b69-11e0-9b19-734f1195ff37", + "name": "256 MB Server", + "ram": 256, + "disk": 10, + "vcpus": 1, + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" + } + ] + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list.json similarity index 78% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list.json index 1e4cdebebd..ab50bead1d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/flavor_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list.json @@ -6,7 +6,7 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" + "href": "http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f1195ff37" }, { "rel": "bookmark", @@ -20,7 +20,7 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" + "href": "http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" }, { "rel": "bookmark", @@ -29,4 +29,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail.json new file mode 100644 index 0000000000..27cbb5b5fc --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail.json @@ -0,0 +1,124 @@ +{ + "flavors": [ + { + "rxtx_quota": 0, + "name": "standard.xsmall", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/100", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ], + "ram": 1024, + "vcpus": 1, + "rxtx_cap": 0, + "swap": 0, + "disk": 30, + "id": 100 + }, + { + "rxtx_quota": 0, + "name": "standard.small", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/101", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/101", + "rel": "bookmark" + } + ], + "ram": 2048, + "vcpus": 2, + "rxtx_cap": 0, + "swap": 0, + "disk": 60, + "id": 101 + }, + { + "rxtx_quota": 0, + "name": "standard.2xlarge", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/105", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/105", + "rel": "bookmark" + } + ], + "ram": 32768, + "vcpus": 8, + "rxtx_cap": 0, + "swap": 0, + "disk": 960, + "id": 105 + }, + { + "rxtx_quota": 0, + "name": "standard.large", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/103", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/103", + "rel": "bookmark" + } + ], + "ram": 8192, + "vcpus": 4, + "rxtx_cap": 0, + "swap": 0, + "disk": 240, + "id": 103 + }, + { + "rxtx_quota": 0, + "name": "standard.medium", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/102", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/102", + "rel": "bookmark" + } + ], + "ram": 4096, + "vcpus": 2, + "rxtx_cap": 0, + "swap": 0, + "disk": 120, + "id": 102 + }, + { + "rxtx_quota": 0, + "name": "standard.xlarge", + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/flavors/104", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/104", + "rel": "bookmark" + } + ], + "ram": 16384, + "vcpus": 4, + "rxtx_cap": 0, + "swap": 0, + "disk": 480, + "id": 104 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail_openstack.json new file mode 100644 index 0000000000..4085d6b6e5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_list_detail_openstack.json @@ -0,0 +1,104 @@ +{ + "flavors": [ + { + "rxtx_quota": 0, + "name": "m1.medium", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/flavors/3", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/flavors/3", + "rel": "bookmark" + } + ], + "ram": 4096, + "vcpus": 2, + "rxtx_cap": 0, + "swap": 0, + "disk": 40, + "id": 3 + }, + { + "rxtx_quota": 0, + "name": "m1.large", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/flavors/4", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/flavors/4", + "rel": "bookmark" + } + ], + "ram": 8192, + "vcpus": 4, + "rxtx_cap": 0, + "swap": 0, + "disk": 80, + "id": 4 + }, + { + "rxtx_quota": 0, + "name": "m1.tiny", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/flavors/1", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/flavors/1", + "rel": "bookmark" + } + ], + "ram": 512, + "vcpus": 1, + "rxtx_cap": 0, + "swap": 0, + "disk": 0, + "id": 1 + }, + { + "rxtx_quota": 0, + "name": "m1.xlarge", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/flavors/5", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/flavors/5", + "rel": "bookmark" + } + ], + "ram": 16384, + "vcpus": 8, + "rxtx_cap": 0, + "swap": 0, + "disk": 160, + "id": 5 + }, + { + "rxtx_quota": 0, + "name": "m1.small", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/flavors/2", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/flavors/2", + "rel": "bookmark" + } + ], + "ram": 2048, + "vcpus": 1, + "rxtx_cap": 0, + "swap": 0, + "disk": 20, + "id": 2 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_new.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_new.json new file mode 100644 index 0000000000..82089932d5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/flavor_new.json @@ -0,0 +1,10 @@ +{ + "flavor": { + "id": "1cb47a44-9b84-4da4-bf81-c1976e8414ab", + "name": "128 MB Server", + "ram": 128, + "disk": 10, + "vcpus": 1, + "links": [] + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_details.json new file mode 100644 index 0000000000..7773b8e705 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_details.json @@ -0,0 +1,9 @@ +{ + "floating_ip": { + "id": 1, + "ip": "10.0.0.3", + "fixed_ip": "10.0.0.2", + "instance_id": 123, + "pool": "nova" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_list.json new file mode 100644 index 0000000000..fd91e25597 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/floatingip_list.json @@ -0,0 +1,30 @@ +{ + "floating_ips": [ + { + "instance_id": 12, + "ip": "10.0.0.3", + "fixed_ip": "11.0.0.1", + "id" : 1, + "pool": "nova" + }, + { + "instance_id": null, + "ip": "10.0.0.5", + "fixed_ip": null, + "id": 2, + "pool": "nova" + }, + { + "instance_id": 13, + "ip": "10.0.0.13", + "fixed_ip": "11.0.0.3", + "id": 3 + }, + { + "instance_id": 14, + "ip": "10.0.0.14", + "fixed_ip": "11.0.0.4", + "id": 4 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host.json new file mode 100644 index 0000000000..bf8532139d --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host.json @@ -0,0 +1,40 @@ +{ + "host": [ + { + "resource": { + "project": "(total)", + "memory_mb": 16083, + "host": "ubuntu", + "cpu": 4, + "disk_gb": 181 + } + }, + { + "resource": { + "project": "(used_now)", + "memory_mb": 3396, + "host": "ubuntu", + "cpu": 3, + "disk_gb": 5 + } + }, + { + "resource": { + "project": "(used_max)", + "memory_mb": 6144, + "host": "ubuntu", + "cpu": 3, + "disk_gb": 80 + } + }, + { + "resource": { + "project": "f8535069c3fb404cb61c873b1a0b4921", + "memory_mb": 6144, + "host": "ubuntu", + "cpu": 3, + "disk_gb": 80 + } + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_details.json new file mode 100644 index 0000000000..7ea6e8e4ac --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_details.json @@ -0,0 +1,17 @@ +{ + "aggregate": { + "name": "jclouds-test-a", + "availability_zone": "nova", + "deleted": false, + "created_at": "2012-05-11 11:40:17", + "updated_at": "2012-05-11 11:46:44", + "operational_state": "created", + "hosts": [], + "deleted_at": null, + "id": 1, + "metadata": { + "somekey": "somevalue", + "anotherkey": "another val" + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_list.json new file mode 100644 index 0000000000..c541306a3f --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_list.json @@ -0,0 +1,19 @@ +{ + "aggregates": [ + { + "name": "jclouds-test-a", + "availability_zone": "nova", + "deleted": false, + "created_at": "2012-05-11 11:40:17", + "updated_at": "2012-05-11 11:46:44", + "operational_state": "created", + "hosts": [], + "deleted_at": null, + "id": 1, + "metadata": { + "somekey": "somevalue", + "anotherkey": "another val" + } + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_with_host_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_with_host_details.json new file mode 100644 index 0000000000..c54aa791fd --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/host_aggregate_with_host_details.json @@ -0,0 +1,19 @@ +{ + "aggregate": { + "name": "jclouds-test-a", + "availability_zone": "nova", + "deleted": false, + "created_at": "2012-05-11 11:40:17", + "updated_at": "2012-05-11 11:46:44", + "operational_state": "created", + "hosts": [ + "ubuntu" + ], + "deleted_at": null, + "id": 1, + "metadata": { + "somekey": "somevalue", + "anotherkey": "another val" + } + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/hosts_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/hosts_list.json new file mode 100644 index 0000000000..6eb136179c --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/hosts_list.json @@ -0,0 +1,8 @@ +{ + "hosts": [ + { + "host_name": "ubuntu", + "service": "compute" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_active.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_active.json new file mode 100644 index 0000000000..2cfce7bfa7 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_active.json @@ -0,0 +1,41 @@ +{ + "image": { + "id": "52415800-8b69-11e0-9b19-734f5736d2a2", + "name": "My Server Backup", + "updated": "2010-10-10T12:00:00Z", + "created": "2010-08-10T12:00:00Z", + "tenant_id": "12345", + "user_id": "joe", + "status": "ACTIVE", + "progress": 80, + "minDisk": 5, + "minRam": 256, + "metadata": { + "ImageType": "Gold", + "ImageVersion": "1.5" + }, + "server": { + "id": "52415800-8b69-11e0-9b19-734f335aa7b3", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + } + ] + }, + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + } + ] + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_details.json new file mode 100644 index 0000000000..7f84ada008 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_details.json @@ -0,0 +1,41 @@ +{ + "image": { + "id": "52415800-8b69-11e0-9b19-734f5736d2a2", + "name": "My Server Backup", + "updated": "2010-10-10T12:00:00Z", + "created": "2010-08-10T12:00:00Z", + "tenant_id": "12345", + "user_id": "joe", + "status": "SAVING", + "progress": 80, + "minDisk": 5, + "minRam": 256, + "metadata": { + "ImageType": "Gold", + "ImageVersion": "1.5" + }, + "server": { + "id": "52415800-8b69-11e0-9b19-734f335aa7b3", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f335aa7b3" + } + ] + }, + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + } + ] + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list.json similarity index 50% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list.json index afecf34dac..c891454004 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/image_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list.json @@ -6,7 +6,7 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" }, { "rel": "bookmark", @@ -15,18 +15,18 @@ ] }, { - "id" : "52415800-8b69-11e0-9b19-734f5736d2a2", - "name" : "My Server Backup", + "id": "52415800-8b69-11e0-9b19-734f5736d2a2", + "name": "My Server Backup", "links": [ { - "rel" : "self", - "href" : "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" }, { - "rel" : "bookmark", - "href" : "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f5736d2a2" } ] - } - ] -} \ No newline at end of file + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail.json new file mode 100644 index 0000000000..0aa48bc78a --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail.json @@ -0,0 +1,503 @@ +{ + "images": [ + { + "status": "ACTIVE", + "updated": "2012-03-12T07:52:30Z", + "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1361", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1361", + "rel": "bookmark" + } + ], + "created": "2012-02-21T14:13:55Z", + "progress": 100, + "id": "1361", + "metadata": { + "hp_image_type": "machine", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "kernel_id": "1359", + "min_ram": 0, + "ramdisk_id": "1360", + "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", + "owner": null, + "hp_image_builddate": "20120123", + "architecture": "amd64", + "min_disk": 0, + "hp_image_version": "1hp1.1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:52:17Z", + "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Ramdisk)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1360", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1360", + "rel": "bookmark" + } + ], + "created": "2012-02-21T14:13:53Z", + "progress": 100, + "id": "1360", + "metadata": { + "hp_image_type": "ramdisk", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "min_ram": 0, + "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", + "owner": null, + "hp_image_builddate": "20120123", + "architecture": "amd64", + "min_disk": 0, + "hp_image_version": "1hp1.1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:52:09Z", + "name": "Debian Squeeze 6.0.3 Server 64-bit 20120123 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1359", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1359", + "rel": "bookmark" + } + ], + "created": "2012-02-21T14:13:52Z", + "progress": 100, + "id": "1359", + "metadata": { + "hp_image_type": "kernel", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "min_ram": 0, + "hp_image_id": "c89dee3bca7a62103f7d88d2a02f4dc8", + "owner": null, + "hp_image_builddate": "20120123", + "architecture": "amd64", + "min_disk": 0, + "hp_image_version": "1hp1.1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:51:52Z", + "name": "CentOS 6.2 Server 64-bit 20120125", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1358", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1358", + "rel": "bookmark" + } + ], + "created": "2012-02-21T13:58:51Z", + "progress": 100, + "id": "1358", + "metadata": { + "hp_image_type": "machine", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "kernel_id": "1356", + "min_ram": 0, + "ramdisk_id": "1357", + "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", + "owner": null, + "hp_image_builddate": "20120125", + "architecture": "x86_64", + "min_disk": 0, + "hp_image_version": "1hp1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:51:37Z", + "name": "CentOS 6.2 Server 64-bit 20120125 (Ramdisk)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1357", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1357", + "rel": "bookmark" + } + ], + "created": "2012-02-21T13:58:49Z", + "progress": 100, + "id": "1357", + "metadata": { + "hp_image_type": "ramdisk", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "min_ram": 0, + "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", + "owner": null, + "hp_image_builddate": "20120125", + "architecture": "x86_64", + "min_disk": 0, + "hp_image_version": "1hp1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:51:28Z", + "name": "CentOS 6.2 Server 64-bit 20120125 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1356", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1356", + "rel": "bookmark" + } + ], + "created": "2012-02-21T13:58:47Z", + "progress": 100, + "id": "1356", + "metadata": { + "hp_image_type": "kernel", + "image_location": "local", + "image_state": "available", + "project_id": "None", + "hp_md_version": "1", + "min_ram": 0, + "hp_image_id": "f2fbb1bf37a13e7c5da897c7082684df", + "owner": null, + "hp_image_builddate": "20120125", + "architecture": "x86_64", + "min_disk": 0, + "hp_image_version": "1hp1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:51:04Z", + "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1242", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1242", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:57:15Z", + "progress": 100, + "id": "1242", + "metadata": { + "image_location": "local", + "image_state": "available", + "kernel_id": "1241", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:50:58Z", + "name": "Ubuntu Oneiric 11.10 Server 64-bit 20111212 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1241", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:57:07Z", + "progress": 100, + "id": "1241", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:50:52Z", + "name": "Ubuntu Natty 11.04 Server 64-bit 20111212", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1240", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1240", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:55:03Z", + "progress": 100, + "id": "1240", + "metadata": { + "image_location": "local", + "image_state": "available", + "kernel_id": "1239", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:50:45Z", + "name": "Ubuntu Natty 11.04 Server 64-bit 20111212 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1239", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1239", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:55:02Z", + "progress": 100, + "id": "1239", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:50:32Z", + "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1238", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1238", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:52:34Z", + "progress": 100, + "id": "1238", + "metadata": { + "image_location": "local", + "image_state": "available", + "kernel_id": "1237", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:50:24Z", + "name": "Ubuntu Maverick 10.10 Server 64-bit 20111212 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1237", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1237", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:52:27Z", + "progress": 100, + "id": "1237", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:49:30Z", + "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1236", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1236", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:40:17Z", + "progress": 100, + "id": "1236", + "metadata": { + "image_location": "local", + "image_state": "available", + "kernel_id": "1235", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:49:23Z", + "name": "Ubuntu Lucid 10.04 LTS Server 64-bit 20111212 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1235", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1235", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:39:58Z", + "progress": 100, + "id": "1235", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "amd64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:49:05Z", + "name": "CentOS 5.6 Server 64-bit 20111207", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1234", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1234", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:07:09Z", + "progress": 100, + "id": "1234", + "metadata": { + "image_location": "local", + "image_state": "available", + "kernel_id": "1232", + "min_ram": 0, + "ramdisk_id": "1233", + "min_disk": 0, + "architecture": "x86_64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:48:59Z", + "name": "CentOS 5.6 Server 64-bit 20111207 (Ramdisk)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1233", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1233", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:07:08Z", + "progress": 100, + "id": "1233", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "x86_64", + "owner": null, + "project_id": "None" + } + }, + { + "status": "ACTIVE", + "updated": "2012-03-12T07:48:39Z", + "name": "CentOS 5.6 Server 64-bit 20111207 (Kernel)", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/images/1232", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1232", + "rel": "bookmark" + } + ], + "created": "2011-12-21T11:07:07Z", + "progress": 100, + "id": "1232", + "metadata": { + "image_location": "local", + "image_state": "available", + "min_ram": 0, + "min_disk": 0, + "architecture": "x86_64", + "owner": null, + "project_id": "None" + } + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_imageextension.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_imageextension.json new file mode 100644 index 0000000000..a26d5b6c31 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_imageextension.json @@ -0,0 +1,146 @@ +{ + "images": [ + { + "status": "UNRECOGNIZED", + "updated": "2012-02-02T19:11:00Z", + "name": "oneiric-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/15", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/15", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:52Z", + "progress": 100, + "id": "15", + "metadata": { + "kernel_id": "14", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + }, + { + "status": "UNKNOWN", + "updated": "2012-02-02T19:10:51Z", + "name": "oneiric-server-cloudimg-amd64-kernel", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/14", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/14", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:50Z", + "progress": 100, + "id": "14", + "metadata": { + "min_disk": 0, + "owner": "1", + "min_ram": 0 + } + }, + { + "status": "ACTIVE", + "updated": "2012-02-02T19:10:41Z", + "name": "natty-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/13", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/13", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:33Z", + "progress": 100, + "id": "13", + "metadata": { + "kernel_id": "12", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + }, + { + "status": "SAVING", + "updated": "2012-02-02T19:10:33Z", + "name": "natty-server-cloudimg-amd64-kernel", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/12", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/12", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:32Z", + "progress": 100, + "id": "12", + "metadata": { + "min_disk": 0, + "owner": "1", + "min_ram": 0 + } + }, + { + "status": "ERROR", + "updated": "2012-02-02T19:10:41Z", + "name": "natty-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/11", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/11", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:33Z", + "progress": 100, + "id": "11", + "metadata": { + "kernel_id": "12", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + }, + { + "status": "ERROR", + "updated": "2012-02-02T19:10:41Z", + "name": "natty-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/10", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/10", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:33Z", + "progress": 100, + "id": "10", + "metadata": { + "kernel_id": "12", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_openstack.json new file mode 100644 index 0000000000..467522f1f0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/image_list_detail_openstack.json @@ -0,0 +1,98 @@ +{ + "images": [ + { + "status": "ACTIVE", + "updated": "2012-02-02T19:11:00Z", + "name": "oneiric-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/15", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/15", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:52Z", + "progress": 100, + "id": "15", + "metadata": { + "kernel_id": "14", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-02-02T19:10:51Z", + "name": "oneiric-server-cloudimg-amd64-kernel", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/14", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/14", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:50Z", + "progress": 100, + "id": "14", + "metadata": { + "min_disk": 0, + "owner": "1", + "min_ram": 0 + } + }, + { + "status": "ACTIVE", + "updated": "2012-02-02T19:10:41Z", + "name": "natty-server-cloudimg-amd64", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/13", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/13", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:33Z", + "progress": 100, + "id": "13", + "metadata": { + "kernel_id": "12", + "min_disk": 0, + "min_ram": 0, + "owner": "1" + } + }, + { + "status": "ACTIVE", + "updated": "2012-02-02T19:10:33Z", + "name": "natty-server-cloudimg-amd64-kernel", + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/images/12", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/images/12", + "rel": "bookmark" + } + ], + "created": "2012-02-02T19:10:32Z", + "progress": 100, + "id": "12", + "metadata": { + "min_disk": 0, + "owner": "1", + "min_ram": 0 + } + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_created_computeservice.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_created_computeservice.json index 7a3cef0a3d..860ade560c 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created_computeservice.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_created_computeservice.json @@ -6,4 +6,4 @@ "name": "jclouds-test-0", "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_details.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_details.json index 188f9296ae..a3fe1672c0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_created.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_details.json @@ -6,4 +6,4 @@ "name": "testkeypair", "fingerprint": "d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_list.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_list.json index 28040ab767..b91ceb3b95 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/keypair_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/keypair_list.json @@ -15,4 +15,4 @@ } } ] -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/listAvailabilityZones.json similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/listAvailabilityZones.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/listAvailabilityZones.json diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_item.json similarity index 93% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_item.json index f853109c10..62c4db5cc8 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_item.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_item.json @@ -1,5 +1,5 @@ -{ +{ "metadata": { "Server Label": "Web Head 1" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_list.json similarity index 95% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_list.json index 174d7d60be..c67c1fb46d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_list.json @@ -1,6 +1,6 @@ -{ +{ "metadata": { "Server Label": "Web Head 1", "Image Version": "2.1" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_updated.json similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_updated.json index 82d9fd3ac9..90f8940862 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/metadata_updated.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/metadata_updated.json @@ -1,7 +1,7 @@ -{ +{ "metadata": { "Server Label": "Web Head 2", "Image Version": "2.1", "Server Description": "Simple Server" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server.json similarity index 55% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server.json index 71fb1f2137..af41c0bb3d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server.json @@ -5,21 +5,26 @@ "hostId": "", "user_id": "54297837463082", "name": "test-e92", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752", - "rel": "self" - }, { - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", - "rel": "bookmark" - }], + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", + "rel": "bookmark" + } + ], "addresses": {}, "tenant_id": "37936628937291", "image": { "id": "1241", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", + "rel": "bookmark" + } + ] }, "created": "2012-03-19T06:21:13Z", "uuid": "47491020-6a78-4f63-9475-23195ac4515c", @@ -29,13 +34,15 @@ "adminPass": "ZWuHcmTMQ7eXoHeM", "flavor": { "id": "100", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ] }, "config_drive": "", "id": 71752, "metadata": {} } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_config_drive.json similarity index 97% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_config_drive.json index 72383334eb..7a94bea7b7 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_auto.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_config_drive.json @@ -34,9 +34,9 @@ "rel": "bookmark" }] }, - "config_drive": "", + "config_drive": "true", "id": 71752, "metadata": {}, "OS-DCF:diskConfig": "AUTO" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_auto.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_auto.json new file mode 100644 index 0000000000..ec2c2ee765 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_auto.json @@ -0,0 +1,49 @@ +{ + "server": { + "status": "BUILD(scheduling)", + "updated": "2012-03-19T06:21:13Z", + "hostId": "", + "user_id": "54297837463082", + "name": "test-e92", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", + "rel": "bookmark" + } + ], + "addresses": {}, + "tenant_id": "37936628937291", + "image": { + "id": "1241", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", + "rel": "bookmark" + } + ] + }, + "created": "2012-03-19T06:21:13Z", + "uuid": "47491020-6a78-4f63-9475-23195ac4515c", + "accessIPv4": "", + "accessIPv6": "", + "key_name": null, + "adminPass": "ZWuHcmTMQ7eXoHeM", + "flavor": { + "id": "100", + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ] + }, + "config_drive": "", + "id": 71752, + "metadata": {}, + "OS-DCF:diskConfig": "AUTO" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_manual.json similarity index 57% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_manual.json index 2cfba41f43..05f8d26459 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_disk_config_manual.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_disk_config_manual.json @@ -5,21 +5,26 @@ "hostId": "", "user_id": "54297837463082", "name": "test-e92", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752", - "rel": "self" - }, { - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", - "rel": "bookmark" - }], + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", + "rel": "bookmark" + } + ], "addresses": {}, "tenant_id": "37936628937291", "image": { "id": "1241", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", + "rel": "bookmark" + } + ] }, "created": "2012-03-19T06:21:13Z", "uuid": "47491020-6a78-4f63-9475-23195ac4515c", @@ -29,14 +34,16 @@ "adminPass": "ZWuHcmTMQ7eXoHeM", "flavor": { "id": "100", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ] }, "config_drive": "", "id": 71752, "metadata": {}, "OS-DCF:diskConfig": "MANUAL" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_in_zone.json similarity index 55% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_in_zone.json index 71fb1f2137..af41c0bb3d 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_in_zone.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_in_zone.json @@ -5,21 +5,26 @@ "hostId": "", "user_id": "54297837463082", "name": "test-e92", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752", - "rel": "self" - }, { - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", - "rel": "bookmark" - }], + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", + "rel": "self" + }, + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", + "rel": "bookmark" + } + ], "addresses": {}, "tenant_id": "37936628937291", "image": { "id": "1241", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/1241", + "rel": "bookmark" + } + ] }, "created": "2012-03-19T06:21:13Z", "uuid": "47491020-6a78-4f63-9475-23195ac4515c", @@ -29,13 +34,15 @@ "adminPass": "ZWuHcmTMQ7eXoHeM", "flavor": { "id": "100", - "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ] }, "config_drive": "", "id": 71752, "metadata": {} } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_networks_response.json similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_networks_response.json index 72383334eb..1e0568aeef 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_networks_response.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_networks_response.json @@ -6,7 +6,7 @@ "user_id": "54297837463082", "name": "test-e92", "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752", + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", "rel": "self" }, { "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_no_adminpass.json similarity index 96% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_no_adminpass.json index a89e48f44d..5a97cab355 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_no_adminpass.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_no_adminpass.json @@ -6,7 +6,7 @@ "user_id": "54297837463082", "name": "test-e92", "links": [{ - "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/71752", + "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/71752", "rel": "self" }, { "href": "https://az-1.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/71752", diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_nova_networks.json similarity index 100% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/new_server_nova_networks.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/new_server_nova_networks.json diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/novnc_console.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/novnc_console.json new file mode 100644 index 0000000000..0d74bcfbed --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/novnc_console.json @@ -0,0 +1,7 @@ +{ + "console": { + "type": "novnc", + "url": "http://example.com:6080/vnc_auto.html?token=f9906a48-b71e-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)" + } +} + diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/quotas.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/quotas.json new file mode 100644 index 0000000000..c7fa803bb1 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/quotas.json @@ -0,0 +1,17 @@ +{ + "quota_set": { + "metadata_items": 128, + "injected_file_content_bytes": 10240, + "injected_files": 5, + "gigabytes": 1000, + "ram": 51200, + "floating_ips": 10, + "security_group_rules": 20, + "instances": 10, + "key_pairs": 100, + "volumes": 10, + "cores": 20, + "id": "demo", + "security_groups": 10 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/rdp_console.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/rdp_console.json new file mode 100644 index 0000000000..6088d57959 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/rdp_console.json @@ -0,0 +1,7 @@ +{ + "console": { + "type": "rdp-html5", + "url": "http://example.com:6083/?token=f9906a48-b71e-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)" + } +} + diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_created.json similarity index 87% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_created.json index fee9b4d3ca..8cdc34a468 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygroup_created.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_created.json @@ -1,9 +1,9 @@ { "security_group": { - "rules": [ ], + "rules": [], "tenant_id": "dev_16767499955063", "id": 160, "name": "jclouds-test", "description": "jclouds-test" } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details.json new file mode 100644 index 0000000000..8c31735ce0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details.json @@ -0,0 +1,33 @@ +{ + "security_group": { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 28, + "ip_range": { + "cidr": "10.2.6.0/24" + }, + "id": 108 + }, + { + "from_port": 22, + "group": { + "tenant_id": "admin", + "name": "11111" + }, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 28, + "ip_range": {}, + "id": 109 + } + ], + "tenant_id": "tenant0", + "id": 0, + "name": "name0", + "description": "description0" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_computeservice_typical.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_computeservice_typical.json new file mode 100644 index 0000000000..248bc5c5db --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_computeservice_typical.json @@ -0,0 +1,56 @@ +{ + "security_group": { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 2769, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 10331 + }, + { + "from_port": 22, + "group": { + "tenant_id": "37936628937291", + "name": "jclouds_mygroup" + }, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 2769, + "ip_range": {}, + "id": 10332 + }, + { + "from_port": 8080, + "group": {}, + "ip_protocol": "tcp", + "to_port": 8080, + "parent_group_id": 2769, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 10333 + }, + { + "from_port": 8080, + "group": { + "tenant_id": "37936628937291", + "name": "jclouds_mygroup" + }, + "ip_protocol": "tcp", + "to_port": 8080, + "parent_group_id": 2769, + "ip_range": {}, + "id": 10334 + } + ], + "tenant_id": "37936628937291", + "id": 2769, + "name": "jclouds_mygroup", + "description": "jclouds_mygroup" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension.json new file mode 100644 index 0000000000..73156c803e --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension.json @@ -0,0 +1,33 @@ +{ + "security_group": { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 160, + "ip_range": { + "cidr": "10.2.6.0/24" + }, + "id": 108 + }, + { + "from_port": 22, + "group": { + "tenant_id": "tenant0", + "name": "name0" + }, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 160, + "ip_range": {}, + "id": 109 + } + ], + "tenant_id": "tenant0", + "id": 160, + "name": "name0", + "description": "description0" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension_norules.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension_norules.json new file mode 100644 index 0000000000..22e2508ef0 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_extension_norules.json @@ -0,0 +1,9 @@ +{ + "security_group": { + "rules": [], + "tenant_id": "tenant0", + "id": 160, + "name": "name0", + "description": "description0" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_port22.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_port22.json new file mode 100644 index 0000000000..75ee674e58 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_details_port22.json @@ -0,0 +1,21 @@ +{ + "security_group": { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 2769, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 10331 + } + ], + "tenant_id": "37936628937291", + "id": 2769, + "name": "jclouds-test", + "description": "jclouds-test" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list.json new file mode 100644 index 0000000000..99de86cb1d --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list.json @@ -0,0 +1,45 @@ +{ + "security_groups": [ + { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 107 + }, + { + "from_port": 7600, + "group": {}, + "ip_protocol": "tcp", + "to_port": 7600, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 118 + }, + { + "from_port": 8084, + "group": {}, + "ip_protocol": "tcp", + "to_port": 8084, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 119 + } + ], + "tenant_id": "tenant1", + "id": 1, + "name": "name1", + "description": "description1" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json new file mode 100644 index 0000000000..2e7622303d --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_details_computeservice_typical.json @@ -0,0 +1,58 @@ +{ + "security_groups": [ + { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 2769, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 10331 + }, + { + "from_port": 22, + "group": { + "tenant_id": "37936628937291", + "name": "jclouds_mygroup" + }, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 2769, + "ip_range": {}, + "id": 10332 + }, + { + "from_port": 8080, + "group": {}, + "ip_protocol": "tcp", + "to_port": 8080, + "parent_group_id": 2769, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 10333 + }, + { + "from_port": 8080, + "group": { + "tenant_id": "37936628937291", + "name": "jclouds_mygroup" + }, + "ip_protocol": "tcp", + "to_port": 8080, + "parent_group_id": 2769, + "ip_range": {}, + "id": 10334 + } + ], + "tenant_id": "37936628937291", + "id": 2769, + "name": "jclouds_mygroup", + "description": "jclouds_mygroup" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_extension.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_extension.json new file mode 100644 index 0000000000..e90f5b5633 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygroup_list_extension.json @@ -0,0 +1,45 @@ +{ + "security_groups": [ + { + "rules": [ + { + "from_port": 22, + "group": {}, + "ip_protocol": "tcp", + "to_port": 22, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 107 + }, + { + "from_port": 7600, + "group": {}, + "ip_protocol": "tcp", + "to_port": 7600, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 118 + }, + { + "from_port": 8084, + "group": {}, + "ip_protocol": "tcp", + "to_port": 8084, + "parent_group_id": 3, + "ip_range": { + "cidr": "0.0.0.0/0" + }, + "id": 119 + } + ], + "tenant_id": "tenant0", + "id": 160, + "name": "name0", + "description": "description0" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created.json similarity index 89% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created.json index 1e8b9fdfaf..d32bdeb2a1 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created.json @@ -8,5 +8,6 @@ "ip_range": { "cidr": "0.0.0.0/0" }, - "id": 218 } -} \ No newline at end of file + "id": 218 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_cidr.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_cidr.json index cc91ac70a5..68fc9acdca 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_cidr.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_cidr.json @@ -10,4 +10,4 @@ }, "id": 108 } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_group.json similarity index 99% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_group.json index ff17bcdc0d..0dfbb349f0 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/securitygrouprule_created_group.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/securitygrouprule_created_group.json @@ -11,4 +11,4 @@ "ip_range": {}, "id": 109 } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details.json similarity index 68% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details.json index 7ad6a75554..8217b8695a 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list_details.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details.json @@ -1,23 +1,23 @@ { - "servers": [ - { - "id": "52415800-8b69-11e0-9b19-734f000004d2", + "server": { + "id": "71752", "tenant_id": "1234", "user_id": "5678", - "name": "sample-server", + "name": "sample-f352", "updated": "2010-10-10T12:00:00Z", "created": "2010-08-10T12:00:00Z", "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0", - "accessIPv4" : "67.23.10.132", - "accessIPv6" : "::babe:67.23.10.132", - "status": "BUILD", + "accessIPv4": "67.23.10.132", + "accessIPv6": "::babe:67.23.10.132", + "status": "BUILD(scheduling)", "progress": 60, - "image" : { + "OS-DCF:diskConfig": "AUTO", + "image": { "id": "52415800-8b69-11e0-9b19-734f6f006e54", "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" }, { "rel": "bookmark", @@ -25,12 +25,12 @@ } ] }, - "flavor" : { + "flavor": { "id": "52415800-8b69-11e0-9b19-734f216543fd", "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" + "href": "http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" }, { "rel": "bookmark", @@ -38,8 +38,8 @@ } ] }, - "addresses": { - "public" : [ + "addresses": { + "public": [ { "version": 4, "addr": "67.23.10.132" @@ -57,7 +57,7 @@ "addr": "::babe:4317:0A83" } ], - "private" : [ + "private": [ { "version": 4, "addr": "10.176.42.16" @@ -73,7 +73,14 @@ "Image Version": "2.1" }, "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/servers/71752" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/servers/71752" + } ] - } - ] -} \ No newline at end of file + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_devstack.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_devstack.json new file mode 100644 index 0000000000..28c0d17e2b --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_devstack.json @@ -0,0 +1,60 @@ +{ + "server": { + "OS-EXT-STS:task_state": null, + "addresses": { + "private": [ + { + "version": 4, + "addr": "10.0.0.8" + } + ] + }, + "links": [ + { + "href": "http://172.16.89.149:8774/v2/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", + "rel": "self" + }, + { + "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/servers/141b775f-7ac1-45f0-9a95-146260f33a53", + "rel": "bookmark" + } + ], + "image": { + "id": "8e6f5bc4-a210-45b2-841f-c510eae14300", + "links": [ + { + "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/images/8e6f5bc4-a210-45b2-841f-c510eae14300", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "paused", + "OS-EXT-SRV-ATTR:instance_name": "instance-00000014", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://172.16.89.149:8774/7f312675f9b84c97bff8f5054e181419/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "141b775f-7ac1-45f0-9a95-146260f33a53", + "user_id": "89c01b67395d4bea945f7f5bfd7f344a", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "OS-EXT-STS:power_state": 3, + "config_drive": "", + "status": "PAUSED", + "updated": "2012-05-04T15:07:48Z", + "hostId": "eab9a77d1c44b8833e4a3dc6d2d9d50de556e780a319f184d8c82d9b", + "OS-EXT-SRV-ATTR:host": "ubuntu", + "key_name": "", + "OS-EXT-SRV-ATTR:hypervisor_hostname": null, + "name": "test", + "created": "2012-05-04T15:07:36Z", + "tenant_id": "7f312675f9b84c97bff8f5054e181419", + "metadata": {} + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_openstack.json similarity index 50% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_openstack.json index 10b7a7d5e1..7a7089cab9 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details_openstack.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_openstack.json @@ -5,26 +5,33 @@ "hostId": "881706597197955ac7cc4b353bc7ec884e13fa280de9cc82057796cb", "user_id": "508151008", "name": "mygroup-72c", - "links": [{ - "href": "https://nova-api.openstack.org:9774/v1.1/37/servers/1459", - "rel": "self" - }, { - "href": "https://nova-api.openstack.org:9774/37/servers/1459", - "rel": "bookmark" - }], + "links": [ + { + "href": "https://nova-api.openstack.org:9774/v2/37/servers/1459", + "rel": "self" + }, + { + "href": "https://nova-api.openstack.org:9774/37/servers/1459", + "rel": "bookmark" + } + ], "addresses": { - "internet": [{ - "version": 4, - "addr": "8.21.28.47" - }] + "internet": [ + { + "version": 4, + "addr": "8.21.28.47" + } + ] }, "tenant_id": "37", "image": { "id": "14", - "links": [{ - "href": "https://nova-api.openstack.org:9774/37/images/14", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://nova-api.openstack.org:9774/37/images/14", + "rel": "bookmark" + } + ] }, "created": "2012-03-23T01:30:26Z", "uuid": "2443c9c7-9791-412e-ac09-a6d55ec25335", @@ -34,13 +41,15 @@ "progress": 100, "flavor": { "id": "1", - "links": [{ - "href": "https://nova-api.openstack.org:9774/37/flavors/1", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://nova-api.openstack.org:9774/37/flavors/1", + "rel": "bookmark" + } + ] }, "config_drive": "", "id": 1459, "metadata": {} } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_without_image.json similarity index 72% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_without_image.json index f548785fbe..bd4b9c8253 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_details.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_details_without_image.json @@ -1,6 +1,6 @@ { "server": { - "id": "52415800-8b69-11e0-9b19-734f000004d2", + "id": "71752", "tenant_id": "1234", "user_id": "5678", "name": "sample-f352", @@ -11,20 +11,8 @@ "accessIPv6" : "::babe:67.23.10.132", "status": "BUILD(scheduling)", "progress": 60, - "OS-DCF:diskConfig": "AUTO", - "image" : { - "id": "52415800-8b69-11e0-9b19-734f6f006e54", - "links": [ - { - "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" - }, - { - "rel": "bookmark", - "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" - } - ] - }, + "OS-DCF:diskConfig": "AUTO", + "image" : "", "flavor" : { "id": "52415800-8b69-11e0-9b19-734f216543fd", "links": [ @@ -75,11 +63,11 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54" + "href": "http://servers.api.openstack.org/v2/1234/servers/71752" }, { "rel": "bookmark", - "href": "http://servers.api.openstack.org/1234/servers/52415800-8b69-11e0-9b19-734f6f006e54" + "href": "http://servers.api.openstack.org/1234/servers/71752" } ] } diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_diagnostics.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_diagnostics.json new file mode 100644 index 0000000000..561f2fbdcc --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_diagnostics.json @@ -0,0 +1,17 @@ +{ + "vnet0_tx_errors": 0, + "vda_read": 77364736, + "vda_write": 415446016, + "vnet0_tx_packets": 9701, + "vda_write_req": 47278, + "cpu0_time": 143150000000, + "vnet0_tx": 1691221, + "vnet0_rx_drop": 0, + "vda_errors": -1, + "vnet0_rx_errors": 0, + "memory": 524288, + "vnet0_rx_packets": 11271, + "vda_read_req": 9551, + "vnet0_rx": 1805288, + "vnet0_tx_drop": 0 +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list.json similarity index 78% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list.json index aa6cf0d477..6cbc4c2e20 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_list.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list.json @@ -6,7 +6,7 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f6af67565" + "href": "http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f6af67565" }, { "rel": "bookmark", @@ -20,7 +20,7 @@ "links": [ { "rel": "self", - "href": "http://servers.api.openstack.org/v1.1/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5" + "href": "http://servers.api.openstack.org/v2/1234/servers/52415800-8b69-11e0-9b19-734f1f1350e5" }, { "rel": "bookmark", diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details.json new file mode 100644 index 0000000000..7d459dbdc3 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details.json @@ -0,0 +1,78 @@ +{ + "servers": [ + { + "id": "71752", + "tenant_id": "1234", + "user_id": "5678", + "name": "sample-server", + "updated": "2010-10-10T12:00:00Z", + "created": "2010-08-10T12:00:00Z", + "hostId": "e4d909c290d0fb1ca068ffaddf22cbd0", + "accessIPv4": "67.23.10.132", + "accessIPv6": "::babe:67.23.10.132", + "status": "BUILD", + "progress": 60, + "image": { + "id": "52415800-8b69-11e0-9b19-734f6f006e54", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/images/52415800-8b69-11e0-9b19-734f6f006e54" + } + ] + }, + "flavor": { + "id": "52415800-8b69-11e0-9b19-734f216543fd", + "links": [ + { + "rel": "self", + "href": "http://servers.api.openstack.org/v2/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" + }, + { + "rel": "bookmark", + "href": "http://servers.api.openstack.org/1234/flavors/52415800-8b69-11e0-9b19-734f216543fd" + } + ] + }, + "addresses": { + "public": [ + { + "version": 4, + "addr": "67.23.10.132" + }, + { + "version": 6, + "addr": "::babe:67.23.10.132" + }, + { + "version": 4, + "addr": "67.23.10.131" + }, + { + "version": 6, + "addr": "::babe:4317:0A83" + } + ], + "private": [ + { + "version": 4, + "addr": "10.176.42.16" + }, + { + "version": 6, + "addr": "::babe:10.176.42.16" + } + ] + }, + "metadata": { + "Server Label": "Web Head 1", + "Image Version": "2.1" + }, + "links": [] + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_essex.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_essex.json new file mode 100644 index 0000000000..a3fafa16f8 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_essex.json @@ -0,0 +1,188 @@ +{ + "servers": [ + { + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Front-Middle": [ + { + "version": 4, + "addr": "172.16.11.5" + } + ], + "Public network": [ + { + "version": 4, + "addr": "172.16.1.13" + }, + { + "version": 4, + "addr": "10.193.112.119" + } + ] + }, + "links": [ + { + "href": "http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", + "rel": "self" + }, + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/0c80b392-db30-4736-ae02-4480090f1207", + "rel": "bookmark" + } + ], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "0c80b392-db30-4736-ae02-4480090f1207", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:21:33Z", + "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", + "key_name": "", + "name": "VM proxy", + "created": "2012-04-12T11:21:23Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + }, + { + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Front-Middle": [ + { + "version": 4, + "addr": "172.16.11.4" + } + ], + "Net TenantA Middle-Back": [ + { + "version": 4, + "addr": "172.16.12.5" + } + ] + }, + "links": [ + { + "href": "http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", + "rel": "self" + }, + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/b332b5cd-535e-4677-b68e-fc8badc13236", + "rel": "bookmark" + } + ], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "b332b5cd-535e-4677-b68e-fc8badc13236", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:18:58Z", + "hostId": "e5bbff80bebacfe1db63951e787b5341427060a602d33abfefb6a1bc", + "key_name": "", + "name": "VM blog", + "created": "2012-04-12T11:18:48Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + }, + { + "OS-EXT-STS:task_state": null, + "addresses": { + "Net TenantA Middle-Back": [ + { + "version": 4, + "addr": "172.16.12.4" + } + ] + }, + "links": [ + { + "href": "http://nova:8774/v2/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "rel": "self" + }, + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/servers/f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "rel": "bookmark" + } + ], + "image": { + "id": "416af940-2d3c-4a7c-977c-a9030685ad5e", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/images/416af940-2d3c-4a7c-977c-a9030685ad5e", + "rel": "bookmark" + } + ] + }, + "OS-EXT-STS:vm_state": "active", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://nova:8774/8d10e6646d5d4585937395b04839a353/flavors/1", + "rel": "bookmark" + } + ] + }, + "id": "f9d43436-4572-4c9b-9b74-5fa6890a2f21", + "user_id": "df13814f6c354d00a8acf66502836323", + "OS-DCF:diskConfig": "MANUAL", + "accessIPv4": "", + "accessIPv6": "", + "progress": 0, + "OS-EXT-STS:power_state": 1, + "config_drive": "", + "status": "ACTIVE", + "updated": "2012-04-12T11:15:09Z", + "hostId": "03d796ebb52b1b555e5f6d9262f7dbd52b3f7c181e3aa89b34ca5408", + "key_name": "", + "name": "VM MySQL", + "created": "2012-04-12T11:14:56Z", + "tenant_id": "8d10e6646d5d4585937395b04839a353", + "metadata": {} + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_states.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_states.json new file mode 100644 index 0000000000..6fb28ed232 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_list_details_states.json @@ -0,0 +1,342 @@ +{ + "servers": [ + { + "OS-DCF:diskConfig": "MANUAL", + "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-SRV-ATTR:host": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:hypervisor_hostname": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:instance_name": "instance-0000000b", + "OS-EXT-STS:power_state": 0, + "OS-EXT-STS:task_state": "spawning", + "OS-EXT-STS:vm_state": "building", + "OS-SRV-USG:launched_at": null, + "OS-SRV-USG:terminated_at": null, + "accessIPv4": "", + "accessIPv6": "", + "addresses": {}, + "config_drive": "", + "created": "2014-03-19T11:54:57Z", + "flavor": { + "id": "6", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6", + "rel": "bookmark" + } + ] + }, + "hostId": "0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8", + "id": "56d51a88-0066-4976-91b6-d1b453be603f", + "image": { + "id": "e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f", + "rel": "self" + }, + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/56d51a88-0066-4976-91b6-d1b453be603f", + "rel": "bookmark" + } + ], + "metadata": {}, + "name": "machine_5", + "os-extended-volumes:volumes_attached": [], + "progress": 0, + "security_groups": [ + { + "name": "default" + } + ], + "status": "BUILD", + "tenant_id": "4e1900cf21924a098709c23480e157c0", + "updated": "2014-03-19T11:54:59Z", + "user_id": "08ba127f0d6842279f9db8e8bc6977e9" + }, + { + "OS-DCF:diskConfig": "MANUAL", + "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-SRV-ATTR:host": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:hypervisor_hostname": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:instance_name": "instance-00000009", + "OS-EXT-STS:power_state": 1, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "active", + "OS-SRV-USG:launched_at": "2014-03-19T11:52:21.000000", + "OS-SRV-USG:terminated_at": null, + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "public": [ + { + "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:df:22:1b", + "OS-EXT-IPS:type": "fixed", + "addr": "172.24.4.232", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2014-03-19T11:51:53Z", + "flavor": { + "id": "6", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6", + "rel": "bookmark" + } + ] + }, + "hostId": "0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8", + "id": "3bc8ab03-52e7-4d2b-ba88-73f9ecadf003", + "image": { + "id": "e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003", + "rel": "self" + }, + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/3bc8ab03-52e7-4d2b-ba88-73f9ecadf003", + "rel": "bookmark" + } + ], + "metadata": {}, + "name": "machine_4", + "os-extended-volumes:volumes_attached": [], + "progress": 0, + "security_groups": [ + { + "name": "default" + } + ], + "status": "ACTIVE", + "tenant_id": "4e1900cf21924a098709c23480e157c0", + "updated": "2014-03-19T11:52:21Z", + "user_id": "08ba127f0d6842279f9db8e8bc6977e9" + }, + { + "OS-DCF:diskConfig": "MANUAL", + "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-SRV-ATTR:host": null, + "OS-EXT-SRV-ATTR:hypervisor_hostname": null, + "OS-EXT-SRV-ATTR:instance_name": "instance-00000006", + "OS-EXT-STS:power_state": 4, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "shelved_offloaded", + "OS-SRV-USG:launched_at": "2014-03-19T11:33:52.000000", + "OS-SRV-USG:terminated_at": null, + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "public": [ + { + "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:cb:56:d6", + "OS-EXT-IPS:type": "fixed", + "addr": "172.24.4.229", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2014-03-19T11:33:27Z", + "flavor": { + "id": "6", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6", + "rel": "bookmark" + } + ] + }, + "hostId": "", + "id": "cad76945-8851-489a-99e1-f1049e02c769", + "image": { + "id": "e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769", + "rel": "self" + }, + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/cad76945-8851-489a-99e1-f1049e02c769", + "rel": "bookmark" + } + ], + "metadata": {}, + "name": "machine_3", + "os-extended-volumes:volumes_attached": [], + "security_groups": [ + { + "name": "default" + } + ], + "status": "SHELVED_OFFLOADED", + "tenant_id": "4e1900cf21924a098709c23480e157c0", + "updated": "2014-03-19T11:38:05Z", + "user_id": "08ba127f0d6842279f9db8e8bc6977e9" + }, + { + "OS-DCF:diskConfig": "MANUAL", + "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-SRV-ATTR:host": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:hypervisor_hostname": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:instance_name": "instance-00000005", + "OS-EXT-STS:power_state": 1, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "rescued", + "OS-SRV-USG:launched_at": "2014-03-19T11:36:05.000000", + "OS-SRV-USG:terminated_at": null, + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "public": [ + { + "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:18:fe:c8", + "OS-EXT-IPS:type": "fixed", + "addr": "172.24.4.227", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2014-03-19T11:31:19Z", + "flavor": { + "id": "6", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6", + "rel": "bookmark" + } + ] + }, + "hostId": "0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8", + "id": "89142a4f-f58c-4205-8571-65f4a2be2bc9", + "image": { + "id": "e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9", + "rel": "self" + }, + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/89142a4f-f58c-4205-8571-65f4a2be2bc9", + "rel": "bookmark" + } + ], + "metadata": {}, + "name": "machine_2", + "os-extended-volumes:volumes_attached": [], + "security_groups": [ + { + "name": "default" + } + ], + "status": "RESCUE", + "tenant_id": "4e1900cf21924a098709c23480e157c0", + "updated": "2014-03-19T11:36:05Z", + "user_id": "08ba127f0d6842279f9db8e8bc6977e9" + }, + { + "OS-DCF:diskConfig": "MANUAL", + "OS-EXT-AZ:availability_zone": "nova", + "OS-EXT-SRV-ATTR:host": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:hypervisor_hostname": "rdohavana.localdomain", + "OS-EXT-SRV-ATTR:instance_name": "instance-00000004", + "OS-EXT-STS:power_state": 4, + "OS-EXT-STS:task_state": null, + "OS-EXT-STS:vm_state": "stopped", + "OS-SRV-USG:launched_at": "2014-03-19T11:30:33.000000", + "OS-SRV-USG:terminated_at": null, + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "public": [ + { + "OS-EXT-IPS-MAC:mac_addr": "fa:16:3e:64:1a:d5", + "OS-EXT-IPS:type": "fixed", + "addr": "172.24.4.228", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2014-03-19T11:28:56Z", + "flavor": { + "id": "6", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/flavors/6", + "rel": "bookmark" + } + ] + }, + "hostId": "0bc453b1c10348e9dc398fed7a5b06f996964ae1643fe460a85a23d8", + "id": "fac50d26-bb38-455f-ad92-eba790187c00", + "image": { + "id": "e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "links": [ + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/images/e3f84189-964e-4dc3-8ac6-832c2b7553d4", + "rel": "bookmark" + } + ] + }, + "key_name": null, + "links": [ + { + "href": "http://openstack:8774/v2/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00", + "rel": "self" + }, + { + "href": "http://openstack:8774/4e1900cf21924a098709c23480e157c0/servers/fac50d26-bb38-455f-ad92-eba790187c00", + "rel": "bookmark" + } + ], + "metadata": {}, + "name": "machine_1", + "os-extended-volumes:volumes_attached": [], + "security_groups": [ + { + "name": "default" + } + ], + "status": "SHUTOFF", + "tenant_id": "4e1900cf21924a098709c23480e157c0", + "updated": "2014-03-19T11:35:26Z", + "user_id": "08ba127f0d6842279f9db8e8bc6977e9" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_public_ip_in_private.json similarity index 50% rename from dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json rename to dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_public_ip_in_private.json index 5a5b84e2f5..4f42d48878 100644 --- a/dependencies/jclouds/apis/openstack-nova/1.7.1-stratos/src/test/resources/server_public_ip_in_private.json +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_public_ip_in_private.json @@ -5,29 +5,37 @@ "hostId": "cb0d9e5004bef8c21270a0b09f7624f4c387f3a523f3aaa4c5694a61", "user_id": "54297837463082", "name": "hpcloud-computes-38d", - "links": [{ - "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v1.1/37936628937291/servers/59662", - "rel": "self" - }, { - "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662", - "rel": "bookmark" - }], + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/v2/37936628937291/servers/59662", + "rel": "self" + }, + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/servers/59662", + "rel": "bookmark" + } + ], "addresses": { - "private": [{ - "version": 4, - "addr": "10.6.39.189" - }, { - "version": 4, - "addr": "15.185.181.94" - }] + "private": [ + { + "version": 4, + "addr": "10.6.39.189" + }, + { + "version": 4, + "addr": "15.185.181.94" + } + ] }, "tenant_id": "37936628937291", "image": { "id": "229", - "links": [{ - "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/229", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/images/229", + "rel": "bookmark" + } + ] }, "created": "2012-03-22T22:11:19Z", "uuid": "7aed8e05-1daf-476a-87b2-640e8f7dcafd", @@ -37,10 +45,12 @@ "progress": 100, "flavor": { "id": "100", - "links": [{ - "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", - "rel": "bookmark" - }] + "links": [ + { + "href": "https://az-2.region-a.geo-1.compute.hpcloudsvc.com/37936628937291/flavors/100", + "rel": "bookmark" + } + ] }, "config_drive": "", "id": 59662, @@ -48,4 +58,4 @@ "Name": "hpcloud-computes" } } -} \ No newline at end of file +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups.json new file mode 100644 index 0000000000..879975f0e2 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups.json @@ -0,0 +1,62 @@ +{ + "server": { + "status": "ACTIVE", + "updated": "2012-05-04T12:15:01Z", + "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", + "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", + "name": "test", + "links": [ + { + "href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "rel": "self" + }, + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "rel": "bookmark" + } + ], + "created": "2012-05-04T12:14:57Z", + "tenant_id": "4287930c796741aa898425f40832cb3c", + "image": { + "id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", + "links": [ + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", + "rel": "bookmark" + } + ] + }, + "addresses": { + "private": [ + { + "version": 4, + "addr": "10.0.0.8" + } + ] + }, + "accessIPv4": "", + "accessIPv6": "", + "key_name": "", + "progress": 0, + "flavor": { + "id": "1", + "links": [ + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/flavors/1", + "rel": "bookmark" + } + ] + }, + "config_drive": "", + "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "security_groups": [ + { + "name": "default" + }, + { + "name": "group1" + } + ], + "metadata": {} + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups_extension.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups_extension.json new file mode 100644 index 0000000000..b84259e6e1 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/server_with_security_groups_extension.json @@ -0,0 +1,59 @@ +{ + "server": { + "status": "ACTIVE", + "updated": "2012-05-04T12:15:01Z", + "hostId": "02c7c81e36024d2bfdb473cb762900138bc07777922479d3d4f8f690", + "user_id": "1e8a56719e0d4ab4b7edb85c77f7290f", + "name": "test", + "links": [ + { + "href": "http://172.16.89.148:8774/v2/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "rel": "self" + }, + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/servers/8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "rel": "bookmark" + } + ], + "created": "2012-05-04T12:14:57Z", + "tenant_id": "4287930c796741aa898425f40832cb3c", + "image": { + "id": "ea17cc36-f7c9-40cd-b6bf-a952b74870f2", + "links": [ + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/images/ea17cc36-f7c9-40cd-b6bf-a952b74870f2", + "rel": "bookmark" + } + ] + }, + "addresses": { + "private": [ + { + "version": 4, + "addr": "10.0.0.8" + } + ] + }, + "accessIPv4": "", + "accessIPv6": "", + "key_name": "", + "progress": 0, + "flavor": { + "id": "1", + "links": [ + { + "href": "http://172.16.89.148:8774/4287930c796741aa898425f40832cb3c/flavors/1", + "rel": "bookmark" + } + ] + }, + "config_drive": "", + "id": "8d0a6ca5-8849-4b3d-b86e-f24c92490ebb", + "security_groups": [ + { + "name": "name1" + } + ], + "metadata": {} + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usage.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usage.json new file mode 100644 index 0000000000..87ec78c917 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usage.json @@ -0,0 +1,39 @@ +{ + "tenant_usage": { + "total_memory_mb_usage": 0.0014847999999999999, + "total_vcpus_usage": 7.249999999999999e-7, + "total_hours": 4.833333333333333e-7, + "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", + "stop": "2012-04-18 13:32:07.255830", + "server_usages": [ + { + "hours": 2.4166666666666665e-7, + "uptime": 91149, + "local_gb": 50, + "ended_at": null, + "name": "test1", + "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", + "vcpus": 2, + "memory_mb": 4096, + "state": "active", + "flavor": "m1.medium", + "started_at": "2012-04-17 12:12:58" + }, + { + "hours": 2.4166666666666665e-7, + "uptime": 84710, + "local_gb": 30, + "ended_at": null, + "name": "mish_test", + "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", + "vcpus": 1, + "memory_mb": 2048, + "state": "active", + "flavor": "m1.small", + "started_at": "2012-04-17 14:00:17" + } + ], + "start": "2012-04-18 13:32:07.255743", + "total_local_gb_usage": 0.00001933333333333333 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usages.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usages.json new file mode 100644 index 0000000000..c29f6b1fe3 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/simple_tenant_usages.json @@ -0,0 +1,13 @@ +{ + "tenant_usages": [ + { + "total_memory_mb_usage": 0.0015018666666666667, + "total_vcpus_usage": 7.333333333333333e-7, + "start": "2012-04-18 12:18:39.702411", + "tenant_id": "f8535069c3fb404cb61c873b1a0b4921", + "stop": "2012-04-18 12:18:39.702499", + "total_hours": 4.888888888888889e-7, + "total_local_gb_usage": 0.000019555555555555557 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_details.json new file mode 100644 index 0000000000..59b279b355 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_details.json @@ -0,0 +1,11 @@ +{ + "snapshot": { + "status": "available", + "displayDescription": "jclouds live test snapshot", + "displayName": "jclouds-live-test", + "volumeId": 9, + "id": 7, + "createdAt": "2012-04-24 13:34:42", + "size": 1 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list.json new file mode 100644 index 0000000000..2b14942ace --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list.json @@ -0,0 +1,13 @@ +{ + "snapshots": [ + { + "status": "available", + "displayDescription": "jclouds live test snapshot", + "displayName": "jclouds-live-test", + "volumeId": 9, + "id": 7, + "createdAt": "2012-04-24 13:34:42", + "size": 1 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list_detail.json new file mode 100644 index 0000000000..2b14942ace --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/snapshot_list_detail.json @@ -0,0 +1,13 @@ +{ + "snapshots": [ + { + "status": "available", + "displayDescription": "jclouds live test snapshot", + "displayName": "jclouds-live-test", + "volumeId": 9, + "id": 7, + "createdAt": "2012-04-24 13:34:42", + "size": 1 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/spice_console.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/spice_console.json new file mode 100644 index 0000000000..bc6f5f54d3 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/spice_console.json @@ -0,0 +1,7 @@ +{ + "console": { + "type": "spice-html5", + "url": "http://example.com:6080/spice_auto.html?token=f9906a48-b71e-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)" + } +} + diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/virtual_interfaces_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/virtual_interfaces_list.json new file mode 100644 index 0000000000..7430b6a7c4 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/virtual_interfaces_list.json @@ -0,0 +1,8 @@ +{ + "virtual_interfaces": [ + { + "id": "02315827-b05c-4668-9c05-75c68838074a", + "mac_address": "fa:16:3e:09:71:34" + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_details.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_details.json new file mode 100644 index 0000000000..13f04c1273 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_details.json @@ -0,0 +1,22 @@ +{ + "volume": { + "status": "in-use", + "displayDescription": "This is a test volume", + "availabilityZone": "nova", + "displayName": "test", + "attachments": [ + { + "device": "/dev/vdc", + "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", + "id": 1, + "volumeId": 1 + } + ], + "volumeType": null, + "snapshotId": null, + "size": 1, + "id": 1, + "createdAt": "2012-04-23 12:16:45", + "metadata": {} + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list.json new file mode 100644 index 0000000000..a62059b65b --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list.json @@ -0,0 +1,24 @@ +{ + "volumes": [ + { + "status": "in-use", + "displayDescription": "This is a test volume", + "availabilityZone": "nova", + "displayName": "test", + "attachments": [ + { + "device": "/dev/vdc", + "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", + "id": 1, + "volumeId": 1 + } + ], + "volumeType": null, + "snapshotId": null, + "size": 1, + "id": 1, + "createdAt": "2012-04-23 12:16:45", + "metadata": {} + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list_detail.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list_detail.json new file mode 100644 index 0000000000..a62059b65b --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_list_detail.json @@ -0,0 +1,24 @@ +{ + "volumes": [ + { + "status": "in-use", + "displayDescription": "This is a test volume", + "availabilityZone": "nova", + "displayName": "test", + "attachments": [ + { + "device": "/dev/vdc", + "serverId": "b4785058-cb80-491b-baa3-e4ee6546450e", + "id": 1, + "volumeId": 1 + } + ], + "volumeType": null, + "snapshotId": null, + "size": 1, + "id": 1, + "createdAt": "2012-04-23 12:16:45", + "metadata": {} + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type.json new file mode 100644 index 0000000000..2c92c8a5a5 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type.json @@ -0,0 +1,14 @@ +{ + "volume_type": { + "name": "jclouds-test-1", + "deleted": false, + "created_at": "2012-05-10 12:33:06", + "updated_at": null, + "extra_specs": { + "test": "value1", + "test1": "wibble" + }, + "deleted_at": null, + "id": 8 + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_extra_specs.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_extra_specs.json new file mode 100644 index 0000000000..8e0f1ffc71 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_extra_specs.json @@ -0,0 +1,5 @@ +{ + "extra_specs": { + "test": "value1" + } +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_list.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_list.json new file mode 100644 index 0000000000..f950916863 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/volume_type_list.json @@ -0,0 +1,16 @@ +{ + "volume_types": [ + { + "name": "jclouds-test-1", + "deleted": false, + "created_at": "2012-05-10 12:33:06", + "updated_at": null, + "extra_specs": { + "test": "value1", + "test1": "wibble" + }, + "deleted_at": null, + "id": 8 + } + ] +} diff --git a/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/xvpvnc_console.json b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/xvpvnc_console.json new file mode 100644 index 0000000000..ddaf6cfc20 --- /dev/null +++ b/dependencies/jclouds/apis/openstack-nova/1.8.0-stratos/src/test/resources/xvpvnc_console.json @@ -0,0 +1,7 @@ +{ + "console": { + "type": "xvpvnc", + "url": "http://example.com:6081/console?token=2abbe0b2-dcf1-479d-8d58-88e82b477865" + } +} + diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/README.txt b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/README.txt similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/README.txt rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/README.txt diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/pom.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/pom.xml similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/pom.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/pom.xml index 43a0adc726..ee1a90eda6 100755 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/pom.xml +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/pom.xml @@ -22,17 +22,17 @@ org.apache.jclouds jclouds-project - 1.7.1 + 1.8.0 org.apache.stratos vcloud - 1.7.1-stratos + 1.8.0-stratos jclouds vcloud api jclouds components to access an implementation of VMWare vCloud bundle - 1.7.1 + 1.8.0 FIXME 1.0 diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java old mode 100755 new mode 100644 similarity index 96% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java index ed152bcfbe..fb54599068 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskInErrorStateException.java @@ -18,11 +18,6 @@ import org.jclouds.vcloud.domain.Task; -/** - * - * @author Adrian Cole - * - */ public class TaskInErrorStateException extends RuntimeException { private final Task task; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java old mode 100755 new mode 100644 similarity index 96% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java index 2bc5b97afa..64eafbed76 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/TaskStillRunningException.java @@ -18,11 +18,6 @@ import org.jclouds.vcloud.domain.Task; -/** - * - * @author Adrian Cole - * - */ public class TaskStillRunningException extends RuntimeException { private final Task task; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java index 2112385136..1c3b46c92c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApi.java @@ -35,7 +35,6 @@ *

* * @see - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VCloudApi extends Closeable { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java index f6055689a1..4c88d8aa0b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudApiMetadata.java @@ -38,8 +38,6 @@ /** * Implementation of {@link ApiMetadata} for VCloud 1.0 API - * - * @author Adrian Cole */ public class VCloudApiMetadata extends BaseHttpApiMetadata { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java index e670157c99..fddefc97f0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudMediaType.java @@ -208,6 +208,7 @@ public interface VCloudMediaType { * "application/vnd.vmware.vcloud.rasdItem+xml" */ public static final MediaType RASDITEM_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.rasdItem+xml"); + /** * "application/vnd.vmware.vcloud.session+xml" */ @@ -217,5 +218,4 @@ public interface VCloudMediaType { * "application/vnd.vmware.vcloud.session+xml" */ public static final MediaType SESSION_XML_TYPE = new MediaType("application", "vnd.vmware.vcloud.session+xml"); - } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java index 0f94f9dfab..ea8d7f83d9 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudResponseException.java @@ -23,9 +23,6 @@ /** * Encapsulates an VCloud Error. - * - * @author Adrian Cole - * */ public class VCloudResponseException extends HttpResponseException { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java index 1ef288e419..2aca7bd8c2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudToken.java @@ -25,9 +25,6 @@ /** * A VCloud Session Token - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java index db22b1ab72..b6c46f9db9 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/VCloudVersionsApi.java @@ -23,10 +23,10 @@ import javax.ws.rs.GET; import javax.ws.rs.Path; -import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.rest.annotations.RequestFilters; -import org.jclouds.vcloud.xml.SupportedVersionsHandler; +import org.jclouds.rest.annotations.XMLResponseParser; import org.jclouds.vcloud.http.filters.VCloudSupportedVersions; +import org.jclouds.vcloud.xml.SupportedVersionsHandler; @RequestFilters(VCloudSupportedVersions.class) public interface VCloudVersionsApi extends Closeable { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java index 84e5fef1d1..fc757a1b84 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCPUCountToXmlPayload.java @@ -34,11 +34,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindCPUCountToXmlPayload extends BindToStringPayload { protected final String ns; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java index 268f0f4eef..8a556be3fd --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCaptureVAppParamsToXmlPayload.java @@ -40,11 +40,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindCaptureVAppParamsToXmlPayload implements MapBinder { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java index 5e91a79c8e..98c4e3a187 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayload.java @@ -41,11 +41,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindCatalogItemToXmlPayload implements MapBinder { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java index 47485de056..71617bc268 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneParamsToXmlPayload.java @@ -37,11 +37,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public abstract class BindCloneParamsToXmlPayload implements MapBinder { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java index 3f6ddd659c..50c3b83112 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayload.java @@ -29,11 +29,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindCloneVAppParamsToXmlPayload extends BindCloneParamsToXmlPayload { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java index 018a009a61..2323c94427 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayload.java @@ -28,11 +28,6 @@ import com.google.inject.Inject; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindCloneVAppTemplateParamsToXmlPayload extends BindCloneParamsToXmlPayload { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java index 4d7f117e72..d376222a1e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayload.java @@ -25,11 +25,6 @@ import com.google.inject.Inject; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindDeployVAppParamsToXmlPayload extends BindParamsToXmlPayload { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java index bf40731b44..3ba51d1d3e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindGuestCustomizationSectionToXmlPayload.java @@ -36,11 +36,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindGuestCustomizationSectionToXmlPayload extends BindToStringPayload { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java index bd80bae7b5..08e5443390 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayload.java @@ -54,11 +54,6 @@ import com.google.common.collect.ImmutableSet; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindInstantiateVAppTemplateParamsToXmlPayload implements MapBinder { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java index 778bd6e150..e6a1cd450f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindMemoryToXmlPayload.java @@ -34,11 +34,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindMemoryToXmlPayload extends BindToStringPayload { protected final String ns; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java index 731bbd9d1a..6a277255f9 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayload.java @@ -37,11 +37,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindNetworkConnectionSectionToXmlPayload extends BindToStringPayload { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java index 99c0f68cb1..f613c1bf6a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindParamsToXmlPayload.java @@ -35,11 +35,6 @@ import com.google.inject.Inject; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindParamsToXmlPayload implements MapBinder { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java index 7f51f68161..d95846e24e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayload.java @@ -25,11 +25,6 @@ import com.google.inject.Inject; -/** - * - * @author Adrian Cole - * - */ @Singleton public class BindUndeployVAppParamsToXmlPayload extends BindParamsToXmlPayload { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java index 28c362be33..09c81e5925 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndCatalogNameToEndpoint.java @@ -34,10 +34,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameAndCatalogNameToEndpoint implements MapBinder { private final Supplier> orgMap; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java index fbef2fe796..b4bc580939 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameAndVDCNameToEndpoint.java @@ -34,10 +34,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameAndVDCNameToEndpoint implements MapBinder { private final Supplier> orgNameToVDCEndpoint; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java index fe842de753..2d9f762254 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameItemNameToEndpoint.java @@ -32,10 +32,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameCatalogNameItemNameToEndpoint implements MapBinder { private final Supplier>> orgCatalogMap; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java index 62414671f8..a8b798dd31 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameCatalogNameVAppTemplateNameToEndpoint.java @@ -34,10 +34,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameCatalogNameVAppTemplateNameToEndpoint implements MapBinder { private final Supplier>>> orgCatalogItemMap; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java index 3003a77d6b..11bfeac959 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameNetworkNameToEndpoint.java @@ -29,10 +29,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameVDCNameNetworkNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint { @Inject diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java index c52e66fb8d..effcc49825 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceEntityNameToEndpoint.java @@ -29,10 +29,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameVDCNameResourceEntityNameToEndpoint extends OrgNameVDCNameResourceNameToEndpoint { @Inject diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java index 79d990eba3..99ac848d23 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/binders/OrgNameVDCNameResourceNameToEndpoint.java @@ -31,10 +31,6 @@ import org.jclouds.vcloud.endpoints.Org; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public abstract class OrgNameVDCNameResourceNameToEndpoint implements MapBinder { protected final Supplier>> orgVDCMap; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java index 2c994afd03..d3538c0c2d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceContextModule.java @@ -24,8 +24,6 @@ /** * Configures the {@link VCloudComputeServiceContext}; requires {@link VCloudComputeClientImpl} * bound. - * - * @author Adrian Cole */ public class VCloudComputeServiceContextModule extends ComputeServiceAdapterContextModule { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java index b975b966b9..8b53c902fc --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/config/VCloudComputeServiceDependenciesModule.java @@ -55,10 +55,6 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; -/** - * - * @author Adrian Cole - */ public class VCloudComputeServiceDependenciesModule extends AbstractModule { @VisibleForTesting diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java index 346016aa06..f7e2cdf386 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/FindLocationForResource.java @@ -32,9 +32,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; -/** - * @author Adrian Cole - */ @Singleton public class FindLocationForResource implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java index 558c78a050..ebfb010d18 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVApp.java @@ -34,9 +34,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ public class HardwareForVApp implements Function { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java index 2671c26078..46d16273b8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/HardwareForVAppTemplate.java @@ -33,9 +33,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class HardwareForVAppTemplate implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java index 9afc714090..eb70f286f7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ImageForVAppTemplate.java @@ -36,9 +36,6 @@ import com.google.common.base.Function; -/** - * @author Adrian Cole - */ @Singleton public class ImageForVAppTemplate implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java index bebbbcef88..0947c78c7a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadata.java @@ -47,7 +47,6 @@ import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; -/** @author Adrian Cole */ @Singleton public class VAppToNodeMetadata implements Function { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java index 302ff47770..2f3bd429de --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/VCloudHardwareBuilderFromResourceAllocations.java @@ -24,9 +24,6 @@ import org.jclouds.compute.domain.internal.VolumeImpl; import org.jclouds.vcloud.domain.ovf.VCloudHardDisk; -/** - * @author Adrian Cole - */ @Singleton public class VCloudHardwareBuilderFromResourceAllocations extends HardwareBuilderFromResourceAllocations { @Override diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java index cecd8128db..dce8306395 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/functions/ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException.java @@ -33,9 +33,6 @@ import com.google.common.base.Function; import com.google.common.cache.LoadingCache; -/** - * @author Adrian Cole - */ @Singleton public class ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java old mode 100755 new mode 100644 similarity index 84% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java index 49a1f78cad..8304466318 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/internal/VCloudTemplateBuilderImpl.java @@ -24,25 +24,22 @@ import org.jclouds.collect.Memoized; import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.domain.internal.TemplateBuilderImpl; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.compute.strategy.GetImageStrategy; +import org.jclouds.compute.suppliers.ImageCacheSupplier; import org.jclouds.domain.Location; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class VCloudTemplateBuilderImpl extends TemplateBuilderImpl { @Inject protected VCloudTemplateBuilderImpl(@Memoized Supplier> locations, - @Memoized Supplier> images, @Memoized Supplier> sizes, + ImageCacheSupplier images, @Memoized Supplier> sizes, Supplier defaultLocation, @Named("DEFAULT") Provider optionsProvider, - @Named("DEFAULT") Provider defaultTemplateProvider) { - super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider); + @Named("DEFAULT") Provider defaultTemplateProvider, GetImageStrategy getImageStrategy) { + super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy); } } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java index f60aae21b6..03b12fe53a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptions.java @@ -44,8 +44,6 @@ * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * - * - * @author Adrian Cole */ public class VCloudTemplateOptions extends TemplateOptions implements Cloneable { @Override diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index caecde652a..e8b9fcd60d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -62,9 +62,6 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Singleton public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java index 7719efbf1f..28c8a9b2a6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/NetworkConfigurationForNetworkAndOptions.java @@ -28,10 +28,6 @@ import com.google.common.annotations.Beta; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Beta public class NetworkConfigurationForNetworkAndOptions { protected final Supplier defaultNetworkConfig; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java index 377c8f9cda..cd636dfab2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapter.java @@ -58,7 +58,6 @@ /** * defines the connection between the {@link org.jclouds.vcloud.VCloudApi} implementation and the jclouds * {@link ComputeService} - * */ @Singleton public class VCloudComputeServiceAdapter implements ComputeServiceAdapter { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java index 45262e9f7e..905565e724 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/compute/util/VCloudComputeUtils.java @@ -36,10 +36,6 @@ import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ public class VCloudComputeUtils { public static OperatingSystem toComputeOs(VApp vApp, OperatingSystem defaultOs) { CIMOperatingSystem cimOs = toComputeOs(vApp); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java index 09e3168d6a..eb700f35b8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultCatalogForOrg.java @@ -35,10 +35,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class DefaultCatalogForOrg implements Function { private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java index d4c67c4153..e336b95e21 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultNetworkForVDC.java @@ -36,10 +36,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class DefaultNetworkForVDC implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java index 6de2674f5f..8ed2ebad93 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultOrgForUser.java @@ -31,10 +31,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class DefaultOrgForUser implements Supplier { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java index 9a499aa9dd..c670161c3f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultTasksListForOrg.java @@ -30,10 +30,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class DefaultTasksListForOrg implements Function { private final Supplier> nameToOrg; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java index dff755635c..5a0ba9dc95 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java @@ -40,10 +40,6 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; -/** - * - * @author Adrian Cole - */ public class DefaultVCloudReferencesModule extends AbstractModule { @Override diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java index bbeb0af008..4eefd30dd0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/DefaultVDCForOrg.java @@ -35,10 +35,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class DefaultVDCForOrg implements Function { private final OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault selector; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java index d60d311cd9..5cc6d675f7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/config/VCloudHttpApiModule.java @@ -106,8 +106,6 @@ /** * Configures the VCloud authentication service connection, including logging and http transport. - * - * @author Adrian Cole */ @ConfiguresHttpApi public class VCloudHttpApiModule extends HttpApiModule { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/AllocationModel.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java index 076b93b04c..73dd7610ae --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Capacity.java @@ -18,8 +18,6 @@ /** * reports storage resource consumption in a vDC. - * - * @author Adrian Cole */ public class Capacity { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java index a9d98bd357..5e2985104b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Catalog.java @@ -24,9 +24,6 @@ import com.google.inject.ImplementedBy; -/** - * @author Adrian Cole - */ @org.jclouds.vcloud.endpoints.Catalog @ImplementedBy(CatalogImpl.class) public interface Catalog extends ReferenceType, Map { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java index caad3b3d39..dc94dbd040 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/CatalogItem.java @@ -22,9 +22,6 @@ import com.google.inject.ImplementedBy; -/** - * @author Adrian Cole - */ @ImplementedBy(CatalogItemImpl.class) public interface CatalogItem extends ReferenceType { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/GuestCustomizationSection.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/InstantiateVAppTemplateParams.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java index fed82dc59b..34aa34226f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnection.java @@ -21,8 +21,6 @@ /** * describes a single network connection. - * - * @author Adrian Cole */ public class NetworkConnection { public static Builder builder() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/NetworkConnectionSection.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java index a71ad2fb5f..7f4ede9dcf --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Org.java @@ -30,8 +30,6 @@ * contain Catalog, Network, and vDC elements. If there are any queued, running, or recently * completed tasks owned by a member of the organization, it also contains a TasksList element. As * viewed by an administrator, an organization also contains users, groups, and other information - * - * @author Adrian Cole */ @ImplementedBy(OrgImpl.class) public interface Org extends ReferenceType { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java index 98712f940f..d36343d15f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ReferenceType.java @@ -25,9 +25,6 @@ /** * Many container elements are populated with references to contained objects. Each reference * consists of a hyperlink, an optional media type, and a name. - * - * @author Adrian Cole - * */ @ImplementedBy(ReferenceTypeImpl.class) public interface ReferenceType extends Comparable { @@ -47,7 +44,7 @@ public interface ReferenceType extends Comparable { * @see VCloudMediaType */ String getType(); - + /** * @return relationship to the referenced object. */ diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java index d21512658d..748099b423 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Status.java @@ -28,8 +28,6 @@ * The deployment status of an object is indicated by the value of its deployed attribute. * * @since vcloud api 0.8 - * - * @author Adrian Cole */ public enum Status { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Task.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java index f2ab975a68..68ee690bad --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TaskStatus.java @@ -18,9 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -/** - * @author Adrian Cole - */ public enum TaskStatus { /** * The task has completed and returned a value indicating success. diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java index 9d41fbc4ed..6405054ed3 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/TasksList.java @@ -23,9 +23,6 @@ import com.google.inject.ImplementedBy; -/** - * @author Adrian Cole - */ @org.jclouds.vcloud.endpoints.TasksList @ImplementedBy(TasksListImpl.class) public interface TasksList { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java index 957bfd8da2..98efea27f3 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VApp.java @@ -27,8 +27,6 @@ *

* When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the * instantiation of the VApp. - * - * @author Adrian Cole */ public interface VApp extends ReferenceType { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java index b290f2c178..8fdd6fb831 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VAppTemplate.java @@ -28,8 +28,6 @@ /** * A VAppTemplate is an abstract description of a vApp. It is created when you upload an OVF package * to a vDC. - * - * @author Adrian Cole */ @ImplementedBy(VAppTemplateImpl.class) public interface VAppTemplate extends ReferenceType { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java index 1c8f26dbb8..3fa88b628f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudError.java @@ -23,11 +23,6 @@ import com.google.inject.ImplementedBy; -/** - * - * - * @author Adrian Cole - */ @ImplementedBy(ErrorImpl.class) public interface VCloudError { public static enum MinorCode { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java old mode 100755 new mode 100644 similarity index 96% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java index 1ba56991e5..01acd91a00 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VCloudSession.java @@ -18,10 +18,6 @@ import java.util.Map; -/** - * - * @author Adrian Cole - */ public interface VCloudSession { String getVCloudToken(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java index 205a38a26b..c741d26d52 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VDC.java @@ -26,8 +26,6 @@ /** * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC. - * - * @author Adrian Cole */ @org.jclouds.vcloud.endpoints.VDC @ImplementedBy(VDCImpl.class) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/VDCStatus.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java index 0fd8f348a9..79657b184d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/Vm.java @@ -30,8 +30,6 @@ *

* When the {@link #getStatus} is {@link Status#UNRESOLVED}, there will be a task present for the * instantiation of the VApp. - * - * @author Adrian Cole */ @ImplementedBy(VmImpl.class) public interface Vm extends ReferenceType { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java index 983600e0d6..03d1532f76 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogImpl.java @@ -33,9 +33,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class CatalogImpl extends LinkedHashMap implements Catalog { @@ -187,7 +184,6 @@ public int compareTo(ReferenceType o) { @Override public String getRelationship() { - throw new UnsupportedOperationException(); + throw new UnsupportedOperationException(); } - } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java index 5a972e5e19..5cac6ab2a2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/CatalogItemImpl.java @@ -28,11 +28,6 @@ import com.google.common.collect.Maps; -/** - * - * @author Adrian Cole - * - */ public class CatalogItemImpl extends ReferenceTypeImpl implements CatalogItem { private final String description; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java index 5eb7ea1a9a..2550f1bb6f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ErrorImpl.java @@ -21,11 +21,6 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.vcloud.domain.VCloudError; -/** - * - * @author Adrian Cole - * - */ public class ErrorImpl implements VCloudError { private final String message; private final int majorErrorCode; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java index a0850768e8..87327d1e7c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/OrgImpl.java @@ -33,9 +33,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class OrgImpl extends ReferenceTypeImpl implements Org { private final String fullName; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java old mode 100755 new mode 100644 similarity index 93% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java index b0ed12f646..fedbe23b43 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/ReferenceTypeImpl.java @@ -27,9 +27,6 @@ /** * Location of a Rest resource - * - * @author Adrian Cole - * */ public class ReferenceTypeImpl implements ReferenceType { private final String name; @@ -43,12 +40,12 @@ public ReferenceTypeImpl(String name, String type, URI href) { this.href = href; this.relationship = null; } - + public ReferenceTypeImpl(String name, String type, URI href, String relationship) { - this.name = name; - this.type = type; - this.href = href; - this.relationship = relationship; + this.name = name; + this.type = type; + this.href = href; + this.relationship = relationship; } @Override @@ -97,7 +94,6 @@ protected ToStringHelper string() { @Override public String getRelationship() { - return relationship; + return relationship; } - } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java index 8e44c4b052..70815a1c5b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TaskImpl.java @@ -30,11 +30,6 @@ import com.google.common.base.Objects; -/** - * - * @author Adrian Cole - * - */ public class TaskImpl extends ReferenceTypeImpl implements Task { private final String operation; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java index 0e9c7cfb97..4c8b2c8226 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/TasksListImpl.java @@ -24,9 +24,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class TasksListImpl implements TasksList { private final SortedSet tasks; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java index 10ca596cb3..7b032bc47e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppImpl.java @@ -36,9 +36,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class VAppImpl extends ReferenceTypeImpl implements VApp { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java index ffa034ea63..fa480c766b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VAppTemplateImpl.java @@ -36,9 +36,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class VAppTemplateImpl extends ReferenceTypeImpl implements VAppTemplate { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java index 8afa6d98e8..740df72be0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VDCImpl.java @@ -36,9 +36,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class VDCImpl extends ReferenceTypeImpl implements VDC { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java index f23c38811d..a6385c60d0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/internal/VmImpl.java @@ -36,9 +36,6 @@ /** * Locations of resources in vCloud - * - * @author Adrian Cole - * */ public class VmImpl extends ReferenceTypeImpl implements Vm { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/DhcpService.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/Features.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java index 97db30acdc..a531b0d415 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/FenceMode.java @@ -24,8 +24,6 @@ * * The FenceMode element contains one of the following strings that specify how a network is * connected to its parent network. - * - * @author Adrian Cole */ public enum FenceMode { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/FirewallService.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java index acb35bc05d..2b32691cfd --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpAddressAllocationMode.java @@ -20,8 +20,6 @@ /** * * The IpAddressAllocationMode element specifies how an IP address is allocated to this connection. - * - * @author Adrian Cole */ public enum IpAddressAllocationMode { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java index 29a24d1278..180d13dbc7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpRange.java @@ -23,7 +23,6 @@ /** * The IpRange element defines a range of IP addresses available on a network. - * */ public class IpRange { private final String startAddress; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java index bdd9671bca..e5af063546 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/IpScope.java @@ -31,7 +31,6 @@ /** * The IpScope element defines the address range, gateway, netmask, and other properties of the * network. - * */ public class IpScope { private final boolean inherited; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/NatService.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java index 1e50e3e087..79e6461b17 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/NetworkConfig.java @@ -22,10 +22,6 @@ import org.jclouds.javax.annotation.Nullable; -/** - * - * @author Adrian Cole - */ public class NetworkConfig { public Builder toBuilder() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java index a104984912..f50d18cd06 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/OrgNetwork.java @@ -28,8 +28,6 @@ /** * A vDC is a deployment environment for vApps. A Vdc element provides a user view of a vDC. - * - * @author Adrian Cole */ @org.jclouds.vcloud.endpoints.Network @ImplementedBy(OrgNetworkImpl.class) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java index 9e85db7d76..44a5e81aeb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallPolicy.java @@ -22,7 +22,6 @@ /** * specifies how packets are handled by the firewall - * */ public enum FirewallPolicy { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java index 7b11fee9db..8b09dc2564 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallProtocols.java @@ -24,8 +24,6 @@ * The Protocols element specifies the protocols to which firewall rules apply. * * @since vcloud api 0.9 emulated for 0.8 - * - * */ public class FirewallProtocols { private final boolean tcp; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java index 6536fb9183..dfb578b01e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/firewall/FirewallRule.java @@ -26,7 +26,6 @@ /** * The FirewallRule element defines a single firewall rule. * - * @author Adrian Cole * @since vcloud api 0.8 */ public class FirewallRule { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java index a072298bf3..76a394f811 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/internal/OrgNetworkImpl.java @@ -38,10 +38,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - */ public class OrgNetworkImpl extends ReferenceTypeImpl implements OrgNetwork { @Nullable private final ReferenceType org; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java index c1e2319439..8a49b33e18 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatPolicy.java @@ -22,7 +22,6 @@ /** * The Policy element of a NatService element specifies how packets are handled by the NAT service. - * */ public enum NatPolicy { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java index 00d89ad6b7..7204bae072 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatProtocol.java @@ -22,8 +22,6 @@ * The Protocol specifies the network protocol to which this rule applies * * @since vcloud api 0.9 - * - * @author Adrian Cole */ public enum NatProtocol { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java index 71f50a2557..b9ca5108f2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatRule.java @@ -23,8 +23,6 @@ * Defines a rule associated with Nat * * @since vcloud api 0.9 - * - * @author Adrian Cole */ public interface NatRule { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java index c1ed970a0e..98b95e2780 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/NatType.java @@ -25,8 +25,6 @@ * The NatType element specifies how network address translation is implemented by the NAT service. * * @since vcloud api 0.9 - * - * @author Adrian Cole */ public enum NatType { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java index e579c513bd..6d71116312 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/MappingMode.java @@ -22,7 +22,6 @@ /** * The MappingMode element specifies how IP address mapping is implemented by the NAT service. - * */ public enum MappingMode { /** diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java index 890c17aee8..c2b1b4bff8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/OneToOneVmRule.java @@ -31,7 +31,6 @@ * the specified VmReference and NIC ID. * * @since vcloud 0.9 - * @author Adrian Cole */ public class OneToOneVmRule implements NatRule { private final MappingMode mappingMode; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java index f176bc6490..3170a7316c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/PortForwardingRule.java @@ -29,7 +29,6 @@ * organization network to an external IP address and port. * * @since vcloud 0.8 - * @author Adrian Cole */ public class PortForwardingRule implements NatRule { private final String externalIP; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java index 5aa74a70cd..8793a58524 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/network/nat/rules/VmRule.java @@ -32,7 +32,6 @@ * VmReference and VmNicId. * * @since vcloud 0.9 - * @author Adrian Cole */ public class VmRule implements NatRule { @Nullable diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java index 35d09348ac..b12be8651b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/EditableResourceAllocationSettingData.java @@ -21,10 +21,6 @@ import org.jclouds.cim.ResourceAllocationSettingData; import org.jclouds.vcloud.domain.ReferenceType; -/** - * @author Adrian Cole - * - */ public class EditableResourceAllocationSettingData extends ResourceAllocationSettingData { public static Builder builder() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java index c1d94303b1..b281785fd2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudHardDisk.java @@ -20,10 +20,6 @@ import org.jclouds.cim.ResourceAllocationSettingData; -/** - * @author Adrian Cole - * - */ public class VCloudHardDisk extends ResourceAllocationSettingData { public static Builder builder() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java index 6280f1069e..7a48916ddb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkAdapter.java @@ -20,10 +20,6 @@ import org.jclouds.cim.ResourceAllocationSettingData; -/** - * @author Adrian Cole - * - */ public class VCloudNetworkAdapter extends ResourceAllocationSettingData { public static Builder builder() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudNetworkSection.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudOperatingSystemSection.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/domain/ovf/VCloudVirtualHardwareSection.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java index 99fcead0ef..7b59d1ee77 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Catalog.java @@ -25,9 +25,6 @@ /** * Related to a VCloud Catalog. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java index ae6a6b7ba5..f30162e14c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Network.java @@ -25,9 +25,6 @@ /** * Related to a VCloud Network. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java index 6385df80d4..167b1ee3ad --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/Org.java @@ -25,9 +25,6 @@ /** * Related to a VCloud express Org. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java index 5090e3266f..5e0caabbce --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/OrgList.java @@ -25,9 +25,6 @@ /** * Related to a VCloud express Org List. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java index b93947aabf..333a39f659 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/TasksList.java @@ -25,9 +25,6 @@ /** * Related to a VCloud express Task List. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java index 9fb935a5be..7d3124be8f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VCloudLogin.java @@ -27,8 +27,6 @@ * Represents a component related to vCloud. * * @see - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java index a93be77ffe..193eb746b4 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/endpoints/VDC.java @@ -25,9 +25,6 @@ /** * Related to a VCloud express Catalog. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = {ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java index 439c73e68e..1aa660e17c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/CatalogApi.java @@ -52,7 +52,6 @@ *

* * @see - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface CatalogApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java index f2a97b0a24..d36e4713f2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/NetworkApi.java @@ -39,7 +39,6 @@ /** * Provides access to Network functionality in vCloud *

- * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface NetworkApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java index 718fda9881..3b7cf3a90b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/OrgApi.java @@ -44,8 +44,6 @@ /** * Provides access to Org functionality in vCloud *

- * - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface OrgApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java index 4fe232ed84..b9a60a69ea --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/TaskApi.java @@ -42,8 +42,6 @@ /** * Provides access to Task functionality in vCloud *

- * - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface TaskApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java index c16a5b5233..af44c3e7b1 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppApi.java @@ -58,7 +58,6 @@ *

* * @see - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VAppApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java index bd11f25e40..8f4aa29867 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VAppTemplateApi.java @@ -64,7 +64,6 @@ *

* * @see - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VAppTemplateApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java index ebb8b6a1f1..7b02798f91 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VDCApi.java @@ -40,8 +40,6 @@ /** * Provides access to VDC functionality in vCloud *

- * - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VDCApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java index 2026ea4c29..8aa186e759 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/features/VmApi.java @@ -60,8 +60,6 @@ /** * Provides access to VM functionality in vCloud *

- * - * @author Adrian Cole */ @RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class) public interface VmApi { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java old mode 100755 new mode 100644 similarity index 63% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java index 9edbad46b0..1d3ba5d2f3 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequest.java @@ -18,22 +18,19 @@ import javax.inject.Inject; import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; -import org.jclouds.vcloud.VCloudToken; import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.vcloud.VCloudToken; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableMultimap; +import com.google.common.net.HttpHeaders; /** * Adds the VCloud Token to the request as a cookie - * - * @author Adrian Cole - * */ @Singleton public class AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilter { @@ -41,23 +38,23 @@ public class AddVCloudAuthorizationAndCookieToRequest implements HttpRequestFilt private final String apiVersion; @Inject - public AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier authTokenProvider, @ApiVersion final String apiVersion) { + public AddVCloudAuthorizationAndCookieToRequest(@VCloudToken Supplier authTokenProvider, @ApiVersion final String apiVersion) { this.vcloudTokenProvider = authTokenProvider; this.apiVersion = apiVersion; } @Override public HttpRequest filter(HttpRequest request) throws HttpException { - String token = vcloudTokenProvider.get(); - String acceptType = request.getFirstHeaderOrNull(HttpHeaders.ACCEPT) == null - ? "application/*+xml" - : request.getFirstHeaderOrNull(HttpHeaders.ACCEPT); - String version = ";version=" + apiVersion; - String acceptHeader = acceptType + version; - return request.toBuilder() - .replaceHeaders(ImmutableMultimap.of(HttpHeaders.ACCEPT, - acceptHeader, "x-vcloud-authorization", token, - HttpHeaders.COOKIE, "vcloud-token=" + - token)).build(); + String token = vcloudTokenProvider.get(); + String acceptType = request.getFirstHeaderOrNull(HttpHeaders.ACCEPT) == null + ? "application/*+xml" + : request.getFirstHeaderOrNull(HttpHeaders.ACCEPT); + String version = ";version=" + apiVersion; + String acceptHeader = acceptType + version; + return request.toBuilder() + .replaceHeaders(ImmutableMultimap.of(HttpHeaders.ACCEPT, + acceptHeader, "x-vcloud-authorization", token, + HttpHeaders.COOKIE, "vcloud-token=" + + token)).build(); } } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java index f5d6a7150c..db18f9e5f1 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInCatalog.java @@ -33,9 +33,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; -/** - * @author Adrian Cole - */ @Singleton public class CatalogItemsInCatalog implements Function> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java index 31f53830e6..f6ccf7d270 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogItemsInOrg.java @@ -26,9 +26,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class CatalogItemsInOrg implements Function> { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java old mode 100755 new mode 100644 similarity index 77% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java index 212569c68c..917f651377 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/CatalogsInOrg.java @@ -18,11 +18,13 @@ import static com.google.common.collect.Iterables.transform; -import java.util.Collection; import javax.annotation.Resource; import javax.inject.Inject; import javax.inject.Singleton; +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableSet; import org.jclouds.logging.Logger; import org.jclouds.vcloud.VCloudApi; import org.jclouds.vcloud.domain.Catalog; @@ -30,13 +32,9 @@ import org.jclouds.vcloud.domain.ReferenceType; import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; -import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ +import java.util.Collection; + @Singleton public class CatalogsInOrg implements Function> { @Resource @@ -51,20 +49,18 @@ public class CatalogsInOrg implements Function> { @Override public Iterable apply(final Org org) { - - Collection filtered = Collections2.filter( - org.getCatalogs().values(), new Predicate() { - @Override - public boolean apply(ReferenceType type) { - if(type == null){ - return false; - } - return !ImmutableSet.of("add", "remove").contains(type.getRelationship()); - } - }); - - - return transform(filtered, new Function() { + Collection filtered = Collections2.filter( + org.getCatalogs().values(), new Predicate() { + @Override + public boolean apply(ReferenceType type) { + if (type == null) { + return false; + } + return !ImmutableSet.of("add", "remove").contains(type.getRelationship()); + } + }); + + return transform(filtered, new Function() { public Catalog apply(ReferenceType from) { return aclient.getCatalogApi().getCatalog(from.getHref()); } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/DefaultNetworkNameInTemplate.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java index 261498cf22..25c18a10a0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/NetworksInOrg.java @@ -30,9 +30,6 @@ import com.google.common.base.Function; -/** - * @author Adrian Cole - */ @Singleton public class NetworksInOrg implements Function> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java index 507d307152..bc762a59c1 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToEndpoint.java @@ -29,10 +29,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameToEndpoint implements Function { private final Supplier> orgNameToEndpointSupplier; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java index bf9fa13fd7..1d3fc4aa6f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgNameToTasksListEndpoint.java @@ -32,10 +32,6 @@ import com.google.common.base.Function; import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ @Singleton public class OrgNameToTasksListEndpoint implements Function { private final Supplier> orgMap; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java index 26a14503c5..72be2f6129 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForLocations.java @@ -34,9 +34,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.FluentIterable; -/** - * @author Adrian Cole - */ @Singleton public class OrgsForLocations implements Function, Iterable> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java index 7749269205..ce3cd9ebb6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/OrgsForNames.java @@ -30,9 +30,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class OrgsForNames implements Function, Iterable> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java index 41c96c256e..d9900fd247 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeaders.java @@ -26,7 +26,6 @@ import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; -import javax.ws.rs.core.HttpHeaders; import org.jclouds.http.HttpResponse; import org.jclouds.http.HttpResponseException; @@ -41,11 +40,10 @@ import com.google.common.base.Function; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; +import com.google.common.net.HttpHeaders; /** * This parses {@link VCloudSession} from HTTP headers. - * - * @author Adrian Cole */ @Singleton public class ParseLoginResponseFromHeaders implements Function { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java index 1a0327a327..d3a6a9b0ff --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesForCatalogItems.java @@ -35,9 +35,6 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; -/** - * @author Adrian Cole - */ @Singleton public class VAppTemplatesForCatalogItems implements Function, Iterable> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java index e7507d4f8a..992c2af7d6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VAppTemplatesInOrg.java @@ -32,9 +32,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Singleton public class VAppTemplatesInOrg implements Function> { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java index 741c1847e2..4457233569 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/functions/VDCsInOrg.java @@ -30,9 +30,6 @@ import com.google.common.base.Function; -/** - * @author Adrian Cole - */ @Singleton public class VDCsInOrg implements Function> { @Resource diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java index c5777a9cca..2c9f96f454 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponse.java @@ -42,9 +42,6 @@ /** * This will parse and set an appropriate exception on the command object. - * - * @author Adrian Cole - * */ @Singleton public class ParseVCloudErrorFromHttpResponse implements HttpErrorHandler { @@ -71,7 +68,7 @@ public void handleError(HttpCommand command, HttpResponse response) { message = error.getMessage(); exception = new VCloudResponseException(command, response, error); } else { - message = Strings2.toString(response.getPayload()); + message = Strings2.toStringAndClose(response.getPayload().openStream()); exception = message != null ? new HttpResponseException(command, response, message) : exception; } } catch (IOException e) { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudBasicAuthentication.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/http/filters/VCloudSupportedVersions.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java index 5f9b9c603c..74a7be471b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/internal/VCloudLoginApi.java @@ -21,13 +21,14 @@ import javax.ws.rs.Consumes; import javax.ws.rs.POST; -import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication; +import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.RequestFilters; import org.jclouds.rest.annotations.ResponseParser; import org.jclouds.vcloud.VCloudMediaType; import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; +import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication; @Endpoint(org.jclouds.vcloud.endpoints.VCloudLogin.class) @RequestFilters(VCloudBasicAuthentication.class) diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/loaders/OVFLoader.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/loaders/VAppTemplateLoader.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/location/DefaultVDC.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java index d2827e5ca7..92b3c2e4d5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/location/OrgAndVDCToLocationSupplier.java @@ -40,9 +40,6 @@ import com.google.common.collect.ImmutableSet.Builder; import com.google.common.collect.Iterables; -/** - * @author Adrian Cole - */ @Singleton public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java index d74b246a0f..89580fdb86 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CaptureVAppOptions.java @@ -18,11 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -/** - * - * @author Adrian Cole - * - */ public class CaptureVAppOptions { private String description; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java index a018530585..6512031db1 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CatalogItemOptions.java @@ -23,11 +23,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * - * @author Adrian Cole - * - */ public class CatalogItemOptions { private String description; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java index 0b6d3a5484..e3f5eeafd5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneOptions.java @@ -18,11 +18,6 @@ import static com.google.common.base.Preconditions.checkNotNull; -/** - * - * @author Adrian Cole - * - */ public class CloneOptions { private String description; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java index 81185c801e..8aed313b18 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppOptions.java @@ -18,11 +18,6 @@ import static com.google.common.base.Preconditions.checkState; -/** - * - * @author Adrian Cole - * - */ public class CloneVAppOptions extends CloneOptions { private boolean deploy; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java index 8f701ebbfb..e10d45dc76 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/CloneVAppTemplateOptions.java @@ -16,11 +16,6 @@ */ package org.jclouds.vcloud.options; -/** - * - * @author Adrian Cole - * - */ public class CloneVAppTemplateOptions extends CloneOptions { /** * {@inheritDoc} diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java index 37d1d035cd..8d35d1d2f4 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptions.java @@ -27,11 +27,6 @@ import com.google.common.base.Objects.ToStringHelper; import com.google.common.collect.Sets; -/** - * - * @author Adrian Cole - * - */ public class InstantiateVAppTemplateOptions { private Set networkConfig = Sets.newLinkedHashSet(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java index b7fabb8fb5..2b249ceb13 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/predicates/TaskSuccess.java @@ -33,8 +33,6 @@ /** * * Tests to see if a task succeeds. - * - * @author Adrian Cole */ @Singleton public class TaskSuccess implements Predicate { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java old mode 100755 new mode 100644 similarity index 94% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java index 4c93a72637..2429c6a8c5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/VCloudConstants.java @@ -18,10 +18,8 @@ /** * Configuration properties and constants used in VCloud connections. - * - * @author Adrian Cole */ -public interface VCloudConstants { +public final class VCloudConstants { public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema"; /** * name of the default org that your vApp will join, if an org isn't @@ -48,4 +46,7 @@ public interface VCloudConstants { public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud.timeout.task-complete"; + private VCloudConstants() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java index efd5c8e71f..158debeaf7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/reference/package-info.java @@ -16,6 +16,5 @@ */ /** * This package contains properties and reference data used in vCloud. - * @author Adrian Cole */ package org.jclouds.vcloud.reference; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java index 03f994e1a6..938b6fd541 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault.java @@ -28,10 +28,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault implements Function, ReferenceType> { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java index 839ffd7885..08e101749c --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/suppliers/VAppTemplatesSupplier.java @@ -41,9 +41,6 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * @author Adrian Cole - */ @Singleton public class VAppTemplatesSupplier implements Supplier> { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java index 9945bba7d4..24abf3d463 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/Utils.java @@ -25,10 +25,6 @@ import org.jclouds.vcloud.domain.internal.ErrorImpl; import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -/** - * - * @author Adrian Cole - */ public class Utils { public static ReferenceType newReferenceType(Map attributes, String defaultType) { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java index 00f9ebfc64..67e24453c5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/util/VCloudUtils.java @@ -32,8 +32,6 @@ /** * Needed to sign and verify requests and responses. - * - * @author Adrian Cole */ @Singleton public class VCloudUtils { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java index 0bb354924f..60bd01f8e8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogHandler.java @@ -37,9 +37,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class CatalogHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java index 714bb5eb5a..926e8a893a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/CatalogItemHandler.java @@ -31,9 +31,6 @@ import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class CatalogItemHandler extends ParseSax.HandlerWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java index 44e88a90fa..3c4704ab21 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ErrorHandler.java @@ -25,9 +25,6 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; -/** - * @author Adrian Cole - */ public class ErrorHandler extends ParseSax.HandlerWithResult { private VCloudError error; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java index 487bf7a2f9..3fb22276b0 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandler.java @@ -26,9 +26,6 @@ import org.jclouds.vcloud.domain.ReferenceType; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class GuestCustomizationSectionHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); private ReferenceType guest; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java index 647f1206e8..aefb753c2a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionHandler.java @@ -24,9 +24,6 @@ import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class NetworkConnectionHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java index 3c80bc69a6..e8d4c74435 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandler.java @@ -32,9 +32,6 @@ import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class NetworkConnectionSectionHandler extends ParseSax.HandlerWithResult { protected StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java index ebd6d2099a..1892e30d01 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgHandler.java @@ -36,9 +36,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class OrgHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java old mode 100755 new mode 100644 similarity index 95% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java index ad5b40a8c3..941d758dcc --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgListHandler.java @@ -28,9 +28,6 @@ import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class OrgListHandler extends ParseSax.HandlerWithResult> { private Map org = Maps.newHashMap(); @@ -42,7 +39,7 @@ public Map getResult() { @Override public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { Map attributes = SaxUtils.cleanseAttributes(attrs); - if (qName.endsWith("Link") || qName.endsWith("Org")) { + if (qName.endsWith("Link") || qName.endsWith("Org")) { String type = attributes.get("type"); if (type != null) { if (type.indexOf("org+xml") != -1) { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java index 175cddef0b..521f086b81 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/OrgNetworkHandler.java @@ -56,9 +56,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class OrgNetworkHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java index a4c29ca7a8..3e393ac482 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/SupportedVersionsHandler.java @@ -24,9 +24,6 @@ import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class SupportedVersionsHandler extends ParseSax.HandlerWithResult> { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java index 8afdec06bb..fd421ab832 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TaskHandler.java @@ -38,9 +38,6 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; -/** - * @author Adrian Cole - */ public class TaskHandler extends ParseSax.HandlerWithResult { protected final DateService dateService; private String operation; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java index 9af449b328..47ef4618ca --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/TasksListHandler.java @@ -33,9 +33,6 @@ import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class TasksListHandler extends ParseSax.HandlerWithResult { private SortedSet tasks = Sets.newTreeSet(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java index 3288be9525..34ac86918a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppHandler.java @@ -41,9 +41,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class VAppHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java index b9c680707f..2476c16443 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VAppTemplateHandler.java @@ -41,9 +41,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; -/** - * @author Adrian Cole - */ public class VAppTemplateHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java index d8893d3bd9..cf6f6e530d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VCloudVirtualHardwareHandler.java @@ -30,9 +30,6 @@ import org.jclouds.vcloud.domain.ovf.VCloudVirtualHardwareSection; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class VCloudVirtualHardwareHandler extends ParseSax.HandlerWithResult { private final VirtualHardwareSectionHandler hardwareHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java index ba67c9380b..a7670be2d8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VDCHandler.java @@ -39,9 +39,6 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; -/** - * @author Adrian Cole - */ public class VDCHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java index 1cad0ad7e9..dd044774cb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/VmHandler.java @@ -40,9 +40,6 @@ import com.google.common.collect.Lists; -/** - * @author Adrian Cole - */ public class VmHandler extends ParseSax.HandlerWithResult { protected final TaskHandler taskHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java index e26af7cb2d..39013bf619 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudNetworkSectionHandler.java @@ -31,9 +31,6 @@ import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class VCloudNetworkSectionHandler extends ParseSax.HandlerWithResult { private final NetworkSectionHandler networkSectionHandler; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java index 981388ed7f..058e76ae5d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemHandler.java @@ -27,9 +27,6 @@ import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class VCloudOperatingSystemHandler extends ParseSax.HandlerWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java index 85d9d8b26a..b576c1fb06 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/java/org/jclouds/vcloud/xml/ovf/VCloudResourceAllocationSettingDataHandler.java @@ -28,9 +28,6 @@ import org.jclouds.vcloud.util.Utils; import org.xml.sax.Attributes; -/** - * @author Adrian Cole - */ public class VCloudResourceAllocationSettingDataHandler extends ResourceAllocationSettingDataHandler { private ReferenceType edit; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java index 7840801b88..8e3f826233 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiMetadataTest.java @@ -19,10 +19,6 @@ import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "unit", testName = "VCloudApiMetadataTest") public class VCloudApiMetadataTest extends BaseComputeServiceApiMetadataTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java index 9578c643ca..049b3d9366 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudApiTest.java @@ -27,8 +27,6 @@ /** * Tests behavior of {@code VCloudApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java index 7c1221da7c..dcd3e8ecc9 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudSessionRefreshLiveTest.java @@ -21,8 +21,6 @@ /** * Tests session refresh works - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class VCloudSessionRefreshLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java index 569903d295..c6164023fb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/VCloudVersionsApiTest.java @@ -34,8 +34,6 @@ /** * Tests behavior of {@code VCloudVersionsApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudVersionsApiTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java index 93ea7cb109..599f4a19e9 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCatalogItemToXmlPayloadTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code BindCatalogItemToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindCatalogItemToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java index 6fbcd8d824..8d6042d591 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppParamsToXmlPayloadTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code BindCloneVAppParamsToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindCloneVAppParamsToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java index e309e67fad..73d6342316 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindCloneVAppTemplateParamsToXmlPayloadTest.java @@ -32,8 +32,6 @@ /** * Tests behavior of {@code BindCloneVAppTemplateParamsToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindCloneVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java index d943b378a2..f145e97014 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindDeployVAppParamsToXmlPayloadTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code BindDeployVAppParamsToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindDeployVAppParamsToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java index b937c85a40..ead0badf9f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindInstantiateVAppTemplateParamsToXmlPayloadTest.java @@ -60,8 +60,6 @@ /** * Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindInstantiateVAppTemplateParamsToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java index d207fb074f..77059b04f8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindNetworkConnectionSectionToXmlPayloadTest.java @@ -32,8 +32,6 @@ /** * Tests behavior of {@code BindNetworkConnectionSectionToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit", testName = "BindNetworkConnectionSectionToXmlPayloadTest") public class BindNetworkConnectionSectionToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java index 4f4a115cf7..59a41419c6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/binders/BindUndeployVAppParamsToXmlPayloadTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code BindUndeployVAppParamsToXmlPayload} - * - * @author Adrian Cole */ @Test(groups = "unit") public class BindUndeployVAppParamsToXmlPayloadTest extends BasePayloadTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java old mode 100755 new mode 100644 similarity index 91% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java index bc4be3a65b..4ec5639917 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/BaseVCloudComputeServiceExpectTest.java @@ -35,8 +35,6 @@ /** * Base class for writing VCloud Expect tests for ComputeService operations - * - * @author Adrian Cole */ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientExpectTest { protected static final String ENDPOINT = "https://zone.myvcloud.com/api"; @@ -58,7 +56,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE // login response includes a cookie and also a vcloud extended header with the session token in it // NOTE: vCloud Director 1.5 returns ;version=1.0 on responses to requests made in 1.0 format. protected HttpResponse successfulVersion1_0LoginResponseFromVCD1_5WithSingleOrg = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/orgList1.0-vcd15.xml", VCloudMediaType.ORGLIST_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/orgList1.0-vcd15.xml", VCloudMediaType.ORGLIST_XML + ";version=1.0")) .addHeader("x-vcloud-authorization", sessionToken) .addHeader(HttpHeaders.SET_COOKIE, String.format("vcloud-token=%s; Secure; Path=/", sessionToken)).build(); @@ -71,7 +69,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetOrgResponseFromVCD1_5WithSingleTasksListVDCAndNetwork = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/org1.0-vcd15.xml", VCloudMediaType.ORG_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/org1.0-vcd15.xml", VCloudMediaType.ORG_XML + ";version=1.0")) .build(); protected String catalogId = "3155f393-1e1d-4572-8c9c-d76f72ddb658"; @@ -83,7 +81,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetCatalogResponseFromVCD1_5WithSingleTemplate = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalog1.0-vcd15.xml", VCloudMediaType.CATALOG_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalog1.0-vcd15.xml", VCloudMediaType.CATALOG_XML + ";version=1.0")) .build(); protected String catalogItemId = "ceb369f7-1d07-4e32-9dbd-ebb5aa6ca55c"; @@ -94,7 +92,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetCatalogItemResponseFromVCD1_5ForTemplate = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalogItem1.0-vcd15.xml", VCloudMediaType.CATALOGITEM_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/catalogItem1.0-vcd15.xml", VCloudMediaType.CATALOGITEM_XML + ";version=1.0")) .build(); // note vAppTemplate has a prefix in its id @@ -106,7 +104,7 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetVDCResponseFromVCD1_5WithSingleTemplateAndNetwork = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/vdc1.0-vcd15.xml", VCloudMediaType.VDC_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/vdc1.0-vcd15.xml", VCloudMediaType.VDC_XML + ";version=1.0")) .build(); protected String networkId = "b466c0c5-8a5c-4335-b703-a2e2e6b5f3e1"; @@ -117,11 +115,11 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithSingleVMAndVDCParent = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15.xml", VCloudMediaType.VAPPTEMPLATE_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0")) .build(); protected HttpResponse successfulVersion1_0GetVAppTemplateResponseFromVCD1_5WithMultipleVMsAndVDCParent = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15-multi-vm.xml", VCloudMediaType.VAPPTEMPLATE_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/template1.0-vcd15-multi-vm.xml", VCloudMediaType.VAPPTEMPLATE_XML + ";version=1.0")) .build(); protected HttpRequest version1_0GetOVFForVAppTemplateRequest = HttpRequest.builder().method("GET").endpoint(ENDPOINT + "/v1.0/vAppTemplate/" + templateId + "/ovf") @@ -130,11 +128,11 @@ public abstract class BaseVCloudComputeServiceExpectTest extends BaseRestClientE .addHeader(HttpHeaders.COOKIE, "vcloud-token=" + sessionToken).build(); protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithSingleVM = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-ubuntu64.xml", MediaType.TEXT_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-ubuntu64.xml", MediaType.TEXT_XML + ";version=1.0")) .build(); protected HttpResponse successfulVersion1_0GetOVFForVAppTemplateResponseFromVCD1_5WithMultipleVMs = HttpResponse.builder().statusCode(200) - .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-multi-vm.xml", MediaType.TEXT_XML +";version=1.0")) + .message("HTTP/1.1 200 OK").payload(payloadFromResourceWithContentType("/ovf-multi-vm.xml", MediaType.TEXT_XML + ";version=1.0")) .build(); public BaseVCloudComputeServiceExpectTest() { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java index 2abd06dc75..f5d3ec68e5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/VCloudComputeServiceLiveTest.java @@ -22,11 +22,6 @@ import com.google.inject.Module; -/** - * - * - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true) public class VCloudComputeServiceLiveTest extends BaseComputeServiceLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java index 39ae435ce5..65534aa087 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/FindLocationForResourceTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of {@code FindLocationForResource} - * - * @author Adrian Cole */ @Test(groups = "unit") public class FindLocationForResourceTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java index f95b1921fb..426de426c8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/ListImagesInVCloudExpectTest.java @@ -39,10 +39,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Test(singleThreaded = true, testName = "ListImagesInVCloudExpectTest") public class ListImagesInVCloudExpectTest extends BaseVCloudComputeServiceExpectTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java index 32bb50d464..3e36be28da --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/functions/VAppToNodeMetadataTest.java @@ -63,8 +63,6 @@ /** * Tests behavior of {@code VAppToNodeMetadata} - * - * @author Adrian Cole */ @Test(groups = "unit") public class VAppToNodeMetadataTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java index 19a3ef7fd9..4677835b07 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/options/VCloudTemplateOptionsTest.java @@ -34,8 +34,6 @@ /** * Tests possible uses of VCloudTemplateOptions and * VCloudTemplateOptions.Builder.* - * - * @author Adrian Cole */ public class VCloudTemplateOptionsTest { @Test diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java index 0e786ab565..26080215d7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest.java @@ -37,10 +37,6 @@ import com.google.common.net.HttpHeaders; import com.jamesmurty.utils.XMLBuilder; -/** - * - * @author Adrian Cole - */ @Test(singleThreaded = true, testName = "InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest") public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOnExpectTest extends BaseVCloudComputeServiceExpectTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java index 09843d2984..232b1513e6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/compute/strategy/VCloudComputeServiceAdapterTest.java @@ -53,7 +53,7 @@ public void testListHardwareProfiles() throws Exception { Iterable hardwareProfiles = adapter.listHardwareProfiles(); - Iterable hardwareProfileRefs = Iterables.transform(ImmutableList.copyOf(hardwareProfiles), new Function() { + Iterable hardwareProfileRefs = Iterables.transform(ImmutableList.copyOf(hardwareProfiles), new Function() { @Override public URI apply(VAppTemplate input) { return input.getHref(); } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java index fa81fa3d42..a787afb318 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiLiveTest.java @@ -29,9 +29,6 @@ import com.google.inject.Key; -/** - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "CatalogApiLiveTest") public class CatalogApiLiveTest extends BaseVCloudApiLiveTest { @Test diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java index cf63390426..c5094d54d7 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/CatalogApiTest.java @@ -34,8 +34,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code CatalogApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java index c9c6e4fc4c..b7d7102b16 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiLiveTest.java @@ -19,9 +19,6 @@ import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; import org.testng.annotations.Test; -/** - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "NetworkApiLiveTest") public class NetworkApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java index 0d23a221af..d6ce45261f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/NetworkApiTest.java @@ -32,8 +32,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code NetworkApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java index ae22a05bee..d1c8528653 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiLiveTest.java @@ -23,9 +23,6 @@ import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; import org.testng.annotations.Test; -/** - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "OrgApiLiveTest") public class OrgApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java index 0f9fc72a1d..1080dde52d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/OrgApiTest.java @@ -34,8 +34,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code OrgApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java index 4a8724712a..5be4bf43de --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiLiveTest.java @@ -19,9 +19,6 @@ import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; import org.testng.annotations.Test; -/** - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "TaskApiLiveTest") public class TaskApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java index 4c3ee519a4..75518f0631 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/TaskApiTest.java @@ -34,8 +34,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code TaskApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java index 7bfb325d7d..cf4aca3836 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiLiveTest.java @@ -26,10 +26,6 @@ import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppApiLiveTest") public class VAppApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java index d8ec98f811..73ca9a1cc2 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java @@ -37,8 +37,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java index 63056dc2f4..e883235cc5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java @@ -41,10 +41,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMap; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppTemplateApiLiveTest") public class VAppTemplateApiLiveTest extends BaseVCloudApiLiveTest { @Test diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java index 06f592eb0f..12bef2efbf --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java @@ -42,8 +42,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VAppTemplateApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java index 5c3632a669..be1efdc874 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java @@ -19,9 +19,6 @@ import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest; import org.testng.annotations.Test; -/** - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "VDCApiLiveTest") public class VDCApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java index 549b47c5a5..02964534ef --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java @@ -34,8 +34,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VDCApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java index 095a12b1de..f6b3d92df4 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java @@ -45,8 +45,6 @@ * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There * are a few advantages to this, including the fact that it can work inside google appengine where * network sockets (ssh:22) are prohibited. - * - * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true, testName = "VmApiLiveTest") public class VmApiLiveTest extends BaseVCloudApiLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java index d7f0b0f50f..b8e786ccc6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java @@ -39,8 +39,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code VmApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java old mode 100755 new mode 100644 similarity index 87% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java index d4a0c066e4..40d1fd5798 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java @@ -18,17 +18,13 @@ import static org.testng.Assert.assertEquals; -import javax.ws.rs.core.HttpHeaders; - import org.jclouds.http.HttpRequest; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.common.base.Supplier; +import com.google.common.net.HttpHeaders; -/** - * @author Adrian Cole - */ @Test(testName = "AddVCloudAuthorizationAndCookieToRequestTest") public class AddVCloudAuthorizationAndCookieToRequestTest { @@ -36,11 +32,11 @@ public class AddVCloudAuthorizationAndCookieToRequestTest { @BeforeTest void setUp() { - filter = new AddVCloudAuthorizationAndCookieToRequest(new Supplier() { - public String get() { - return "token"; - } - }, "1.0"); + filter = new AddVCloudAuthorizationAndCookieToRequest(new Supplier() { + public String get() { + return "token"; + } + }, "1.0"); } @Test diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java index 77d106963f..66a4f4ab6b --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of {@code ParseLoginResponseFromHeaders} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java index e8247151f0..9466191bfe --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java @@ -26,10 +26,6 @@ import org.jclouds.vcloud.VCloudMediaType; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = { "unit" }) public class ParseVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java index 73880ee881..a4db473f55 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java @@ -25,10 +25,6 @@ import com.google.inject.Module; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", enabled = true, singleThreaded = true) public abstract class BaseVCloudApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java index 2ac9667c5f..0f97e263b4 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java @@ -70,8 +70,6 @@ /** * Tests behavior of {@code VCloudApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "BaseVCloudApiTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java index 4652e5ee9e..1bd3fdbf8e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java @@ -22,9 +22,8 @@ import java.io.IOException; import java.net.URI; -import javax.ws.rs.core.HttpHeaders; - import org.jclouds.http.HttpRequest; +import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.location.Provider; import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; @@ -37,14 +36,13 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; +import com.google.common.net.HttpHeaders; import com.google.common.reflect.Invokable; import com.google.inject.Binder; import com.google.inject.Module; import com.google.inject.Provides; /** * Tests behavior of {@code VCloudLoginApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudLoginApiTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java index dd84c984e7..89942844e8 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of {@code InstantiateVAppTemplateOptions} - * - * @author Adrian Cole */ @Test(groups = "unit") public class InstantiateVAppTemplateOptionsTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java index d33bb324a7..4bdb5b8ab6 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java @@ -36,8 +36,6 @@ /** * Tests behavior of * {@code OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java old mode 100755 new mode 100644 similarity index 97% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java index 9a3026631e..9a844ed728 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java @@ -19,8 +19,6 @@ /** * Utility class for test - * - * @author Andrew Phillips */ public class TestUtils { public static final Object[][] NO_INVOCATIONS = new Object[0][0]; diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java index 86cb8ac23a..2a883e61bb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java @@ -39,8 +39,6 @@ /** * Tests behavior of {@code CatalogHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class CatalogHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java old mode 100755 new mode 100644 similarity index 96% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java index 25c48cdc99..6f2b100860 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of {@code CatalogItemHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class CatalogItemHandlerTest { @@ -68,7 +66,7 @@ public void testApplyInputStreamWithNamespaceUsingVcloud() { URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.of())); + ImmutableSortedMap.of())); } public void testApplyInputStreamWithNamespaceUsingDefault() { @@ -81,6 +79,6 @@ public void testApplyInputStreamWithNamespaceUsingDefault() { URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.of())); + ImmutableSortedMap.of())); } } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java index 5608d96455..503611eb68 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java @@ -30,8 +30,6 @@ /** * Tests behavior of {@code GuestCustomizationSectionHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "GuestCustomizationSectionHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java index 03ed047ed9..7895c8122f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionHandlerTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code NetworkConnectionHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "NetworkConnectionHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java index aec8c254fd..632981ed6e --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/NetworkConnectionSectionHandlerTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of {@code NetworkConnectionSectionHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class NetworkConnectionSectionHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java index 738a5a1690..6c56e66b3a --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgHandlerTest.java @@ -41,8 +41,6 @@ /** * Tests behavior of {@code OrgHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class OrgHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java index 7887a56a10..68bf197f5d --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgListHandlerTest.java @@ -31,8 +31,6 @@ /** * Tests behavior of {@code OrgListHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "OrgListHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java index e350131ca8..22b81c692f --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/OrgNetworkHandlerTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code OrgNetworkHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class OrgNetworkHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java old mode 100755 new mode 100644 similarity index 98% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java index e9f8cbb2e3..c264c60ad4 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/SupportedVersionsHandlerTest.java @@ -33,8 +33,6 @@ /** * Tests behavior of {@code SupportedVersionsHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class SupportedVersionsHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java index 45d5d07429..f5a4688cdb --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TaskHandlerTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of {@code TaskHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "TaskHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java index a5c83d5194..24552b0300 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/TasksListHandlerTest.java @@ -36,8 +36,6 @@ /** * Tests behavior of {@code TasksListHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "TasksListHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java index e6c05c7d97..992e3432da --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppHandlerTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code VAppHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class VAppHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java index 0accf60818..c0cc110357 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VAppTemplateHandlerTest.java @@ -45,8 +45,6 @@ /** * Tests behavior of {@code VAppTemplateHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class VAppTemplateHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java index 869530b49c..d5cc9da247 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VDCHandlerTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code VDCHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class VDCHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java index 2faa656a83..342b04a4a1 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/VmHandlerTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code VmHandler} - * - * @author Adrian Cole */ @Test(groups = "unit") public class VmHandlerTest { diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java old mode 100755 new mode 100644 similarity index 99% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java index a5604ffccd..307b3f1ef5 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudOperatingSystemSectionHandlerTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code VCloudOperatingSystemSectionHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudOperatingSystemSectionHandlerTest") diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java old mode 100755 new mode 100644 similarity index 95% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java index 65f4560a72..b772b103a3 --- a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java +++ b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/java/org/jclouds/vcloud/xml/ovf/VCloudVirtualHardwareSectionHandlerTest.java @@ -43,8 +43,6 @@ /** * Tests behavior of {@code VCloudVirtualHardwareSectionHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "VCloudVirtualHardwareSectionHandlerTest") @@ -127,7 +125,7 @@ public static void checkHardware(VCloudVirtualHardwareSection result) { null, "application/vnd.vmware.vcloud.rasdItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"),"edit")) + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/cpu"),"edit")) .build().toString()); assertEquals( @@ -147,7 +145,7 @@ public static void checkHardware(VCloudVirtualHardwareSection result) { null, "application/vnd.vmware.vcloud.rasdItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"),"edit")) + .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/virtualHardwareSection/memory"),"edit")) .build().toString()); } } diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/captureVApp-default.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/captureVApp-default.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/captureVApp-default.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/captureVApp.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/captureVApp.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/captureVApp.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog-blank.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog-blank.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog-blank.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalog1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalog1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-carrenza-with-default-namespace.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-carrenza-with-vcloud-namespace.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-terremark.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-terremark.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem-terremark.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem-terremark.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/catalogItem1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/catalogItem1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVApp-default.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVApp-default.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVApp-default.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVApp-default.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVApp.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVApp.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVApp.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVAppTemplate-default.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVAppTemplate-default.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVAppTemplate-default.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVAppTemplate-default.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVAppTemplate.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/copyVAppTemplate.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/copyVAppTemplate.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/cpuItem.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/cpuItem.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/cpuItem.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/cpuItem.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/guestCustomization.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/guestCustomization.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/guestCustomization.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/guestCustomization.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/guestCustomizationSection.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/guestCustomizationSection.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/guestCustomizationSection.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/guestCustomizationSection.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiatedvapp.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiatedvapp.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiatedvapp.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiatedvapp.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams-description.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams-description.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams-description.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams-description.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams-network.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams-network.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams-network.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams-network.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/instantiationparams.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/instantiationparams.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/log4j.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/log4j.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/log4j.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/log4j.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/memoryItem.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/memoryItem.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/memoryItem.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/memoryItem.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/moveVApp.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/moveVApp.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/moveVApp.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/moveVApp.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/moveVAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/moveVAppTemplate.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/moveVAppTemplate.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/moveVAppTemplate.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/networkconnection.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/networkconnection.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/networkconnection.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/networkconnection.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/networkconnectionsection.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/networkconnectionsection.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/networkconnectionsection.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/networkconnectionsection.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-1.0.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-1.0.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-1.0.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-1.0.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-savvis.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-savvis.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org-savvis.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org-savvis.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/org1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/org1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgList1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgList1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgList1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgList1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orglist-savvis.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orglist-savvis.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orglist-savvis.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orglist-savvis.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orglist.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orglist.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orglist.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orglist.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgnetwork-bridged.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgnetwork-bridged.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgnetwork-bridged.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgnetwork-bridged.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgnetwork-isolated.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgnetwork-isolated.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/orgnetwork-isolated.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/orgnetwork-isolated.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/os.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/os.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/os.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/os.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/ovf-multi-vm.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/ovf-multi-vm.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/ovf-multi-vm.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/ovf-multi-vm.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/ovf-ubuntu64.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/ovf-ubuntu64.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/ovf-ubuntu64.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/ovf-ubuntu64.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-1.0.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-1.0.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-1.0.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-1.0.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-error.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-error.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-error.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-error.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-self.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-self.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-self.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-self.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/task.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/task.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/taskslist-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/taskslist-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/taskslist-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/taskslist-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/taskslist.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/taskslist.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/taskslist.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/taskslist.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/template1.0-vcd15-multi-vm.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/template1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/template1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/template1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/template1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate-copying.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate-copying.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate-copying.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate-copying.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vAppTemplate1.0-vcd15_withNewlines.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-none.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-none.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-none.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-none.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-pool.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-pool.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-pool.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-pool.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-rhel-off-static.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-rhel-off-static.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-rhel-off-static.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-rhel-off-static.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-ubuntu-off-dhcp.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-ubuntu-off-dhcp.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-ubuntu-off-dhcp.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-ubuntu-off-dhcp.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-unresolved.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-unresolved.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-unresolved.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-unresolved.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-win-off-static.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-win-off-static.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vapp-win-off-static.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vapp-win-off-static.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-1.0.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-1.0.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-1.0.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-1.0.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-hosting.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-hosting.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-hosting.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-hosting.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-nonet.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-nonet.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc-nonet.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc-nonet.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc1.0-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc1.0-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vdc1.0-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vdc1.0-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/versions-vcd15.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/versions-vcd15.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/versions-vcd15.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/versions-vcd15.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/versions.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/versions.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/versions.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/versions.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/virtualhardwaresection.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/virtualhardwaresection.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/virtualhardwaresection.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/virtualhardwaresection.xml diff --git a/dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vm-rhel-off-static.xml b/dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vm-rhel-off-static.xml old mode 100755 new mode 100644 similarity index 100% rename from dependencies/jclouds/apis/vcloud/1.7.1-stratos/src/test/resources/vm-rhel-off-static.xml rename to dependencies/jclouds/apis/vcloud/1.8.0-stratos/src/test/resources/vm-rhel-off-static.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java deleted file mode 100644 index e09c4ac5bc..0000000000 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java +++ /dev/null @@ -1,58 +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.jclouds.aws.ec2.features; - -import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; -import static org.testng.Assert.assertNotNull; - -import java.util.Set; - -import org.jclouds.aws.domain.Region; -import org.jclouds.ec2.domain.Image; -import org.jclouds.ec2.features.AMIApiLiveTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; - -/** - * Tests behavior of {@code AMIApi} - * - * @author Adrian Cole - */ -@Test(groups = "live", singleThreaded = true) -public class AWSAMIApiLiveTest extends AMIApiLiveTest { - - public AWSAMIApiLiveTest() { - provider = "aws-ec2"; - } - - public void testDescribeImagesCC() { - Set ccResults = client.describeImagesInRegion(Region.US_EAST_1, - filters(ImmutableMultimap. builder()// - .put("virtualization-type", "hvm")// - .put("architecture", "x86_64")// - .putAll("owner-id", ImmutableSet. of("137112412989", "099720109477"))// - .put("hypervisor", "xen")// - .put("state", "available")// - .put("image-type", "machine")// - .put("root-device-type", "ebs")// - .build()).ownedBy("137112412989", "099720109477")); - assertNotNull(ccResults); - assert ccResults.size() >= 34 : ccResults; - } -} diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/README.txt similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/README.txt rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/README.txt diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/pom.xml similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/pom.xml index 3b2a64014e..1d07608084 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/pom.xml +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/pom.xml @@ -22,18 +22,18 @@ org.apache.jclouds jclouds-project - 1.7.1 + 1.8.0 ../../project/pom.xml org.apache.stratos aws-ec2 - 1.7.1-stratos + 1.8.0-stratos jclouds Amazon EC2 provider EC2 implementation targeted to Amazon Web Services bundle - 1.7.1 + 1.8.0 https://ec2.us-east-1.amazonaws.com 2014-02-01 diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/clojure/org/jclouds/aws/ec2.clj similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/clojure/org/jclouds/aws/ec2.clj rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/clojure/org/jclouds/aws/ec2.clj diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java index e54a0ea58b..b7e3f80607 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2Api.java @@ -33,8 +33,6 @@ /** * Provides synchronous access to EC2 services. - * - * @author Adrian Cole */ public interface AWSEC2Api extends EC2Api { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ApiMetadata.java diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index 7827171e78..da1f65c7d0 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -31,8 +31,6 @@ /** * Implementation of {@ link org.jclouds.types.ProviderMetadata} for Amazon's * Elastic Compute Cloud (EC2) provider. - * - * @author Adrian Cole */ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { @@ -83,7 +81,7 @@ protected Builder() { .homepage(URI.create("http://aws.amazon.com/ec2")) .console(URI.create("https://console.aws.amazon.com/ec2/home")) .defaultProperties(AWSEC2ProviderMetadata.defaultProperties()) - .linkedServices("aws-ec2","aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") + .linkedServices("aws-ec2", "aws-elb", "aws-cloudwatch", "aws-s3", "aws-simpledb") .iso3166Codes("US-VA", "US-CA", "US-OR", "BR-SP", "IE", "SG", "AU-NSW", "JP-13"); } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java similarity index 88% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java index aaf57ce669..0029c862f1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParams.java @@ -35,10 +35,6 @@ import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Multimaps; -/** - * - * @author Adrian Cole - */ @Singleton public class BindLaunchSpecificationToFormParams implements Binder, Function> { @@ -65,17 +61,17 @@ public Map apply(LaunchSpecification launchSpec) { if (launchSpec.getSecurityGroupIds().size() > 0) options.withSecurityGroupIds(launchSpec.getSecurityGroupIds()); options.asType(checkNotNull(launchSpec.getInstanceType(), "instanceType")); - if (launchSpec.getSubnetId() != null){ - if (Boolean.TRUE.equals(launchSpec.isPublicIpAddressAssociated())) { - options.associatePublicIpAddressAndSubnetId(launchSpec.getSubnetId()); - if (launchSpec.getSecurityGroupIds().size() > 0){ - options.withSecurityGroupIdsForNetworkInterface(launchSpec.getSecurityGroupIds()); - } - } - else{ - options.withSubnetId(launchSpec.getSubnetId()); - } - } + if (launchSpec.getSubnetId() != null){ + if (Boolean.TRUE.equals(launchSpec.isPublicIpAddressAssociated())) { + options.associatePublicIpAddressAndSubnetId(launchSpec.getSubnetId()); + if (launchSpec.getSecurityGroupIds().size() > 0){ + options.withSecurityGroupIdsForNetworkInterface(launchSpec.getSecurityGroupIds()); + } + } + else{ + options.withSubnetId(launchSpec.getSubnetId()); + } + } if (launchSpec.getKernelId() != null) options.withKernelId(launchSpec.getKernelId()); if (launchSpec.getKeyName() != null) diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java index dfdf38e2ec..11816dfe2b 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindSpotInstanceRequestIdsToIndexedFormParams.java @@ -24,8 +24,6 @@ /** * Binds the String [] to form parameters named with SpotInstanceRequestId.index - * - * @author Adrian Cole */ @Singleton public class BindSpotInstanceRequestIdsToIndexedFormParams implements Binder { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java similarity index 93% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java index 7641c566ce..b842d2ddfa 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagFiltersToIndexedFormParams.java @@ -25,13 +25,10 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.Binder; -/** - * @author grkvlt@apache.org - */ public class BindTagFiltersToIndexedFormParams implements Binder { @Override public R bindToRequest(R request, Object input) { - checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map>"); + checkArgument(checkNotNull(input, "input") instanceof Map, "this binder is only valid for Map>"); return AWSUtils.indexMapOfIterableToFormValuesWithPrefix(request, "Filter", "Name", "Value", input); } } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java index f703b89d0e..a96736144e 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParams.java @@ -25,9 +25,6 @@ import org.jclouds.http.HttpRequest; import org.jclouds.rest.Binder; -/** - * @author grkvlt@apache.org - */ public class BindTagsToIndexedFormParams implements Binder { @Override public R bindToRequest(R request, Object input) { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java index f512074ce6..472b414115 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeService.java @@ -74,9 +74,6 @@ import com.google.common.cache.LoadingCache; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * @author Adrian Cole - */ @Singleton public class AWSEC2ComputeService extends EC2ComputeService { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java index 36c381fc55..d9d79b9bf5 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceContext.java @@ -21,9 +21,6 @@ import com.google.inject.ImplementedBy; -/** - * @author Adrian Cole - */ @ImplementedBy(AWSEC2ComputeServiceContextImpl.class) public interface AWSEC2ComputeServiceContext extends EC2ComputeServiceContext { @Override diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java similarity index 82% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java index b3adb8b826..160c37f9cf 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderImpl.java @@ -27,6 +27,8 @@ import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.TemplateOptions; +import org.jclouds.compute.strategy.GetImageStrategy; +import org.jclouds.compute.suppliers.ImageCacheSupplier; import org.jclouds.domain.Location; import org.jclouds.ec2.compute.domain.RegionAndName; import org.jclouds.ec2.compute.internal.EC2TemplateBuilderImpl; @@ -34,18 +36,15 @@ import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; -/** - * - * @author Adrian Cole - */ public class AWSEC2TemplateBuilderImpl extends EC2TemplateBuilderImpl { @Inject protected AWSEC2TemplateBuilderImpl(@Memoized Supplier> locations, - @Memoized Supplier> images, @Memoized Supplier> sizes, + ImageCacheSupplier images, @Memoized Supplier> sizes, Supplier defaultLocation, @Named("DEFAULT") Provider optionsProvider, - @Named("DEFAULT") Provider defaultTemplateProvider, Supplier> imageMap) { - super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, imageMap); + @Named("DEFAULT") Provider defaultTemplateProvider, GetImageStrategy getImageStrategy, + Supplier> imageMap) { + super(locations, images, sizes, defaultLocation, optionsProvider, defaultTemplateProvider, getImageStrategy, imageMap); } } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java index 56ad2df3d3..5bfb2b0c3f 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateOptions.java @@ -53,8 +53,6 @@ * templateBuilder.options(inboundPorts(22, 80, 8080, 443)); * Set set = client.createNodesInGroup(tag, 2, templateBuilder.build()); * - * - * @author Adrian Cole */ public class AWSEC2TemplateOptions extends EC2TemplateOptions implements Cloneable { @Override @@ -131,7 +129,7 @@ public ToStringHelper string() { if (monitoringEnabled) toString.add("monitoringEnabled", monitoringEnabled); if (publicIpAddressAssociated) - toString.add("publicIpAddressAssociated", publicIpAddressAssociated); + toString.add("publicIpAddressAssociated", publicIpAddressAssociated); toString.add("placementGroup", placementGroup); if (noPlacementGroup) toString.add("noPlacementGroup", noPlacementGroup); @@ -158,14 +156,14 @@ public AWSEC2TemplateOptions enableMonitoring() { return this; } - /** - * Associate a public Ip Address - * - */ - public AWSEC2TemplateOptions associatePublicIpAddress() { - this.publicIpAddressAssociated = true; - return this; - } + /** + * Associate a public Ip Address + * + */ + public AWSEC2TemplateOptions associatePublicIpAddress() { + this.publicIpAddressAssociated = true; + return this; + } /** * Specifies the keypair used to run instances with @@ -392,22 +390,21 @@ public static AWSEC2TemplateOptions noPlacementGroup() { return options.noPlacementGroup(); } - /** - * @see AWSEC2TemplateOptions#enableMonitoring - */ - public static AWSEC2TemplateOptions enableMonitoring() { - AWSEC2TemplateOptions options = new AWSEC2TemplateOptions(); - return options.enableMonitoring(); - } - + /** + * @see AWSEC2TemplateOptions#enableMonitoring + */ + public static AWSEC2TemplateOptions enableMonitoring() { + AWSEC2TemplateOptions options = new AWSEC2TemplateOptions(); + return options.enableMonitoring(); + } - /** - * @see AWSEC2TemplateOptions#associatePublicIpAddress - */ - public static AWSEC2TemplateOptions associatePublicIpAddress() { - AWSEC2TemplateOptions options = new AWSEC2TemplateOptions(); - return options.associatePublicIpAddress(); - } + /** + * @see AWSEC2TemplateOptions#associatePublicIpAddress + */ + public static AWSEC2TemplateOptions associatePublicIpAddress() { + AWSEC2TemplateOptions options = new AWSEC2TemplateOptions(); + return options.associatePublicIpAddress(); + } // methods that only facilitate returning the correct object type /** @@ -774,12 +771,10 @@ public boolean isMonitoringEnabled() { return monitoringEnabled; } - /** - * @return true (default is false) if we are supposed to associate a public ip address - */ - public boolean isPublicIpAddressAssociated() { - return publicIpAddressAssociated; - } + /** + * @return true (default is false) if we are supposed to associate a public ip address + */ + public boolean isPublicIpAddressAssociated() { return publicIpAddressAssociated; } /** * @return subnetId to use when running the instance or null. diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java index f088bcdd83..c72ff56327 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2BindComputeSuppliersByClass.java @@ -23,9 +23,6 @@ import org.jclouds.ec2.compute.config.EC2BindComputeSuppliersByClass; import com.google.common.base.Supplier; -/** - * @author Aled Sage - */ public class AWSEC2BindComputeSuppliersByClass extends EC2BindComputeSuppliersByClass { @Override protected Class>> defineImageSupplier() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java index 5341d57a46..2f801bff38 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModule.java @@ -72,10 +72,6 @@ import com.google.inject.Provides; import com.google.inject.TypeLiteral; -/** - * - * @author Adrian Cole - */ public class AWSEC2ComputeServiceContextModule extends BaseComputeServiceContextModule { @Override protected void configure() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java index 466deb1971..5a32459ef4 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceDependenciesModule.java @@ -81,10 +81,6 @@ import com.google.inject.assistedinject.FactoryModuleBuilder; import com.google.inject.name.Names; -/** - * - * @author Adrian Cole - */ public class AWSEC2ComputeServiceDependenciesModule extends EC2ComputeServiceDependenciesModule { @Override protected void configure() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java index 1cfabb1db0..bb2191b2a3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ClusterCompute.java @@ -25,9 +25,6 @@ /** * Related to a ClusterCompute resource. - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java index 2bfedf48a4..76bdd98443 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/config/ImageQuery.java @@ -25,9 +25,6 @@ /** * Related to an Image Query - * - * @author Adrian Cole - * */ @Retention(value = RetentionPolicy.RUNTIME) @Target(value = { ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD }) diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java index 3b04335218..b73ff43109 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtension.java @@ -22,11 +22,16 @@ import static com.google.common.collect.Iterables.getOnlyElement; import static com.google.common.collect.Iterables.transform; -import java.util.Set; - import javax.inject.Inject; import javax.inject.Named; +import java.util.Set; +import com.google.common.base.Function; +import com.google.common.base.Supplier; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.Iterables; +import com.google.common.collect.Multimap; +import com.google.common.util.concurrent.ListeningExecutorService; import org.jclouds.Constants; import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.util.AWSUtils; @@ -41,18 +46,9 @@ import org.jclouds.net.domain.IpPermission; import org.jclouds.net.domain.IpProtocol; -import com.google.common.base.Function; -import com.google.common.base.Supplier; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.Iterables; -import com.google.common.collect.Multimap; -import com.google.common.util.concurrent.ListeningExecutorService; - /** * An extension to compute service to allow for the manipulation of {@link SecurityGroup}s. Implementation * is optional by providers. - * - * @author Andrew Bayer */ public class AWSEC2SecurityGroupExtension extends EC2SecurityGroupExtension { protected final AWSEC2Api client; @@ -79,7 +75,7 @@ public SecurityGroup createSecurityGroup(String name, String region) { false); groupCreator.getUnchecked(regionAndName); - String groupId = groupNameToId.apply(markerGroup); + String groupId = groupNameToId.apply(regionAndName.slashEncode()); return getSecurityGroupById(regionAndName.getRegion() + "/" + groupId); } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java index b0c3cd3445..c145bafb78 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroup.java @@ -31,8 +31,6 @@ /** * A function for transforming an EC2-specific SecurityGroup into a generic * SecurityGroup object. - * - * @author Andrew Bayer */ @Singleton public class AWSEC2SecurityGroupToSecurityGroup extends EC2SecurityGroupToSecurityGroup { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java index efbb07bfed..bdb109dd35 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadata.java @@ -41,9 +41,6 @@ import com.google.common.base.Supplier; import com.google.common.cache.LoadingCache; -/** - * @author Adrian Cole - */ @Singleton public class AWSRunningInstanceToNodeMetadata extends RunningInstanceToNodeMetadata { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java index f754a577c3..9b7a4e92d1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstances.java @@ -49,8 +49,6 @@ /** * returns either the instances present in the list, or spot instances, if they ids start with {@code sir-}. Makes a * single rest call per aggregate on region. - * - * @author Adrian Cole */ @Singleton public class PresentSpotRequestsAndInstances extends PresentInstances { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java index 4055cda89e..6fdcd4f7b9 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java @@ -28,9 +28,6 @@ import com.google.common.reflect.TypeToken; -/** - * @author Adrian Cole - */ @Singleton public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java index a9c13912bd..dd8ccf8274 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeeded.java @@ -42,11 +42,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - * @author Andrew Bayer - */ @Singleton public class AWSEC2CreateSecurityGroupIfNeeded extends CacheLoader { @Resource diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java index 1cf8836190..fefde8fe49 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2CreateNodesInGroupThenAddToSet.java @@ -15,12 +15,20 @@ * limitations under the License. */ package org.jclouds.aws.ec2.compute.strategy; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.cache.LoadingCache; -import com.google.common.collect.ImmutableSet; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.collect.Iterables.transform; +import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; +import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; + +import javax.annotation.Resource; +import javax.inject.Inject; +import javax.inject.Named; +import javax.inject.Singleton; + import org.jclouds.aws.ec2.AWSEC2Api; import org.jclouds.aws.ec2.compute.AWSEC2TemplateOptions; import org.jclouds.aws.ec2.compute.functions.PresentSpotRequestsAndInstances; @@ -41,23 +49,13 @@ import org.jclouds.ec2.options.RunInstancesOptions; import org.jclouds.logging.Logger; -import javax.annotation.Resource; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; - -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.collect.Iterables.transform; -import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING; -import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_GENERATE_INSTANCE_NAMES; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Function; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.common.cache.LoadingCache; +import com.google.common.collect.ImmutableSet; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2CreateNodesInGroupThenAddToSet extends EC2CreateNodesInGroupThenAddToSet { @@ -95,7 +93,7 @@ protected Set createNodesInRegionAndZone(String region, String AWSEC2TemplateOptions awsOptions = AWSEC2TemplateOptions.class.cast(template.getOptions()); LaunchSpecification spec = AWSRunInstancesOptions.class.cast(instanceOptions).getLaunchSpecificationBuilder() .imageId(template.getImage().getProviderId()).availabilityZone(zone).subnetId(awsOptions.getSubnetId()) - .publicIpAddressAssociated(awsOptions.isPublicIpAddressAssociated()) + .publicIpAddressAssociated(awsOptions.isPublicIpAddressAssociated()) .iamInstanceProfileArn(awsOptions.getIAMInstanceProfileArn()) .iamInstanceProfileName(awsOptions.getIAMInstanceProfileName()).build(); RequestSpotInstancesOptions options = awsOptions.getSpotOptions(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java index ee7b03bac3..e14b52a394 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2DestroyNodeStrategy.java @@ -35,10 +35,6 @@ import com.google.common.cache.LoadingCache; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2DestroyNodeStrategy extends EC2DestroyNodeStrategy { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java index ffc2e0b218..3ea27879a6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2GetNodeMetadataStrategy.java @@ -31,10 +31,6 @@ import com.google.common.base.Function; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2GetNodeMetadataStrategy extends EC2GetNodeMetadataStrategy { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java index 81a7382335..017eb6f738 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ListNodesStrategy.java @@ -44,10 +44,6 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.inject.Inject; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2ListNodesStrategy extends EC2ListNodesStrategy { @@ -74,7 +70,7 @@ protected Iterable pollRunningInstances() { } @Override - protected Iterable pollRunningInstancesByRegionsAndIds(final Multimap idsByRegions) { + protected Iterable pollRunningInstancesByRegionsAndIds(final Multimap idsByRegions) { Iterable spots = filter(transform(concat(transform(idsByRegions.keySet(), spotInstancesByIdInRegion(idsByRegions))), @@ -93,7 +89,7 @@ public Set apply(String from) { }; } - protected Function> spotInstancesByIdInRegion(final Multimap idsByRegions) { + protected Function> spotInstancesByIdInRegion(final Multimap idsByRegions) { return new Function>() { @Override diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java index 521aa95301..fb7d739c9f 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImage.java @@ -34,9 +34,6 @@ import org.jclouds.ec2.compute.strategy.ReviseParsedImage; import org.jclouds.logging.Logger; -/** - * @author Adrian Cole - */ @Singleton public class AWSEC2ReviseParsedImage implements ReviseParsedImage { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java similarity index 94% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java index 92668d6452..096d959623 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions.java @@ -47,10 +47,6 @@ import com.google.common.base.Predicate; import com.google.common.cache.LoadingCache; -/** - * - * @author Adrian Cole - */ @Singleton public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions extends CreateKeyPairAndSecurityGroupsAsNeededAndReturnRunOptions { @@ -178,23 +174,24 @@ protected boolean userSpecifiedTheirOwnGroups(TemplateOptions options) { protected void addSecurityGroups(String region, String group, Template template, RunInstancesOptions instanceOptions) { AWSEC2TemplateOptions awsTemplateOptions = AWSEC2TemplateOptions.class.cast(template.getOptions()); AWSRunInstancesOptions awsInstanceOptions = AWSRunInstancesOptions.class.cast(instanceOptions); - + if (awsTemplateOptions.getGroupIds().size() > 0) + awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds()); String subnetId = awsTemplateOptions.getSubnetId(); boolean associatePublicIpAddress = awsTemplateOptions.isPublicIpAddressAssociated(); if (subnetId != null) { if(associatePublicIpAddress){ AWSRunInstancesOptions.class.cast(instanceOptions).associatePublicIpAddressAndSubnetId(subnetId); if (awsTemplateOptions.getGroupIds().size() > 0) - awsInstanceOptions.withSecurityGroupIdsForNetworkInterface(awsTemplateOptions.getGroupIds()); + awsInstanceOptions.withSecurityGroupIdsForNetworkInterface(awsTemplateOptions.getGroupIds()); }else{ AWSRunInstancesOptions.class.cast(instanceOptions).withSubnetId(subnetId); if (awsTemplateOptions.getGroupIds().size() > 0) - awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds()); + awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds()); } } else { if (awsTemplateOptions.getGroupIds().size() > 0) - awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds()); - super.addSecurityGroups(region, group, template, instanceOptions); + awsInstanceOptions.withSecurityGroupIds(awsTemplateOptions.getGroupIds()); + super.addSecurityGroups(region, group, template, instanceOptions); } } } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java index 0abc94f2ec..41f7bef208 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2HardwareSupplier.java @@ -22,6 +22,7 @@ import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_8xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_xlarge; +import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.c3_large; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc1_4xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cc2_8xlarge; import static org.jclouds.ec2.compute.domain.EC2HardwareBuilder.cg1_4xlarge; @@ -57,10 +58,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2HardwareSupplier extends EC2HardwareSupplier { @@ -84,6 +81,7 @@ public Set get() { sizes.add(t1_micro().build()); sizes.add(c1_medium().build()); sizes.add(c1_xlarge().build()); + sizes.add(c3_large().build()); sizes.add(c3_xlarge().build()); sizes.add(c3_2xlarge().build()); sizes.add(c3_4xlarge().build()); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java index 03fadb8172..16b472efc1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/AWSEC2ImageSupplier.java @@ -54,10 +54,6 @@ import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; -/** - * - * @author Adrian Cole - */ @Singleton public class AWSEC2ImageSupplier implements Supplier> { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java index 7fcc7de42e..b9046f3b72 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/compute/suppliers/CallForImages.java @@ -42,10 +42,6 @@ import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.assistedinject.Assisted; -/** - * - * @author Adrian Cole - */ @Singleton public class CallForImages implements Callable> { public interface Factory { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java index a227e8f52c..9ba5af803d 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/config/AWSEC2HttpApiModule.java @@ -38,8 +38,6 @@ /** * Configures the EC2 connection. - * - * @author Adrian Cole */ @ConfiguresHttpApi public class AWSEC2HttpApiModule extends BaseEC2HttpApiModule { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java similarity index 93% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java index 3da4bcd352..6c4d586162 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/AWSRunningInstance.java @@ -45,7 +45,6 @@ * @see - * @author Adrian Cole */ public class AWSRunningInstance extends RunningInstance { @@ -109,7 +108,6 @@ public Builder subnetId(String subnetId) { return this; } - public Builder associatedPublicIpAddress(boolean associatedPublicIpAddress) { this.associatedPublicIpAddress = associatedPublicIpAddress; return this; @@ -200,13 +198,13 @@ protected Builder self() { private final Optional iamInstanceProfile; protected AWSRunningInstance(String region, Map securityGroupIdToNames, String amiLaunchIndex, - String dnsName, String imageId, String instanceId, InstanceState instanceState, String rawState, - String instanceType, String ipAddress, String kernelId, String keyName, Date launchTime, - String availabilityZone, String virtualizationType, String platform, String privateDnsName, - String privateIpAddress, String ramdiskId, String reason, RootDeviceType rootDeviceType, - String rootDeviceName, Map ebsBlockDevices, MonitoringState monitoringState, - String placementGroup, Iterable productCodes, String subnetId, String spotInstanceRequestId, - String vpcId, Hypervisor hypervisor, Map tags, Optional iamInstanceProfile, boolean associatedPublicIpAddress) { + String dnsName, String imageId, String instanceId, InstanceState instanceState, String rawState, + String instanceType, String ipAddress, String kernelId, String keyName, Date launchTime, + String availabilityZone, String virtualizationType, String platform, String privateDnsName, + String privateIpAddress, String ramdiskId, String reason, RootDeviceType rootDeviceType, + String rootDeviceName, Map ebsBlockDevices, MonitoringState monitoringState, + String placementGroup, Iterable productCodes, String subnetId, String spotInstanceRequestId, + String vpcId, Hypervisor hypervisor, Map tags, Optional iamInstanceProfile, boolean associatedPublicIpAddress) { super(region, securityGroupIdToNames.values(), amiLaunchIndex, dnsName, imageId, instanceId, instanceState, rawState, instanceType, ipAddress, kernelId, keyName, launchTime, availabilityZone, virtualizationType, platform, privateDnsName, privateIpAddress, ramdiskId, reason, rootDeviceType, rootDeviceName, diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java similarity index 92% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java index a9192f9cd0..98816eafcd 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/LaunchSpecification.java @@ -42,7 +42,6 @@ * @see - * @author Adrian Cole */ public class LaunchSpecification { @@ -109,10 +108,9 @@ public Builder monitoringEnabled(Boolean monitoringEnabled) { return this; } - public Builder publicIpAddressAssociated(Boolean publicIpAddressAssociated) { - this.publicIpAddressAssociated = publicIpAddressAssociated; - return this; + this.publicIpAddressAssociated = publicIpAddressAssociated; + return this; } public Builder instanceType(String instanceType) { @@ -139,7 +137,7 @@ public Builder subnetId(String subnetId) { this.subnetId = subnetId; return this; } - + public Builder ramdiskId(String ramdiskId) { this.ramdiskId = ramdiskId; return this; @@ -147,12 +145,26 @@ public Builder ramdiskId(String ramdiskId) { public Builder mapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib, boolean deleteOnTermination) { - blockDeviceMappings.add(new MapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination)); + return mapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination, null, null, null); + } + + public Builder mapEBSSnapshotToDevice(String deviceName, String snapshotId, @Nullable Integer sizeInGib, + boolean deleteOnTermination, @Nullable String volumeType, + @Nullable Integer iops, @Nullable Boolean encrypted) { + blockDeviceMappings.add(new MapEBSSnapshotToDevice(deviceName, snapshotId, sizeInGib, deleteOnTermination, + volumeType, iops, encrypted)); return this; } public Builder mapNewVolumeToDevice(String deviceName, int sizeInGib, boolean deleteOnTermination) { - blockDeviceMappings.add(new MapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination)); + return mapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination, null, null, null); + } + + public Builder mapNewVolumeToDevice(String deviceName, int sizeInGib, boolean deleteOnTermination, + @Nullable String volumeType, @Nullable Integer iops, + @Nullable Boolean encrypted) { + blockDeviceMappings.add(new MapNewVolumeToDevice(deviceName, sizeInGib, deleteOnTermination, + volumeType, iops, encrypted)); return this; } @@ -238,7 +250,8 @@ public static Builder fromLaunchSpecification(LaunchSpecification in) { .keyName(in.getKeyName()).securityGroupIdToNames(in.getSecurityGroupIdToNames()) .securityGroupIds(in.getSecurityGroupIds()).securityGroupNames(in.getSecurityGroupNames()) .blockDeviceMappings(in.getBlockDeviceMappings()).monitoringEnabled(in.isMonitoringEnabled()) - .publicIpAddressAssociated(in.publicIpAddressAssociated).userData(in.getUserData()); + .publicIpAddressAssociated(in.publicIpAddressAssociated).userData(in.getUserData()) + .userData(in.getUserData()); if (in.getIAMInstanceProfile().isPresent()) { builder.iamInstanceProfileArn(in.getIAMInstanceProfile().get().getArn().orNull()); builder.iamInstanceProfileName(in.getIAMInstanceProfile().get().getName().orNull()); @@ -303,13 +316,10 @@ public Boolean isMonitoringEnabled() { return monitoringEnabled; } - /** * Public ip address associated */ - public Boolean isPublicIpAddressAssociated() { - return publicIpAddressAssociated; - } + public Boolean isPublicIpAddressAssociated() { return publicIpAddressAssociated; } /** * The instance type. @@ -457,16 +467,16 @@ public boolean equals(Object obj) { } else if (!keyName.equals(other.keyName)) return false; if (monitoringEnabled == null) { - if (other.monitoringEnabled != null) - return false; - } else if (!monitoringEnabled.equals(other.monitoringEnabled)) + if (other.monitoringEnabled != null) return false; + } else if (!monitoringEnabled.equals(other.monitoringEnabled)) + return false; if (publicIpAddressAssociated == null) { - if (other.publicIpAddressAssociated != null) - return false; - } else if (!publicIpAddressAssociated.equals(other.publicIpAddressAssociated)) + if (other.publicIpAddressAssociated != null) return false; - if (ramdiskId == null) { + } else if (!publicIpAddressAssociated.equals(other.publicIpAddressAssociated)) + return false; + if (ramdiskId == null) { if (other.ramdiskId != null) return false; } else if (!ramdiskId.equals(other.ramdiskId)) diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java index d5f4019ff3..8c208a7221 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/MonitoringState.java @@ -22,7 +22,6 @@ * * State of monitoring for the instance. * - * @author Adrian Cole * @see InstanceClient#runInstances * @see MonitoringClient#monitorInstances * @see MonitoringClient#UnmonitorInstances diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java index be385229df..717e8385aa 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/PlacementGroup.java @@ -34,7 +34,6 @@ * * @see - * @author Adrian Cole */ public class PlacementGroup implements Comparable { public static enum State { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java index fdfbac9442..ed1f6eaee6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/RegionNameAndPublicKeyMaterial.java @@ -18,10 +18,6 @@ import org.jclouds.ec2.compute.domain.RegionAndName; -/** - * - * @author Adrian Cole - */ public class RegionNameAndPublicKeyMaterial extends RegionAndName { private final String publicKeyMaterial; diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java index 3a4bac6a70..b8a9170f0d 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/Spot.java @@ -24,7 +24,6 @@ * @see - * @author Adrian Cole */ public class Spot implements Comparable { public static Builder builder() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java index 27b4565d12..58f5819cab 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/domain/SpotInstanceRequest.java @@ -28,10 +28,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; -/** - * - * @author Adrian Cole - */ public class SpotInstanceRequest implements Comparable { public static Builder builder() { return new Builder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java index 92eb3b0f92..45f7f615cd 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSAMIApi.java @@ -41,8 +41,6 @@ /** * Provides access to AMI Services. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java index 4ccb4a29b3..186b47316b 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSInstanceApi.java @@ -51,8 +51,6 @@ /** * Provides access to EC2 Instance Services via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java index 5813dce259..0fb7bdfff1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSKeyPairApi.java @@ -37,9 +37,6 @@ import org.jclouds.rest.annotations.VirtualHost; import org.jclouds.rest.annotations.XMLResponseParser; -/** - * @author Adrian Cole - */ @RequestFilters(FormSigner.class) @VirtualHost public interface AWSKeyPairApi extends KeyPairApi { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java index 161afba5ea..f4e06f6cec 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApi.java @@ -55,8 +55,6 @@ /** * Provides access to EC2 SecurityGroup Services via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java index bb1de8a11d..dbe2dde972 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/MonitoringApi.java @@ -41,8 +41,6 @@ /** * Provides access to EC2 Monitoring Services via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java index ec6f9865be..e165509554 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/PlacementGroupApi.java @@ -47,8 +47,6 @@ /** * Provides access to EC2 Placement Groups via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java index aee2c9d501..694aab4ab7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/features/SpotInstanceApi.java @@ -54,8 +54,6 @@ /** * Provides access to EC2 Spot Instances via their REST API. *

- * - * @author Adrian Cole */ @RequestFilters(FormSigner.class) @VirtualHost diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java index 0143aaef23..80d70545f3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/CreatePlacementGroupIfNeeded.java @@ -35,10 +35,6 @@ import com.google.common.base.Predicate; import com.google.common.cache.CacheLoader; -/** - * - * @author Adrian Cole - */ @Singleton public class CreatePlacementGroupIfNeeded extends CacheLoader { @Resource diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java index 52bef6c47b..9155b7ab11 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypair.java @@ -34,10 +34,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Singleton public class ImportOrReturnExistingKeypair implements Function { @Resource diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java index 887e610b23..7d9cf7480a 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstance.java @@ -25,9 +25,6 @@ import com.google.common.base.Function; -/** - * @author Adrian Cole - */ public class SpotInstanceRequestToAWSRunningInstance implements Function { @Override diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java index a0b59b25a8..2771c49575 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptions.java @@ -31,7 +31,6 @@ * Extra options only available in Amazon's implementation * * @see DescribeImagesOptions - * @author Adrian Cole */ public class AWSDescribeImagesOptions extends DescribeImagesOptions { public static final AWSDescribeImagesOptions NONE = new AWSDescribeImagesOptions(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java index 78b36485ce..258977f873 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptions.java @@ -40,7 +40,6 @@ * Future instances = connection.runInstances(executableBy("123125").imageIds(1000, 1004)); * * - * @author Adrian Cole * @see @@ -70,16 +69,15 @@ public AWSRunInstancesOptions enableMonitoring() { return this; } - - /** - * Associate public ip for the instance - */ + /** + * Associate public ip for the instance + */ public AWSRunInstancesOptions associatePublicIpAddressAndSubnetId(String subnetId) { - formParameters.put("NetworkInterface.0.DeviceIndex", "0"); - formParameters.put("NetworkInterface.0.AssociatePublicIpAddress", "true"); - formParameters.put("NetworkInterface.0.SubnetId", checkNotNull(subnetId, "subnetId")); - launchSpecificationBuilder.publicIpAddressAssociated(true); - return this; + formParameters.put("NetworkInterface.0.DeviceIndex", "0"); + formParameters.put("NetworkInterface.0.AssociatePublicIpAddress", "true"); + formParameters.put("NetworkInterface.0.SubnetId", checkNotNull(subnetId, "subnetId")); + launchSpecificationBuilder.publicIpAddressAssociated(true); + return this; } /** @@ -101,7 +99,6 @@ public AWSRunInstancesOptions withSecurityGroupIds(Iterable securityGrou return this; } - public AWSRunInstancesOptions withSecurityGroupIdsForNetworkInterface(Iterable securityGroupIds) { launchSpecificationBuilder.securityGroupIds(securityGroupIds); indexFormValuesWithPrefix("NetworkInterface.0.SecurityGroupId", securityGroupIds); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java index 3a929bf0da..8e1ec948a6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/CreateSecurityGroupOptions.java @@ -34,7 +34,6 @@ * group = connection.getAMIServices().createSecurityGroup(vpcId("123125").noReboot()); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java index 228f681bad..d1bdf2d41c 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptions.java @@ -37,7 +37,6 @@ * history = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(from(yesterday).instanceType("m1.small")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java index 7f902693db..727973f32a 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptions.java @@ -38,7 +38,6 @@ * history = client.getSpotInstanceServices().requestSpotInstancesInRegion("us-east-1",validFrom(yesterday).type("m1.small")); * * - * @author Adrian Cole * @see diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java index c04b8d574a..72844f87a3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupAvailable.java @@ -30,11 +30,6 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; -/** - * - * - * @author Adrian Cole - */ @Singleton public class PlacementGroupAvailable implements Predicate { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java index b8257ebee5..9db4eec63b 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/PlacementGroupDeleted.java @@ -29,11 +29,6 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; -/** - * - * - * @author Adrian Cole - */ @Singleton public class PlacementGroupDeleted implements Predicate { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java index 83951612ee..8c483ef5f3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/predicates/SpotInstanceRequestActive.java @@ -30,11 +30,6 @@ import com.google.common.collect.Iterables; import com.google.inject.Inject; -/** - * - * - * @author Adrian Cole - */ @Singleton public class SpotInstanceRequestActive implements Predicate { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java similarity index 90% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java index d2cc3c7805..8d4cc722a8 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/reference/AWSEC2Constants.java @@ -20,10 +20,8 @@ /** * Configuration properties and constants used in EC2 connections. - * - * @author Adrian Cole */ -public interface AWSEC2Constants extends EC2Constants { +public final class AWSEC2Constants extends EC2Constants { /** * expression to find amis that work on the cluster instance type
* ex. {@code @@ -36,4 +34,7 @@ public interface AWSEC2Constants extends EC2Constants { public static final String PROPERTY_EC2_CC_REGIONS = "jclouds.ec2.cc-regions"; public static final String PROPERTY_EC2_AMI_QUERY = "jclouds.ec2.ami-query"; + private AWSEC2Constants() { + throw new AssertionError("intentionally unimplemented"); + } } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java index 4ae3e97143..abb2ab2bd7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandler.java @@ -39,7 +39,6 @@ *

* DescribeImagesResponse xmlns="http: * - * @author Adrian Cole * @see - * @author Adrian Cole */ public class AWSEC2DescribeSecurityGroupsResponseHandler extends HandlerForGeneratedRequestWithResult> { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java index 392fb5f964..27410fff2d 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2IpPermissionHandler.java @@ -24,10 +24,6 @@ import org.jclouds.net.domain.IpProtocol; import org.xml.sax.SAXException; -/** - * - * @author Adrian Cole - */ public class AWSEC2IpPermissionHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java index 552303bd55..ce20cbe90a 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSEC2SecurityGroupHandler.java @@ -31,9 +31,6 @@ import com.google.common.base.Supplier; import com.google.inject.Inject; -/** - * @author Adrian Cole - */ public class AWSEC2SecurityGroupHandler extends HandlerForGeneratedRequestWithResult { protected final AWSEC2IpPermissionHandler ipPermissionHandler; diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java index b2ca4d2f5c..ae8d87966d 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandler.java @@ -30,7 +30,6 @@ *

* RunInstancesResponse xmlns="http: * - * @author Adrian Cole * @see > { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java index 8b084c7a6c..6fadf34c61 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/PlacementGroupHandler.java @@ -26,10 +26,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class PlacementGroupHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java index a028764f48..6f4915be92 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ProductCodesHandler.java @@ -26,7 +26,6 @@ * * @see - * @author Adrian Cole */ public class ProductCodesHandler extends ParseSax.HandlerWithResult> { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java index 63ffe3ffef..786c26196e 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/ReservedInstancesOfferingHandler.java @@ -29,7 +29,6 @@ * * @see - * @author Adrian Cole */ public class ReservedInstancesOfferingHandler extends ParseSax.HandlerForGeneratedRequestWithResult { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java index ba01984610..78d29ef475 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotHandler.java @@ -27,10 +27,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class SpotHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java index 302f1b4352..d5bf014871 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstanceHandler.java @@ -34,10 +34,6 @@ import com.google.common.base.Supplier; -/** - * - * @author Adrian Cole - */ public class SpotInstanceHandler extends ParseSax.HandlerForGeneratedRequestWithResult { private StringBuilder currentText = new StringBuilder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java index 7f08167657..beea2938e2 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/java/org/jclouds/aws/ec2/xml/SpotInstancesHandler.java @@ -30,9 +30,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet.Builder; -/** - * @author Adrian Cole - */ public class SpotInstancesHandler extends ParseSax.HandlerWithResult> { private final Builder spotRequests = ImmutableSet.builder(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/main/resources/META-INF/services/org.jclouds.providers.ProviderMetadata diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/clojure/org/jclouds/aws/ec2_test.clj diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java index 42a64507c1..14d0c097f5 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ContextBuilderTest.java @@ -34,9 +34,6 @@ import com.google.inject.Key; import com.google.inject.TypeLiteral; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "AWSEC2ContextBuilderTest") public class AWSEC2ContextBuilderTest { private Map queriesForProperties(Properties input) { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java similarity index 95% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java index 465cb63747..1661f2c0f0 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/AWSEC2ProviderTest.java @@ -21,8 +21,6 @@ /** * The AWSEC2ProviderTest tests the org.jclouds.providers.AWSEC2Provider class. - * - * @author Jeremy Whitlock */ @Test(groups = "unit", testName = "AWSEC2ProviderTest") public class AWSEC2ProviderTest extends BaseProviderMetadataTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java index 586c92434a..5c3fad36c3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindLaunchSpecificationToFormParamsTest.java @@ -28,9 +28,6 @@ import com.google.common.collect.ImmutableMap; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class BindLaunchSpecificationToFormParamsTest { BindLaunchSpecificationToFormParams binder = new BindLaunchSpecificationToFormParams(); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java index 2ae04227ca..64283f7fd6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/binders/BindTagsToIndexedFormParamsTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code BindTagsToIndexedFormParams} - * - * @author grkvlt@apache.org */ @Test(groups = "unit") public class BindTagsToIndexedFormParamsTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java index 61f816984f..da2f898995 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceExpectTest.java @@ -37,8 +37,6 @@ /** * Tests the compute service abstraction of the EC2 api. - * - * @author Adrian Cole */ @Test(groups = "unit", testName = "AWSEC2ComputeServiceExpectTest") public class AWSEC2ComputeServiceExpectTest extends BaseAWSEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index 83bb96cf48..ba7431bd5e 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -59,10 +59,6 @@ import com.google.common.collect.ImmutableSortedSet; import com.google.common.util.concurrent.ListenableFuture; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2ComputeServiceLiveTest") public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 3cbad70325..9220e15704 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -54,10 +54,6 @@ import com.google.common.collect.Lists; import com.google.inject.Module; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", testName = "AWSEC2TemplateBuilderLiveTest") public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java index 27e3e577e3..f3710ceca3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/config/AWSEC2ComputeServiceContextModuleTest.java @@ -30,9 +30,6 @@ import com.google.common.base.Supplier; import com.google.common.cache.CacheLoader; -/** - * @author Aled Sage - */ @Test(groups = "unit") public class AWSEC2ComputeServiceContextModuleTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java index 4ae398baa1..ef0d539c45 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2ImageExtensionLiveTest.java @@ -31,9 +31,6 @@ /** * Live test for aws-ec2 {@link ImageExtension} implementation - * - * @author David Alves - * */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2ImageExtensionLiveTest") public class AWSEC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java similarity index 85% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java index f13737a10e..3e597940a1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionExpectTest.java @@ -20,10 +20,17 @@ import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; -import java.util.Set; - import javax.ws.rs.core.MediaType; +import java.util.Set; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMap.Builder; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; +import com.google.common.collect.Sets; import org.jclouds.aws.ec2.compute.internal.BaseAWSEC2ComputeServiceExpectTest; import org.jclouds.compute.domain.SecurityGroup; import org.jclouds.compute.domain.SecurityGroupBuilder; @@ -36,19 +43,6 @@ import org.jclouds.net.domain.IpProtocol; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.collect.LinkedHashMultimap; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; - -/** - * - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "AWSEC2SecurityGroupExtensionExpectTest") public class AWSEC2SecurityGroupExtensionExpectTest extends BaseAWSEC2ComputeServiceExpectTest { @@ -354,6 +348,62 @@ public void testAddIpPermissionGroupFromParams() { assertTrue(newPerm.getTenantIdGroupNamePairs().values().contains(origGroup.getProviderId())); } + public void testCreateSecurityGroup() { + HttpRequest createSecurityGroupExtRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "CreateSecurityGroup") + .addFormParam("GroupDescription", "jclouds#some-group") + .addFormParam("GroupName", "jclouds#some-group").build()); + + HttpRequest describeSecurityGroupsSingleRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "DescribeSecurityGroups") + .addFormParam("GroupName.1", "jclouds#some-group").build()); + + HttpRequest describeSecurityGroupsByIdRequest = + formSigner.filter(HttpRequest.builder() + .method("POST") + .endpoint("https://ec2." + region + ".amazonaws.com/") + .addHeader("Host", "ec2." + region + ".amazonaws.com") + .addFormParam("Action", "DescribeSecurityGroups") + .addFormParam("GroupId.1", "sg-3c6ef654").build()); + + HttpResponse describeSecurityGroupsSingleResponse = + HttpResponse.builder().statusCode(200) + .payload(payloadFromResourceWithContentType( + "/describe_securitygroups_extension_single.xml", MediaType.APPLICATION_XML)).build(); + + + Builder requestResponseMap = ImmutableMap. builder(); + requestResponseMap.put(describeRegionsRequest, describeRegionsResponse); + requestResponseMap.put(describeAvailabilityZonesRequest, describeAvailabilityZonesResponse); + requestResponseMap.put(describeSecurityGroupsSingleRequest, describeSecurityGroupsSingleResponse); + requestResponseMap.put(describeSecurityGroupsByIdRequest, describeSecurityGroupsSingleResponse); + requestResponseMap.put(createKeyPairRequest, createKeyPairResponse); + requestResponseMap.put(createSecurityGroupExtRequest, createSecurityGroupResponse); + + requestResponseMap.put(authorizeSecurityGroupIngressRequest22, authorizeSecurityGroupIngressResponse); + requestResponseMap.put(authorizeSecurityGroupIngressRequestGroup, authorizeSecurityGroupIngressResponse); + + + SecurityGroupExtension extension = requestsSendResponses(requestResponseMap.build()).getSecurityGroupExtension().get(); + + SecurityGroup group = extension.createSecurityGroup("some-group", new LocationBuilder() + .scope(LocationScope.REGION) + .id(region) + .description("region") + .build()); + + assertEquals("sg-3c6ef654", group.getProviderId()); + assertEquals(region + "/sg-3c6ef654", group.getId()); + } + private Multimap emptyMultimap() { return LinkedHashMultimap.create(); } diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java similarity index 97% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java index c3d77eba41..5e1ba7c107 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/extensions/AWSEC2SecurityGroupExtensionLiveTest.java @@ -23,9 +23,6 @@ /** * Live test for aws-ec2 {@link SecurityGroupExtension} implementation - * - * @author Andrew Bayer - * */ @Test(groups = "live", singleThreaded = true, testName = "AWSEC2SecurityGroupExtensionLiveTest") public class AWSEC2SecurityGroupExtensionLiveTest extends BaseSecurityGroupExtensionLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java index 8c0bc448b5..2d15321595 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSEC2SecurityGroupToSecurityGroupTest.java @@ -31,9 +31,6 @@ import com.google.common.base.Supplier; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "AWSEC2SecurityGroupToSecurityGroupTest") public class AWSEC2SecurityGroupToSecurityGroupTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java index f231882481..b7b19891cb 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/AWSRunningInstanceToNodeMetadataTest.java @@ -57,9 +57,6 @@ import com.google.inject.Guice; import com.google.inject.name.Names; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class AWSRunningInstanceToNodeMetadataTest { @@ -106,7 +103,7 @@ public void test2Nodes() { .tag("Name", "foo") .tag("Empty", "") .hypervisor(Hypervisor.XEN) - .build(),// + .build(), new AWSRunningInstance.Builder() .region(defaultRegion) .instanceId("i-931444f2") @@ -206,7 +203,7 @@ public Set get() { @Override protected void configure() { - Names.bindProperties(binder(),new AWSEC2ApiMetadata().getDefaultProperties()); + Names.bindProperties(binder(), new AWSEC2ApiMetadata().getDefaultProperties()); } }).getInstance(GroupNamingConvention.Factory.class); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java index babe978882..227480c12f 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/functions/PresentSpotRequestsAndInstancesTest.java @@ -39,9 +39,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class PresentSpotRequestsAndInstancesTest { AWSRunningInstance instance1 = createMock(AWSRunningInstance.class); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java index c5f9838fe4..376b169ba4 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/internal/BaseAWSEC2ComputeServiceExpectTest.java @@ -36,8 +36,6 @@ /** * Tests the compute service abstraction of the EC2 api. - * - * @author Adrian Cole */ public abstract class BaseAWSEC2ComputeServiceExpectTest extends BaseEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java index 60f86f565c..d1691a1956 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/loaders/AWSEC2CreateSecurityGroupIfNeededTest.java @@ -39,10 +39,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - * @author Andrew Bayer - */ @Test(groups = "unit", singleThreaded = true, testName = "AWSEC2CreateSecurityGroupIfNeeded") public class AWSEC2CreateSecurityGroupIfNeededTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java index 11e1526f45..04a079b0d6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/options/AWSEC2TemplateOptionsTest.java @@ -40,8 +40,6 @@ /** * Tests possible uses of AWSEC2TemplateOptions and * AWSEC2TemplateOptions.Builder.* - * - * @author Adrian Cole */ public class AWSEC2TemplateOptionsTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java similarity index 93% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java index 433fd7f4f9..bee444961e 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ImageParserTest.java @@ -48,9 +48,6 @@ import com.google.gson.Gson; import com.google.inject.Guice; -/** - * @author Adrian Cole - */ @Test(groups = "unit", testName = "AWSEC2ImageParserTest") public class AWSEC2ImageParserTest { public void testParseAlesticCanonicalImage() { @@ -173,11 +170,11 @@ public void testParseRightScaleImage() { assertEquals( new Gson().toJson(Iterables.get(result, 1)), - "{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"authenticateSudo\":false,\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-c19db6b5\",\"name\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"paravirtual\",\"hypervisor\":\"xen\"}}"); + "{\"operatingSystem\":{\"family\":\"UBUNTU\",\"arch\":\"paravirtual\",\"version\":\"9.10\",\"description\":\"411009282317/RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"is64Bit\":true},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"4.5.3_EBS_Alpha\",\"description\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"defaultCredentials\":{\"authenticateSudo\":false,\"password\":{},\"privateKey\":{},\"identity\":\"root\"},\"id\":\"us-east-1/ami-c19db6b5\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-c19db6b5\",\"name\":\"RightImage_Ubuntu_9.10_x64_v4.5.3_EBS_Alpha\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"paravirtual\",\"hypervisor\":\"xen\"}}"); assertEquals( new Gson().toJson(Iterables.get(result, 2)), - "{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"authenticateSudo\":false,\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-710c2605\",\"name\":\"RightImage Windows_2003_i386_v5.4.3\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"hvm\",\"hypervisor\":\"xen\"}}"); + "{\"operatingSystem\":{\"family\":\"WINDOWS\",\"arch\":\"hvm\",\"version\":\"2003\",\"description\":\"411009282317/RightImage Windows_2003_i386_v5.4.3\",\"is64Bit\":false},\"status\":\"AVAILABLE\",\"backendStatus\":\"available\",\"version\":\"5.4.3\",\"description\":\"Built by RightScale\",\"defaultCredentials\":{\"authenticateSudo\":false,\"password\":{},\"privateKey\":{},\"identity\":\"root\"},\"id\":\"us-east-1/ami-710c2605\",\"type\":\"IMAGE\",\"tags\":[],\"providerId\":\"ami-710c2605\",\"name\":\"RightImage Windows_2003_i386_v5.4.3\",\"location\":{\"scope\":\"REGION\",\"id\":\"us-east-1\",\"description\":\"us-east-1\",\"iso3166Codes\":[],\"metadata\":{}},\"userMetadata\":{\"owner\":\"411009282317\",\"rootDeviceType\":\"ebs\",\"virtualizationType\":\"hvm\",\"hypervisor\":\"xen\"}}"); } public void testParseAmznImage() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/AWSEC2ReviseParsedImageTest.java diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java index 9ed90fb9e3..feeaa6684f 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/compute/strategy/CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest.java @@ -61,9 +61,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit", singleThreaded = true, testName = "CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest") public class CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptionsTest { private static final Provider OPTIONS_PROVIDER = new javax.inject.Provider() { @@ -466,7 +463,7 @@ public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_ImportPublicKeyWhen // we specify we have a public key we want to use for authentication expect(options.getPublicKey()).andReturn("ssh-rsa").times(2); - expect(options.getLoginPrivateKey()).andReturn(CREDENTIALS.getPrivateKey()).atLeastOnce(); + expect(options.getLoginPrivateKey()).andReturn(CREDENTIALS.getOptionalPrivateKey().get()).atLeastOnce(); // Here, we import the keypair and place it into the cache expect(strategy.importExistingKeyPair.apply(new RegionNameAndPublicKeyMaterial(region, group, "ssh-rsa"))) @@ -761,7 +758,7 @@ public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPort int[] ports = {}; boolean shouldAuthorizeSelf = true; boolean groupExisted = true; - Set returnVal = ImmutableSet. of("group1", "group2"); + Set returnVal = ImmutableSet. of(generatedMarkerGroup, "group1", "group2"); // create mocks CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions strategy = setupStrategy(); @@ -785,7 +782,7 @@ public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPort // verify mocks verify(options); -// verifyStrategy(strategy); + verifyStrategy(strategy); } public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPortsAreSpecifiedWhenDoesExistAndAcceptsUserSuppliedGroupIds() { @@ -817,12 +814,11 @@ public void testGetSecurityGroupsForTagAndOptions_reusesGroupByDefaultWhenNoPort replayStrategy(strategy); // run - //FIXME these tests seems to be wrong, need to have a look -// assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal); + assertEquals(strategy.getSecurityGroupsForTagAndOptions(region, group, options), returnVal); // verify mocks -// verify(options); -// verifyStrategy(strategy); + verify(options); + verifyStrategy(strategy); } public void testCreateNewPlacementGroupUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java new file mode 100644 index 0000000000..f0b7b2f4de --- /dev/null +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiLiveTest.java @@ -0,0 +1,129 @@ +/* + * 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.jclouds.aws.ec2.features; + +import static com.google.common.collect.Iterables.concat; +import static com.google.common.collect.Iterables.getOnlyElement; +import static java.util.concurrent.TimeUnit.SECONDS; +import static org.jclouds.aws.ec2.options.AWSDescribeImagesOptions.Builder.filters; +import static org.jclouds.ec2.options.RegisterImageBackedByEbsOptions.Builder.addNewBlockDevice; +import static org.jclouds.ec2.options.RunInstancesOptions.Builder.withBlockDeviceMappings; +import static org.jclouds.util.Predicates2.retry; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; + +import java.util.Properties; +import java.util.Set; + +import com.google.common.base.Predicate; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import org.jclouds.Constants; +import org.jclouds.aws.domain.Region; +import org.jclouds.compute.RunNodesException; +import org.jclouds.ec2.domain.BlockDevice; +import org.jclouds.ec2.domain.BlockDeviceMapping; +import org.jclouds.ec2.domain.Image; +import org.jclouds.ec2.domain.RunningInstance; +import org.jclouds.ec2.domain.Snapshot; +import org.jclouds.ec2.domain.Volume; +import org.jclouds.ec2.features.AMIApiLiveTest; +import org.jclouds.ec2.options.RegisterImageBackedByEbsOptions; +import org.jclouds.ec2.options.RunInstancesOptions; +import org.jclouds.ec2.predicates.SnapshotCompleted; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code AMIApi} + */ +@Test(groups = "live", singleThreaded = true) +public class AWSAMIApiLiveTest extends AMIApiLiveTest { + + public AWSAMIApiLiveTest() { + provider = "aws-ec2"; + } + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.put(Constants.PROPERTY_API_VERSION, "2014-05-01"); + return overrides; + } + + public void testDescribeImagesCC() { + Set ccResults = client.describeImagesInRegion(Region.US_EAST_1, + filters(ImmutableMultimap. builder()// + .put("virtualization-type", "hvm")// + .put("architecture", "x86_64")// + .putAll("owner-id", ImmutableSet. of("137112412989", "099720109477"))// + .put("hypervisor", "xen")// + .put("state", "available")// + .put("image-type", "machine")// + .put("root-device-type", "ebs")// + .build()).ownedBy("137112412989", "099720109477")); + assertNotNull(ccResults); + assert ccResults.size() >= 34 : ccResults; + } + + protected RegisterImageBackedByEbsOptions newBlockDeviceOption() { + return addNewBlockDevice("/dev/sda2", "myvirtual", 5, false, "gp2", null, false).withDescription("adrian"); + } + + protected Image.EbsBlockDevice newBlockDeviceInfo() { + return new Image.EbsBlockDevice(null, 5, false, "gp2", null, false); + } + + + @Override + protected Snapshot createSnapshot() throws RunNodesException { + + String instanceId = null; + try { + BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sdb", 1, true, "gp2", null, false); + RunInstancesOptions options = withBlockDeviceMappings(ImmutableSet + . of(mapping)); + + RunningInstance instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().runInstancesInRegion( + regionId, null, imageId, 1, 1, options))); + instanceId = instance.getId(); + + assertTrue(runningTester.apply(instance), instanceId + "didn't achieve the state running!"); + + instance = getOnlyElement(concat(ec2Api.getInstanceApi().get().describeInstancesInRegion(regionId, + instanceId))); + BlockDevice gp2Device = instance.getEbsBlockDevices().get("/dev/sdb"); + assertNotNull(gp2Device, "device /dev/sdb not present on " + instance); + Volume gp2Volume = Iterables.getOnlyElement(ec2Api.getElasticBlockStoreApi().get().describeVolumesInRegion(regionId, gp2Device.getVolumeId())); + assertNotNull(gp2Volume, "/dev/sdb volume is null"); + assertEquals(gp2Volume.getVolumeType(), "gp2"); + BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); + assertNotNull(device, "device: /dev/sda1 not present on: " + instance); + Snapshot snapshot = ec2Api.getElasticBlockStoreApi().get().createSnapshotInRegion(regionId, + device.getVolumeId()); + snapshotsToDelete.add(snapshot.getId()); + Predicate snapshotted = retry(new SnapshotCompleted(ec2Api.getElasticBlockStoreApi().get()), 600, 10, SECONDS); + assert snapshotted.apply(snapshot); + return snapshot; + } finally { + if (instanceId != null) + ec2Api.getInstanceApi().get().terminateInstancesInRegion(regionId, instanceId); + } + } + +} diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java similarity index 93% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java index 8f8a856aca..cc99fb28a6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSAMIApiTest.java @@ -42,8 +42,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSAMIApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AWSAMIApiTest") @@ -265,28 +263,29 @@ public void testRegisterImageBackedByEBS() throws SecurityException, NoSuchMetho } HttpRequest registerImageBackedByEBSOptions = HttpRequest.builder().method("POST") - .endpoint("https://ec2.us-east-1.amazonaws.com/") - .addHeader("Host", "ec2.us-east-1.amazonaws.com") - .addFormParam("Action", "RegisterImage") - .addFormParam("BlockDeviceMapping.0.DeviceName", "/dev/sda1") - .addFormParam("BlockDeviceMapping.0.Ebs.SnapshotId", "snapshotId") - .addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/device") - .addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false") - .addFormParam("BlockDeviceMapping.1.Ebs.SnapshotId", "snapshot") - .addFormParam("BlockDeviceMapping.2.DeviceName", "/dev/newdevice") - .addFormParam("BlockDeviceMapping.2.Ebs.DeleteOnTermination", "false") - .addFormParam("BlockDeviceMapping.2.Ebs.VolumeSize", "100") - .addFormParam("BlockDeviceMapping.2.VirtualName", "newblock") - .addFormParam("Description", "description") - .addFormParam("Name", "imageName") - .addFormParam("RootDeviceName", "/dev/sda1").build(); + .endpoint("https://ec2.us-east-1.amazonaws.com/") + .addHeader("Host", "ec2.us-east-1.amazonaws.com") + .addFormParam("Action", "RegisterImage") + .addFormParam("BlockDeviceMapping.0.DeviceName", "/dev/sda1") + .addFormParam("BlockDeviceMapping.0.Ebs.SnapshotId", "snapshotId") + .addFormParam("BlockDeviceMapping.1.DeviceName", "/dev/device") + .addFormParam("BlockDeviceMapping.1.Ebs.DeleteOnTermination", "false") + .addFormParam("BlockDeviceMapping.1.Ebs.SnapshotId", "snapshot") + .addFormParam("BlockDeviceMapping.1.Ebs.VolumeType", "gp2") + .addFormParam("BlockDeviceMapping.2.DeviceName", "/dev/newdevice") + .addFormParam("BlockDeviceMapping.2.Ebs.DeleteOnTermination", "false") + .addFormParam("BlockDeviceMapping.2.Ebs.VolumeSize", "100") + .addFormParam("BlockDeviceMapping.2.VirtualName", "newblock") + .addFormParam("Description", "description") + .addFormParam("Name", "imageName") + .addFormParam("RootDeviceName", "/dev/sda1").build(); public void testRegisterImageBackedByEBSOptions() throws SecurityException, NoSuchMethodException, IOException { Invokable method = method(AWSAMIApi.class, "registerUnixImageBackedByEbsInRegion", String.class, String.class, String.class, RegisterImageBackedByEbsOptions[].class); GeneratedHttpRequest request = processor.createRequest(method, Lists. newArrayList(null, "imageName", "snapshotId", new RegisterImageBackedByEbsOptions().withDescription("description").addBlockDeviceFromSnapshot( - "/dev/device", null, "snapshot").addNewBlockDevice("/dev/newdevice", "newblock", 100))); + "/dev/device", null, "snapshot", false, "gp2", null, false).addNewBlockDevice("/dev/newdevice", "newblock", 100))); request = (GeneratedHttpRequest) request.getFilters().get(0).filter(request); diff --git a/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSElasticBlockStoreApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSElasticBlockStoreApiLiveTest.java new file mode 100644 index 0000000000..689118d308 --- /dev/null +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSElasticBlockStoreApiLiveTest.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.jclouds.aws.ec2.features; + +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.volumeType; +import static org.jclouds.ec2.options.CreateVolumeOptions.Builder.withSize; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.Properties; +import java.util.Set; + +import com.google.common.collect.Sets; +import org.jclouds.Constants; +import org.jclouds.ec2.domain.Volume; +import org.jclouds.ec2.features.ElasticBlockStoreApiLiveTest; +import org.testng.annotations.Test; + +/** + * Tests behavior of {@code ElasticBlockStoreApi} + */ +@Test(groups = "live", singleThreaded = true) +public class AWSElasticBlockStoreApiLiveTest extends ElasticBlockStoreApiLiveTest { + + public AWSElasticBlockStoreApiLiveTest() { + provider = "aws-ec2"; + } + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + overrides.put(Constants.PROPERTY_API_VERSION, "2014-05-01"); + return overrides; + } + + @Test + void testCreateVolumeInAvailabilityZoneWithVolumeType() { + Volume expected = client.createVolumeInAvailabilityZone(defaultZone, + volumeType("gp2"), withSize(1)); + assertNotNull(expected); + assertEquals(expected.getAvailabilityZone(), defaultZone); + assertEquals(expected.getVolumeType(), "gp2"); + + Set result = Sets.newLinkedHashSet(client.describeVolumesInRegion(defaultRegion, expected.getId())); + assertNotNull(result); + assertEquals(result.size(), 1); + Volume volume = result.iterator().next(); + assertEquals(volume.getId(), expected.getId()); + assertEquals(volume.getVolumeType(), expected.getVolumeType()); + + client.deleteVolumeInRegion(volume.getRegion(), volume.getId()); + } + +} diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java index c6174394e5..d6c6b14fcb 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiLiveTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code AWSEC2Api} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class AWSInstanceApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java index c59037d22a..5f5c05b833 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSInstanceApiTest.java @@ -47,8 +47,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSInstanceApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java index c2ddc8a5e2..f11730e243 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiLiveTest.java @@ -55,8 +55,6 @@ /** * Tests behavior of {@code AWSKeyPairApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class AWSKeyPairApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java index d97ee6efdf..d52751ff16 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSKeyPairApiTest.java @@ -33,8 +33,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSKeyPairApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "AWSKeyPairApiTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java index 7766d17994..48081e4ed7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiLiveTest.java @@ -32,10 +32,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.ImmutableMultimap; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", singleThreaded = true) public class AWSSecurityGroupApiLiveTest extends SecurityGroupApiLiveTest { public AWSSecurityGroupApiLiveTest() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java index 8b696ef835..735af5bff4 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSecurityGroupApiTest.java @@ -37,8 +37,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code AWSSecurityGroupApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java index 74d4839435..0dc9b081ac 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/AWSSubnetApiLiveTest.java @@ -19,10 +19,6 @@ import org.jclouds.ec2.features.SubnetApiLiveTest; import org.testng.annotations.Test; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", testName = "AWSSubnetApiLiveTest") public class AWSSubnetApiLiveTest extends SubnetApiLiveTest { public AWSSubnetApiLiveTest() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java index f617c9b653..30ac6f44de 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/BaseAWSEC2ApiTest.java @@ -52,9 +52,6 @@ import com.google.inject.Module; import com.google.inject.Provides; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public abstract class BaseAWSEC2ApiTest extends BaseAsyncApiTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java index 65c6ebd052..9acaedf9e3 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiLiveTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code MonitoringApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class MonitoringApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java index 1d10906706..23b9d62111 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/MonitoringApiTest.java @@ -29,8 +29,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code MonitoringApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "MonitoringApiTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java index dab1f0a9ac..02c0d51445 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiExpectTest.java @@ -29,9 +29,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "PlacementGroupApiExpectTest") public class PlacementGroupApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java index ae4d842414..206baf6ce7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiLiveTest.java @@ -59,8 +59,6 @@ /** * Tests behavior of {@code PlacementGroupApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "PlacementGroupApiLiveTest") public class PlacementGroupApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java index 69eb068ce6..76bd95461c 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/PlacementGroupApiTest.java @@ -33,8 +33,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code PlacementGroupApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "PlacementGroupApiTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java index 3bec3692c1..2a41c4e523 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiExpectTest.java @@ -29,9 +29,6 @@ import com.google.common.collect.ImmutableMultimap; import com.google.common.collect.ImmutableSet; -/** - * @author Andrew Bayer - */ @Test(groups = "unit", testName = "SpotInstanceApiExpectTest") public class SpotInstanceApiExpectTest extends BaseAWSEC2ComputeServiceExpectTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java index ca6ee0adb3..f7d2f87b8e 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiLiveTest.java @@ -51,8 +51,6 @@ /** * Tests behavior of {@code SpotInstanceApi} - * - * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) public class SpotInstanceApiLiveTest extends BaseComputeServiceContextLiveTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java index f8276e3016..5337ca8e2d 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/SpotInstanceApiTest.java @@ -34,8 +34,6 @@ import com.google.common.reflect.Invokable; /** * Tests behavior of {@code SpotInstanceApi} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SpotInstanceApiTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java index f5d6d4d01d..b2d943c5cd 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/features/TagSecurityGroupLiveTest.java @@ -24,10 +24,6 @@ import com.google.common.collect.Iterables; -/** - * - * @author Adrian Cole - */ @Test(groups = "live", singleThreaded = true) public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest { public TagSecurityGroupLiveTest() { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java index cd6b3b75d0..e08d64ed82 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/ImportOrReturnExistingKeypairTest.java @@ -31,9 +31,6 @@ import com.google.common.base.Optional; import com.google.common.collect.ImmutableSet; -/** - * @author Adrian Cole - */ @Test(groups = "unit") public class ImportOrReturnExistingKeypairTest { private static final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCcm8DjTHg4r72dVhNLQ33XpUyMLr+ph78i4NR3LqF1bXDP0g4xNLcI/GUTQq6g07X8zs7vIWyjoitqBPFSQ2onaZQ6pXQF/QISRQgrN5hEZ+nH5Aw+isdstBeOMWKdYrCJtm6/qWq2+rByyuNbtulazP3H7SqoozSjRSGNQyFNGpmhjGgTbNQftYDwlFq0T9tCSO/+dYF8j79bNIOEmfsCMiqXQ13hD5vGiEgkRm7zIPDUfpOl3ubDzebpRgGTh5kfv2vd3Z665AxQoi6fItvDu80knyphMlC41giIm5YqfPOPG4lR+6aF06p+NKhvOeECNMtRsD9u1kKJD9NqxXhx"; diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java index 1d9283cd3e..aae4eb8483 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/functions/SpotInstanceRequestToAWSRunningInstanceTest.java @@ -16,6 +16,8 @@ */ package org.jclouds.aws.ec2.functions; +import static org.testng.Assert.assertEquals; + import org.jclouds.aws.ec2.domain.AWSRunningInstance; import org.jclouds.aws.ec2.domain.LaunchSpecification; import org.jclouds.aws.ec2.domain.MonitoringState; @@ -27,12 +29,8 @@ import org.jclouds.ec2.domain.InstanceState; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; - /** * Tests behavior of {@code SpotInstanceRequestToAWSRunningInstance} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "SpotInstanceRequestToAWSRunningInstanceTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java index ba2e8fa76a..7a27d96079 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSDescribeImagesOptionsTest.java @@ -31,8 +31,6 @@ /** * Tests possible uses of AWSDescribeImagesOptions and AWSDescribeImagesOptions.Builder.* - * - * @author Adrian Cole */ public class AWSDescribeImagesOptionsTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java index ef75922790..c680777fa7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/AWSRunInstancesOptionsTest.java @@ -40,8 +40,6 @@ /** * Tests possible uses of AWSRunInstancesOptions and AWSRunInstancesOptions.Builder.* - * - * @author Adrian Cole */ public class AWSRunInstancesOptionsTest { @@ -333,7 +331,7 @@ public void testNullWithVirtualName() { @Test public void testWithBlockDeviceMapping() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); + BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, "gp2", 10, true); AWSRunInstancesOptions options = new AWSRunInstancesOptions().withBlockDeviceMappings(ImmutableSet . of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), @@ -342,6 +340,12 @@ public void testWithBlockDeviceMapping() { ImmutableList.of("120")); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.DeleteOnTermination"), ImmutableList.of("true")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.VolumeType"), + ImmutableList.of("gp2")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Iops"), + ImmutableList.of("10")); + assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.Ebs.Encrypted"), + ImmutableList.of("true")); } @Test @@ -352,7 +356,7 @@ public void testNullWithBlockDeviceMapping() { @Test public void testWithBlockDeviceMappingStatic() { - BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true); + BlockDeviceMapping mapping = new BlockDeviceMapping.MapNewVolumeToDevice("/dev/sda1", 120, true, null, null, false); AWSRunInstancesOptions options = withBlockDeviceMappings(ImmutableSet. of(mapping)); assertEquals(options.buildFormParameters().get("BlockDeviceMapping.1.DeviceName"), ImmutableList.of("/dev/sda1")); diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java index 54e4578c0c..2a955a1703 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/DescribeSpotPriceHistoryOptionsTest.java @@ -31,8 +31,6 @@ /** * Tests possible uses of DescribeSpotPriceHistoryOptions and * DescribeSpotPriceHistoryOptions.Builder.* - * - * @author Adrian Cole */ public class DescribeSpotPriceHistoryOptionsTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java index 93b3406c4c..4442338bb1 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/options/RequestSpotInstancesOptionsTest.java @@ -33,8 +33,6 @@ /** * Tests possible uses of RequestSpotInstancesOptions and RequestSpotInstancesOptions.Builder.* - * - * @author Adrian Cole */ public class RequestSpotInstancesOptionsTest { diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java index cc1e95307d..540b352f0a 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeInstancesResponseTest.java @@ -40,8 +40,6 @@ /** * Tests behavior of {@code AWSDescribeInstancesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java similarity index 96% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java index d3d4148e7c..a3566a85f5 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/parse/DescribeSecurityGroupsResponseTest.java @@ -31,10 +31,6 @@ import com.google.common.collect.ImmutableSet; -/** - * - * @author Adrian Cole - */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire @Test(groups = "unit", testName = "DescribeSecurityGroupsResponseTest") @@ -62,7 +58,7 @@ public Set expected() { // .vpcId("vpc-99999999") .ipPermission(IpPermission.builder() .ipProtocol(IpProtocol.ALL) - .tenantIdGroupNamePair("123123123123","sg-11111111").build()) + .tenantIdGroupNamePair("123123123123", "sg-11111111").build()) // .ipPermissionEgress(IpPermission.builder() // .ipProtocol(IpProtocol.ALL) // .ipRange("0.0.0.0/0").build()) diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java index bea5606aab..5aeb659245 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSDescribeInstancesResponseHandlerTest.java @@ -50,8 +50,6 @@ /** * Tests behavior of {@code AWSDescribeInstancesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java index 5d15a59f39..f71766b9e7 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/AWSRunInstancesResponseHandlerTest.java @@ -43,8 +43,6 @@ /** * Tests behavior of {@code RunInstancesResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java index e0659b1b57..f12bfe8432 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribePlacementGroupsResponseHandlerTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code DescribePlacementGroupsResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribePlacementGroupsResponseHandlerTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java index 194f0ca95c..13710c2fd2 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeReservedInstancesOfferingResponseHandlerTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code DescribeReservedInstancesOfferingResponseHandler} - * - * @author Adrian Cole */ //NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeReservedInstancesOfferingResponseHandlerTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java index ee4f08d24f..4c72a5adeb 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/DescribeSpotPriceHistoryResponseHandlerTest.java @@ -35,8 +35,6 @@ /** * Tests behavior of {@code DescribeSpotPriceHistoryResponseHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "DescribeSpotPriceHistoryResponseHandlerTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java index dd07a06066..2b070a4d56 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/MonitoringStateHandlerTest.java @@ -29,8 +29,6 @@ /** * Tests behavior of {@code MonitoringStateHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "MonitoringStateHandlerTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java index a93ebb446d..7df3fadcd4 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/ProductCodesHandlerTest.java @@ -28,8 +28,6 @@ /** * Tests behavior of {@code ProductCodesHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during surefire @Test(groups = "unit", testName = "ProductCodesHandlerTest") diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java index dfe18fe29e..ff5f230c12 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstanceHandlerTest.java @@ -41,8 +41,6 @@ /** * Tests behavior of {@code SpotInstanceHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java similarity index 99% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java index 99b7f2d6d0..0e27dd5503 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/java/org/jclouds/aws/ec2/xml/SpotInstancesHandlerTest.java @@ -42,8 +42,6 @@ /** * Tests behavior of {@code SpotInstancesHandler} - * - * @author Adrian Cole */ // NOTE:without testName, this will not call @Before* and fail w/NPE during // surefire diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/alestic_canonical.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/alestic_canonical.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/alestic_canonical.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/amzn_images.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/amzn_images.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/amzn_images.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_productCodes.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_image_attribute_productCodes.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_image_attribute_productCodes.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_images_cc.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_images_cc.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_images_cc.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_1.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_1.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_1.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_2.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_2.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_2.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_3.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_3.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_3.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_latest.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_latest.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_latest.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_pending.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_instances_pending.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_instances_pending.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_placement_groups.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_placement_groups.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_placement_groups.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_reserved_instances_offerings.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_reserved_instances_offerings.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_reserved_instances_offerings.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_security_groups_vpc.xml similarity index 98% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_security_groups_vpc.xml index 99f7678f4f..e444aa51d6 100644 --- a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_security_groups_vpc.xml +++ b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_security_groups_vpc.xml @@ -1,4 +1,4 @@ - + xxxxxxxxxxxxxxxx diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance_requests.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_requests.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance_requests.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance_tags.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instance_tags.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instance_tags.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instances_1.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_instances_1.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_instances_1.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_price_history.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/describe_spot_price_history.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/describe_spot_price_history.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/monitoring.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/monitoring.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/monitoring.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/request_spot_instances-ebs.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances-ebs.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/request_spot_instances-ebs.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/request_spot_instances.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/request_spot_instances.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/request_spot_instances.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/rightscale_images.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/rightscale_images.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/rightscale_images.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/run_instances_1.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/run_instances_1.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/run_instances_1.xml diff --git a/dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml b/dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/vostok.xml similarity index 100% rename from dependencies/jclouds/provider/aws-ec2/1.7.1-stratos/src/test/resources/vostok.xml rename to dependencies/jclouds/provider/aws-ec2/1.8.0-stratos/src/test/resources/vostok.xml diff --git a/dependencies/pom.xml b/dependencies/pom.xml index b87d9835e5..5c9a1b0674 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -33,11 +33,11 @@ http://apache.org - jclouds/apis/vcloud/1.7.1-stratos - jclouds/apis/ec2/1.7.1-stratos - jclouds/apis/openstack-nova/1.7.1-stratos - jclouds/apis/docker/1.7.1-stratos - jclouds/provider/aws-ec2/1.7.1-stratos + jclouds/apis/vcloud/1.8.0-stratos + jclouds/apis/ec2/1.8.0-stratos + jclouds/apis/openstack-nova/1.8.0-stratos + jclouds/apis/docker/1.8.0-stratos + jclouds/provider/aws-ec2/1.8.0-stratos org.wso2.carbon.ui diff --git a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml index af7a596730..23efdf66ea 100644 --- a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml +++ b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml @@ -17,7 +17,8 @@ # specific language governing permissions and limitations # under the License. --> - + org.apache.stratos @@ -32,153 +33,172 @@ http://apache.org This feature contains the required bundles for the functionality of Cloud Controller - + org.apache.stratos org.apache.stratos.cloud.controller ${project.version} - org.apache.jclouds - jclouds-core - ${jclouds.version} - - - org.apache.jclouds - jclouds-compute - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-bouncycastle - ${jclouds.version} - - - org.bouncycastle - bcprov-jdk16 - - - - - org.apache.jclouds.driver - jclouds-sshj - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-log4j - ${jclouds.version} - - - org.apache.jclouds.driver - jclouds-enterprise - ${jclouds.version} - - - org.apache.stratos - ec2 - 1.7.1-stratos - - - org.apache.stratos - aws-ec2 - 1.7.1-stratos - - - org.apache.stratos - openstack-nova - 1.7.1-stratos - - + com.google.guava + guava + 17.0 + + + com.jcraft + jsch.agentproxy.jsch + 0.0.7 + + + com.jcraft + jsch.agentproxy.core + 0.0.7 + + + com.jcraft + jsch.agentproxy.connector-factory + 0.0.7 + + + net.schmizz + sshj + 0.9.0 + + + org.apache.jclouds + jclouds-core + ${jclouds.version} + + + org.apache.jclouds + jclouds-compute + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-bouncycastle + ${jclouds.version} + + + org.bouncycastle + bcprov-jdk16 + + + + + org.apache.jclouds.driver + jclouds-sshj + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-log4j + ${jclouds.version} + + + org.apache.jclouds.driver + jclouds-enterprise + ${jclouds.version} + + + org.apache.stratos + ec2 + 1.8.0-stratos + + + org.apache.stratos + aws-ec2 + 1.8.0-stratos + + + org.apache.stratos + openstack-nova + 1.8.0-stratos + + org.apache.stratos docker - 1.7.1-stratos - + 1.8.0-stratos + org.apache.commons commons-compress 1.5 - - org.apache.jclouds.api - openstack-keystone - ${jclouds.version} - + + org.apache.jclouds.api + openstack-keystone + ${jclouds.version} + - - org.apache.jclouds + + org.apache.jclouds jclouds-scriptbuilder - ${jclouds.version} - - - org.apache.jclouds.api - sts - ${jclouds.version} - - - - com.google.guava - guava - 15.0 - - - com.jamesmurty.utils.wso2 - java-xmlbuilder - 0.4.wso2v1 - + ${jclouds.version} + + + org.apache.jclouds.api + sts + ${jclouds.version} + + + com.jamesmurty.utils.wso2 + java-xmlbuilder + 0.4.wso2v1 + org.apache.stratos vcloud - 1.7.1-stratos - - - com.google.code.gson - gson - ${gson2.version} - - - com.google.guice.wso2 - guice - ${google.guice.wso2.version} - - - com.google.guice.assistedinject.wso2 - guice-assistedinject - ${com.google.guice.assistedinject.wso2.version} - - - com.sun.jersey - jersey-core - ${sun.jersey.version} - - - net.oauth.core - oauth - 20100527 - - - commons-io.wso2 - commons-io - 2.0.0.wso2v1 - - - rhino.wso2 - js - 1.7.0.R1-wso2v3 - - + 1.8.0-stratos + + + com.google.code.gson + gson + ${gson2.version} + + + com.google.guice.wso2 + guice + ${google.guice.wso2.version} + + + com.google.guice.assistedinject.wso2 + guice-assistedinject + ${com.google.guice.assistedinject.wso2.version} + + + com.sun.jersey + jersey-core + ${sun.jersey.version} + + + net.oauth.core + oauth + 20100527 + + + commons-io.wso2 + commons-io + 2.0.0.wso2v1 + + + rhino.wso2 + js + 1.7.0.R1-wso2v3 + + org.apache.stratos org.apache.stratos.messaging ${project.version} - - javax.ws.rs - jsr311-api - 1.1.1 - - + + javax.ws.rs + jsr311-api + 1.1.1 + + org.wso2.andes.wso2 andes-client - 0.13.wso2v8 + 0.13.wso2v8 @@ -231,46 +251,67 @@ - org.apache.stratos:org.apache.stratos.cloud.controller:${project.version} + org.apache.stratos:org.apache.stratos.cloud.controller:${project.version} + org.apache.jclouds.driver:jclouds-bouncycastle:${jclouds.version} org.apache.jclouds.driver:jclouds-sshj:${jclouds.version} org.apache.jclouds.driver:jclouds-enterprise:${jclouds.version} org.apache.jclouds:jclouds-core:${jclouds.version} org.apache.jclouds:jclouds-compute:${jclouds.version} - org.apache.stratos:ec2:1.7.1-stratos - org.apache.stratos:openstack-nova:1.7.1-stratos - org.apache.stratos:vcloud:1.7.1-stratos - org.apache.stratos:docker:1.7.1-stratos + org.apache.stratos:ec2:1.8.0-stratos + org.apache.stratos:openstack-nova:1.8.0-stratos + org.apache.stratos:vcloud:1.8.0-stratos + org.apache.stratos:docker:1.8.0-stratos org.apache.commons:commons-compress:1.5 com.jamesmurty.utils.wso2:java-xmlbuilder:0.4.wso2v1 org.apache.jclouds.common:openstack-common:${jclouds.version} org.apache.jclouds.api:openstack-keystone:${jclouds.version} - org.apache.stratos:aws-ec2:1.7.1-stratos - com.google.guava:guava:15.0 + org.apache.stratos:aws-ec2:1.8.0-stratos + com.google.guava:guava:17.0 + + + + org.apache.servicemix.bundles:org.apache.servicemix.bundles.jsch-agentproxy-jsch:0.0.7_1 + + com.jcraft:jsch.agentproxy.connector-factory:0.0.7 + com.jcraft:jsch.agentproxy.sshagent:0.0.7 + com.jcraft:jsch.agentproxy.usocket-jna:0.0.7 + com.jcraft:jsch.agentproxy.core:0.0.7 + net.java.dev.jna:jna:4.1.0 + + org.apache.servicemix.bundles:org.apache.servicemix.bundles.jsch-agentproxy-sshj:0.0.7_1 + + net.schmizz:sshj:0.9.0 + org.apache.servicemix.bundles:org.apache.servicemix.bundles.jzlib:1.1.1_1 + + com.google.code.gson:gson:${gson2.version} com.google.guice.wso2:guice:${google.guice.wso2.version} - com.google.guice.assistedinject.wso2:guice-assistedinject:${com.google.guice.assistedinject.wso2.version} + + com.google.guice.assistedinject.wso2:guice-assistedinject:${com.google.guice.assistedinject.wso2.version} + com.sun.jersey:jersey-core:${sun.jersey.version} org.apache.jclouds:jclouds-scriptbuilder:${jclouds.version} org.99soft.guice.wso2:rocoto:6.1.wso2v1 org.bouncycastle.wso2:bcprov-jdk16:1.45.wso2v1 net.schmizz:sshj:0.8.0 org.apache.jclouds.driver:jclouds-joda:${jclouds.version} - com.jcraft.wso2:jzlib:1.0.7.wso2v1 org.apache.jclouds.driver:jclouds-netty:${jclouds.version} io.netty:netty:3.3.0.Final commons-io.wso2:commons-io:2.0.0.wso2v1 - org.slf4j:slf4j-api:1.6.4 - org.slf4j:slf4j-log4j12:1.6.4 + org.slf4j:slf4j-api:1.7.0 + org.slf4j:slf4j-log4j12:1.7.0 org.apache.jclouds.driver:jclouds-slf4j:${jclouds.version} - com.google.common.wso2:google-collect:${google.collect.osgi.version} + com.google.common.wso2:google-collect:${google.collect.osgi.version} + jdom.wso2:jdom:1.0.0.wso2v1 org.json.wso2:json:1.0.0.wso2v1 org.apache.jclouds.api:sts:${jclouds.version} javax.ws.rs:jsr311-api:1.1.1 - org.apache.stratos:org.apache.stratos.messaging:${project.version} + org.apache.stratos:org.apache.stratos.messaging:${project.version} + diff --git a/pom.xml b/pom.xml index 7b6ce65d5c..05920976f2 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,7 @@ extensions features products + tools @@ -97,6 +98,18 @@ ignore + + + central + Maven Repository Switchboard + default + http://repo1.maven.org/maven2 + + true + daily + ignore + + @@ -526,7 +539,7 @@ [4.2.0, 5.0.0) 4.2.0 1.6.1.wso2v10 - 1.7.1 - 1.7.1-stratos + 1.8.0 + 1.8.0-stratos diff --git a/products/stratos/modules/distribution/src/main/license/LICENSE b/products/stratos/modules/distribution/src/main/license/LICENSE index e293289a3f..cb34d1dfab 100644 --- a/products/stratos/modules/distribution/src/main/license/LICENSE +++ b/products/stratos/modules/distribution/src/main/license/LICENSE @@ -227,7 +227,7 @@ apache-cassandra_1.1.3.wso2v5.jar, atomikos_3.8.0.wso2v1.jar, authenticator_0.7.0.wso2v1.jar, avro_1.4.0.fixeswso2v1.jar, -aws-ec2_1.7.1.stratos.jar, +aws-ec2_1.8.0.stratos.jar, axiom_1.2.11.wso2v4.jar, axis2-json_1.6.1.wso2v10.jar, axis2-transport-jms_1.1.0.wso2v9.jar, @@ -276,7 +276,7 @@ drools-decisiontables-5.5.0.Final.jar, drools-jsr94-5.5.0.Final.jar, drools-templates-5.5.0.Final.jar, drools-verifier-5.5.0.Final.jar, -ec2_1.7.1.stratos.jar, +ec2_1.8.0.stratos.jar, ehcache-core-2.5.1.jar, ehcache_1.5.0.wso2v3.jar, el-impl_2.2.0.wso2v1.jar, @@ -314,15 +314,15 @@ jackson-mapper-asl_1.9.2.jar, jamm_0.2.5.wso2v2.jar, java-xmlbuilder_0.4.0.wso2v1.jar, javax.cache.wso2_4.2.0.jar, -jclouds-bouncycastle_1.7.1.jar, -jclouds-compute_1.7.1.jar, -jclouds-core_1.7.1.jar, -jclouds-enterprise_1.7.1.jar, -jclouds-joda_1.7.1.jar, -jclouds-netty_1.7.1.jar, -jclouds-scriptbuilder_1.7.1.jar, -jclouds-slf4j_1.7.1.jar, -jclouds-sshj_1.7.1.jar , +jclouds-bouncycastle_1.8.0.jar, +jclouds-compute_1.8.0.jar, +jclouds-core_1.8.0.jar, +jclouds-enterprise_1.8.0.jar, +jclouds-joda_1.8.0.jar, +jclouds-netty_1.8.0.jar, +jclouds-scriptbuilder_1.8.0.jar, +jclouds-slf4j_1.8.0.jar, +jclouds-sshj_1.8.0.jar , jdbc-pool_7.0.34.wso2v1.jar, jdom_1.0.0.wso2v1.jar, jettison-1.3.4.jar, @@ -350,9 +350,9 @@ openid4java-nodeps_0.9.6.wso2v2.jar, opensaml-1.1.406.jar, opensaml-2.4.1.jar, opensaml2_2.4.1.wso2v1.jar, -openstack-common_1.7.1.jar, -openstack-keystone_1.7.1.jar, -openstack-nova_1.7.1.stratos.jar, +openstack-common_1.8.0.jar, +openstack-keystone_1.8.0.jar, +openstack-nova_1.8.0.stratos.jar, openws-1.4.1.jar, openxri-client-1.2.0.jar, openxri-syntax-1.2.0.jar, @@ -667,7 +667,7 @@ tiles-jsp_2.0.5.wso2v1.jar, tomcat-ha_7.0.34.wso2v1.jar, tomcat_7.0.34.wso2v1.jar, tribes_7.0.34.wso2v1.jar, -vcloud_1.7.1.stratos.jar, +vcloud_1.8.0.stratos.jar, velocity-1.7.jar, woden_1.0.0.M8-wso2v1.jar, woodstox-core-asl-4.2.0.jar, diff --git a/tools/pom.xml b/tools/pom.xml new file mode 100644 index 0000000000..b61f0b242e --- /dev/null +++ b/tools/pom.xml @@ -0,0 +1,39 @@ + + + + + + org.apache.stratos + stratos-parent + 4.1.0-SNAPSHOT + + + 4.0.0 + stratos-tools + pom + Apache Stratos - Tools + Apache Stratos plafrom tools + http://apache.org + + + stratos-docker-images + + + diff --git a/tools/stratos-docker-images/README.md b/tools/stratos-docker-images/README.md index 17b0b49d3d..c953967eba 100644 --- a/tools/stratos-docker-images/README.md +++ b/tools/stratos-docker-images/README.md @@ -7,17 +7,17 @@ docker images for installing stratos To build mysql, activemq and stratos images: -`./build-all.sh` +`mvn install -Pdocker-build` + +The above command requires you to be able to execute the docker command without sudo usually by being in the 'docker' group. + ### Upload to registry.hub.docker.com To upload images: -`./push-all.sh` +`mvn install -Pdocker-push` ### Running -Have a look at the example, in particular configuring the IaaS with your settings: - -`./run-example.sh` - +Take a look at the Stratos wiki: https://cwiki.apache.org/confluence/display/STRATOS/Running+Stratos+inside+docker diff --git a/tools/stratos-docker-images/activemq/Dockerfile b/tools/stratos-docker-images/activemq/Dockerfile index 7edf7d5849..d896a93801 100755 --- a/tools/stratos-docker-images/activemq/Dockerfile +++ b/tools/stratos-docker-images/activemq/Dockerfile @@ -22,14 +22,16 @@ # Server configuration script for Apache Stratos # ---------------------------------------------------------------------------- -FROM ubuntu:14.04 +FROM ubuntu:14.04 -RUN apt-get update -RUN apt-get upgrade tzdata -y -RUN apt-get install openjdk-7-jre-headless curl -y +RUN apt-get update && \ + apt-get upgrade tzdata -y && \ + apt-get install openjdk-7-jre-headless curl -y && \ + apt-get clean && \ + rm -rf /var/cache/apt/* -RUN curl http://www.mirrorservice.org/sites/ftp.apache.org/activemq/5.10.0/apache-activemq-5.10.0-bin.tar.gz > apache-activemq-5.10.0-bin.tar.gz -RUN tar xzf apache-activemq-5.10.0-bin.tar.gz + +RUN curl http://www.mirrorservice.org/sites/ftp.apache.org/activemq/5.10.0/apache-activemq-5.10.0-bin.tar.gz | tar -zx EXPOSE 61616 8161 diff --git a/tools/stratos-docker-images/activemq/docker-build.sh b/tools/stratos-docker-images/activemq/docker-build.sh index 81daa41678..36ce6c2fee 100755 --- a/tools/stratos-docker-images/activemq/docker-build.sh +++ b/tools/stratos-docker-images/activemq/docker-build.sh @@ -23,4 +23,4 @@ # Server configuration script for Apache Stratos # ---------------------------------------------------------------------------- -docker build -t=apachestratos/activemq . +docker build -t=apachestratos/activemq:$VERSION . diff --git a/tools/stratos-docker-images/bind/docker-build.sh b/tools/stratos-docker-images/bind/docker-build.sh index 0edb9e7646..243886e42a 100755 --- a/tools/stratos-docker-images/bind/docker-build.sh +++ b/tools/stratos-docker-images/bind/docker-build.sh @@ -20,4 +20,4 @@ # # ---------------------------------------------------------------------------- -docker build -t=apachestratos/bind . +docker build -t=apachestratos/bind:$VERSION . diff --git a/tools/stratos-docker-images/build-all.sh b/tools/stratos-docker-images/build-all.sh index a57568a99a..af9443b3bd 100755 --- a/tools/stratos-docker-images/build-all.sh +++ b/tools/stratos-docker-images/build-all.sh @@ -20,10 +20,14 @@ # # ---------------------------------------------------------------------------- +# This script is executed by mvn - see the README for more information + set -e export STRATOS_SOURCE="$(cd ../../; pwd)" +export VERSION=$VERSION + cd bind ./docker-build.sh cd .. diff --git a/tools/stratos-docker-images/mysql/Dockerfile b/tools/stratos-docker-images/mysql/Dockerfile index a5e266c3b5..d5855eba92 100755 --- a/tools/stratos-docker-images/mysql/Dockerfile +++ b/tools/stratos-docker-images/mysql/Dockerfile @@ -19,9 +19,12 @@ # # ---------------------------------------------------------------------------- -FROM stackbrew/ubuntu:12.04 +FROM ubuntu:14.04 -RUN apt-get update -qq && apt-get install -y mysql-server-5.5 +RUN apt-get update && \ + apt-get install mysql-server-5.5 -y && \ + apt-get clean && \ + rm -rf /var/cache/apt/* ADD my.cnf /etc/mysql/conf.d/my.cnf RUN chmod 664 /etc/mysql/conf.d/my.cnf diff --git a/tools/stratos-docker-images/mysql/docker-build.sh b/tools/stratos-docker-images/mysql/docker-build.sh index 98346d13b5..1477c9c5e1 100755 --- a/tools/stratos-docker-images/mysql/docker-build.sh +++ b/tools/stratos-docker-images/mysql/docker-build.sh @@ -43,5 +43,4 @@ rm files/mysql.tmp.* ### build docker -docker build -t=apachestratos/mysql . -#sudo docker push apachestratos/mysql +docker build -t=apachestratos/mysql:$VERSION . diff --git a/tools/stratos-docker-images/pom.xml b/tools/stratos-docker-images/pom.xml new file mode 100644 index 0000000000..2310a18737 --- /dev/null +++ b/tools/stratos-docker-images/pom.xml @@ -0,0 +1,103 @@ + + + + + + org.apache.stratos + stratos-parent + 4.1.0-SNAPSHOT + ../../pom.xml + + + 4.0.0 + stratos-docker-images + pom + Apache Stratos - Docker Images + Apache Stratos plafrom docker images + http://apache.org + + + + + + + + + docker-build + + + + org.codehaus.mojo + exec-maven-plugin + 1.3 + + + + bash + . + + build-all.sh + + + ${project.version} + + + docker-build + install + + exec + + + + + + + + + + docker-push + + + + org.codehaus.mojo + exec-maven-plugin + 1.3 + + + + bash + . + + push-all.sh + + + docker-push + install + + exec + + + + + + + + + diff --git a/tools/stratos-docker-images/puppetmaster/Dockerfile b/tools/stratos-docker-images/puppetmaster/Dockerfile index 2fbd4d5ba2..8d5d4088a6 100755 --- a/tools/stratos-docker-images/puppetmaster/Dockerfile +++ b/tools/stratos-docker-images/puppetmaster/Dockerfile @@ -21,28 +21,29 @@ FROM ubuntu:14.04 -RUN apt-get update -qq -RUN apt-get install -y wget - -RUN wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb -RUN dpkg -i puppetlabs-release-precise.deb -RUN apt-get update -qq -RUN apt-get install -y puppetmaster - -RUN mkdir -p /etc/puppet/modules/agent/files -RUN mkdir -p /etc/puppet/modules/java/files -RUN mkdir -p /etc/puppet/modules/tomcat/files +RUN apt-get update -qq && \ + apt-get install -y wget && \ + wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb && \ + dpkg -i puppetlabs-release-precise.deb && \ + rm puppetlabs-release-precise.deb && \ + apt-get update -qq && \ + apt-get install -y puppetmaster && \ + apt-get clean && \ + rm -rf /var/cache/apt/* + +RUN mkdir -p /etc/puppet/modules/agent/files && \ + mkdir -p /etc/puppet/modules/java/files && \ + mkdir -p /etc/puppet/modules/tomcat/files COPY files/manifests /etc/puppet/manifests COPY files/modules /etc/puppet/modules -ADD files/jdk-7u51-linux-x64.tar.gz /etc/puppet/modules/java/files/ -ADD files/apache-tomcat-7.0.52.tar.gz /etc/puppet/modules/tomcat/files/ - -ADD files/agentfiles.tgz /tmp/ +ADD files/apache-activemq-libs.tgz /etc/puppet/modules/agent/files/activemq/ +ADD files/jdk.tgz /etc/puppet/modules/java/files/ +ADD files/apache-tomcat.tgz /etc/puppet/modules/tomcat/files/ +ADD files/apache-stratos-cartridge-agent.tgz /etc/puppet/modules/agent/files/ +ADD files/apache-stratos-load-balancer.tgz /etc/puppet/modules/lb/files/ -RUN mv /tmp/apache-stratos-cartridge-agent-*.zip /etc/puppet/modules/agent/files/ -RUN mv /tmp/apache-stratos-load-balancer-*.zip /etc/puppet/modules/agent/files/ ADD run /usr/local/bin/run RUN chmod +x /usr/local/bin/run diff --git a/tools/stratos-docker-images/puppetmaster/addpuppetdomain.txt b/tools/stratos-docker-images/puppetmaster/addpuppetdomain.txt deleted file mode 100644 index 90112eb5d5..0000000000 --- a/tools/stratos-docker-images/puppetmaster/addpuppetdomain.txt +++ /dev/null @@ -1,5 +0,0 @@ -server 127.0.0.1 -zone example.com -prereq nxdomain puppetmaster.example.com. -update add puppetmaster.example.com. 10 A 192.168.56.10 -send diff --git a/tools/stratos-docker-images/puppetmaster/docker-build.sh b/tools/stratos-docker-images/puppetmaster/docker-build.sh index 62be759eea..86280a79dc 100755 --- a/tools/stratos-docker-images/puppetmaster/docker-build.sh +++ b/tools/stratos-docker-images/puppetmaster/docker-build.sh @@ -34,27 +34,65 @@ MYSQLJ_URL="http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.29/mysq # if you change the tomcat version, you will need to change the version in the Dockerfile too TOMCAT_URL="http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz" -HAWTBUF_URL="http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.2/hawtbuf-1.2.jar" +HAWTBUF_URL="http://repo1.maven.org/maven2/org/fusesource/hawtbuf/hawtbuf/1.9/hawtbuf-1.9.jar" # if you change the JDK version, you will need to change the version in the Dockerfile too JDK_URL="http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.tar.gz" +# +# Tomcat to be copied to the image +# + wget -N -c -P files $TOMCAT_URL +# +# JDK to be copied to the image +# + wget -N -c -P files \ --no-cookies --no-check-certificate \ --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \ ${JDK_URL} +# +# ActiveMQ files to be copied to the image +# + +wget -N -q -P files/ $ACTIVEMQ_URL +rm -rf files/apache-activemq-lib files/apache-activemq-lib-tmp +mkdir files/apache-activemq-lib files/apache-activemq-lib-tmp +tar -xzf files/apache-activemq-5.9.1-bin.tar.gz -C files/apache-activemq-lib-tmp +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/activemq-broker-5.9.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/activemq-client-5.9.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/geronimo-jms_1.1_spec-1.1.1.jar files/apache-activemq-lib + +# +# HAWTBUF to be copied to the image +# + +wget -N -q -P files/apache-activemq-lib/ $HAWTBUF_URL + +# +# Stratos files to be copied to the image +# + cp -rf $STRATOS_SOURCE/tools/puppet3/manifests files/ cp -rf $STRATOS_SOURCE/tools/puppet3/modules files/ - cp -f $STRATOS_SOURCE/products/cartridge-agent/modules/distribution/target/apache-stratos-cartridge-agent-*.zip files/ - cp -f $STRATOS_SOURCE/products/load-balancer/modules/distribution/target/apache-stratos-load-balancer-*.zip files/ +# Docker files can't use wildcards for ADDing files, so we tar them up into a tar archive without version +# numbering in the file name. When the files are extracted, the original version numbers are retained. + cd files/ -tar -cvzf agentfiles.tgz apache-stratos-cartridge-agent-*.zip apache-stratos-load-balancer-*.zip +tar -cvzf apache-activemq-libs.tgz -C apache-activemq-lib/ . +tar -cvzf jdk.tgz jdk-7u51-linux-x64.tar.gz +tar -cvzf apache-tomcat.tgz apache-tomcat-7.0.52.tar.gz +tar -cvzf apache-stratos-cartridge-agent.tgz apache-stratos-cartridge-agent-*.zip +tar -cvzf apache-stratos-load-balancer.tgz apache-stratos-load-balancer-*.zip cd .. -docker build -t=apachestratos/puppetmaster . +# Build the image + +docker build -t=apachestratos/puppetmaster:$VERSION . diff --git a/tools/stratos-docker-images/puppetmaster/run-example.sh b/tools/stratos-docker-images/puppetmaster/run-example.sh index b7dc3fc999..89d9566936 100755 --- a/tools/stratos-docker-images/puppetmaster/run-example.sh +++ b/tools/stratos-docker-images/puppetmaster/run-example.sh @@ -27,16 +27,7 @@ MB_HOSTNAME= MB_PORT= TRUSTSTORE_PASSWORD=wso2carbon - -# To run interactively: -# docker run -i -t -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -p 8140 apachestratos/puppet /bin/bash - PUPPET_ID=$(docker run -d --dns=${IP_ADDR} -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -p 8140 apachestratos/puppet) PUPPET_IP_ADDR=$(docker inspect --format '{{ .NetworkSettings.Gateway }}' $PUPPET_ID) PUPPET_PORT=$(docker port $PUPPET_ID 8140 | awk -F':' '{ print $2 }') -# TODO create a docker cartridge -# add dns record for cartridge, e.g. cartridge1.$DOMAIN -# start puppet agent in cartridge to test puppetmaster: -# puppet agent --server ${MASTERHOSTNAME} --masterport ${PUPPET_PORT} --test --verbose --debug - diff --git a/tools/stratos-docker-images/puppettestnode/docker-build.sh b/tools/stratos-docker-images/puppettestnode/docker-build.sh index 2359cb68f2..e0d2270183 100755 --- a/tools/stratos-docker-images/puppettestnode/docker-build.sh +++ b/tools/stratos-docker-images/puppettestnode/docker-build.sh @@ -22,4 +22,4 @@ set -e # exit on error -docker build -t=apachestratos/puppettestnode . +docker build -t=apachestratos/puppettestnode:$VERSION . diff --git a/tools/stratos-docker-images/push-all.sh b/tools/stratos-docker-images/push-all.sh index abee36db2b..bbb16daa81 100755 --- a/tools/stratos-docker-images/push-all.sh +++ b/tools/stratos-docker-images/push-all.sh @@ -20,28 +20,29 @@ # # ---------------------------------------------------------------------------- -set -e +set -e # fail on error +set -x # debug output cd bind -docker push apachestratos/bind +docker -D push apachestratos/bind:$VERSION cd .. cd puppetmaster -docker push apachestratos/puppetmaster +docker push apachestratos/puppetmaster:$VERSION cd .. cd puppettestnode -docker push apachestratos/puppettestnode +docker push apachestratos/puppettestnode:$VERSION cd .. cd mysql -docker push apachestratos/mysql +docker push apachestratos/mysql:$VERSION cd .. cd activemq -docker push apachestratos/activemq +docker push apachestratos/activemq:$VERSION cd .. cd stratos -docker push apachestratos/stratos +docker push apachestratos/stratos:$VERSION cd .. diff --git a/tools/stratos-docker-images/remove_stratos_images.sh b/tools/stratos-docker-images/remove_stratos_images.sh new file mode 100755 index 0000000000..bed3c3c754 --- /dev/null +++ b/tools/stratos-docker-images/remove_stratos_images.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# ---------------------------------------------------------------------------- +# +# 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. +# +# ---------------------------------------------------------------------------- + +set -e +set -u + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +. /$SCRIPT_DIR/stop_stratos_containers.sh + +stratos_image_ids=$(docker images -a | grep '^apachestratos' | awk '{print $3}') +if [[ -n $stratos_image_ids ]]; then + docker rmi $stratos_image_ids +fi diff --git a/tools/stratos-docker-images/run-example.sh b/tools/stratos-docker-images/run-example.sh index ae471251e3..2b892ce0fd 100755 --- a/tools/stratos-docker-images/run-example.sh +++ b/tools/stratos-docker-images/run-example.sh @@ -30,6 +30,9 @@ export DOMAIN=example.com # Set the IP_ADDR to the IP address you use to reach the docker host export IP_ADDR=192.168.56.5 +# Set the version of Stratos docker images +export STRATOS_VERSION=4.1.0-SNAPSHOT + ######## # Bind ######## @@ -38,14 +41,14 @@ export IP_ADDR=192.168.56.5 # See http://www.zytrax.com/books/dns/ch7/address_match_list.html for more info export UPDATE_ADDR_LIST=any -export BIND_ID=$(docker run -d -p 53:53/udp -e "DOMAIN=$DOMAIN" -e "IP_ADDR=$IP_ADDR" -e "UPDATE_ADDR_LIST=$UPDATE_ADDR_LIST" apachestratos/bind); sleep 2s; +export BIND_ID=$(docker run -d -p 53:53/udp -e "DOMAIN=$DOMAIN" -e "IP_ADDR=$IP_ADDR" -e "UPDATE_ADDR_LIST=$UPDATE_ADDR_LIST" apachestratos/bind:$STRATOS_VERSION); sleep 2s; export BIND_IP_ADDR=$(docker inspect --format '{{ .NetworkSettings.Gateway }}' $BIND_ID) ########### # ActiveMQ ########### -export MB_ID=$(docker run -p 61616 -d apachestratos/activemq); sleep 2s; +export MB_ID=$(docker run -p 61616 -d apachestratos/activemq:$STRATOS_VERSION); sleep 2s; export MB_IP_ADDR=$(docker inspect --format '{{ .NetworkSettings.Gateway }}' $MB_ID) export MB_PORT=$(docker port $MB_ID 61616 | awk -F':' '{ print $2 }') @@ -69,7 +72,7 @@ rm -f addpuppetdomain.txt export MASTERHOSTNAME=puppet.$DOMAIN export TRUSTSTORE_PASSWORD=wso2carbon -export PUPPET_ID=$(docker run -d -h ${MASTERHOSTNAME} --dns=${BIND_IP_ADDR} -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -e "MB_HOSTNAME=${MB_IP_ADDR}" -e "MB_PORT=${MB_PORT}" -e "TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD}" -p 8140 apachestratos/puppetmaster); sleep 2s; +export PUPPET_ID=$(docker run -d -h ${MASTERHOSTNAME} --dns=${BIND_IP_ADDR} -e "DOMAIN=${DOMAIN}" -e "MASTERHOSTNAME=${MASTERHOSTNAME}" -e "MB_HOSTNAME=${MB_IP_ADDR}" -e "MB_PORT=${MB_PORT}" -e "TRUSTSTORE_PASSWORD=${TRUSTSTORE_PASSWORD}" -p 8140 apachestratos/puppetmaster:$STRATOS_VERSION); sleep 2s; export PUPPET_IP_ADDR=$(docker inspect --format '{{ .NetworkSettings.Gateway }}' $PUPPET_ID) export PUPPET_PORT=$(docker port $PUPPET_ID 8140 | awk -F':' '{ print $2 }') @@ -77,7 +80,7 @@ export PUPPET_PORT=$(docker port $PUPPET_ID 8140 | awk -F':' '{ print $2 }') # MySQL ######## -export USERSTORE_ID=$(docker run -d -p 3306 -e MYSQL_ROOT_PASSWORD=password apachestratos/mysql); sleep 2s; +export USERSTORE_ID=$(docker run -d -p 3306 -e MYSQL_ROOT_PASSWORD=password apachestratos/mysql:$STRATOS_VERSION); sleep 2s; export USERSTORE_IP_ADDR=$(docker inspect --format '{{ .NetworkSettings.Gateway }}' $USERSTORE_ID) export USERSTORE_PORT=$(docker port $USERSTORE_ID 3306 | awk -F':' '{ print $2 }') @@ -96,7 +99,7 @@ docker_env+=(-e "USERSTORE_DB_PASS=password") # Puppet Setings docker_env+=(-e "PUPPET_IP=${IP_ADDR}") -docker_env+=(-e "PUPPET_HOSTNAME=${DOMAIN}") +docker_env+=(-e "PUPPET_HOSTNAME=${MASTERHOSTNAME}") docker_env+=(-e "PUPPET_ENVIRONMENT=none") # MB Settings @@ -126,5 +129,15 @@ docker_env+=(-e "VCLOUD_ENDPOINT=none") docker_env+=(-e "STRATOS_PROFILE=default") # Start Stratos container as daemon -STRATOS_ID=$(docker run -d "${docker_env[@]}" -p 9443:9443 apachestratos/stratos) -sudo docker logs -f $STRATOS_ID +STRATOS_ID=$(docker run -d "${docker_env[@]}" -p 9443:9443 --dns=${BIND_IP_ADDR} apachestratos/stratos:$STRATOS_VERSION) + +echo ============================================== +echo Starting Stratos docker images. +echo +echo To view the stratos log file, run the command: +echo +echo docker logs -f $STRATOS_ID +echo ============================================== + +# To run stratos interactively - e.g. for debugging +# docker run -i -t "${docker_env[@]}" -p 9443:9443 --dns=${BIND_IP_ADDR} apachestratos/stratos:$STRATOS_VERSION /bin/bash diff --git a/tools/stratos-docker-images/run-nsenter.sh b/tools/stratos-docker-images/run-nsenter.sh new file mode 100755 index 0000000000..c0a185be51 --- /dev/null +++ b/tools/stratos-docker-images/run-nsenter.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +container_id="$1" + +[ $# -eq 0 ] && { echo "Usage: $0 container_id"; exit 1; } + +if [ ! -e /usr/local/bin/nsenter ]; then + docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter +fi + +PID=$(docker inspect --format {{.State.Pid}} $container_id) + +nsenter --target $PID --mount --uts --ipc --net --pid diff --git a/tools/stratos-docker-images/stop_and_remove_stratos_containers.sh b/tools/stratos-docker-images/stop_stratos_containers.sh similarity index 79% rename from tools/stratos-docker-images/stop_and_remove_stratos_containers.sh rename to tools/stratos-docker-images/stop_stratos_containers.sh index b2ff6c394e..2296987c45 100755 --- a/tools/stratos-docker-images/stop_and_remove_stratos_containers.sh +++ b/tools/stratos-docker-images/stop_stratos_containers.sh @@ -23,9 +23,9 @@ set -e set -u -stratos_container_ids=$(sudo docker ps -a | awk '{print $2, $1}' | grep '^apachestratos' | awk '{print $2}') +running_stratos_container_ids=$(docker ps -a | awk '{print $2, $1}' | grep '^apachestratos' | awk '{print $2}') -if [[ -n $stratos_container_ids ]]; then - sudo docker stop $stratos_container_ids - sudo docker rm $stratos_container_ids +if [[ -n $running_stratos_container_ids ]]; then + docker stop $running_stratos_container_ids + docker rm $running_stratos_container_ids fi diff --git a/tools/stratos-docker-images/stratos/Dockerfile b/tools/stratos-docker-images/stratos/Dockerfile index 9ebb9c21c2..73990f0487 100755 --- a/tools/stratos-docker-images/stratos/Dockerfile +++ b/tools/stratos-docker-images/stratos/Dockerfile @@ -19,22 +19,20 @@ # # ---------------------------------------------------------------------------- -FROM ubuntu:14.04 +FROM ubuntu:14.04 + +RUN apt-get update && \ + apt-get upgrade tzdata -y && \ + apt-get install openjdk-7-jre-headless -y && \ + apt-get clean && \ + rm -rf /var/cache/apt/* -RUN apt-get update -RUN apt-get upgrade tzdata -y -RUN apt-get install openjdk-7-jre-headless unzip wget -y ################# # Unpack Stratos ################# -WORKDIR /opt/ - -ADD /files/apache-stratos.zip /opt/apache-stratos.zip -RUN unzip -q apache-stratos.zip -RUN rm apache-stratos.zip -RUN mv apache-stratos-* apache-stratos +ADD /files/apache-stratos /opt/apache-stratos/ ADD /files/stratos-installer/config/all/repository/conf/activemq/jndi.properties /opt/apache-stratos/repository/conf/ @@ -42,13 +40,7 @@ ADD /files/stratos-installer/config/all/repository/conf/activemq/jndi.properties # Get ActiveMQ libs #################### -ADD /files/apache-activemq-5.9.1-bin.tar.gz /opt/ - -RUN cp -f apache-activemq-5.9.1/lib/activemq-broker-5.9.1.jar /opt/apache-stratos/repository/components/lib/ -RUN cp -f apache-activemq-5.9.1/lib/activemq-client-5.9.1.jar /opt/apache-stratos/repository/components/lib/ -RUN cp -f apache-activemq-5.9.1/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar /opt/apache-stratos/repository/components/lib/ -RUN cp -f apache-activemq-5.9.1/lib/geronimo-jms_1.1_spec-1.1.1.jar /opt/apache-stratos/repository/components/lib/ -RUN rm -rf apache-activemq-5.9.1 +#ADD /files/apache-activemq-lib /opt/apache-stratos/repository/components/lib/ ########### # CC Setup diff --git a/tools/stratos-docker-images/stratos/docker-build.sh b/tools/stratos-docker-images/stratos/docker-build.sh index fc890ccf1a..99109f009d 100755 --- a/tools/stratos-docker-images/stratos/docker-build.sh +++ b/tools/stratos-docker-images/stratos/docker-build.sh @@ -22,14 +22,43 @@ set -e -cp -f $STRATOS_SOURCE/products/stratos/modules/distribution/target/apache-stratos-*.zip files/apache-stratos.zip +# +# Stratos files to be copied to the image +# + +rm -rf files/apache-stratos files/apache-stratos-* +unzip $STRATOS_SOURCE/products/stratos/modules/distribution/target/apache-stratos-*.zip -d files/ +mv files/apache-stratos-* files/apache-stratos + +# +# ActiveMQ files to be copied to the image +# wget -N -q -P files/ http://archive.apache.org/dist/activemq/5.9.1/apache-activemq-5.9.1-bin.tar.gz +rm -rf files/apache-activemq-lib files/apache-activemq-lib-tmp +mkdir files/apache-activemq-lib files/apache-activemq-lib-tmp +tar -xzf files/apache-activemq-5.9.1-bin.tar.gz -C files/apache-activemq-lib-tmp +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/activemq-broker-5.9.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/activemq-client-5.9.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/geronimo-j2ee-management_1.1_spec-1.0.1.jar files/apache-activemq-lib +cp files/apache-activemq-lib-tmp/apache-activemq-5.9.1/lib/geronimo-jms_1.1_spec-1.1.1.jar files/apache-activemq-lib + +# +# MySQL jar to be copied to the image +# wget -N -q -P files/ http://repo1.maven.org/maven2/mysql/mysql-connector-java/5.1.29/mysql-connector-java-5.1.29.jar +# +# Stratos installer files to copy to the image +# + cp -rf $STRATOS_SOURCE/tools/stratos-installer files/ +# +# Extensions files to copy to the image +# + cp -rf $STRATOS_SOURCE/extensions/ files/ -docker build -t=apachestratos/stratos . +docker build -t=apachestratos/stratos:$VERSION . diff --git a/tools/stratos-docker-images/stratos/run b/tools/stratos-docker-images/stratos/run index 1213d5170a..c388dea82d 100755 --- a/tools/stratos-docker-images/stratos/run +++ b/tools/stratos-docker-images/stratos/run @@ -122,7 +122,7 @@ if [[ $EC2_ENABLED = true ]]; then sed -i "s@EC2_OWNER_ID@$EC2_OWNER_ID@g" $CLOUD_CONTROLLER_CONFIG_FILE sed -i "s@EC2_AVAILABILITY_ZONE@$EC2_AVAILABILITY_ZONE@g" $CLOUD_CONTROLLER_CONFIG_FILE sed -i "s@EC2_SECURITY_GROUPS@$EC2_SECURITY_GROUPS@g" $CLOUD_CONTROLLER_CONFIG_FILE - sed -i "s@EC2_KEYPAIR@$EC2_KEYPAIR_NAME@g" $CLOUD_CONTROLLER_CONFIG_FILE + sed -i "s@EC2_KEYPAIR@$EC2_KEYPAIR@g" $CLOUD_CONTROLLER_CONFIG_FILE sed -i "s@EC2_PROVIDER_END@@g" $CLOUD_CONTROLLER_CONFIG_FILE sed -i "s@OPENSTACK_PROVIDER_START@!--@g" $CLOUD_CONTROLLER_CONFIG_FILE sed -i "s@OPENSTACK_PROVIDER_END@--@g" $CLOUD_CONTROLLER_CONFIG_FILE From 6dc7a58a98f570bc7d9c056444adda0921dc7ab1 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 9 Sep 2014 18:45:00 +0530 Subject: [PATCH 042/436] initial changes for messaging and parsing Application Definition in CC --- .../autoscaler/ComplexApplicationContext.java | 56 +- .../application/ApplicationUtils.java | 33 + .../parser/DefaultApplicationParser.java | 414 +++++++++++++ .../ApplicationDefinitionException.java | 47 ++ .../impl/CloudControllerServiceImpl.java | 8 + .../interfaces/ApplicationParser.java | 28 + .../interfaces/CloudControllerService.java | 18 +- .../pojo/application/ApplicationContext.java | 65 ++ .../pojo/application/ComponentContext.java | 56 ++ .../pojo/application/DependencyContext.java | 45 ++ .../pojo/application/GroupContext.java | 86 +++ .../pojo/application/StartupOrderContext.java | 43 ++ .../pojo/application/SubscribableContext.java | 44 ++ .../application/SubscribableInfoContext.java | 93 +++ .../composite/application/TemporyClass.java | 7 - .../domain/topology/Application.java | 95 +++ .../messaging/domain/topology/Cartridge.java | 10 +- .../domain/topology/CompositeApplication.java | 18 +- .../domain/topology/Dependencies.java | 24 +- .../domain/topology/DependencyOrder.java | 50 ++ .../messaging/domain/topology/Group.java | 584 +++--------------- .../messaging/domain/topology/GroupTemp.java | 503 +++++++++++++++ .../domain/topology/StartupOrder.java | 40 ++ .../domain/topology/Subscribable.java | 4 +- .../domain/topology/SubscribableBehavior.java | 42 ++ .../messaging/domain/topology/Topology.java | 22 +- .../util/CompositeApplicationBuilder.java | 50 +- .../topology/ApplicationCreatedEvent.java | 40 ++ .../topology/ApplicationRemovedEvent.java | 33 + .../CompositeApplicationCreatedEvent.java | 1 - .../ApplicationCreatedEventListener.java | 26 + .../ApplicationRemovedEventListener.java | 26 + .../ApplicationCreatedMessageProcessor.java | 88 +++ .../ApplicationRemovedMessageProcessor.java | 35 ++ .../CompleteTopologyMessageProcessor.java | 21 +- .../TopologyMessageProcessorChain.java | 34 +- .../resources/CloudControllerService.wsdl | 503 ++++++++------- 37 files changed, 2469 insertions(+), 823 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationDefinitionException.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java delete mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/TemporyClass.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupTemp.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java index 547483540f..84df0fbec5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java @@ -89,7 +89,7 @@ public static boolean checkServiceDependencies(String serviceType, String cluste return true; } - List service_type_groups = complexApplication.findAllGroupsForServiceType(serviceType); + List service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType); String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); @@ -99,16 +99,16 @@ public static boolean checkServiceDependencies(String serviceType, String cluste } } - for (Group service_type_group : service_type_groups) { + for (GroupTemp service_type_groupTemp : service_type_groupTemps) { // check if cluster is in the group if (log.isDebugEnabled()) { - log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_group.getAlias() + + log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + "extracted group from clusterId is " + clusterGroupFromClusterId); } - if (service_type_group.getAlias().equals(clusterGroupFromClusterId)) { - boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_group); + if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) { + boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_groupTemp); if (log.isDebugEnabled()) { - log.debug("cluster is " + clusterId + " is in the group " + service_type_group.getAlias() + " and startup dependency check is " + result_flag); + log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and startup dependency check is " + result_flag); } return result_flag; } @@ -122,11 +122,11 @@ public static boolean checkServiceDependencies(String serviceType, String cluste } - public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, Group home_group) { + public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, GroupTemp home_groupTemp) { String aServiceId = serviceType; - if (home_group == null) { + if (home_groupTemp == null) { if (log.isDebugEnabled()) { log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no dependency check)" ); } @@ -134,7 +134,7 @@ public static boolean checkServiceDependenciesForServiceType(String serviceType, } - if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_group.getAlias()))) { + if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_groupTemp.getAlias()))) { if (log.isDebugEnabled()) { log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" ); } @@ -145,7 +145,7 @@ public static boolean checkServiceDependenciesForServiceType(String serviceType, } } - Map downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); + Map downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId); if (downstreamDependencies == null || downstreamDependencies.size() == 0) { @@ -223,7 +223,7 @@ public boolean checkKillTerminateDependencies (String serviceType, String cluste return true; } - List service_type_groups = complexApplication.findAllGroupsForServiceType(serviceType); + List service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType); String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); @@ -233,17 +233,17 @@ public boolean checkKillTerminateDependencies (String serviceType, String cluste } } - for (Group service_type_group : service_type_groups) { + for (GroupTemp service_type_groupTemp : service_type_groupTemps) { // check if cluster is in the group if (log.isDebugEnabled()) { - log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_group.getAlias() + + log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + "extracted group from clusterId is " + clusterGroupFromClusterId); } - if (service_type_group.getAlias().equals(clusterGroupFromClusterId)) { - boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag, - service_type_group, complexApplication); + if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) { + boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag, + service_type_groupTemp, complexApplication); if (log.isDebugEnabled()) { - log.debug("cluster is " + clusterId + " is in the group " + service_type_group.getAlias() + " and kill dependency check is " + result_flag); + log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and kill dependency check is " + result_flag); } return result_flag; } @@ -258,16 +258,16 @@ public boolean checkKillTerminateDependencies (String serviceType, String cluste // return false will terminate instances public boolean checkKillTerminateDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag, - Group home_group, CompositeApplication complexApplication ) { + GroupTemp home_groupTemp, CompositeApplication complexApplication ) { String aServiceId = serviceType; - if (home_group == null) { + if (home_groupTemp == null) { if (log.isDebugEnabled()) { log.debug(" lone cluster without top level group " + aServiceId + "skip checking and return true (no kill)" ); } return true; - } else if (home_group.findGroup(aServiceId) == null) { + } else if (home_groupTemp.findGroup(aServiceId) == null) { if (log.isDebugEnabled()) { log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no kill)" ); } @@ -281,7 +281,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, log.debug("checking downstream dependencies for " + aServiceId ); } Map downstreamDependencies = null; - downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); + downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId); if (log.isDebugEnabled()) { StringBuffer buf = new StringBuffer(); buf.append("downstreamdependencies list: [ "); @@ -305,7 +305,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, log.debug("checking upstream dependencies for " + aServiceId ); } // 2. get upstream dependencies - Map upstreamDependencies = home_group.getUpstreamDependenciesAsMap(aServiceId); + Map upstreamDependencies = home_groupTemp.getUpstreamDependenciesAsMap(aServiceId); if (log.isDebugEnabled()) { StringBuffer buf = new StringBuffer(); @@ -335,7 +335,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, // return false if instances should be terminated, true if not for (String serviceTypeAlias : in_active_upstreams) { String gr_alias = upstreamDependencies.get(serviceTypeAlias); - Group gr = complexApplication.getGroupFromGroupAlias(gr_alias); + GroupTemp gr = complexApplication.getGroupFromGroupAlias(gr_alias); if (gr != null) { kill_behavior = gr.getDependencies().getKill_behavior(); @@ -350,7 +350,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, // building key from alias + group alias ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias,gr.getAlias())); // building key from alias + group alias - ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId,home_group.getAlias())); + ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId, home_groupTemp.getAlias())); return false; } else { if (log.isDebugEnabled()) { @@ -384,8 +384,8 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, } // check kill_all_enabled flag - Map all = complexApplication.getAllInPathOfAsMap(aServiceId, home_group); - String [] group_with_kill_all_aliases = home_group.findAllGroupsWithKill2(all, Dependencies.KILL_ALL); + Map all = complexApplication.getAllInPathOfAsMap(aServiceId, home_groupTemp); + String [] group_with_kill_all_aliases = home_groupTemp.findAllGroupsWithKill2(all, Dependencies.KILL_ALL); // "persistent flag for each group" this.updateEnableKillAllFlag(all, group_with_kill_all_aliases); @@ -398,7 +398,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, kill_behavior = Dependencies.KILL_UNDEFINED; for (String alias : in_active_downstreams) { - Group gr = home_group.findGroup(alias); + GroupTemp gr = home_groupTemp.findGroup(alias); if (gr !=null) { kill_behavior = gr.getDependencies().getKill_behavior(); if (kill_behavior.equals(Dependencies.KILL_ALL) ) { @@ -447,7 +447,7 @@ public boolean checkKillTerminateDependenciesForServiceType (String serviceType, } // this cluster - Group gr = home_group.findGroup(aServiceId); + GroupTemp gr = home_groupTemp.findGroup(aServiceId); if (gr == null) { if (log.isDebugEnabled()) { log.debug(" cluster without group, should not reach this code ? for " + aServiceId ); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java new file mode 100644 index 0000000000..ac7845386e --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +import java.util.regex.Pattern; + +public class ApplicationUtils { + + public static boolean isAliasValid (String alias) { + + String patternString = "([a-z0-9]+([-][a-z0-9])*)+"; + Pattern pattern = Pattern.compile(patternString); + + return pattern.matcher(alias).matches(); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java new file mode 100644 index 0000000000..ef9432ffe8 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.parser; + +import org.apache.axis2.AxisFault; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.application.ApplicationUtils; +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; +import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.pojo.application.GroupContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; +import org.apache.stratos.messaging.domain.topology.Application; + +import java.rmi.RemoteException; +import java.util.*; + +public class DefaultApplicationParser implements ApplicationParser { + + private static Log log = LogFactory.getLog(DefaultApplicationParser.class); + + @Override + public Application parse(Object obj) throws ApplicationDefinitionException { + + ApplicationContext applicationCtxt = null; + + if (obj instanceof ApplicationContext) { + applicationCtxt = (ApplicationContext) obj; + } + + if (applicationCtxt == null) { + throw new ApplicationDefinitionException("Invalid Composite Application Definition"); + } + + if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) { + throw new ApplicationDefinitionException("Invalid alias specified"); + } + + if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) { + throw new ApplicationDefinitionException("Invalid Composite App id specified"); + } + + // get the defined groups + Map definedGroups = getDefinedGroups(applicationCtxt); + if (log.isDebugEnabled()) { + Set> groupEntries = definedGroups.entrySet(); + log.debug("Defined Groups: [ "); + for (Map.Entry groupEntry : groupEntries) { + log.debug("Group alias: " + groupEntry.getKey()); + } + log.debug(" ]"); + } + + // get the Subscribables Information + Map subscribablesInfo = getSubscribableInformation(applicationCtxt); + if (log.isDebugEnabled()) { + Set> subscribableInfoCtxtEntries = subscribablesInfo.entrySet(); + log.debug("Defined Subscribable Information: [ "); + for (Map.Entry subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) { + log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey()); + } + log.debug(" ]"); + } + + if (subscribablesInfo == null) { + throw new ApplicationDefinitionException("Invalid Composite Application Definition, no Subscribable Information specified"); + } + + //TODO + //return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); + return null; + } + + private Map getDefinedGroups (ApplicationContext appCtxt) throws + ApplicationDefinitionException { + + // map [group alias -> Group Definition] + Map definedGroups = null; + + if (appCtxt.getComponents() != null) { + if (appCtxt.getComponents().getGroupContexts() != null) { + definedGroups = new HashMap(); + + for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) { + + // check validity of group name + if (groupContext.getName() == null || groupContext.getName().isEmpty()) { + throw new ApplicationDefinitionException("Invalid Group name specified"); + } + + // check if group is deployed + if(!isGroupDeployed(groupContext.getName())) { + throw new ApplicationDefinitionException("Group with name " + groupContext.getName() + " not deployed"); + } + + // check validity of group alias + if (groupContext.getAlias() == null || groupContext.getAlias().isEmpty() || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { + throw new ApplicationDefinitionException("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); + } + + // check if a group is already defined under the same alias + if(definedGroups.get(groupContext.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new ApplicationDefinitionException("A Group with alias " + groupContext.getAlias() + " already exists"); + } + + definedGroups.put(groupContext.getAlias(), groupContext); + if (log.isDebugEnabled()) { + log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]"); + } + } + } + } + + return definedGroups; + } + + private Map getSubscribableInformation (ApplicationContext appCtxt) throws + ApplicationDefinitionException { + + // map [cartridge alias -> Subscribable Information] + Map subscribableInformation = null; + + if (appCtxt.getSubscribableInfoContext() != null) { + subscribableInformation = new HashMap(); + + for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) { + + if (subscribableInfoCtxt.getAlias() == null || subscribableInfoCtxt.getAlias().isEmpty() || + !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) { + throw new ApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); + } + + // check if a group is already defined under the same alias + if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) { + // a group with same alias already exists, can't continue + throw new ApplicationDefinitionException("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists"); + } + + subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt); + if (log.isDebugEnabled()) { + log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]"); + } + } + } + + return subscribableInformation; + } + + private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException { + + //TODO + return true; + } + +// private Application buildCompositeAppStructure (ApplicationContext appCtxt, +// Map definedGroupCtxts, +// Map subscribableInfoCtxts) +// throws ApplicationDefinitionException { +// +// Application application = new Application(appCtxt.getApplicationId()); +// +// if (appCtxt.getComponents() != null) { +// // get top level Subscribables +// if (appCtxt.getComponents().getSubscribableContexts() != null) { +// application.setSubscribableContexts(getSubsribableContexts(appCtxt.getComponents().getSubscribables(), +// subscribableInfoCtxts)); +// } +// +// // get Groups +// if (appCtxt.getComponents().getGroups() != null) { +// application.setGroupContexts(getGroupContexts(appCtxt.getComponents().getGroups(), +// subscribableInfoCtxts, definedGroupCtxts)); +// } +// +// // get top level Dependency definitions +// if (appCtxt.getComponents().getDependencies() != null) { +// application.setStartupOrder(getStartupOrderForApplicationComponents(appCtxt.getComponents(). +// getDependencies().getStartupOrder())); +// +// application.setKillBehaviour(appCtxt.getComponents().getDependencies().getKillBehaviour()); +// } +// } +// +// return application; +// } +// +// private Set getGroupContexts (List groupDefinitions, +// Map subscribableInformation, +// Map definedGroups) +// throws CompositeApplicationDefinitionException { +// +// Set groupContexts = new HashSet(); +// +// for (GroupDefinition group : groupDefinitions) { +// groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); +// } +// +// //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); +// Set nestedGroupContexts = new HashSet(); +// getNestedGroupContexts(nestedGroupContexts, groupContexts); +// filterDuplicatedGroupContexts(groupContexts, nestedGroupContexts); +// +// return groupContexts; +// } +// +// private void getNestedGroupContexts (Set nestedGroupContexts, Set groupContexts) { +// +// if (groupContexts != null) { +// for (GroupContext groupContext : groupContexts) { +// if (groupContext.getGroupContexts() != null) { +// nestedGroupContexts.addAll(groupContext.getGroupContexts()); +// getNestedGroupContexts(nestedGroupContexts, groupContext.getGroupContexts()); +// } +// } +// } +// } +// +// private void filterDuplicatedGroupContexts (Set topLevelGroupContexts, Set nestedGroupContexts) { +// +// for (GroupContext nestedGropCtxt : nestedGroupContexts) { +// filterNestedGroupFromTopLevel(topLevelGroupContexts, nestedGropCtxt); +// } +// } +// +// private void filterNestedGroupFromTopLevel (Set topLevelGroupContexts, GroupContext nestedGroupCtxt) { +// +// Iterator parentIterator = topLevelGroupContexts.iterator(); +// while (parentIterator.hasNext()) { +// GroupContext parentGroupCtxt = parentIterator.next(); +// // if there is an exactly similar nested Group Context and a top level Group Context +// // it implies that they are duplicates. Should be removed from top level. +// if (parentGroupCtxt.equals(nestedGroupCtxt)) { +// parentIterator.remove(); +// } +// } +// } +// +// private GroupContext getGroupContext (GroupDefinition group, Map subscribableInformation, +// Map definedGroups) throws CompositeApplicationDefinitionException { +// +// // check if are in the defined Group set +// GroupDefinition definedGroupDef = definedGroups.get(group.getAlias()); +// if (definedGroupDef == null) { +// throw new CompositeApplicationDefinitionException("Group Definition with name: " + group.getName() + ", alias: " + +// group.getAlias() + " is not found in the all Group Definitions collection"); +// } +// +// GroupContext groupContext = new GroupContext(); +// +// groupContext.setName(group.getName()); +// groupContext.setAlias(group.getAlias()); +// groupContext.setAutoscalingPolicy(group.getAutoscalingPolicy()); +// groupContext.setDeploymentPolicy(group.getDeploymentPolicy()); +// groupContext.setStartupOrder(getStartupOrderForGroup(group.getName())); +// groupContext.setKillBehaviour(getKillbehaviour(group.getName())); +// +// // get group level Subscribables +// if (group.getSubscribables() != null) { +// groupContext.setSubscribableContexts(getSubsribableContexts(group.getSubscribables(), subscribableInformation)); +// } +// // get nested groups +// if (group.getSubGroups() != null) { +// Set nestedGroupContexts = new HashSet(); +// // check sub groups +// for (GroupDefinition subGroup : group.getSubGroups()) { +// // get the complete Group Definition +// subGroup = definedGroups.get(subGroup.getAlias()); +// nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); +// } +// +// groupContext.setGroupContexts(nestedGroupContexts); +// } +// +// return groupContext; +// } +// +// private Set getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { +// +// ServiceGroupDefinition groupDefinition; +// +// try { +// groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); +// +// } catch (PersistenceManagerException e) { +// throw new CompositeApplicationDefinitionException(e); +// } +// +// if (groupDefinition == null) { +// throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); +// } +// +// if (groupDefinition.getDependencies() != null) { +// if (groupDefinition.getDependencies().getStartupOrder() != null) { +// return ParserUtils.convert(groupDefinition.getDependencies().getStartupOrder()); +// } +// } +// +// return null; +// } +// +// private Set getStartupOrderForApplicationComponents (List startupOrderDefinitions) +// throws CompositeApplicationDefinitionException { +// +// if (startupOrderDefinitions == null) { +// return null; +// } +// +// Set startupOrders = new HashSet(); +// +// for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { +// startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); +// } +// +// return startupOrders; +// } +// +// private String getKillbehaviour (String serviceGroupName) throws CompositeApplicationDefinitionException { +// +// ServiceGroupDefinition groupDefinition; +// +// try { +// groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); +// +// } catch (PersistenceManagerException e) { +// throw new CompositeApplicationDefinitionException(e); +// } +// +// if (groupDefinition == null) { +// throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); +// } +// +// if (groupDefinition.getDependencies() != null) { +// return groupDefinition.getDependencies().getKillBehaviour(); +// } +// +// return null; +// +// } +// +// private Set getSubsribableContexts (List subscribableDefinitions, +// Map subscribableInformation) +// throws CompositeApplicationDefinitionException { +// +// Set subscribableContexts = new HashSet(); +// +// for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { +// // check is there is a related Subscribable Information +// SubscribableInfo subscribableInfo = subscribableInformation.get(subscribableDefinition.getAlias()); +// if (subscribableInfo == null) { +// throw new CompositeApplicationDefinitionException("Related Subscribable Information not found for Subscribable with alias: " +// + subscribableDefinition.getAlias()); +// } +// +// // check if Cartridge Type is valid +// if (subscribableDefinition.getType() == null || subscribableDefinition.getType().isEmpty()) { +// throw new CompositeApplicationDefinitionException ("Invalid Cartridge Type specified : [ " +// + subscribableDefinition.getType() + " ]"); +// } +// +// // check if a cartridge with relevant type is already deployed. else, can't continue +// if (!isCartrigdeDeployed(subscribableDefinition.getType())) { +// throw new CompositeApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableDefinition.getType() + +// " ] for Composite Application"); +// } +// +// subscribableContexts.add(ParserUtils.convert(subscribableDefinition, subscribableInfo)); +// } +// +// return subscribableContexts; +// } +// +// private boolean isCartrigdeDeployed (String cartridgeType) throws CompositeApplicationDefinitionException { +// +// CloudControllerServiceClient ccServiceClient; +// +// try { +// ccServiceClient = CloudControllerServiceClient.getServiceClient(); +// +// } catch (AxisFault axisFault) { +// throw new CompositeApplicationDefinitionException(axisFault); +// } +// +// try { +// return ccServiceClient.getCartridgeInfo(cartridgeType) != null; +// +// } catch (RemoteException e) { +// throw new CompositeApplicationDefinitionException(e); +// +// } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { +// throw new CompositeApplicationDefinitionException(e); +// } +// } + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationDefinitionException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationDefinitionException.java new file mode 100644 index 0000000000..a1a9581d01 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationDefinitionException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.exception; + +public class ApplicationDefinitionException extends Exception { + + private String message; + + public ApplicationDefinitionException () { + super(); + } + + public ApplicationDefinitionException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public ApplicationDefinitionException (String message) { + super(message); + this.message = message; + } + + public ApplicationDefinitionException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 151234cd62..8471d87bfe 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -31,6 +31,7 @@ import org.apache.stratos.cloud.controller.interfaces.Iaas; import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; +import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -1305,6 +1306,13 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } + public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { + + // TODO: + // 1. parse and create Composite App tree + // 2. send the ApplicationCreated event + } + private List restoreConfigCompositeApplication () { List apps = this.dataHolder.getConfigCompositeApplication(); if (apps == null) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java new file mode 100644 index 0000000000..fc9fad842c --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.interfaces; + +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +import org.apache.stratos.messaging.domain.topology.Application; + +public interface ApplicationParser { + + public Application parse (Object obj) throws ApplicationDefinitionException; +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index bcbd3270b8..1ebcf236b6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -19,15 +19,9 @@ package org.apache.stratos.cloud.controller.interfaces; import org.apache.stratos.cloud.controller.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.exception.InvalidCartridgeDefinitionException; -import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; -import org.apache.stratos.cloud.controller.exception.InvalidClusterException; -import org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException; -import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -import org.apache.stratos.cloud.controller.exception.InvalidPartitionException; -import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException; -import org.apache.stratos.cloud.controller.exception.UnregisteredClusterException; +import org.apache.stratos.cloud.controller.exception.*; import org.apache.stratos.cloud.controller.pojo.*; +import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; /** * This API provides a way to communicate with underline @@ -162,4 +156,12 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit */ public ClusterContext getClusterContext (String clusterId); + /** + * deployed an Application Definition + * + * @param applicationContext {@link org.apache.stratos.cloud.controller.pojo.application.ApplicationContext} object + * @throws ApplicationDefinitionException if an error is encountered + */ + public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException; + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java new file mode 100644 index 0000000000..898dcdd94e --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +import java.util.List; + +public class ApplicationContext { + + private String applicationId; + + private String alias; + + private ComponentContext componentContext; + + private List subscribableInfoContexts; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public ComponentContext getComponents() { + return componentContext; + } + + public void setComponents(ComponentContext componentContext) { + this.componentContext = componentContext; + } + + public List getSubscribableInfoContext() { + return subscribableInfoContexts; + } + + public void setSubscribableInfoContext(List subscribableInfoContexts) { + this.subscribableInfoContexts = subscribableInfoContexts; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java new file mode 100644 index 0000000000..f8ab53b7e7 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +import java.util.List; + +public class ComponentContext { + + private List groupContexts; + + private List subscribableContexts; + + private DependencyContext dependencyContext; + + + public List getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(List groupContexts) { + this.groupContexts = groupContexts; + } + + public List getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(List subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public DependencyContext getDependencyContext() { + return dependencyContext; + } + + public void setDependencyContext(DependencyContext dependencyContext) { + this.dependencyContext = dependencyContext; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java new file mode 100644 index 0000000000..fe7331d952 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +import java.util.List; + +public class DependencyContext { + + private List startupOrderContexts; + + private String killBehaviour; + + public List getStartupOrder() { + return startupOrderContexts; + } + + public void setStartupOrder(List startupOrderContexts) { + this.startupOrderContexts = startupOrderContexts; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java new file mode 100644 index 0000000000..54908c129e --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java @@ -0,0 +1,86 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +import java.util.List; + +public class GroupContext { + + private String name; + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private List subscribableContexts; + + private List groupContexts; + + + 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 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 List getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(List subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public List getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(List groupContexts) { + this.groupContexts = groupContexts; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java new file mode 100644 index 0000000000..13120397ca --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +public class StartupOrderContext { + + 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; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java new file mode 100644 index 0000000000..6f7f4bc8ed --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +public class SubscribableContext { + + 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; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java new file mode 100644 index 0000000000..6812962c43 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.application; + +public class SubscribableInfoContext { + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private String repoUrl; + + private boolean privateRepo; + + private String repoUsername; + + private String repoPassword; + + 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; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/TemporyClass.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/TemporyClass.java deleted file mode 100644 index aadec5efe2..0000000000 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/TemporyClass.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.apache.stratos.manager.composite.application; - -/** - * Created by udara on 7/23/14. - */ -public class TemporyClass { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java new file mode 100644 index 0000000000..5e57a5d411 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.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.messaging.domain.topology; + +import org.apache.commons.lang3.RandomStringUtils; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class Application implements SubscribableBehavior { + + // Unique id for the Application, defined in Application Definition + private String id; + // Key used for authentication (with metadata service, etc.) + private String key; + // Dependency Order + private DependencyOrder dependencyOrder; + // Group Map, key = Group.name + private Map groupMap; + // Cluster Id map, key = service name + private Map clusterIdMap; + + public Application (String id) { + this.id = id; + this.key = RandomStringUtils.randomAlphanumeric(16); + groupMap = new HashMap(); + clusterIdMap = new HashMap(); + } + + @Override + public void addGroup(Group group) { + groupMap.put(group.getName(), group); + } + + @Override + public Group getGroup(String groupName) { + return groupMap.get(groupName); + } + + @Override + public Collection getGroups() { + return groupMap.values(); + } + + @Override + public void setDependencyOrder(DependencyOrder dependencyOrder) { + this.dependencyOrder = dependencyOrder; + } + + @Override + public DependencyOrder getDependencyOrder() { + return dependencyOrder; + } + + @Override + public void addClusterId(String serviceName, String clusterId) { + clusterIdMap.put(serviceName, clusterId); + } + + @Override + public String getClusterId(String serviceName) { + return clusterIdMap.get(serviceName); + } + + @Override + public Collection getClusterIds() { + return clusterIdMap.values(); + } + + public String getId() { + return id; + } + + public String getKey() { + return key; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java index a51fcdbf59..b13c588bb7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cartridge.java @@ -12,7 +12,7 @@ public class Cartridge implements Subscribable, Scalable { private String cartridgeId; private Dependencies dependencies; private Subscribable parent; - private Group homeGroup; + private GroupTemp homeGroupTemp; private Cluster cluster; private static final Log log = LogFactory.getLog(Cartridge.class); @@ -40,12 +40,12 @@ public Subscribable getParent() { return parent; } - public Group getHomeGroup() { - return homeGroup; + public GroupTemp getHomeGroup() { + return homeGroupTemp; } - public void setHomeGroup(Group homeGroup) { - this.homeGroup = homeGroup; + public void setHomeGroup(GroupTemp homeGroupTemp) { + this.homeGroupTemp = homeGroupTemp; } public void setParent(Subscribable parent) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java index d336a0b369..90e878780b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/CompositeApplication.java @@ -35,8 +35,8 @@ public class CompositeApplication implements Serializable { private static final long serialVersionUID = -1L; // Key: Service.serviceName private String alias; - private Group top_level; - private Map all_groups = null; + private GroupTemp top_level; + private Map all_groups = null; private List clusterIds; private static final Log log = LogFactory.getLog(CompositeApplication.class); @@ -63,21 +63,21 @@ public void setTop_level(Group top_level) { } */ - public Map getAll_groups() { + public Map getAll_groups() { return all_groups; } - public void setAll_groups(Map all_groups) { + public void setAll_groups(Map all_groups) { this.all_groups = all_groups; } - public List findAllGroupsForServiceType(String serviceType) { + public List findAllGroupsForServiceType(String serviceType) { Set group_names = this.all_groups.keySet(); - List found_groups = new ArrayList(); + List found_groups = new ArrayList(); for (String group_name: group_names) { - Group gr = this.all_groups.get(group_name); + GroupTemp gr = this.all_groups.get(group_name); Subscribable sub = gr.getSubscribable(serviceType); if (sub != null) { found_groups.add(gr); @@ -87,7 +87,7 @@ public List findAllGroupsForServiceType(String serviceType) { return found_groups; } - public Group getGroupFromGroupAlias(String alias) { + public GroupTemp getGroupFromGroupAlias(String alias) { return this.all_groups.get(alias); } @@ -260,7 +260,7 @@ public String extractAliasFromClusterId (String clusterId) { return arrayAll; } */ - public Map getAllInPathOfAsMap(String aServiceId, Group home_group) { + public Map getAllInPathOfAsMap(String aServiceId, GroupTemp home_group) { // check kill_all_enabled flag Map upstreamDependencies = home_group.getUpstreamDependenciesAsMap(aServiceId); Map downstreamDependencies = home_group.getDownStreamDependenciesAsMap(aServiceId); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java index 7e97143434..bef7f0e832 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Dependencies.java @@ -20,7 +20,7 @@ public class Dependencies implements Serializable{ private Map> dependencies = new HashMap>(); private String kill_behavior = KILL_UNDEFINED; private boolean isKillAllEnabled = false; - private Group group; + private GroupTemp groupTemp; private static final Log log = LogFactory.getLog(Dependencies.class); public static String KILL_NONE = "kill-none"; public static String KILL_ALL = "kill-all"; @@ -207,7 +207,7 @@ public List getUpstreamDependents (String alias) { for (String key : keys) { if (log.isDebugEnabled()) { log.debug("looping over dependency list with key:" + key + " for alias " + alias + - " in group " + this.getGroup().getAlias()); + " in group " + this.getGroupTemp().getAlias()); } List my_dep = dependencies.get(key); if (my_dep != null) { @@ -217,7 +217,7 @@ public List getUpstreamDependents (String alias) { if (alias.equals(obj.getAlias())) { //results.add(obj); // adding "key" - Subscribable key_upstreamdep = this.group.getSubscribable(key); + Subscribable key_upstreamdep = this.groupTemp.getSubscribable(key); if (log.isDebugEnabled()) { log.debug("adding subscribalbe " + key_upstreamdep.getAlias() + " to upstream dependency list"); } @@ -238,17 +238,17 @@ public List getUpstreamDependents (String alias) { } } // get upstream subscribables which have group as dependency - Subscribable parent = group.getParent(); - if (parent instanceof Group) { - Group gr = (Group)parent; - List results2 = gr.getUpstreamDependencies(this.group); + Subscribable parent = groupTemp.getParent(); + if (parent instanceof GroupTemp) { + GroupTemp gr = (GroupTemp)parent; + List results2 = gr.getUpstreamDependencies(this.groupTemp); for (Subscribable s : results2) { if (!results.contains(s)) { results.add(s); } } if (log.isDebugEnabled()) { - log.debug("added " + results2.size() + " elements as subsequent upstream dependencies for " + this.group.getAlias() + + log.debug("added " + results2.size() + " elements as subsequent upstream dependencies for " + this.groupTemp.getAlias() + " as dependency for " + alias); } @@ -299,12 +299,12 @@ public List getAllDependencies() { return results; } */ - public Group getGroup() { - return group; + public GroupTemp getGroupTemp() { + return groupTemp; } - public void setGroup(Group group) { - this.group = group; + public void setGroupTemp(GroupTemp groupTemp) { + this.groupTemp = groupTemp; } public String toString() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java new file mode 100644 index 0000000000..b25b7adbf0 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.domain.topology; + +import java.util.HashSet; +import java.util.Set; + +public class DependencyOrder { + + private Set startupOrders; + + private String killbehavior; + + public DependencyOrder () { + this.startupOrders = new HashSet(); + } + + public Set getStartupOrders() { + return startupOrders; + } + + public void addStartupOrders(StartupOrder startupOrder) { + this.startupOrders.add(startupOrder); + } + + public String getKillbehavior() { + return killbehavior; + } + + public void setKillbehavior(String killbehavior) { + this.killbehavior = killbehavior; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index fd76bfb795..66cdb667bd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -1,503 +1,93 @@ +/* + * 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.messaging.domain.topology; -import java.io.Serializable; -import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; -import java.util.List; import java.util.Map; -import java.util.Set; - -import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.Log; - -public class Group implements Subscribable,Composite, Serializable { - - /** - * - */ - private static final long serialVersionUID = 1L; - private String alias; - private Map subscribables = new HashMap(); - private Dependencies dependencies; - private Subscribable parent = null; - private Group homeGroup; - private static final Log log = LogFactory.getLog(Group.class); - - public Group(String alias) { - this.alias = alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public String getAlias() { - return alias; - } - - public Map getSubscribables() { - return subscribables; - } - - public Subscribable getSubscribable(String alias) { - return subscribables.get(alias); - } - - public Subscribable getParent() { - return parent; - } - - public Group getHomeGroup() { - return homeGroup; - } - - public void setHomeGroup(Group homeGroup) { - this.homeGroup = homeGroup; - } - - public void setParent(Subscribable parent) { - this.parent = parent; - } - - public String getKillBehaviorForAlias(String alias) { - if (this.dependencies != null) { - return this.dependencies.getKill_behavior_for_alias(alias); - } else { - return Dependencies.KILL_UNDEFINED; - } - } - - public String findKillBehavior(String alias) { - - List all_groups = getAllGroups(); - String kill_behavior = Dependencies.KILL_UNDEFINED; - - if (log.isDebugEnabled()) { - log.debug("searching kill behavior for " + alias + " in group " + this.alias); - } - - for (Group group : all_groups) { - kill_behavior = group.getKillBehaviorForAlias(alias); - if (Dependencies.KILL_UNDEFINED.equals(kill_behavior)) { - if (log.isDebugEnabled()) { - log.debug("kill behavior for " + alias + " in group " + this.alias + " is undefined"); - } - } else { - if (log.isDebugEnabled()) { - log.debug("found kill behavior for " + alias + " in group " + this.alias); - } - return group.getKillBehaviorForAlias(alias); - } - } - return dependencies.getKill_behavior(); - } - - public List getAllGroups () { - List results = new ArrayList(); - // adding the group to list - results.add(this); - Set keys = subscribables.keySet(); - if (log.isDebugEnabled()) { - log.debug("adding all nested groups to result list with number of keys " + keys.size() + " in group " + this.alias); - } - - Iterator keyit = keys.iterator(); - - while (keyit.hasNext()) { - String key = keyit.next(); - Object obj = subscribables.get(key); - if (!(obj instanceof Group)) { - if (log.isDebugEnabled()) { - log.debug("skipping non composite obj " + obj); - } - - } else { - - Group group = (Group) obj; - if (log.isDebugEnabled()) { - log.debug("adding nested groups / composite to result list " + group.getAlias()); - } - List sub_results = group.getAllGroups(); - results.addAll(sub_results); - } - } - - return results; - } - - public Dependencies findDependencies(String alias) { - Group gr = findGroup(alias); - if (gr !=null) { - return gr.dependencies; - } - return null; - } - - public Group findGroup(String alias) { - List all_groups = getAllGroups(); - for (Group group : all_groups) { - if (log.isDebugEnabled()) { - log.debug("findGroup in group " + group.getAlias() + " for alias " + alias); - } - if (group.subscribables.containsKey(alias)) { - return group; - } else { - // does it need to be checked ? - } - } - - return null; - } - - // returns all groups which equal the kill_behavior as parameter - public String [] findAllGroupsWithKill(String [] aliases, String kill_behavior) { - List results = new ArrayList(); - for (String alias : aliases) { - Group gr = findGroup(alias); - // no null check, shouldn't be null - if (gr != null) { - Dependencies dep = gr.getDependencies(); - if (dep != null) { - if (kill_behavior.equals(dep.getKill_behavior())) { - results.add(gr.getAlias()); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("no group found for alias " + alias); - } - } - } - String [] arr = new String[results.size()]; - arr = results.toArray(arr); - return arr; - } - - public String [] findAllGroupsWithKill2(Map aliasesMap, String kill_behavior) { - List results = new ArrayList(); - Set aliases = aliasesMap.keySet(); - for (String alias : aliases) { - Group gr = findGroup(alias); - // no null check, shouldn't be null - if (gr != null) { - Dependencies dep = gr.getDependencies(); - if (dep != null) { - if (kill_behavior.equals(dep.getKill_behavior())) { - results.add(gr.getAlias()); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("no group found for alias " + alias); - } - } - } - String [] arr = new String[results.size()]; - arr = results.toArray(arr); - return arr; - } - - - public Dependencies getDependencies() { - return dependencies; - } - - public List getAllDependencies() { - List results = new ArrayList(); - - if (log.isDebugEnabled()) { - log.debug("adding all nested subscribables to result list in subscribable " + this.alias); - } - - Set keys = subscribables.keySet(); - if (log.isDebugEnabled()) { - log.debug("adding all nested dependencies to result list with number of keys " + keys.size()); - } - - Iterator keyit = keys.iterator(); - - while (keyit.hasNext()) { - String key = keyit.next(); - Subscribable obj = subscribables.get(key); - if (obj instanceof Scalable) { - if (log.isDebugEnabled()) { - log.debug("adding scalable / cartridge " + obj.getAlias() + " to result list"); - } - results.add(obj); - } else { - if (log.isDebugEnabled()) { - log.debug("adding nested dependencies to result list"); - } - List sub_results = obj.getAllDependencies(); - results.addAll(sub_results); - } - } - if (log.isDebugEnabled()) { - log.debug("returning " + results.size() + " subscribables while getting all dependent subscribables "); - } - return results; - } - - public String [] getDownStreamDependenciesAsArray (String alias) { - if (log.isDebugEnabled()) { - log.debug("getting dependencies from group :" + this.getAlias()); - } - - String [] dependenciesAliasArray = null; - List results = null; - - if (log.isDebugEnabled()) { - log.debug("getting selected dependencies from group : " + alias); - } - Dependencies group_deps = this.getDependencies(); - results = group_deps.getDownStreamDependents(alias); - dependenciesAliasArray = new String [results.size()]; - for (int i = 0; i < results.size(); i++ ) { - Subscribable s = results.get(i); - dependenciesAliasArray[i] = s.getAlias(); - if (log.isDebugEnabled()) { - log.debug("adding " + s.getAlias() + " to dependency array"); - } - } - - if (log.isDebugEnabled()) { - log.debug("returning dependencies for subscribale : " + alias); - } - return dependenciesAliasArray; - } - - public Map getDownStreamDependenciesAsMap (String alias) { - if (log.isDebugEnabled()) { - log.debug("getting dependencies from group :" + this.getAlias()); - } - - Map dependencies_map= null; - List results = null; - - if (log.isDebugEnabled()) { - log.debug("getting selected dependencies from group : " + alias); - } - Dependencies group_deps = this.getDependencies(); - results = group_deps.getDownStreamDependents(alias); - dependencies_map = new HashMap(results.size()); - for (int i = 0; i < results.size(); i++ ) { - Subscribable s = results.get(i); - - Group gr = s.getHomeGroup(); // TODO - need to change return type to Group - String gr_alias = null; - if (gr != null) { - gr_alias = gr.getAlias(); - } else { - if (log.isDebugEnabled()) { - log.debug("home group is null for subscribable " + s.getAlias()); - } - } - dependencies_map.put(s.getAlias(), gr_alias); - if (log.isDebugEnabled()) { - log.debug("adding " + s.getAlias() + " in group " + gr_alias + " to downstream dependency map "); - } - - } - - if (log.isDebugEnabled()) { - log.debug("returning dependencies for subscribale : " + alias); - } - return dependencies_map; - } - - public String [] getUpstreamDependenciesAsArray (String alias) { - String [] dependenciesAliasArray = new String[0]; - if (log.isDebugEnabled()) { - log.debug("searching home group for : " + alias); - } - Group gr = this; - Subscribable sub = gr.getSubscribable(alias); - if (log.isDebugEnabled()) { - log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); - } - //List results = gr.getUpstreamDependencies(sub); - List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); - if (log.isDebugEnabled()) { - log.debug("home group upstream result for : " + alias + " is " + results.size()); - } - dependenciesAliasArray = new String [results.size()]; - for (int i = 0; i < results.size(); i++) { - Subscribable item = results.get(i); - if (item != null) { - dependenciesAliasArray[i] = item.getAlias(); - } else { - if (log.isDebugEnabled()) { - log.debug("dependenciesAliasArray in getUpstreamDependencies has null value"); - dependenciesAliasArray[i] = null; - } - } - } - return dependenciesAliasArray; - } - - public Map getUpstreamDependenciesAsMap (String alias) { - if (log.isDebugEnabled()) { - log.debug("searching home group for : " + alias); - } - Group gr = this; - Map dependencies_map = null; - Subscribable sub = gr.getSubscribable(alias); - if (log.isDebugEnabled()) { - log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); - } - - List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); - if (log.isDebugEnabled()) { - log.debug("home group upstream result for : " + alias + " is " + results.size()); - } - dependencies_map = new HashMap(results.size()); - for (int i = 0; i < results.size(); i++) { - Subscribable s = results.get(i); - if (s != null) { - Group home_gr = s.getHomeGroup(); // TODO - need to change return type to Group - String key = null; - String val = null; - if (home_gr != null) { - key = s.getAlias(); - val = home_gr.getAlias(); - if (log.isDebugEnabled()) { - log.debug("adding " + key + " in group " + val + " to upstream dependency map "); - } - dependencies_map.put(key, val); - } - - } else { - if (log.isDebugEnabled()) { - log.debug("dependenciesAliasMap in getUpstreamDependencies has null value"); - } - } - - - } - return dependencies_map; - } - - public List getUpstreamDependencies(Subscribable subscribable) { - List upstream = new ArrayList(); - Subscribable parentSubscribable = this.getParent(); - if (log.isDebugEnabled()) { - log.debug("getting upstream dependencies for " + subscribable.getAlias() + " in group " + this.alias); - } - if (subscribable instanceof Scalable) { - // this would be typically where the upstream search starts - if (log.isDebugEnabled()) { - log.debug("subscribable is cartridge with alias " + subscribable.getAlias() + " in group " + this.alias); - } - if (parent == null) { - if (log.isDebugEnabled()) { - log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); - } - return upstream; - } else if (parent instanceof Group) { - - Group parentGroup = (Group) parentSubscribable; - if (log.isDebugEnabled()) { - log.debug("continue upstream search in parent group " + parentGroup.alias + " for " + alias ); - } - // continue with group alias as dependency alias (dependent would be group) - List list = parentGroup.getUpstreamDependencies(this); - if (log.isDebugEnabled()) { - log.debug("found " + list.size() + " items in upstream search in parent group " + parentGroup.alias + " for " + alias ); - } - upstream.addAll(list); - } - } else if (subscribable instanceof Group) { - // get local dependencies - if (log.isDebugEnabled()) { - log.debug(subscribable.getAlias() + " is a group, checking in dependencies list of this group " + this.alias + " for " + alias ); - } - List listlocal = dependencies.getUpstreamDependents(subscribable.getAlias()); - if (log.isDebugEnabled()) { - log.debug("found " + listlocal.size() + " items in upstream search in group " + this.alias + " for " + alias ); - } - // add local cartridges which depend on the group - upstream.addAll(listlocal); - // continue upstream with parent of this group - Subscribable parent = this.getParent(); - if (parent == null) { - if (log.isDebugEnabled()) { - log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); - } - return upstream; - } else if (parent instanceof Group) { - if (log.isDebugEnabled()) { - log.debug("continue upstream search in parent group " + parent.getAlias() + " for " + alias ); - } - // continue with group alias as dependency alias (dependent would be group) - List list = ((Group) parent).getUpstreamDependencies(this); - if (log.isDebugEnabled()) { - log.debug("found " + list.size() + " items in upstream search in parent group " + parent.getAlias() + " for " + alias ); - } - // merge upstream dependencies and local dependencies - upstream.addAll(list); - } - - } - return upstream; - } - - public void setDependencies(Dependencies dependencies) { - this.dependencies = dependencies; - } - - - - - - @Override - public void subscribe() { - // TODO Auto-generated method stub - log.debug("subscribing to group: " + alias); - - Iterator it = subscribables.keySet().iterator(); - - while (it.hasNext()) { - String key = it.next(); - Subscribable subscribable = subscribables.get(key); - subscribable.subscribe(); - } - - } - - @Override - public void unsubscribe() { - // TODO Auto-generated method stub - - } - - @Override - public void add(Subscribable subscribale) { - // TODO Auto-generated method stub - if (log.isDebugEnabled()) { - log.debug("building the group, adding subscribable " + subscribale.getAlias() + " to group " + this.getAlias()); - } - subscribables.put(subscribale.getAlias(), subscribale); - } - - @Override - public void remove(Subscribable subscribale) { - // TODO Auto-generated method stub - subscribables.remove(subscribale.getAlias()); - } - - public String toString() { - StringBuffer buf = new StringBuffer(); - Iterator it = subscribables.keySet().iterator(); - - while (it.hasNext()) { - String key = it.next(); - Subscribable subscribable = subscribables.get(key); - buf.append("subscribable: " + subscribable.toString()); - - } - return buf.toString(); - } - +public class Group implements SubscribableBehavior { + + // Name of the Group, specified in Group Definition + private String name; + // Group alias + private String alias; + // Dependency Order + private DependencyOrder dependencyOrder; + // Sub Group Map, key = Group.name + private Map groupMap; + // Cluster Id map, key = service name + private Map clusterIdMap; + + public Group (String name, String alias) { + this.name = name; + this.alias = alias; + groupMap = new HashMap(); + clusterIdMap = new HashMap(); + } + + @Override + public void addGroup(Group group) { + groupMap.put(group.name, group); + } + + @Override + public Group getGroup(String groupName) { + return groupMap.get(groupName); + } + + @Override + public Collection getGroups() { + return groupMap.values(); + } + + @Override + public void setDependencyOrder(DependencyOrder dependencyOrder) { + this.dependencyOrder = dependencyOrder; + } + + @Override + public DependencyOrder getDependencyOrder() { + return dependencyOrder; + } + + @Override + public void addClusterId(String serviceName, String clusterId) { + clusterIdMap.put(serviceName, clusterId); + } + + @Override + public String getClusterId(String serviceName) { + return clusterIdMap.get(serviceName); + } + + @Override + public Collection getClusterIds() { + return clusterIdMap.values(); + } + + public String getName() { + return name; + } + + public String getAlias() { + return alias; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupTemp.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupTemp.java new file mode 100644 index 0000000000..36adae6d91 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupTemp.java @@ -0,0 +1,503 @@ +package org.apache.stratos.messaging.domain.topology; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; + +public class GroupTemp implements Subscribable,Composite, Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + private String alias; + private Map subscribables = new HashMap(); + private Dependencies dependencies; + private Subscribable parent = null; + private GroupTemp homeGroupTemp; + private static final Log log = LogFactory.getLog(GroupTemp.class); + + public GroupTemp(String alias) { + this.alias = alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getAlias() { + return alias; + } + + public Map getSubscribables() { + return subscribables; + } + + public Subscribable getSubscribable(String alias) { + return subscribables.get(alias); + } + + public Subscribable getParent() { + return parent; + } + + public GroupTemp getHomeGroup() { + return homeGroupTemp; + } + + public void setHomeGroup(GroupTemp homeGroupTemp) { + this.homeGroupTemp = homeGroupTemp; + } + + public void setParent(Subscribable parent) { + this.parent = parent; + } + + public String getKillBehaviorForAlias(String alias) { + if (this.dependencies != null) { + return this.dependencies.getKill_behavior_for_alias(alias); + } else { + return Dependencies.KILL_UNDEFINED; + } + } + + public String findKillBehavior(String alias) { + + List all_groupTemps = getAllGroups(); + String kill_behavior = Dependencies.KILL_UNDEFINED; + + if (log.isDebugEnabled()) { + log.debug("searching kill behavior for " + alias + " in group " + this.alias); + } + + for (GroupTemp groupTemp : all_groupTemps) { + kill_behavior = groupTemp.getKillBehaviorForAlias(alias); + if (Dependencies.KILL_UNDEFINED.equals(kill_behavior)) { + if (log.isDebugEnabled()) { + log.debug("kill behavior for " + alias + " in group " + this.alias + " is undefined"); + } + } else { + if (log.isDebugEnabled()) { + log.debug("found kill behavior for " + alias + " in group " + this.alias); + } + return groupTemp.getKillBehaviorForAlias(alias); + } + } + return dependencies.getKill_behavior(); + } + + public List getAllGroups () { + List results = new ArrayList(); + // adding the group to list + results.add(this); + Set keys = subscribables.keySet(); + if (log.isDebugEnabled()) { + log.debug("adding all nested groups to result list with number of keys " + keys.size() + " in group " + this.alias); + } + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + Object obj = subscribables.get(key); + if (!(obj instanceof GroupTemp)) { + if (log.isDebugEnabled()) { + log.debug("skipping non composite obj " + obj); + } + + } else { + + GroupTemp groupTemp = (GroupTemp) obj; + if (log.isDebugEnabled()) { + log.debug("adding nested groups / composite to result list " + groupTemp.getAlias()); + } + List sub_results = groupTemp.getAllGroups(); + results.addAll(sub_results); + } + } + + return results; + } + + public Dependencies findDependencies(String alias) { + GroupTemp gr = findGroup(alias); + if (gr !=null) { + return gr.dependencies; + } + return null; + } + + public GroupTemp findGroup(String alias) { + List all_groupTemps = getAllGroups(); + for (GroupTemp groupTemp : all_groupTemps) { + if (log.isDebugEnabled()) { + log.debug("findGroup in group " + groupTemp.getAlias() + " for alias " + alias); + } + if (groupTemp.subscribables.containsKey(alias)) { + return groupTemp; + } else { + // does it need to be checked ? + } + } + + return null; + } + + // returns all groups which equal the kill_behavior as parameter + public String [] findAllGroupsWithKill(String [] aliases, String kill_behavior) { + List results = new ArrayList(); + for (String alias : aliases) { + GroupTemp gr = findGroup(alias); + // no null check, shouldn't be null + if (gr != null) { + Dependencies dep = gr.getDependencies(); + if (dep != null) { + if (kill_behavior.equals(dep.getKill_behavior())) { + results.add(gr.getAlias()); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("no group found for alias " + alias); + } + } + } + String [] arr = new String[results.size()]; + arr = results.toArray(arr); + return arr; + } + + public String [] findAllGroupsWithKill2(Map aliasesMap, String kill_behavior) { + List results = new ArrayList(); + Set aliases = aliasesMap.keySet(); + for (String alias : aliases) { + GroupTemp gr = findGroup(alias); + // no null check, shouldn't be null + if (gr != null) { + Dependencies dep = gr.getDependencies(); + if (dep != null) { + if (kill_behavior.equals(dep.getKill_behavior())) { + results.add(gr.getAlias()); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("no group found for alias " + alias); + } + } + } + String [] arr = new String[results.size()]; + arr = results.toArray(arr); + return arr; + } + + + public Dependencies getDependencies() { + return dependencies; + } + + public List getAllDependencies() { + List results = new ArrayList(); + + if (log.isDebugEnabled()) { + log.debug("adding all nested subscribables to result list in subscribable " + this.alias); + } + + Set keys = subscribables.keySet(); + if (log.isDebugEnabled()) { + log.debug("adding all nested dependencies to result list with number of keys " + keys.size()); + } + + Iterator keyit = keys.iterator(); + + while (keyit.hasNext()) { + String key = keyit.next(); + Subscribable obj = subscribables.get(key); + if (obj instanceof Scalable) { + if (log.isDebugEnabled()) { + log.debug("adding scalable / cartridge " + obj.getAlias() + " to result list"); + } + results.add(obj); + } else { + if (log.isDebugEnabled()) { + log.debug("adding nested dependencies to result list"); + } + List sub_results = obj.getAllDependencies(); + results.addAll(sub_results); + } + } + if (log.isDebugEnabled()) { + log.debug("returning " + results.size() + " subscribables while getting all dependent subscribables "); + } + return results; + } + + public String [] getDownStreamDependenciesAsArray (String alias) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.getAlias()); + } + + String [] dependenciesAliasArray = null; + List results = null; + + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.getDependencies(); + results = group_deps.getDownStreamDependents(alias); + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + dependenciesAliasArray[i] = s.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " to dependency array"); + } + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependenciesAliasArray; + } + + public Map getDownStreamDependenciesAsMap (String alias) { + if (log.isDebugEnabled()) { + log.debug("getting dependencies from group :" + this.getAlias()); + } + + Map dependencies_map= null; + List results = null; + + if (log.isDebugEnabled()) { + log.debug("getting selected dependencies from group : " + alias); + } + Dependencies group_deps = this.getDependencies(); + results = group_deps.getDownStreamDependents(alias); + dependencies_map = new HashMap(results.size()); + for (int i = 0; i < results.size(); i++ ) { + Subscribable s = results.get(i); + + GroupTemp gr = s.getHomeGroup(); // TODO - need to change return type to Group + String gr_alias = null; + if (gr != null) { + gr_alias = gr.getAlias(); + } else { + if (log.isDebugEnabled()) { + log.debug("home group is null for subscribable " + s.getAlias()); + } + } + dependencies_map.put(s.getAlias(), gr_alias); + if (log.isDebugEnabled()) { + log.debug("adding " + s.getAlias() + " in group " + gr_alias + " to downstream dependency map "); + } + + } + + if (log.isDebugEnabled()) { + log.debug("returning dependencies for subscribale : " + alias); + } + return dependencies_map; + } + + public String [] getUpstreamDependenciesAsArray (String alias) { + String [] dependenciesAliasArray = new String[0]; + if (log.isDebugEnabled()) { + log.debug("searching home group for : " + alias); + } + GroupTemp gr = this; + Subscribable sub = gr.getSubscribable(alias); + if (log.isDebugEnabled()) { + log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); + } + //List results = gr.getUpstreamDependencies(sub); + List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); + if (log.isDebugEnabled()) { + log.debug("home group upstream result for : " + alias + " is " + results.size()); + } + dependenciesAliasArray = new String [results.size()]; + for (int i = 0; i < results.size(); i++) { + Subscribable item = results.get(i); + if (item != null) { + dependenciesAliasArray[i] = item.getAlias(); + } else { + if (log.isDebugEnabled()) { + log.debug("dependenciesAliasArray in getUpstreamDependencies has null value"); + dependenciesAliasArray[i] = null; + } + } + } + return dependenciesAliasArray; + } + + public Map getUpstreamDependenciesAsMap (String alias) { + if (log.isDebugEnabled()) { + log.debug("searching home group for : " + alias); + } + GroupTemp gr = this; + Map dependencies_map = null; + Subscribable sub = gr.getSubscribable(alias); + if (log.isDebugEnabled()) { + log.debug("found home group for : " + alias + " , group is " + gr.getAlias() + " subscribable is " + sub); + } + + List results = gr.getDependencies().getUpstreamDependents(sub.getAlias()); + if (log.isDebugEnabled()) { + log.debug("home group upstream result for : " + alias + " is " + results.size()); + } + dependencies_map = new HashMap(results.size()); + for (int i = 0; i < results.size(); i++) { + Subscribable s = results.get(i); + if (s != null) { + GroupTemp home_gr = s.getHomeGroup(); // TODO - need to change return type to Group + String key = null; + String val = null; + if (home_gr != null) { + key = s.getAlias(); + val = home_gr.getAlias(); + if (log.isDebugEnabled()) { + log.debug("adding " + key + " in group " + val + " to upstream dependency map "); + } + dependencies_map.put(key, val); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("dependenciesAliasMap in getUpstreamDependencies has null value"); + } + } + + + } + return dependencies_map; + } + + public List getUpstreamDependencies(Subscribable subscribable) { + List upstream = new ArrayList(); + Subscribable parentSubscribable = this.getParent(); + if (log.isDebugEnabled()) { + log.debug("getting upstream dependencies for " + subscribable.getAlias() + " in group " + this.alias); + } + if (subscribable instanceof Scalable) { + // this would be typically where the upstream search starts + if (log.isDebugEnabled()) { + log.debug("subscribable is cartridge with alias " + subscribable.getAlias() + " in group " + this.alias); + } + if (parent == null) { + if (log.isDebugEnabled()) { + log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); + } + return upstream; + } else if (parent instanceof GroupTemp) { + + GroupTemp parentGroupTemp = (GroupTemp) parentSubscribable; + if (log.isDebugEnabled()) { + log.debug("continue upstream search in parent group " + parentGroupTemp.alias + " for " + alias ); + } + // continue with group alias as dependency alias (dependent would be group) + List list = parentGroupTemp.getUpstreamDependencies(this); + if (log.isDebugEnabled()) { + log.debug("found " + list.size() + " items in upstream search in parent group " + parentGroupTemp.alias + " for " + alias ); + } + upstream.addAll(list); + } + } else if (subscribable instanceof GroupTemp) { + // get local dependencies + if (log.isDebugEnabled()) { + log.debug(subscribable.getAlias() + " is a group, checking in dependencies list of this group " + this.alias + " for " + alias ); + } + List listlocal = dependencies.getUpstreamDependents(subscribable.getAlias()); + if (log.isDebugEnabled()) { + log.debug("found " + listlocal.size() + " items in upstream search in group " + this.alias + " for " + alias ); + } + // add local cartridges which depend on the group + upstream.addAll(listlocal); + // continue upstream with parent of this group + Subscribable parent = this.getParent(); + if (parent == null) { + if (log.isDebugEnabled()) { + log.debug("parent is null, stopping upstream search in group " + this.alias + " for " + alias ); + } + return upstream; + } else if (parent instanceof GroupTemp) { + if (log.isDebugEnabled()) { + log.debug("continue upstream search in parent group " + parent.getAlias() + " for " + alias ); + } + // continue with group alias as dependency alias (dependent would be group) + List list = ((GroupTemp) parent).getUpstreamDependencies(this); + if (log.isDebugEnabled()) { + log.debug("found " + list.size() + " items in upstream search in parent group " + parent.getAlias() + " for " + alias ); + } + // merge upstream dependencies and local dependencies + upstream.addAll(list); + } + + } + return upstream; + } + + public void setDependencies(Dependencies dependencies) { + this.dependencies = dependencies; + } + + + + + + @Override + public void subscribe() { + // TODO Auto-generated method stub + log.debug("subscribing to group: " + alias); + + Iterator it = subscribables.keySet().iterator(); + + while (it.hasNext()) { + String key = it.next(); + Subscribable subscribable = subscribables.get(key); + subscribable.subscribe(); + } + + } + + @Override + public void unsubscribe() { + // TODO Auto-generated method stub + + } + + @Override + public void add(Subscribable subscribale) { + // TODO Auto-generated method stub + if (log.isDebugEnabled()) { + log.debug("building the group, adding subscribable " + subscribale.getAlias() + " to group " + this.getAlias()); + } + subscribables.put(subscribale.getAlias(), subscribale); + } + + @Override + public void remove(Subscribable subscribale) { + // TODO Auto-generated method stub + subscribables.remove(subscribale.getAlias()); + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + Iterator it = subscribables.keySet().iterator(); + + while (it.hasNext()) { + String key = it.next(); + Subscribable subscribable = subscribables.get(key); + buf.append("subscribable: " + subscribable.toString()); + + } + return buf.toString(); + } + + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java new file mode 100644 index 0000000000..33a062550c --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java @@ -0,0 +1,40 @@ +/* + * 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.messaging.domain.topology; + +public class StartupOrder { + + private String start; + + private String after; + + public StartupOrder (String start, String after) { + this.start = start; + this.after = after; + } + + public String getStart() { + return start; + } + + public String getAfter() { + return after; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java index 4f0245f4b1..1c18b7a36e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Subscribable.java @@ -18,8 +18,8 @@ public interface Subscribable { public void unsubscribe(); - public void setHomeGroup(Group homeGroup); + public void setHomeGroup(GroupTemp homeGroupTemp); - public Group getHomeGroup(); + public GroupTemp getHomeGroup(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java new file mode 100644 index 0000000000..05e42d1652 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java @@ -0,0 +1,42 @@ +/* + * 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.messaging.domain.topology; + +import java.io.Serializable; +import java.util.Collection; + +public interface SubscribableBehavior extends Serializable { + + public void addGroup (Group group); + + public Group getGroup (String groupName); + + public Collection getGroups (); + + public void setDependencyOrder (DependencyOrder dependencyOrder); + + public DependencyOrder getDependencyOrder (); + + public void addClusterId (String serviceName, String clusterId); + + public String getClusterId (String serviceName); + + public Collection getClusterIds (); +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index ae0e112ee2..a27dd8ec45 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -39,6 +39,9 @@ public class Topology implements Serializable { //Grouping private Map compositeApplicationMap; private Map configCompositeApplicationMap; + // Key: Application.id + private Map applicationMap; + private boolean initialized; private static Log log = LogFactory.getLog(Topology.class); @@ -46,6 +49,23 @@ public Topology() { this.serviceMap = new HashMap(); this.compositeApplicationMap = new HashMap(); this.configCompositeApplicationMap = new HashMap(); + this.applicationMap = new HashMap(); + } + + public void addApplication (Application application) { + this.applicationMap.put(application.getId(), application); + } + + public Application getApplication (String applicationId) { + return applicationMap.get(applicationId); + } + + public Collection getApplications () { + return applicationMap.values(); + } + + public boolean applicationExists (String applicationId) { + return this.applicationMap.containsKey(applicationId); } public Collection getServices() { @@ -120,7 +140,7 @@ public void addConfigCompositeApplication(String alias, ConfigCompositeApplicati public void removeConfigCompositeApplication(String alias) { this.configCompositeApplicationMap.remove(alias); } - + public void removeAllCompositeApplication() { java.util.Set keys = this.compositeApplicationMap.keySet(); for (String key : keys) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java index 671b953dbd..e29fdbba83 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java @@ -10,7 +10,7 @@ public class CompositeApplicationBuilder { - private Map groups = null; + private Map groups = null; private Map cartridgesTypes = null; private List configGroupArray = null; @@ -40,7 +40,7 @@ public CompositeApplication buildCompositeApplication(Topology topology, String } setConfigConfiguration(configComplexApplication); - Group top_level = this.buildApplication(); + GroupTemp top_level = this.buildApplication(); if (top_level != null) { if (log.isDebugEnabled()) { log.debug("ServiceGroupContext:configComplexApplication toplevel is " + top_level.getAlias()); @@ -71,12 +71,12 @@ public CompositeApplication buildCompositeApplication(Topology topology, String - public Group buildApplication() { + public GroupTemp buildApplication() { for (ConfigGroup configGroup : configGroupArray) { log.debug("deploying group " + configGroup.getAlias()); - Group realGroup = new Group(configGroup.getAlias()); - groups.put(realGroup.getAlias(), realGroup); + GroupTemp realGroupTemp = new GroupTemp(configGroup.getAlias()); + groups.put(realGroupTemp.getAlias(), realGroupTemp); } @@ -90,29 +90,29 @@ public Group buildApplication() { // this should be done when reading the topology event in autoscaler log.debug("converting group configuration to groups and assembling application"); for (ConfigGroup configGroup : configGroupArray) { - Group assembleGroup = groups.get(configGroup.getAlias()); + GroupTemp assembleGroupTemp = groups.get(configGroup.getAlias()); Map groupCartridges = new HashMap(); - log.debug("converting configuration for group " + assembleGroup.getAlias()); + log.debug("converting configuration for group " + assembleGroupTemp.getAlias()); for (String key : configGroup.getSubscribables()) { - Group realgroup = groups.get(key); + GroupTemp realgroup = groups.get(key); if (realgroup != null) { // try cartridges - assembleGroup.add(realgroup); - realgroup.setParent(assembleGroup); - realgroup.setHomeGroup(assembleGroup); + assembleGroupTemp.add(realgroup); + realgroup.setParent(assembleGroupTemp); + realgroup.setHomeGroup(assembleGroupTemp); } else { Cartridge realcartridge_type = cartridgesTypes.get(key); if (realcartridge_type != null) { // create a copy of the cartridge type Cartridge groupCartridge = new Cartridge(realcartridge_type.getAlias()); - groupCartridge.setCartridgeId(getCartridgeId(assembleGroup.getAlias(), realcartridge_type.getAlias())); - assembleGroup.add(groupCartridge); - groupCartridge.setParent(assembleGroup); - groupCartridge.setHomeGroup(assembleGroup); // TODO need to consolidate parent / home group + groupCartridge.setCartridgeId(getCartridgeId(assembleGroupTemp.getAlias(), realcartridge_type.getAlias())); + assembleGroupTemp.add(groupCartridge); + groupCartridge.setParent(assembleGroupTemp); + groupCartridge.setHomeGroup(assembleGroupTemp); // TODO need to consolidate parent / home group groupCartridges.put(groupCartridge.getAlias(), groupCartridge); if (log.isDebugEnabled()) { log.debug("added new cartrdige of type " + groupCartridge.getAlias() + " and cartrdigeId " + groupCartridge.getCartridgeId() + - " to group " + assembleGroup.getAlias()); + " to group " + assembleGroupTemp.getAlias()); } } else { log.debug("Error: no group, cartridge found for alias: " + key); @@ -120,19 +120,19 @@ public Group buildApplication() { } } // build dependencies - log.debug("building dependencies for group " + assembleGroup.getAlias()); + log.debug("building dependencies for group " + assembleGroupTemp.getAlias()); Dependencies real_dependencies = buildDependency(configGroup, groups, groupCartridges); - assembleGroup.setDependencies(real_dependencies); - real_dependencies.setGroup(assembleGroup); + assembleGroupTemp.setDependencies(real_dependencies); + real_dependencies.setGroupTemp(assembleGroupTemp); } - Group application = getTopLevelGroup(); + GroupTemp application = getTopLevelGroup(); log.debug("top level group is: " + application.getAlias()); return application; } - public Group getTopLevelGroup () { + public GroupTemp getTopLevelGroup () { String alias = null; for (ConfigGroup configGroup : configGroupArray) { alias = configGroup.getAlias(); @@ -153,12 +153,12 @@ public Group getTopLevelGroup () { break; } } - Group application = groups.get(alias); + GroupTemp application = groups.get(alias); log.debug("top level group is: " + alias); return application; } - public Dependencies buildDependency(ConfigGroup configGroup, Map groups, Map groupCartridges) { + public Dependencies buildDependency(ConfigGroup configGroup, Map groups, Map groupCartridges) { // building dependencies ConfigDependencies config_dep = configGroup.getDependencies(); @@ -171,7 +171,7 @@ public Dependencies buildDependency(ConfigGroup configGroup, Map String key = pair.getKey(); String value = pair.getValue(); //check groups - Group gr = groups.get(value); + GroupTemp gr = groups.get(value); log.debug("checking dependency for key " + key + " /val: " + value + " in groups"); if (gr != null) { real_dependencies.addDependency(key, gr); @@ -202,7 +202,7 @@ public Dependencies buildDependency(ConfigGroup configGroup, Map } private void setConfigConfiguration(ConfigCompositeApplication configApp) { - this.groups = new HashMap(); + this.groups = new HashMap(); this.cartridgesTypes = new HashMap(); if (configApp.getComponents() != null) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java new file mode 100644 index 0000000000..b336d9ac46 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -0,0 +1,40 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.Application; + +public class ApplicationCreatedEvent extends TopologyEvent { + + private Application application; + + public ApplicationCreatedEvent (Application application) { + this.application = application; + } + + public Application getApplication() { + return application; + } + + public String toString() { + return "ApplicationCreatedEvent [app id= " + application.getId() + ", groups= " + application.getGroups() + ", clusters= " + + application.getClusterIds() + "]"; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java new file mode 100644 index 0000000000..c025fe6d5a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java @@ -0,0 +1,33 @@ +/* + * 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.messaging.event.topology; + +public class ApplicationRemovedEvent extends TopologyEvent { + + private String applicationId; + + public ApplicationRemovedEvent (String applicationId) { + this.applicationId = applicationId; + } + + public String getApplicationId() { + return applicationId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java index e7a62c9464..fe8a621cd0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/CompositeApplicationCreatedEvent.java @@ -22,7 +22,6 @@ import java.io.Serializable; import java.util.*; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java new file mode 100644 index 0000000000..bbc853f668 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ApplicationCreatedEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java new file mode 100644 index 0000000000..c3a1178ff5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ApplicationRemovedEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java new file mode 100644 index 0000000000..701807706b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -0,0 +1,88 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ApplicationCreatedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + + if (ApplicationCreatedEvent.class.getName().equals(type)) { + if (!topology.isInitialized()) { + return false; + } + + ApplicationCreatedEvent appCreatedEvent = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + if (appCreatedEvent == null) { + log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); + return false; + } + + // check if required properties are available + if (appCreatedEvent.getApplication() == null) { + String errorMsg = "Application object of application created event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (appCreatedEvent.getApplication().getId() == null || appCreatedEvent.getApplication().getId().isEmpty()) { + String errorMsg = "App id of application created event is invalid: [ " + appCreatedEvent.getApplication().getId() + " ]"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + if (topology.applicationExists(appCreatedEvent.getApplication().getId())) { + log.error("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); + return false; + } + + // add to Topology + topology.addApplication(appCreatedEvent.getApplication()); + notifyEventListeners(appCreatedEvent); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java new file mode 100644 index 0000000000..e16e84e229 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -0,0 +1,35 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.stratos.messaging.message.processor.MessageProcessor; + +public class ApplicationRemovedMessageProcessor extends MessageProcessor { + + @Override + public void setNext(MessageProcessor nextProcessor) { + //To change body of implemented methods use File | Settings | File Templates. + } + + @Override + public boolean process(String type, String message, Object object) { + return false; //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 029cdae276..135bdaedf2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -20,10 +20,7 @@ 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.Member; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -32,6 +29,7 @@ import org.apache.stratos.messaging.util.Util; import java.util.ArrayList; +import java.util.Collection; import java.util.List; public class CompleteTopologyMessageProcessor extends MessageProcessor { @@ -121,6 +119,21 @@ public boolean process(String type, String message, Object object) { } } + // add existing Applications to Topology + Collection applications = event.getTopology().getApplications(); + if (applications != null && !applications.isEmpty()) { + for (Application application : applications) { + topology.addApplication(application); + if (log.isDebugEnabled()) { + log.debug("Application with id [ " + application.getId() + " ] added to Topology"); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Application information found in Complete Topology event"); + } + } + if (log.isInfoEnabled()) { log.info("Topology initialized"); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index b19551c5ce..ca6afb415b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -45,8 +45,10 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor; private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; - private CompositeApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; - private CompositeApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; + private CompositeApplicationCreatedMessageProcessor compositeApplicationCreatedMessageProcessor; + private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; + private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; + private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; public void initialize() { // Add topology event processors @@ -89,14 +91,20 @@ public void initialize() { memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor(); add(memberTerminatedMessageProcessor); - applicationCreatedMessageProcessor = new CompositeApplicationCreatedMessageProcessor(); - add(applicationCreatedMessageProcessor); - - applicationRemovedMessageProcessor = new CompositeApplicationRemovedMessageProcessor(); - add(applicationRemovedMessageProcessor); - + applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); + add(applicationCreatedMessageProcessor); + + applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor(); + add(applicationRemovedMessageProcessor); + + compositeApplicationCreatedMessageProcessor = new CompositeApplicationCreatedMessageProcessor(); + add(applicationCreatedMessageProcessor); + + compositeApplicationRemovedMessageProcessor = new CompositeApplicationRemovedMessageProcessor(); + add(applicationRemovedMessageProcessor); + if (log.isDebugEnabled()) { - log.debug("Grouping: added applicationCreatedMessageProcessor, applicationRemovedMessageProcessor: " + + log.debug("Grouping: added applicationCreatedMessageProcessor, applicationRemovedMessageProcessor: " + applicationCreatedMessageProcessor + " / " + applicationRemovedMessageProcessor); } @@ -133,14 +141,18 @@ public void addEventListener(EventListener eventListener) { serviceRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof MemberMaintenanceListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationCreatedEventListener) { + applicationCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationRemovedEventListener) { + applicationRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof CompositeApplicationCreatedEventListener) { - applicationCreatedMessageProcessor.addEventListener(eventListener); + compositeApplicationCreatedMessageProcessor.addEventListener(eventListener); if (log.isDebugEnabled()) { log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); } } else if (eventListener instanceof CompositeApplicationRemovedEventListener) { - applicationRemovedMessageProcessor.addEventListener(eventListener); + compositeApplicationRemovedMessageProcessor.addEventListener(eventListener); if (log.isDebugEnabled()) { log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 758e5a12d0..b24f895534 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,18 +1,41 @@ - + CloudControllerService + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -22,89 +45,103 @@ - + - + - + - + - + + + + + + - + - - + + + - + - + - + - + - + - + - + - + + - + - + - + + + + + + + + - + - + @@ -115,218 +152,164 @@ - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -335,16 +318,40 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -359,16 +366,21 @@ - + - - - + + + + + + + + - + @@ -376,11 +388,11 @@ - + - - - + + + @@ -393,24 +405,25 @@ - + - - - - - - - - + + + + + + + + + - - + + @@ -421,14 +434,14 @@ - + - + @@ -437,34 +450,64 @@ - + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -517,6 +560,12 @@ + + + + + + @@ -591,6 +640,10 @@ + + + + @@ -657,18 +710,6 @@ - - - - - - - - - - - - @@ -681,6 +722,18 @@ + + + + + + + + + + + + @@ -705,6 +758,15 @@ + + + + + + + + + @@ -819,18 +881,6 @@ - - - - - - - - - - - - @@ -843,6 +893,18 @@ + + + + + + + + + + + + @@ -867,6 +929,15 @@ + + + + + + + + + @@ -972,12 +1043,6 @@ - - - - - - @@ -987,6 +1052,12 @@ + + + + + + @@ -1002,6 +1073,12 @@ + + + + + + @@ -1062,22 +1139,22 @@ - + - + - + - + - + - + \ No newline at end of file From e1b83c9ff631875c2155fafb91841b49772b1ffa Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 9 Sep 2014 18:02:59 -0700 Subject: [PATCH 043/436] initial changes for service group APIs in CC --- .../InvalidServiceGroupException.java | 46 ++++++ .../impl/CloudControllerServiceImpl.java | 58 ++++++++ .../interfaces/CloudControllerService.java | 5 + .../cloud/controller/pojo/Dependencies.java | 48 ++++++ .../cloud/controller/pojo/ServiceGroup.java | 69 +++++++++ .../cloud/controller/pojo/StartupOrder.java | 47 ++++++ .../runtime/FasterLookUpDataHolder.java | 34 +++++ .../client/CloudControllerServiceClient.java | 9 ++ .../deployer/DefaultServiceGroupDeployer.java | 140 ++++++++++++++---- .../bean/util/converter/PojoConverter.java | 9 ++ .../webapp/stratos/WEB-INF/schemas/schema.xsd | 25 ++++ .../resources/CloudControllerService.wsdl | 99 ++++++++++++- 12 files changed, 556 insertions(+), 33 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidServiceGroupException.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidServiceGroupException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidServiceGroupException.java new file mode 100644 index 0000000000..10b65dcf3a --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/InvalidServiceGroupException.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.cloud.controller.exception; + +public class InvalidServiceGroupException extends Exception { + + + private static final long serialVersionUID = 2651280146514042590L; + + private String message; + + public InvalidServiceGroupException(String msg) { + super(msg); + this.setMessage(msg); + } + + public InvalidServiceGroupException(String msg, Exception ex) { + super(msg, ex); + this.setMessage(msg); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 8471d87bfe..530e99f5df 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -272,6 +272,64 @@ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCart log.error(msg); throw new InvalidCartridgeTypeException(msg); } + + public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException { + + if (servicegroup == null) { + String msg = "Invalid ServiceGroup Definition: Definition is null."; + log.error(msg); + throw new IllegalArgumentException(msg); + + } + + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName()); + } + + Dependencies dependencies = servicegroup.getDependencies(); + + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); + } + + StartupOrder [] startupOrder = dependencies.getStartupOrder(); + + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder" + startupOrder); + + if (startupOrder != null) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrder.length); + } else { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); + } + } + + dataHolder.addServiceGroup(servicegroup); + + this.persist(); + + } + + public void undeployServiceGroup(String name) throws InvalidServiceGroupException { + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:undeployServiceGroup: " + name); + } + + ServiceGroup serviceGroup = null; + if((serviceGroup = dataHolder.getServiceGroup(name)) != null) { + if (dataHolder.getServiceGroups().remove(name)) { + persist(); + if(log.isInfoEnabled()) { + log.info("Successfully undeployed the Service Group definition: " + serviceGroup); + } + return; + } + } + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; + log.error(msg); + throw new InvalidServiceGroupException(msg); + + } @Override public MemberContext startInstance(MemberContext memberContext) throws diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 1ebcf236b6..9aa1fce321 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -20,6 +20,7 @@ import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; +import org.apache.stratos.cloud.controller.exception.InvalidServiceGroupException; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; @@ -46,6 +47,10 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) * @throws InvalidCartridgeTypeException if the cartridge type specified is not a deployed cartridge. */ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException; + + public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException; + + public void undeployServiceGroup(String name) throws InvalidServiceGroupException; /** * Validate a given {@link Partition} for basic property existence. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java new file mode 100644 index 0000000000..0177341375 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; +import java.util.List; + +public class Dependencies implements Serializable { + + private static final long serialVersionUID = 4187267350546153680L; + + private StartupOrder [] startupOrder; + + private String killBehaviour; + + public StartupOrder [] getStartupOrder() { + return startupOrder; + } + + public void setStartupOrder(StartupOrder [] startupOrder) { + this.startupOrder = startupOrder; + } + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java new file mode 100644 index 0000000000..45957f59cb --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; +import java.util.List; + +public class ServiceGroup implements Serializable { + + + private static final long serialVersionUID = -7413745300105885793L; + + private String name; + + private String [] subGroups; + + private String [] cartridges; + + private Dependencies dependencies; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String [] getSubGroups() { + return subGroups; + } + + public void setSubGroups(String [] subGroups) { + this.subGroups = subGroups; + } + + public String [] getCartridges() { + return cartridges; + } + + public void setCartridges(String [] cartridges) { + this.cartridges = cartridges; + } + + public Dependencies getDependencies() { + return dependencies; + } + + public void setDependencies(Dependencies dependencies) { + this.dependencies = dependencies; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java new file mode 100644 index 0000000000..0f1c64719d --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +import java.io.Serializable; + +public class StartupOrder implements Serializable { + + private static final long serialVersionUID = 280860334002791396L; + + 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; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java index 6024606634..e9e550a1f2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java @@ -83,6 +83,11 @@ public class FasterLookUpDataHolder implements Serializable{ */ private List cartridges; + /** + * List of deployed service groups + */ + private List serviceGroups; + private List configCompositeApplication; /** @@ -128,6 +133,7 @@ public static FasterLookUpDataHolder getInstance() { private FasterLookUpDataHolder() { cartridges = new ArrayList(); + serviceGroups = new ArrayList(); configCompositeApplication = new ArrayList(); } @@ -139,6 +145,14 @@ public List getCartridges() { public void setCartridges(List cartridges) { this.cartridges = cartridges; } + + public void setServiceGroups(List serviceGroups) { + this.serviceGroups = serviceGroups; + } + + public List getServiceGroups() { + return this.serviceGroups; + } public List getConfigCompositeApplication() { return configCompositeApplication; @@ -178,6 +192,26 @@ public void removeCartridges(List cartridges) { } + public ServiceGroup getServiceGroup(String name) { + for (ServiceGroup serviceGroup : serviceGroups) { + if (serviceGroup.getName().equals(name)) { + return serviceGroup; + } + } + + return null; + } + + public void addServiceGroup(ServiceGroup newServiceGroup) { + this.serviceGroups.add(newServiceGroup); + } + + public void removeServiceGroup(List serviceGroup) { + if (this.serviceGroups != null) { + this.serviceGroups.removeAll(serviceGroup); + } + } + public IaasProvider getIaasProvider(String type) { if(type == null) { return null; 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 1729d209c5..d08fca6c21 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 @@ -35,6 +35,7 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredClusterExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; import java.rmi.RemoteException; import java.util.Iterator; @@ -92,6 +93,14 @@ public void unDeployCartridgeDefinition (String cartridgeType) throws RemoteExce stub.undeployCartridgeDefinition(cartridgeType); } + + public void deployServiceGroup (ServiceGroup serviceGroup) throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + stub.deployServiceGroup(serviceGroup); + } + + public void undeployServiceGroup (String name)throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + stub.undeployServiceGroup(name); + } public boolean register(String clusterId, String cartridgeType, String payload, String tenantRange, 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 index 2fd3eee01c..0ed749aad6 100644 --- 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 @@ -22,45 +22,65 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +//import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; 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.PersistenceManagerException; import org.apache.stratos.manager.exception.ServiceGroupDefinitioException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; -import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; +import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; +import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup; +import org.apache.stratos.cloud.controller.stub.pojo.Dependencies; +import org.apache.stratos.cloud.controller.stub.pojo.StartupOrder; +import org.apache.stratos.cloud.controller.stub.*; import java.rmi.RemoteException; +import java.util.ArrayList; import java.util.List; public class DefaultServiceGroupDeployer implements ServiceGroupDeployer { private static Log log = LogFactory.getLog(DefaultServiceGroupDeployer.class); - private DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr; public DefaultServiceGroupDeployer () { - dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); } - public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) throws InvalidServiceGroupException, - CloudControllerServiceUnregisteredCartridgeExceptionException, ServiceGroupDefinitioException, ADCException { + public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) throws InvalidServiceGroupException, ServiceGroupDefinitioException, ADCException { - ServiceGroupDefinition serviceGroupDefinition = null; + 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 (serviceGroupDefinition == null) { - throw new InvalidServiceGroupException("Service Group definition not found"); - } - -// if any cartridges are specified in the group, they should be already deployed + // 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 cartridgeTypes = serviceGroupDefinition.getCartridges(); CloudControllerServiceClient ccServiceClient = null; @@ -76,50 +96,110 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro 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 (CloudControllerServiceUnregisteredCartridgeExceptionException e) { + throw new ADCException(e); } } } // if any sub groups are specified in the group, they should be already deployed if (serviceGroupDefinition.getSubGroups() != null) { + + if (log.isDebugEnabled()) { + log.debug("checking subGroups in service group " + serviceGroupDefinition.getName()); + } + List subGroupNames = serviceGroupDefinition.getSubGroups(); + for (String subGroupName : subGroupNames) { if (getServiceGroupDefinition(subGroupName) == null) { // sub group not deployed, can't continue - throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); + log.error("invalid sub group found in service group " + subGroupName); + //throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); } } } - try { - dataInsertionAndRetrievalMgr.peristServiceGroupDefinition(serviceGroupDefinition); + + CloudControllerServiceClient ccServiceClient = null; - } catch (PersistenceManagerException e) { - throw new InvalidServiceGroupException(e); + try { + ccServiceClient = CloudControllerServiceClient.getServiceClient(); + + if (log.isDebugEnabled()) { + log.debug("deplying to cloud controller service group " + serviceGroupDefinition.getName()); + } + + ccServiceClient.deployServiceGroup(serviceGroup); + + } catch (AxisFault axisFault) { + throw new ADCException(axisFault); + }catch (RemoteException e) { + throw new ADCException(e); + } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) { + throw new ADCException(e); } } - public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { - - try { - return dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupDefinitionName); + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) /*throws ServiceGroupDefinitioException */{ - } catch (PersistenceManagerException e) { - throw new ServiceGroupDefinitioException(e); + if (log.isDebugEnabled()) { + log.debug("getting service group from cloud controller " + serviceGroupDefinitionName); } + //throw new ServiceGroupDefinitioException("method not supported"); + return null; } public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { - try { - dataInsertionAndRetrievalMgr.removeServiceGroupDefinition(serviceGroupDefinitionName); - - } catch (PersistenceManagerException e) { - throw new ServiceGroupDefinitioException(e); - } + throw new ServiceGroupDefinitioException("method not supported"); + } + + private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) { + ServiceGroup servicegroup = new ServiceGroup(); + + // implement conversion (mostly List -> Array) + servicegroup.setName(serviceGroupDefinition.getName()); + List subGroupsDef = serviceGroupDefinition.getSubGroups(); + List cartridgesDef = serviceGroupDefinition.getCartridges(); + + if (subGroupsDef == null) { + subGroupsDef = new ArrayList(0); + } + + if (cartridgesDef == null) { + cartridgesDef = new ArrayList(0); + } + + String [] subGroups = new String[subGroupsDef.size()]; + String [] cartridges = new String[cartridgesDef.size()]; + + subGroups = subGroupsDef.toArray(subGroups); + cartridges = cartridgesDef.toArray(cartridges); + + servicegroup.setSubGroups(subGroups); + servicegroup.setCartridges(cartridges); + + DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies(); + List startDefs = depDefs.getStartupOrder(); + + Dependencies deps = new Dependencies(); + StartupOrder [] startups = new StartupOrder [startDefs.size()]; + for (int i = 0; i < startDefs.size(); i++) { + StartupOrderDefinition stDef = startDefs.get(i); + StartupOrder st = new StartupOrder(); + st.setStart(stDef.getStart()); + st.setAfter(stDef.getAfter()); + startups[i] = st; + } + deps.setStartupOrder(startups); + servicegroup.setDependencies(deps); + + return servicegroup; } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 974c34d113..354e9c98ce 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -23,6 +23,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.deploy.service.Service; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; @@ -90,6 +91,14 @@ public static CartridgeConfig populateCartridgeConfigPojo (CartridgeDefinitionBe return cartridgeConfig; } + + public static ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) { + ServiceGroup servicegroup = new ServiceGroup(); + + // implement conversion (mostly List -> Array) + + return servicegroup; + } private static LoadbalancerConfig getLBConfig(LoadBalancerBean loadBalancer) { LoadbalancerConfig lbConfig = new LoadbalancerConfig(); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd index 0de935f712..c384bae3c4 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd @@ -201,6 +201,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index b24f895534..929016b0a2 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -59,6 +59,10 @@ + + + + @@ -188,6 +192,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -406,7 +430,6 @@ - @@ -416,8 +439,6 @@ - - @@ -451,6 +472,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -554,6 +606,12 @@ + + + + + + @@ -605,6 +663,9 @@ + + + @@ -635,6 +696,10 @@ + + + + @@ -675,6 +740,10 @@ + + + + @@ -839,6 +908,15 @@ + + + + + + + + + @@ -1010,6 +1088,15 @@ + + + + + + + + + @@ -1130,6 +1217,12 @@ + + + + + + From bb45a5fc1d7a831e128b7231020b8effe05b9488 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 9 Sep 2014 19:16:40 -0700 Subject: [PATCH 044/436] regenerated CloudControllerService.wsdl --- .../resources/CloudControllerService.wsdl | 472 +++++++++--------- 1 file changed, 245 insertions(+), 227 deletions(-) diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 929016b0a2..6d403282d4 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -35,36 +35,37 @@ - + - + - + - + - + + - + @@ -74,13 +75,13 @@ - + - + @@ -92,53 +93,53 @@ - + - + - + - + + - + - + - + - - + - + - + - + - + - + - + @@ -149,133 +150,127 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - + - - - + - + - + - + - + - + - + - + - + - - - - - - + - + - + - + - + - + @@ -293,43 +288,50 @@ - + - + - + - + - + - + - + - + - + - + + + + + + + + - + @@ -342,6 +344,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -359,22 +413,15 @@ - + - - + - - - - - - - - + + @@ -390,21 +437,8 @@ - - - - - - - - - - - - - + - @@ -412,98 +446,67 @@ + - + - + - + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + - + - - - - - - - - + + + - + - - - - + + - + - - + + - + - - + + + + + @@ -511,43 +514,34 @@ - - + - + - - - - - + - - - - - - - - - - - + - - - + + + + + + + + + @@ -606,18 +600,18 @@ - - - - - - + + + + + + @@ -696,15 +690,15 @@ - - - - + + + + @@ -779,18 +773,6 @@ - - - - - - - - - - - - @@ -803,6 +785,18 @@ + + + + + + + + + + + + @@ -815,6 +809,15 @@ + + + + + + + + + @@ -959,18 +962,6 @@ - - - - - - - - - - - - @@ -983,6 +974,18 @@ + + + + + + + + + + + + @@ -995,6 +998,15 @@ + + + + + + + + + @@ -1130,6 +1142,12 @@ + + + + + + @@ -1139,14 +1157,14 @@ - - + + - - + + @@ -1232,22 +1250,22 @@ - + - + - + - + - + - + \ No newline at end of file From 8d6054273ea4853b91601ec5e5e9753d15c2ead6 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Wed, 10 Sep 2014 15:43:52 -0700 Subject: [PATCH 045/436] adding getServiceGroup CC API --- .../impl/CloudControllerServiceImpl.java | 32 +- .../interfaces/CloudControllerService.java | 9 +- .../client/CloudControllerServiceClient.java | 4 + .../deployer/DefaultServiceGroupDeployer.java | 90 ++- .../deployer/ServiceGroupDeployer.java | 4 +- .../manager/ServiceGroupingManager.java | 4 +- .../rest/endpoint/services/ServiceUtils.java | 8 +- .../resources/CloudControllerService.wsdl | 668 ++++++++++++------ 8 files changed, 582 insertions(+), 237 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 530e99f5df..534839ba84 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; + import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,8 +42,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; -import org.apache.stratos.cloud.controller.pojo.ConfigDependencies; -import org.apache.stratos.cloud.controller.pojo.ConfigGroup; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; @@ -330,6 +329,35 @@ public void undeployServiceGroup(String name) throws InvalidServiceGroupExceptio throw new InvalidServiceGroupException(msg); } + + @Override + public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupException { + + if(log.isDebugEnabled()) { + log.debug("getServiceGroupDefinition:" + name); + } + + ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); + + if (serviceGroup == null) { + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; + throw new InvalidServiceGroupException(msg); + } + + return serviceGroup; + } + + public String []getServiceGroupSubGroups (String name) throws InvalidServiceGroupException { + return null; + } + + public Dependencies getServiceGroupCartridges (String name) throws InvalidServiceGroupException { + return null; + } + + public Dependencies getServiceGroupDepenencies (String name) throws InvalidServiceGroupException { + return null; + } @Override public MemberContext startInstance(MemberContext memberContext) throws diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 9aa1fce321..53821dd7ad 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -20,7 +20,6 @@ import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; -import org.apache.stratos.cloud.controller.exception.InvalidServiceGroupException; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; @@ -51,6 +50,14 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException; public void undeployServiceGroup(String name) throws InvalidServiceGroupException; + + public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupException; + + public String []getServiceGroupSubGroups (String name) throws InvalidServiceGroupException; + + public Dependencies getServiceGroupCartridges (String name) throws InvalidServiceGroupException; + + public Dependencies getServiceGroupDepenencies (String name) throws InvalidServiceGroupException; /** * Validate a given {@link Partition} for basic property existence. 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 d08fca6c21..5c31ff99fe 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 @@ -101,6 +101,10 @@ public void deployServiceGroup (ServiceGroup serviceGroup) throws RemoteExceptio public void undeployServiceGroup (String name)throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { stub.undeployServiceGroup(name); } + + public ServiceGroup getServiceGroup(String name) throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + return stub.getServiceGroup(name); + } public boolean register(String clusterId, String cartridgeType, String payload, String tenantRange, 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 index 0ed749aad6..9a2ea184d0 100644 --- 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 @@ -22,7 +22,6 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -//import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.InvalidServiceGroupException; @@ -33,10 +32,12 @@ import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.pojo.Dependencies; import org.apache.stratos.cloud.controller.stub.pojo.StartupOrder; -import org.apache.stratos.cloud.controller.stub.*; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import java.rmi.RemoteException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; public class DefaultServiceGroupDeployer implements ServiceGroupDeployer { @@ -119,12 +120,13 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro for (String subGroupName : subGroupNames) { if (getServiceGroupDefinition(subGroupName) == null) { // sub group not deployed, can't continue - log.error("invalid sub group found in service group " + subGroupName); - //throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); + if (log.isDebugEnabled()) { + log.debug("invalid sub group found in service group " + subGroupName); + } + throw new InvalidServiceGroupException("No Service Group Definition found with name " + subGroupName); } } } - CloudControllerServiceClient ccServiceClient = null; @@ -146,20 +148,61 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro } } - public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) /*throws ServiceGroupDefinitioException */{ + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException { if (log.isDebugEnabled()) { log.debug("getting service group from cloud controller " + serviceGroupDefinitionName); } - //throw new ServiceGroupDefinitioException("method not supported"); - return null; + + CloudControllerServiceClient ccServiceClient = null; + + try { + ccServiceClient = CloudControllerServiceClient.getServiceClient(); + + if (log.isDebugEnabled()) { + log.debug("deploying to cloud controller service group " + serviceGroupDefinitionName); + } + + ServiceGroup serviceGroup = ccServiceClient.getServiceGroup(serviceGroupDefinitionName); + ServiceGroupDefinition serviceGroupDef = populateServiceGroupDefinitionPojo(serviceGroup); + return serviceGroupDef; + + } catch (AxisFault axisFault) { + throw new ADCException(axisFault); + } catch (RemoteException e) { + throw new ADCException(e); + } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) { + throw new ADCException(e); + } + } - public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { - throw new ServiceGroupDefinitioException("method not supported"); + public void undeployServiceGroupDefinition (String name) throws ADCException, ServiceGroupDefinitioException { + + //throw new ServiceGroupDefinitioException("method not supported"); + + CloudControllerServiceClient ccServiceClient = null; + + try { + ccServiceClient = CloudControllerServiceClient.getServiceClient(); + + if (log.isDebugEnabled()) { + log.debug("undeploying service group from cloud controller " + name); + } + + ccServiceClient.undeployServiceGroup(name); + + } catch (AxisFault axisFault) { + throw new ADCException(axisFault); + } catch (RemoteException e) { + throw new ADCException(e); + } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) { + throw new ADCException(e); + } } + private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) { ServiceGroup servicegroup = new ServiceGroup(); @@ -202,4 +245,31 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro return servicegroup; } + + private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup serviceGroup ) { + ServiceGroupDefinition servicegroupDef = new ServiceGroupDefinition(); + + String [] cartridges = serviceGroup.getCartridges(); + String [] subGroups = serviceGroup.getSubGroups(); + Dependencies deps = serviceGroup.getDependencies(); + StartupOrder [] startupOrders = deps.getStartupOrder(); + + List cartridgesDef = new ArrayList(Arrays.asList(cartridges)); + List subGroupsDef = new ArrayList(Arrays.asList(subGroups)); + DependencyDefinitions depsDef = new DependencyDefinitions(); + List startupsDef = new ArrayList(); + for (StartupOrder startupOrder : startupOrders) { + StartupOrderDefinition astartupDef = new StartupOrderDefinition(); + astartupDef.setAfter(startupOrder.getAfter()); + astartupDef.setStart(startupOrder.getStart()); + startupsDef.add(astartupDef); + } + depsDef.setStartupOrder(startupsDef); + depsDef.setKillBehaviour(deps.getKillBehaviour()); + servicegroupDef.setCartridges(cartridgesDef); + servicegroupDef.setSubGroups(subGroupsDef); + servicegroupDef.setDependencies(depsDef); + + return servicegroupDef; + } } 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 index da8ff531e1..1fc28e531c 100644 --- 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 @@ -30,7 +30,7 @@ public interface ServiceGroupDeployer { public void deployServiceGroupDefinition (Object serviceGroupObj) throws InvalidServiceGroupException, ServiceGroupDefinitioException, ADCException, CloudControllerServiceUnregisteredCartridgeExceptionException; - public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException; + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException, ADCException; - public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException; + public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException; } 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 index 3c42e01ce0..26096dd84d 100644 --- 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 @@ -45,12 +45,12 @@ public void deployServiceGroupDefinition (ServiceGroupDefinition serviceGroupDef serviceGroupDeployer.deployServiceGroupDefinition(serviceGroupDefinition); } - public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException { return serviceGroupDeployer.getServiceGroupDefinition(serviceGroupDefinitionName); } - public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ServiceGroupDefinitioException { + public void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws ADCException, ServiceGroupDefinitioException { serviceGroupDeployer.undeployServiceGroupDefinition(serviceGroupDefinitionName); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 5f6f7f5dbb..10d4865f0c 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -1491,7 +1491,9 @@ static ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefi } catch (ServiceGroupDefinitioException e) { throw new RestAPIException(e); - } + } catch (ADCException e) { + throw new RestAPIException(e); + } } static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) throws RestAPIException { @@ -1501,7 +1503,9 @@ static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) t } catch (ServiceGroupDefinitioException e) { throw new RestAPIException(e); - } + } catch (ADCException e) { + throw new RestAPIException(e); + } log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName); } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 6d403282d4..218d5d6e2e 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,13 +6,13 @@ - + - + @@ -25,52 +25,52 @@ - + - + - + - + - + - + - + - + - + - + @@ -81,11 +81,81 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -104,7 +174,7 @@ - + @@ -122,17 +192,10 @@ - - - - - - - - + @@ -160,7 +223,7 @@ - + @@ -171,141 +234,134 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + @@ -319,7 +375,7 @@ - + @@ -331,112 +387,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - - - - + + + + + + + @@ -446,12 +410,12 @@ - - + + - - - + + + @@ -466,16 +430,16 @@ - + - + - + @@ -485,16 +449,39 @@ + + + + + + + + + + + - + - + + + + + + + + + + + + + @@ -506,7 +493,7 @@ - + @@ -514,11 +501,11 @@ - + - - - + + + @@ -531,6 +518,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -539,24 +607,12 @@ - - + + - - - - - - - - - - - - @@ -576,6 +632,15 @@ + + + + + + + + + @@ -591,6 +656,18 @@ + + + + + + + + + + + + @@ -600,18 +677,15 @@ + + + - - - - - - @@ -651,6 +725,12 @@ + + + + + + @@ -675,6 +755,11 @@ + + + + + @@ -685,20 +770,30 @@ + + + + + + + + + + + + + + - - - - @@ -730,6 +825,11 @@ + + + + + @@ -773,6 +873,18 @@ + + + + + + + + + + + + @@ -797,6 +909,18 @@ + + + + + + + + + + + + @@ -809,11 +933,14 @@ - - + + + + + @@ -830,6 +957,15 @@ + + + + + + + + + @@ -902,6 +1038,18 @@ + + + + + + + + + + + + @@ -962,6 +1110,18 @@ + + + + + + + + + + + + @@ -986,6 +1146,18 @@ + + + + + + + + + + + + @@ -998,11 +1170,14 @@ - - + + + + + @@ -1019,6 +1194,15 @@ + + + + + + + + + @@ -1091,6 +1275,18 @@ + + + + + + + + + + + + @@ -1142,6 +1338,15 @@ + + + + + + + + + @@ -1157,17 +1362,29 @@ + + + + + + + + + - - + + + + + @@ -1178,6 +1395,12 @@ + + + + + + @@ -1226,6 +1449,15 @@ + + + + + + + + + From bdbe14e7e3a45e95b1d9077fd0c065939f046b4f Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 11 Sep 2014 12:28:23 -0700 Subject: [PATCH 046/436] fixing issues with ServiceGroup APIs --- .../cloud/controller/impl/CloudControllerServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 534839ba84..aa24cec3cd 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -93,6 +93,7 @@ private void acquireData() { currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); currentData.setCartridges(serializedObj.getCartridges()); currentData.setConfigCompositeApplication(serializedObj.getConfigCompositeApplication()); + currentData.setServiceGroups(serializedObj.getServiceGroups()); if(log.isDebugEnabled()) { @@ -340,6 +341,9 @@ public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupExce ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); if (serviceGroup == null) { + if(log.isDebugEnabled()) { + log.debug("getServiceGroupDefinition: no entry found for service group " + name); + } String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; throw new InvalidServiceGroupException(msg); } From 581412b1783b0f05daf9cdda6357c03ab2f37908 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 11 Sep 2014 14:15:50 -0700 Subject: [PATCH 047/436] adding validation for CompositeAppDefinition --- .../webapp/stratos/WEB-INF/schemas/schema.xsd | 71 ++++++++++++++++--- 1 file changed, 60 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd index c384bae3c4..0b78f88ca8 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd @@ -208,24 +208,73 @@ - + + + + + + + + + + + - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 66f92f794fc3a8ff3cc1a6ea93c044b7b54b2c9d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 15 Sep 2014 23:15:57 +0530 Subject: [PATCH 048/436] further changes to topoogy and app definition parsing. removed rest EP schema validation temporarily --- .../pom.xml | 2 + .../application/ApplicationUtils.java | 9 + .../application/ClusterInformation.java | 27 + .../application/MTClusterInformation.java | 45 ++ .../application/STClusterInformation.java | 55 ++ .../parser/DefaultApplicationParser.java | 520 ++++++++------ .../application/parser/ParserUtils.java | 43 ++ .../impl/CloudControllerServiceImpl.java | 9 +- .../interfaces/ApplicationParser.java | 3 +- .../pojo/ApplicationDataHolder.java | 48 ++ .../controller/pojo/ClusterDataHolder.java | 47 ++ .../controller/pojo/GroupDataHolder.java | 67 ++ .../pojo/application/ApplicationContext.java | 8 +- .../pojo/application/ComponentContext.java | 14 +- .../pojo/application/DependencyContext.java | 7 +- .../pojo/application/GroupContext.java | 14 +- .../pojo/application/StartupOrderContext.java | 4 + .../controller/topology/TopologyBuilder.java | 20 + .../topology/TopologyEventPublisher.java | 9 + .../client/CloudControllerServiceClient.java | 19 +- .../application/beans/GroupDefinition.java | 1 - .../deployer/DefaultServiceGroupDeployer.java | 71 +- .../domain/topology/Application.java | 11 + .../messaging/domain/topology/Cluster.java | 17 + .../domain/topology/DependencyOrder.java | 4 + .../messaging/domain/topology/Group.java | 50 +- .../domain/topology/SubscribableBehavior.java | 5 + .../bean/util/converter/PojoConverter.java | 128 ++++ .../rest/endpoint/services/ServiceUtils.java | 44 +- .../rest/endpoint/services/StratosAdmin.java | 2 +- .../webapp/stratos/WEB-INF/cxf-servlet.xml | 8 +- .../pom.xml | 7 +- .../pom.xml | 3 +- .../resources/CloudControllerService.wsdl | 665 +++++++++--------- 34 files changed, 1348 insertions(+), 638 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index ec808d1690..6a1ffee040 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -55,6 +55,7 @@ org.apache.stratos.cloud.controller.topology.*, org.apache.stratos.cloud.controller.iaases.*, org.apache.stratos.cloud.controller.pojo.*, + org.apache.stratos.cloud.controller.pojo.application.*, org.apache.stratos.cloud.controller.deployers.*, org.apache.stratos.cloud.controller.exception.*, @@ -64,6 +65,7 @@ !org.apache.stratos.cloud.controller.topic.*, !org.apache.stratos.cloud.controller.iaases.*, !org.apache.stratos.cloud.controller.pojo.*, + !org.apache.stratos.cloud.controller.pojo.application.*, !org.apache.stratos.cloud.controller.deployers.*, !org.apache.stratos.cloud.controller.exception.*, !org.apache.stratos.cloud.controller.topology.*, diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index ac7845386e..3cd3a0ef10 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -30,4 +30,13 @@ public static boolean isAliasValid (String alias) { return pattern.matcher(alias).matches(); } + + public static boolean isValid (String arg) { + + if (arg == null || arg.isEmpty()) { + return false; + } else { + return true; + } + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java new file mode 100644 index 0000000000..5fd6d571bc --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +public interface ClusterInformation { + + public String getClusterId (String alias, String cartridgeType); + + public String getHostName (String alias, String cartridgeDefinitionHostName); +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java new file mode 100644 index 0000000000..ef3b255590 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +public class MTClusterInformation implements ClusterInformation { + + @Override + public String getClusterId(String alias, String cartridgeType) { + + if (!ApplicationUtils.isValid(cartridgeType)) { + // cannot happen + throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); + } + + return cartridgeType + ".domain"; + } + + @Override + public String getHostName(String alias, String cartridgeDefinitionHostName) { + + if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { + // cannot happen + throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); + } + + return cartridgeDefinitionHostName; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java new file mode 100644 index 0000000000..c8c3d9b0a5 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +public class STClusterInformation implements ClusterInformation { + + @Override + public String getClusterId(String alias, String cartridgeType) { + + if (!ApplicationUtils.isValid(alias)) { + // cannot happen + throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); + } + + if (!ApplicationUtils.isValid(cartridgeType)) { + // cannot happen + throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); + } + + return alias + "." + cartridgeType + ".domain"; + } + + @Override + public String getHostName(String alias, String cartridgeDefinitionHostName) { + + if (!ApplicationUtils.isValid(alias)) { + // cannot happen + throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); + } + + if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { + // cannot happen + throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); + } + + return alias + "." + cartridgeDefinitionHostName; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index ef9432ffe8..80cf4aec42 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -19,19 +19,22 @@ package org.apache.stratos.cloud.controller.application.parser; -import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.application.ApplicationUtils; +import org.apache.stratos.cloud.controller.application.ClusterInformation; +import org.apache.stratos.cloud.controller.application.MTClusterInformation; +import org.apache.stratos.cloud.controller.application.STClusterInformation; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; -import org.apache.stratos.cloud.controller.pojo.application.GroupContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; -import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.cloud.controller.pojo.ApplicationDataHolder; +import org.apache.stratos.cloud.controller.pojo.Cartridge; +import org.apache.stratos.cloud.controller.pojo.ClusterDataHolder; +import org.apache.stratos.cloud.controller.pojo.ServiceGroup; +import org.apache.stratos.cloud.controller.pojo.application.*; +import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; +import org.apache.stratos.messaging.domain.topology.*; -import java.rmi.RemoteException; import java.util.*; public class DefaultApplicationParser implements ApplicationParser { @@ -39,7 +42,7 @@ public class DefaultApplicationParser implements ApplicationParser { private static Log log = LogFactory.getLog(DefaultApplicationParser.class); @Override - public Application parse(Object obj) throws ApplicationDefinitionException { + public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionException { ApplicationContext applicationCtxt = null; @@ -85,9 +88,7 @@ public Application parse(Object obj) throws ApplicationDefinitionException { throw new ApplicationDefinitionException("Invalid Composite Application Definition, no Subscribable Information specified"); } - //TODO - //return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); - return null; + return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); } private Map getDefinedGroups (ApplicationContext appCtxt) throws @@ -168,247 +169,316 @@ private Map getSubscribableInformation (Applica private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException { - //TODO - return true; + return FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName) != null; + } + + private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext appCtxt, + Map definedGroupCtxts, + Map subscribableInfoCtxts) + throws ApplicationDefinitionException { + + Application application = new Application(appCtxt.getApplicationId()); + // following keeps track of all Clusters created for this application + Set clusters = new HashSet(); + + if (appCtxt.getComponents() != null) { + // get top level Subscribables + if (appCtxt.getComponents().getSubscribableContexts() != null) { + ClusterDataHolder clusterDataHolder = getClusterInformation(Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); + application.setClusterIds(clusterDataHolder.getClusterIdMap()); + clusters.addAll(clusterDataHolder.getClusters()); + } + + // get Groups + if (appCtxt.getComponents().getGroupContexts() != null) { + application.setGroups(getGroupInfo(clusters, Arrays.asList(appCtxt.getComponents().getGroupContexts()), subscribableInfoCtxts, definedGroupCtxts)); + } + + // get top level Dependency definitions + if (appCtxt.getComponents().getDependencyContext() != null) { + DependencyOrder appDependencyOrder = new DependencyOrder(); + Set startupOrders = getStartupOrderForApplicationComponents(new HashSet(Arrays.asList(appCtxt.getComponents(). + getDependencyContext().getStartupOrderContext()))); + if (startupOrders != null) { + appDependencyOrder.setStartupOrders(startupOrders); + } + appDependencyOrder.setKillbehavior(appCtxt.getComponents().getDependencyContext().getKillBehaviour()); + + application.setDependencyOrder(appDependencyOrder); + } + } + + log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); + + ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); + applicationDataHolder.setClusters(clusters); + applicationDataHolder.setApplication(application); + + return applicationDataHolder; + } + + private Map getGroupInfo (Set clusters, List groupCtxts, + Map subscribableInformation, + Map definedGroupCtxts) + throws ApplicationDefinitionException { + + Map groupNameToGroup = new HashMap(); + + for (GroupContext groupCtxt : groupCtxts) { + Group group = getGroup(clusters, groupCtxt, subscribableInformation, definedGroupCtxts); + groupNameToGroup.put(group.getName(), group); + } + + //Set topLevelGroupContexts = getTopLevelGroupContexts(groupNameToGroup); + Set nestedGroups = new HashSet(); + getNestedGroupContexts(nestedGroups, groupNameToGroup.values()); + filterDuplicatedGroupContexts(groupNameToGroup.values(), nestedGroups); + + return groupNameToGroup; + } + + private void getNestedGroupContexts (Set nestedGroups, Collection groups) { + + if (groups != null) { + for (Group group : groups) { + if (group.getGroups() != null) { + nestedGroups.addAll(group.getGroups()); + getNestedGroupContexts(nestedGroups, group.getGroups()); + } + } + } + } + + private void filterDuplicatedGroupContexts (Collection topLevelGroups, Set nestedGroups) { + + for (Group nestedGroup : nestedGroups) { + filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup); + } + } + + private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Group nestedGroup) { + + Iterator parentIterator = topLevelGroups.iterator(); + while (parentIterator.hasNext()) { + Group parentGroup = parentIterator.next(); + // if there is an exactly similar nested Group Context and a top level Group Context + // it implies that they are duplicates. Should be removed from top level. + if (parentGroup.equals(nestedGroup)) { + parentIterator.remove(); + } + } + } + + private Group getGroup(Set clusters, GroupContext groupCtxt, Map subscribableInfoCtxts, + Map definedGroupCtxts) throws ApplicationDefinitionException { + + // check if are in the defined Group set + GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias()); + if (definedGroupDef == null) { + throw new ApplicationDefinitionException("Group Definition with name: " + groupCtxt.getName() + ", alias: " + + groupCtxt.getAlias() + " is not found in the all Group Definitions collection"); + } + + Group group = new Group(groupCtxt.getName(), groupCtxt.getAlias()); + + group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy()); + group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); + DependencyOrder dependencyOrder = new DependencyOrder(); + // create the Dependency Ordering + Set startupOrders = getStartupOrderForGroup(groupCtxt.getName()); + if (startupOrders != null) { + dependencyOrder.setStartupOrders(startupOrders); + } + dependencyOrder.setKillbehavior(getKillbehaviour(groupCtxt.getName())); + group.setDependencyOrder(dependencyOrder); + + ClusterDataHolder clusterDataHolder; + + // get group level Subscribables + if (groupCtxt.getSubscribableContexts() != null) { + clusterDataHolder = getClusterInformation(Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); + group.setClusterIds(clusterDataHolder.getClusterIdMap()); + clusters.addAll(clusterDataHolder.getClusters()); + } + + // get nested groups + if (groupCtxt.getGroupContexts() != null) { + Map nestedGroups = new HashMap(); + // check sub groups + for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) { + // get the complete Group Definition + subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); + Group nestedGroup = getGroup(clusters, subGroupCtxt, subscribableInfoCtxts, definedGroupCtxts); + nestedGroups.put(nestedGroup.getName(), nestedGroup); + } + + group.setGroups(nestedGroups); + } + + return group; + } + + private Set getStartupOrderForGroup(String serviceGroupName) throws ApplicationDefinitionException { + + ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); + + if (serviceGroup == null) { + throw new ApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + } + + if (serviceGroup.getDependencies() != null) { + if (serviceGroup.getDependencies().getStartupOrder() != null) { + return ParserUtils.convert(serviceGroup.getDependencies().getStartupOrder()); + } + } + + return null; + } + + private Set getStartupOrderForApplicationComponents (Set startupOrderCtxts) + throws ApplicationDefinitionException { + + if (startupOrderCtxts == null) { + return null; + } + + Set startupOrders = new HashSet(); + + for (StartupOrderContext startupOrderContext : startupOrderCtxts) { + startupOrders.add(new StartupOrder(startupOrderContext.getStart(), startupOrderContext.getAfter())); + } + + return startupOrders; + } + + private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException { + + ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); + + if (serviceGroup == null) { + throw new ApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + } + + if (serviceGroup.getDependencies() != null) { + return serviceGroup.getDependencies().getKillBehaviour(); + } + + return null; + } -// private Application buildCompositeAppStructure (ApplicationContext appCtxt, -// Map definedGroupCtxts, -// Map subscribableInfoCtxts) +// private Set getSubsribableContexts (List subscribableCtxts, +// Map subscribableInfoCtxts) // throws ApplicationDefinitionException { // -// Application application = new Application(appCtxt.getApplicationId()); -// -// if (appCtxt.getComponents() != null) { -// // get top level Subscribables -// if (appCtxt.getComponents().getSubscribableContexts() != null) { -// application.setSubscribableContexts(getSubsribableContexts(appCtxt.getComponents().getSubscribables(), -// subscribableInfoCtxts)); -// } -// -// // get Groups -// if (appCtxt.getComponents().getGroups() != null) { -// application.setGroupContexts(getGroupContexts(appCtxt.getComponents().getGroups(), -// subscribableInfoCtxts, definedGroupCtxts)); -// } -// -// // get top level Dependency definitions -// if (appCtxt.getComponents().getDependencies() != null) { -// application.setStartupOrder(getStartupOrderForApplicationComponents(appCtxt.getComponents(). -// getDependencies().getStartupOrder())); -// -// application.setKillBehaviour(appCtxt.getComponents().getDependencies().getKillBehaviour()); -// } -// } -// -// return application; -// } -// -// private Set getGroupContexts (List groupDefinitions, -// Map subscribableInformation, -// Map definedGroups) -// throws CompositeApplicationDefinitionException { -// -// Set groupContexts = new HashSet(); -// -// for (GroupDefinition group : groupDefinitions) { -// groupContexts.add(getGroupContext(group, subscribableInformation, definedGroups)); -// } -// -// //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); -// Set nestedGroupContexts = new HashSet(); -// getNestedGroupContexts(nestedGroupContexts, groupContexts); -// filterDuplicatedGroupContexts(groupContexts, nestedGroupContexts); -// -// return groupContexts; -// } -// -// private void getNestedGroupContexts (Set nestedGroupContexts, Set groupContexts) { -// -// if (groupContexts != null) { -// for (GroupContext groupContext : groupContexts) { -// if (groupContext.getGroupContexts() != null) { -// nestedGroupContexts.addAll(groupContext.getGroupContexts()); -// getNestedGroupContexts(nestedGroupContexts, groupContext.getGroupContexts()); -// } -// } -// } -// } -// -// private void filterDuplicatedGroupContexts (Set topLevelGroupContexts, Set nestedGroupContexts) { -// -// for (GroupContext nestedGropCtxt : nestedGroupContexts) { -// filterNestedGroupFromTopLevel(topLevelGroupContexts, nestedGropCtxt); -// } -// } -// -// private void filterNestedGroupFromTopLevel (Set topLevelGroupContexts, GroupContext nestedGroupCtxt) { -// -// Iterator parentIterator = topLevelGroupContexts.iterator(); -// while (parentIterator.hasNext()) { -// GroupContext parentGroupCtxt = parentIterator.next(); -// // if there is an exactly similar nested Group Context and a top level Group Context -// // it implies that they are duplicates. Should be removed from top level. -// if (parentGroupCtxt.equals(nestedGroupCtxt)) { -// parentIterator.remove(); -// } -// } -// } -// -// private GroupContext getGroupContext (GroupDefinition group, Map subscribableInformation, -// Map definedGroups) throws CompositeApplicationDefinitionException { -// -// // check if are in the defined Group set -// GroupDefinition definedGroupDef = definedGroups.get(group.getAlias()); -// if (definedGroupDef == null) { -// throw new CompositeApplicationDefinitionException("Group Definition with name: " + group.getName() + ", alias: " + -// group.getAlias() + " is not found in the all Group Definitions collection"); -// } -// -// GroupContext groupContext = new GroupContext(); -// -// groupContext.setName(group.getName()); -// groupContext.setAlias(group.getAlias()); -// groupContext.setAutoscalingPolicy(group.getAutoscalingPolicy()); -// groupContext.setDeploymentPolicy(group.getDeploymentPolicy()); -// groupContext.setStartupOrder(getStartupOrderForGroup(group.getName())); -// groupContext.setKillBehaviour(getKillbehaviour(group.getName())); -// -// // get group level Subscribables -// if (group.getSubscribables() != null) { -// groupContext.setSubscribableContexts(getSubsribableContexts(group.getSubscribables(), subscribableInformation)); -// } -// // get nested groups -// if (group.getSubGroups() != null) { -// Set nestedGroupContexts = new HashSet(); -// // check sub groups -// for (GroupDefinition subGroup : group.getSubGroups()) { -// // get the complete Group Definition -// subGroup = definedGroups.get(subGroup.getAlias()); -// nestedGroupContexts.add(getGroupContext(subGroup, subscribableInformation, definedGroups)); -// } -// -// groupContext.setGroupContexts(nestedGroupContexts); -// } -// -// return groupContext; -// } -// -// private Set getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { -// -// ServiceGroupDefinition groupDefinition; -// -// try { -// groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); -// -// } catch (PersistenceManagerException e) { -// throw new CompositeApplicationDefinitionException(e); -// } -// -// if (groupDefinition == null) { -// throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); -// } -// -// if (groupDefinition.getDependencies() != null) { -// if (groupDefinition.getDependencies().getStartupOrder() != null) { -// return ParserUtils.convert(groupDefinition.getDependencies().getStartupOrder()); -// } -// } -// -// return null; -// } -// -// private Set getStartupOrderForApplicationComponents (List startupOrderDefinitions) -// throws CompositeApplicationDefinitionException { -// -// if (startupOrderDefinitions == null) { -// return null; -// } -// -// Set startupOrders = new HashSet(); -// -// for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { -// startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); -// } -// -// return startupOrders; -// } -// -// private String getKillbehaviour (String serviceGroupName) throws CompositeApplicationDefinitionException { -// -// ServiceGroupDefinition groupDefinition; -// -// try { -// groupDefinition = dataInsertionAndRetrievalMgr.getServiceGroupDefinition(serviceGroupName); -// -// } catch (PersistenceManagerException e) { -// throw new CompositeApplicationDefinitionException(e); -// } -// -// if (groupDefinition == null) { -// throw new CompositeApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); -// } -// -// if (groupDefinition.getDependencies() != null) { -// return groupDefinition.getDependencies().getKillBehaviour(); -// } -// -// return null; -// -// } -// -// private Set getSubsribableContexts (List subscribableDefinitions, -// Map subscribableInformation) -// throws CompositeApplicationDefinitionException { -// // Set subscribableContexts = new HashSet(); // -// for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { +// for (SubscribableContext subscribableCtxt : subscribableCtxts) { // // check is there is a related Subscribable Information -// SubscribableInfo subscribableInfo = subscribableInformation.get(subscribableDefinition.getAlias()); +// SubscribableInfo subscribableInfo = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); // if (subscribableInfo == null) { // throw new CompositeApplicationDefinitionException("Related Subscribable Information not found for Subscribable with alias: " -// + subscribableDefinition.getAlias()); +// + subscribableCtxt.getAlias()); // } // // // check if Cartridge Type is valid -// if (subscribableDefinition.getType() == null || subscribableDefinition.getType().isEmpty()) { +// if (subscribableCtxt.getType() == null || subscribableCtxt.getType().isEmpty()) { // throw new CompositeApplicationDefinitionException ("Invalid Cartridge Type specified : [ " -// + subscribableDefinition.getType() + " ]"); +// + subscribableCtxt.getType() + " ]"); // } // // // check if a cartridge with relevant type is already deployed. else, can't continue -// if (!isCartrigdeDeployed(subscribableDefinition.getType())) { -// throw new CompositeApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableDefinition.getType() + +// if (!isCartrigdeDeployed(subscribableCtxt.getType())) { +// throw new CompositeApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + // " ] for Composite Application"); // } // -// subscribableContexts.add(ParserUtils.convert(subscribableDefinition, subscribableInfo)); +// subscribableContexts.add(ParserUtils.convert(subscribableCtxt, subscribableInfo)); // } // // return subscribableContexts; // } + + private ClusterDataHolder getClusterInformation (List subscribableCtxts, + Map subscribableInfoCtxts) + throws ApplicationDefinitionException { + + Map clusterIdMap = new HashMap(); + Set clusters = new HashSet(); + + for (SubscribableContext subscribableCtxt : subscribableCtxts) { + // check is there is a related Subscribable Information + SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); + if (subscribableInfoCtxt == null) { + throw new ApplicationDefinitionException("Related Subscribable Information Ctxt not found for Subscribable with alias: " + + subscribableCtxt.getAlias()); + } + + // check if Cartridge Type is valid + if (subscribableCtxt.getType() == null || subscribableCtxt.getType().isEmpty()) { + throw new ApplicationDefinitionException ("Invalid Cartridge Type specified : [ " + + subscribableCtxt.getType() + " ]"); + } + + // check if a cartridge with relevant type is already deployed. else, can't continue + Cartridge cartridge = getCartridge(subscribableCtxt.getType()); + if (cartridge == null) { + throw new ApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + + " ] for Composite Application"); + } + + Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); + clusters.add(cluster); + clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()); + } + + return new ClusterDataHolder(clusterIdMap, clusters); + } + + private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) + throws ApplicationDefinitionException { + + // get hostname and cluster id + ClusterInformation clusterInfo; + if (cartridge.isMultiTenant()) { + clusterInfo = new MTClusterInformation(); + } else { + clusterInfo = new STClusterInformation(); + } + + String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); + String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); + + Cluster cluster = new Cluster(subscribableCtxt.getType(), clusterId, subscribableInfoCtxt.getDeploymentPolicy(), + subscribableInfoCtxt.getAutoscalingPolicy()); + + cluster.addHostName(hostname); + cluster.setLbCluster(false); + cluster.setStatus(ClusterStatus.Created); + + return cluster; + } + +// private GroupDataHolder getGroupInformation (List groupCtxts, +// Map subscribableInformation, +// Map definedGroupCtxts) +// throws ApplicationDefinitionException { // -// private boolean isCartrigdeDeployed (String cartridgeType) throws CompositeApplicationDefinitionException { -// -// CloudControllerServiceClient ccServiceClient; -// -// try { -// ccServiceClient = CloudControllerServiceClient.getServiceClient(); +// Set groupContexts = new HashSet(); // -// } catch (AxisFault axisFault) { -// throw new CompositeApplicationDefinitionException(axisFault); +// for (GroupContext groupCtxt : groupCtxts) { +// groupContexts.add(getGroup(groupCtxt, subscribableInformation, definedGroupCtxts)); // } // -// try { -// return ccServiceClient.getCartridgeInfo(cartridgeType) != null; -// -// } catch (RemoteException e) { -// throw new CompositeApplicationDefinitionException(e); -// -// } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { -// throw new CompositeApplicationDefinitionException(e); -// } +// //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); +// Set nestedGroupContexts = new HashSet(); +// getNestedGroupContexts(nestedGroupContexts, groupContexts); +// filterDuplicatedGroupContexts(groupContexts, nestedGroupContexts); // } + private Cartridge getCartridge (String cartridgeType) { + + return FasterLookUpDataHolder.getInstance().getCartridge(cartridgeType); + } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java new file mode 100644 index 0000000000..7ae90107a2 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.parser; + +import org.apache.stratos.messaging.domain.topology.StartupOrder; + +import java.util.HashSet; +import java.util.Set; + +public class ParserUtils { + + public static Set convert (org.apache.stratos.cloud.controller.pojo.StartupOrder [] startupOrderArr) { + + Set startupOrders = new HashSet(); + + if (startupOrderArr == null) { + return startupOrders; + } + + for (int i = 0; i < startupOrderArr.length ; i++) { + startupOrders.add(new StartupOrder(startupOrderArr[i].getStart(), startupOrderArr[i].getAfter())); + } + + return startupOrders; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index aa24cec3cd..2a1c52cad9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -24,10 +24,12 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor; import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; +import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.interfaces.Iaas; import org.apache.stratos.cloud.controller.persist.Deserializer; @@ -1398,9 +1400,10 @@ public ClusterContext getClusterContext (String clusterId) { public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { - // TODO: - // 1. parse and create Composite App tree - // 2. send the ApplicationCreated event + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationDataHolder applicationDataHolder = applicationParser.parse(applicationContext); + + TopologyBuilder.handleApplicationDepolyed(applicationDataHolder); } private List restoreConfigCompositeApplication () { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java index fc9fad842c..48bae4f1a4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java @@ -20,9 +20,10 @@ package org.apache.stratos.cloud.controller.interfaces; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.pojo.ApplicationDataHolder; import org.apache.stratos.messaging.domain.topology.Application; public interface ApplicationParser { - public Application parse (Object obj) throws ApplicationDefinitionException; + public ApplicationDataHolder parse (Object obj) throws ApplicationDefinitionException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java new file mode 100644 index 0000000000..0007ab8352 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Cluster; + +import java.util.Set; + +public class ApplicationDataHolder { + + private Application application; + + private Set clusters; + + public Application getApplication() { + return application; + } + + public void setApplication(Application application) { + this.application = application; + } + + public Set getClusters() { + return clusters; + } + + public void setClusters(Set clusters) { + this.clusters = clusters; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java new file mode 100644 index 0000000000..bc4f7ebc39 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +import org.apache.stratos.messaging.domain.topology.Cluster; + +import java.util.Map; +import java.util.Set; + +public class ClusterDataHolder { + + // Cluster Id map, key = service name + private Map clusterIdMap; + + // Cluster object collection + private Set clusters; + + public ClusterDataHolder (Map clusterIdMap, Set clusters) { + this.clusterIdMap = clusterIdMap; + this.clusters = clusters; + } + + public Map getClusterIdMap() { + return clusterIdMap; + } + + public Set getClusters() { + return clusters; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java new file mode 100644 index 0000000000..534814f700 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.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.cloud.controller.pojo; + +import org.apache.stratos.messaging.domain.topology.Group; + +import java.util.HashMap; +import java.util.Map; + +public class GroupDataHolder { + + // Sub Group Map, key = Group.name + private Map groupMap; + // Cluster Data Holder + private ClusterDataHolder clusterDataHolder; + // nested Group Data + private GroupDataHolder groupDataHolder; + + public GroupDataHolder () { + this.groupMap = new HashMap(); + } + + public void addGroup (Group group) { + groupMap.put(group.getName(), group); + } + + public void addGroups (Map groupNameToGroup) { + groupMap.putAll(groupNameToGroup); + } + + public Map getGroupMap() { + return groupMap; + } + + public ClusterDataHolder getClusterDataHolder() { + return clusterDataHolder; + } + + public GroupDataHolder getGroupDataHolder() { + return groupDataHolder; + } + + public void setGroupDataHolder(GroupDataHolder groupDataHolder) { + this.groupDataHolder = groupDataHolder; + } + + public void setClusterDataHolder(ClusterDataHolder clusterDataHolder) { + this.clusterDataHolder = clusterDataHolder; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java index 898dcdd94e..7dfdb441c1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java @@ -19,8 +19,6 @@ package org.apache.stratos.cloud.controller.pojo.application; -import java.util.List; - public class ApplicationContext { private String applicationId; @@ -29,7 +27,7 @@ public class ApplicationContext { private ComponentContext componentContext; - private List subscribableInfoContexts; + private SubscribableInfoContext[] subscribableInfoContexts; public String getApplicationId() { return applicationId; @@ -55,11 +53,11 @@ public void setComponents(ComponentContext componentContext) { this.componentContext = componentContext; } - public List getSubscribableInfoContext() { + public SubscribableInfoContext[] getSubscribableInfoContext() { return subscribableInfoContexts; } - public void setSubscribableInfoContext(List subscribableInfoContexts) { + public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) { this.subscribableInfoContexts = subscribableInfoContexts; } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java index f8ab53b7e7..d1a13a5d9d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java @@ -19,30 +19,28 @@ package org.apache.stratos.cloud.controller.pojo.application; -import java.util.List; - public class ComponentContext { - private List groupContexts; + private GroupContext[] groupContexts; - private List subscribableContexts; + private SubscribableContext[] subscribableContexts; private DependencyContext dependencyContext; - public List getGroupContexts() { + public GroupContext[] getGroupContexts() { return groupContexts; } - public void setGroupContexts(List groupContexts) { + public void setGroupContexts(GroupContext[] groupContexts) { this.groupContexts = groupContexts; } - public List getSubscribableContexts() { + public SubscribableContext[] getSubscribableContexts() { return subscribableContexts; } - public void setSubscribableContexts(List subscribableContexts) { + public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { this.subscribableContexts = subscribableContexts; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java index fe7331d952..2b31729242 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java @@ -19,19 +19,18 @@ package org.apache.stratos.cloud.controller.pojo.application; -import java.util.List; public class DependencyContext { - private List startupOrderContexts; + private StartupOrderContext[] startupOrderContexts; private String killBehaviour; - public List getStartupOrder() { + public StartupOrderContext[] getStartupOrderContext() { return startupOrderContexts; } - public void setStartupOrder(List startupOrderContexts) { + public void setStartupOrderContext(StartupOrderContext[] startupOrderContexts) { this.startupOrderContexts = startupOrderContexts; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java index 54908c129e..fda4becbec 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java @@ -19,8 +19,6 @@ package org.apache.stratos.cloud.controller.pojo.application; -import java.util.List; - public class GroupContext { private String name; @@ -31,9 +29,9 @@ public class GroupContext { private String autoscalingPolicy; - private List subscribableContexts; + private SubscribableContext[] subscribableContexts; - private List groupContexts; + private GroupContext[] groupContexts; public String getName() { @@ -68,19 +66,19 @@ public void setAutoscalingPolicy(String autoscalingPolicy) { this.autoscalingPolicy = autoscalingPolicy; } - public List getSubscribableContexts() { + public SubscribableContext[] getSubscribableContexts() { return subscribableContexts; } - public void setSubscribableContexts(List subscribableContexts) { + public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { this.subscribableContexts = subscribableContexts; } - public List getGroupContexts() { + public GroupContext[] getGroupContexts() { return groupContexts; } - public void setGroupContexts(List groupContexts) { + public void setGroupContexts(GroupContext[] groupContexts) { this.groupContexts = groupContexts; } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java index 13120397ca..3c2a2da36b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java @@ -25,6 +25,10 @@ public class StartupOrderContext { private String after; + public StartupOrderContext () { + + } + public String getStart() { return start; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index a051cf41df..4420b0b84f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -613,6 +613,26 @@ public static void handleMemberSuspended() { } } + public static void handleApplicationDepolyed (ApplicationDataHolder applicationDataHolder) { + + Topology topology = TopologyManager.getTopology(); + try { + TopologyManager.acquireWriteLock(); + + for (Cluster cluster : applicationDataHolder.getClusters()) { + String cartridgeType = cluster.getServiceName(); + topology.getService(cartridgeType).addCluster(cluster); + log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + applicationDataHolder.getApplication().getId()); + } + TopologyManager.updateTopology(topology); + + TopologyEventPublisher.sendApplicationCreatedEvent(applicationDataHolder.getApplication()); + + } finally { + TopologyManager.releaseWriteLock(); + } + } + public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { Topology topology = TopologyManager.getTopology(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 0ffc0ffdd5..ee10f9d689 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -90,6 +90,15 @@ public static void sendClusterCreatedEvent(String serviceName, String clusterId, } + public static void sendApplicationCreatedEvent (Application application) { + + if(log.isInfoEnabled()) { + log.info("Publishing Application created event: " + application.toString()); + } + + publishEvent(new ApplicationCreatedEvent(application)); + } + public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) { ClusterRemovedEvent clusterRemovedEvent = new ClusterRemovedEvent(ctxt.getCartridgeType(), ctxt.getClusterId(), deploymentPolicy, ctxt.isLbCluster()); 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 5c31ff99fe..92b9da7bd8 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 @@ -24,18 +24,11 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidClusterExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceStub; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredClusterExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; import java.rmi.RemoteException; import java.util.Iterator; @@ -126,11 +119,11 @@ public boolean register(String clusterId, String cartridgeType, } - public void deployCompositeApplicationDefinition (CompositeApplicationDefinition compositeApplicationDefinition) - throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException - { + public void deployApplicationDefinition(ApplicationContext applicationContext) + throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, + CloudControllerServiceInvalidIaasProviderExceptionException, CloudControllerServiceApplicationDefinitionExceptionException { - stub.deployCompositeApplicationDefinition(compositeApplicationDefinition); + stub.deployApplicationDefinition(applicationContext); } 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 index 4cb77f98c3..d7418c7b80 100644 --- 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 @@ -19,7 +19,6 @@ package org.apache.stratos.manager.composite.application.beans; -import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import java.util.List; 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 index 9a2ea184d0..8735ab3600 100644 --- 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 @@ -229,19 +229,24 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro servicegroup.setCartridges(cartridges); DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies(); - List startDefs = depDefs.getStartupOrder(); - - Dependencies deps = new Dependencies(); - StartupOrder [] startups = new StartupOrder [startDefs.size()]; - for (int i = 0; i < startDefs.size(); i++) { - StartupOrderDefinition stDef = startDefs.get(i); - StartupOrder st = new StartupOrder(); - st.setStart(stDef.getStart()); - st.setAfter(stDef.getAfter()); - startups[i] = st; - } - deps.setStartupOrder(startups); - servicegroup.setDependencies(deps); + if (depDefs != null) { + List startDefs = depDefs.getStartupOrder(); + + Dependencies deps = new Dependencies(); + if (startDefs != null) { + StartupOrder [] startups = new StartupOrder [startDefs.size()]; + for (int i = 0; i < startDefs.size(); i++) { + StartupOrderDefinition stDef = startDefs.get(i); + StartupOrder st = new StartupOrder(); + st.setStart(stDef.getStart()); + st.setAfter(stDef.getAfter()); + startups[i] = st; + } + deps.setStartupOrder(startups); + } + deps.setKillBehaviour(depDefs.getKillBehaviour()); + servicegroup.setDependencies(deps); + } return servicegroup; } @@ -252,23 +257,33 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup String [] cartridges = serviceGroup.getCartridges(); String [] subGroups = serviceGroup.getSubGroups(); Dependencies deps = serviceGroup.getDependencies(); - StartupOrder [] startupOrders = deps.getStartupOrder(); - - List cartridgesDef = new ArrayList(Arrays.asList(cartridges)); - List subGroupsDef = new ArrayList(Arrays.asList(subGroups)); - DependencyDefinitions depsDef = new DependencyDefinitions(); - List startupsDef = new ArrayList(); - for (StartupOrder startupOrder : startupOrders) { - StartupOrderDefinition astartupDef = new StartupOrderDefinition(); - astartupDef.setAfter(startupOrder.getAfter()); - astartupDef.setStart(startupOrder.getStart()); - startupsDef.add(astartupDef); - } - depsDef.setStartupOrder(startupsDef); - depsDef.setKillBehaviour(deps.getKillBehaviour()); + + if (deps != null) { + DependencyDefinitions depsDef = new DependencyDefinitions(); + StartupOrder [] startupOrders = deps.getStartupOrder(); + if (startupOrders != null && startupOrders.length > 0) { + List startupsDef = new ArrayList(); + for (StartupOrder startupOrder : startupOrders) { + if (startupOrder != null) { + StartupOrderDefinition astartupDef = new StartupOrderDefinition(); + astartupDef.setAfter(startupOrder.getAfter()); + astartupDef.setStart(startupOrder.getStart()); + startupsDef.add(astartupDef); + } + } + + depsDef.setStartupOrder(startupsDef); + } + + depsDef.setKillBehaviour(deps.getKillBehaviour()); + servicegroupDef.setDependencies(depsDef); + } + + List cartridgesDef = new ArrayList(Arrays.asList(cartridges)); + List subGroupsDef = new ArrayList(Arrays.asList(subGroups)); + servicegroupDef.setCartridges(cartridgesDef); servicegroupDef.setSubGroups(subGroupsDef); - servicegroupDef.setDependencies(depsDef); return servicegroupDef; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 5e57a5d411..e4429969f3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -27,6 +27,7 @@ public class Application implements SubscribableBehavior { + private static final long serialVersionUID = -5092959597171649688L; // Unique id for the Application, defined in Application Definition private String id; // Key used for authentication (with metadata service, etc.) @@ -50,6 +51,11 @@ public void addGroup(Group group) { groupMap.put(group.getName(), group); } + @Override + public void setGroups(Map groupNameToGroup) { + groupMap.putAll(groupNameToGroup); + } + @Override public Group getGroup(String groupName) { return groupMap.get(groupName); @@ -75,6 +81,11 @@ public void addClusterId(String serviceName, String clusterId) { clusterIdMap.put(serviceName, clusterId); } + @Override + public void setClusterIds(Map serviceNameToClusterId) { + clusterIdMap.putAll(serviceNameToClusterId); + } + @Override public String getClusterId(String serviceName) { return clusterIdMap.get(serviceName); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 08bd2621f0..80a2277e03 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -210,5 +210,22 @@ public ClusterStatus getStatus() { public void setStatus(ClusterStatus status) { this.status = status; } + + public boolean equals(Object other) { + if(other == null || !(other instanceof Cluster)) { + return false; + } + + if(this == other) { + return true; + } + + Cluster that = (Cluster)other; + return this.clusterId.equals(that.clusterId); + } + + public int hashCode () { + return clusterId.hashCode(); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java index b25b7adbf0..b5992ada49 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -32,6 +32,10 @@ public DependencyOrder () { this.startupOrders = new HashSet(); } + public void setStartupOrders (Set startupOrders) { + this.startupOrders.addAll(startupOrders); + } + public Set getStartupOrders() { return startupOrders; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 66cdb667bd..16ec77595f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -25,15 +25,20 @@ public class Group implements SubscribableBehavior { + private static final long serialVersionUID = 8347096598203655846L; // Name of the Group, specified in Group Definition private String name; // Group alias private String alias; + // Group deployment policy + private String deploymentPolicy; + // Group level autoscaling policy + private String autoscalingPolicy; // Dependency Order private DependencyOrder dependencyOrder; // Sub Group Map, key = Group.name private Map groupMap; - // Cluster Id map, key = service name + // Cluster id map, key = service name private Map clusterIdMap; public Group (String name, String alias) { @@ -48,6 +53,11 @@ public void addGroup(Group group) { groupMap.put(group.name, group); } + @Override + public void setGroups(Map groupNameToGroup) { + groupMap.putAll(groupNameToGroup); + } + @Override public Group getGroup(String groupName) { return groupMap.get(groupName); @@ -73,6 +83,11 @@ public void addClusterId(String serviceName, String clusterId) { clusterIdMap.put(serviceName, clusterId); } + @Override + public void setClusterIds(Map serviceNameToClusterId) { + clusterIdMap.putAll(serviceNameToClusterId); + } + @Override public String getClusterId(String serviceName) { return clusterIdMap.get(serviceName); @@ -90,4 +105,37 @@ public String getName() { public String getAlias() { return 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 boolean equals(Object other) { + if(other == null || !(other instanceof Group)) { + return false; + } + + if(this == other) { + return true; + } + + Group that = (Group)other; + return this.name.equals(that.name) && this.alias.equals(that.alias); + } + + public int hashCode () { + return name.hashCode() + alias.hashCode(); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java index 05e42d1652..b66b0c7552 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java @@ -21,11 +21,14 @@ import java.io.Serializable; import java.util.Collection; +import java.util.Map; public interface SubscribableBehavior extends Serializable { public void addGroup (Group group); + public void setGroups (Map groupNameToGroup); + public Group getGroup (String groupName); public Collection getGroups (); @@ -36,6 +39,8 @@ public interface SubscribableBehavior extends Serializable { public void addClusterId (String serviceName, String clusterId); + public void setClusterIds (Map serviceNameToClusterId); + public String getClusterId (String serviceName); public Collection getClusterIds (); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 354e9c98ce..0067d37193 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -22,8 +22,15 @@ import org.apache.commons.logging.LogFactory; import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.cloud.controller.stub.pojo.application.*; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.GroupDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; +import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; import org.apache.stratos.manager.deploy.service.Service; +import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; +import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; @@ -664,6 +671,127 @@ public static List convertToServiceDefinitionBeans (Colle } private static Log log = LogFactory.getLog(PojoConverter.class); + + public static ApplicationContext convertApplicationBeanToApplicationContext (CompositeAppDefinition compositeAppDefinition) { + + ApplicationContext applicationContext = new ApplicationContext(); + applicationContext.setApplicationId(compositeAppDefinition.getApplicationId()); + applicationContext.setAlias(compositeAppDefinition.getAlias()); + + // convert and set components + if (compositeAppDefinition.getComponents() != null) { + ComponentContext componentContext = new ComponentContext(); + // top level subscribables + if (compositeAppDefinition.getComponents().getSubscribables() != null) { + componentContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions( + compositeAppDefinition.getComponents().getSubscribables())); + } + // top level Groups + if (compositeAppDefinition.getComponents().getGroups() != null) { + componentContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(compositeAppDefinition.getComponents().getGroups())); + } + // top level dependency information + if (compositeAppDefinition.getComponents().getDependencies() != null) { + componentContext.setDependencyContext(getDependencyContextFromDependencyDefinition(compositeAppDefinition.getComponents().getDependencies())); + } + + applicationContext.setComponents(componentContext); + } + + // subscribable information + applicationContext.setSubscribableInfoContext(getSubscribableInfoContextArrFromSubscribableInfoDefinition(compositeAppDefinition.getSubscribableInfo())); + + return applicationContext; + } + + private static SubscribableInfoContext[] getSubscribableInfoContextArrFromSubscribableInfoDefinition (List subscribableInfos) { + + SubscribableInfoContext[] subscribableInfoContexts = new SubscribableInfoContext[subscribableInfos.size()]; + int i = 0; + for (SubscribableInfo subscribableInfo : subscribableInfos) { + SubscribableInfoContext subscribableInfoContext = new SubscribableInfoContext(); + subscribableInfoContext.setAlias(subscribableInfo.getAlias()); + subscribableInfoContext.setAutoscalingPolicy(subscribableInfo.getAutoscalingPolicy()); + subscribableInfoContext.setDeploymentPolicy(subscribableInfo.getDeploymentPolicy()); + subscribableInfoContext.setRepoUrl(subscribableInfo.getRepoUrl()); + subscribableInfoContext.setPrivateRepo(subscribableInfo.isPrivateRepo()); + subscribableInfoContext.setRepoUsername(subscribableInfo.getRepoUsername()); + subscribableInfoContext.setRepoPassword(subscribableInfo.getRepoPassword()); + subscribableInfoContexts[i++] = subscribableInfoContext; + } + + return subscribableInfoContexts; + } + + private static DependencyContext getDependencyContextFromDependencyDefinition (DependencyDefinitions dependencyDefinitions) { + + DependencyContext dependencyContext = new DependencyContext(); + dependencyContext.setKillBehaviour(dependencyDefinitions.getKillBehaviour()); + if (dependencyDefinitions.getStartupOrder() != null) { + dependencyContext.setStartupOrderContext(getStartupOrderContextArrFromStartupDefinition(dependencyDefinitions.getStartupOrder())); + } + + return dependencyContext; + } + + private static StartupOrderContext[] getStartupOrderContextArrFromStartupDefinition (List startupOrderDefinitions) { + + StartupOrderContext[] startupOrderContexts = new StartupOrderContext[startupOrderDefinitions.size()]; + int i = 0; + for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { + StartupOrderContext startupOrderContext = new StartupOrderContext(); + startupOrderContext.setStart(startupOrderDefinition.getStart()); + startupOrderContext.setAfter(startupOrderDefinition.getAfter()); + startupOrderContexts[i++] = startupOrderContext; + } + + return startupOrderContexts; + } + + private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List groupDefinitions) { + + GroupContext[] groupContexts = new GroupContext[groupDefinitions.size()]; + int i = 0; + for (GroupDefinition groupDefinition : groupDefinitions) { + GroupContext groupContext = new GroupContext(); + groupContext.setName(groupDefinition.getName()); + groupContext.setAlias(groupDefinition.getAlias()); + groupContext.setDeploymentPolicy(groupDefinition.getDeploymentPolicy()); + groupContext.setAutoscalingPolicy(groupDefinition.getAutoscalingPolicy()); + // nested Subscribables + if (groupDefinition.getSubscribables() != null) { + groupContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions(groupDefinition.getSubscribables())); + } + // nested Groups + if (groupDefinition.getSubGroups() != null) { + groupContext.setGroupContexts(getgroupContextArrayFromGroupDefinitions(groupDefinition.getSubGroups())); + } + groupContexts[i++] = groupContext; + } + + return groupContexts; + } + + private static SubscribableContext [] getSubscribableContextArrayFromSubscribableDefinitions(List subscribableDefinitions) { + + SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()]; + int i = 0; + for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { + SubscribableContext subscribableContext = new SubscribableContext(); + subscribableContext.setType(subscribableDefinition.getType()); + subscribableContext.setAlias(subscribableDefinition.getAlias()); + subscribableContexts[i++] = subscribableContext; + } + + return subscribableContexts; + } + + private static SubscribableContext getSubscribableContextFromSubscribableDefinition (SubscribableDefinition subscribableDefinition) { + + SubscribableContext subscribableContext = new SubscribableContext(); + subscribableContext.setType(subscribableDefinition.getType()); + return subscribableContext; + } /* public static ConfigCompositeApplication convertToCompositeApplication(CompositeApplicationDefinitionBean appBean) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 10d4865f0c..69d09e0a97 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -24,14 +24,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.CompositeApplicationDefinition; +import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeDefinitionExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidIaasProviderExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; @@ -51,7 +47,6 @@ import org.apache.stratos.manager.subscription.CartridgeSubscription; import org.apache.stratos.manager.subscription.DataCartridgeSubscription; import org.apache.stratos.manager.subscription.SubscriptionData; -import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.manager.utils.CartridgeConstants; @@ -61,7 +56,6 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; -import org.apache.stratos.rest.endpoint.bean.StratosAdminResponse; import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; @@ -73,7 +67,6 @@ import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; -import org.apache.stratos.cloud.controller.stub.pojo.*; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; @@ -199,7 +192,7 @@ static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean log.debug("deployeing composite app in cloud controller"); } - ServiceUtils.deployCompositeApplicationDefinition(applicationDefinitionBean, ctxt, userName, tenantDomain); + ServiceUtils.deployApplicationDefinition(applicationDefinitionBean, ctxt, userName, tenantDomain); if (log.isDebugEnabled()) { log.debug("done deployeing composite app in cloud controller"); @@ -210,7 +203,7 @@ static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean return stratosAdminResponse; } */ /* - static StratosAdminResponse deployCompositeApplicationDefinition (CompositeApplicationDefinitionBean compositeApplicationDefinition, ConfigurationContext ctxt, + static StratosAdminResponse deployApplicationDefinition (CompositeApplicationDefinitionBean compositeApplicationDefinition, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { log.info("Starting to deploy composite application definition "+ compositeApplicationDefinition); @@ -223,7 +216,7 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli if (cloudControllerServiceClient != null) { // call CC try { - cloudControllerServiceClient.deployCompositeApplicationDefinition(appConfig); + cloudControllerServiceClient.deployApplicationDefinition(appConfig); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -256,17 +249,32 @@ static StratosAdminResponse deployCompositeApplicationDefinition (CompositeAppli static void deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { - - int tenantId = ApplicationManagementUtil.getTenantId(ctxt); +// +// int tenantId = ApplicationManagementUtil.getTenantId(ctxt); +// +// try { +// compositeApplicationManager.deployCompositeApplication(compositeAppDefinition, tenantId, tenantDomain, userName); +// +// } catch (CompositeApplicationDefinitionException e) { +// throw new RestAPIException(e); +// } catch (PersistenceManagerException e) { +// throw new RestAPIException(e); +// } catch (CompositeApplicationException e) { +// throw new RestAPIException(e); +// } + + ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(compositeAppDefinition); try { - compositeApplicationManager.deployCompositeApplication(compositeAppDefinition, tenantId, tenantDomain, userName); + CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); - } catch (CompositeApplicationDefinitionException e) { + } catch (RemoteException e) { + throw new RestAPIException(e); + } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { throw new RestAPIException(e); - } catch (PersistenceManagerException e) { + } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { throw new RestAPIException(e); - } catch (CompositeApplicationException e) { + } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { throw new RestAPIException(e); } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 5c86c5045c..e9ed346b3c 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -133,7 +133,7 @@ public Response getCookie(){ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefinitionBean applicationDefinitionBean) throws RestAPIException { - return ServiceUtils.deployCompositeApplicationDefinition(applicationDefinitionBean, getConfigContext(), getUsername(), + return ServiceUtils.deployApplicationDefinition(applicationDefinitionBean, getConfigContext(), getUsername(), getTenantDomain()); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml index ac758b7bba..c7d50099ff 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/cxf-servlet.xml @@ -33,11 +33,11 @@ - - + - + @@ -61,7 +61,7 @@ - + diff --git a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml index 23efdf66ea..45e61e95b0 100644 --- a/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml +++ b/features/cloud-controller/org.apache.stratos.cloud.controller.feature/pom.xml @@ -200,6 +200,11 @@ andes-client 0.13.wso2v8 + + com.jcraft + jsch.agentproxy.usocket-nc + 0.0.7 + @@ -276,7 +281,7 @@ com.jcraft:jsch.agentproxy.connector-factory:0.0.7 com.jcraft:jsch.agentproxy.sshagent:0.0.7 - com.jcraft:jsch.agentproxy.usocket-jna:0.0.7 + com.jcraft:jsch.agentproxy.usocket-nc:0.0.7 com.jcraft:jsch.agentproxy.core:0.0.7 net.java.dev.jna:jna:4.1.0 diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml index e527dd43bd..7aff96698f 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml @@ -46,7 +46,7 @@ - + @@ -89,6 +89,7 @@ org.apache.stratos.cloud.controller.stub.exception.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.deployment.partition.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.pojo.*; version=${project.version}, + org.apache.stratos.cloud.controller.stub.pojo.application.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.impl.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.*; version=${project.version} diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 218d5d6e2e..af7bc272ed 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,259 +6,292 @@ - - + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -272,186 +305,126 @@ - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -460,16 +433,40 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -484,16 +481,41 @@ - + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + - + @@ -501,11 +523,11 @@ - + - - - + + + @@ -518,24 +540,25 @@ - + - - - - - - - - + + + + + + + + + - - + + @@ -546,14 +569,14 @@ - + - + @@ -562,54 +585,64 @@ - + - - - - + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + - + - - + - + - - - - - - - - - - - - - + + + - + + + + - - - - - - - - - + + + + + @@ -662,12 +695,6 @@ - - - - - - @@ -677,8 +704,11 @@ - - + + + + + @@ -686,6 +716,9 @@ + + + @@ -775,25 +808,25 @@ - - - - - - - - + + + + + + + + @@ -921,6 +954,18 @@ + + + + + + + + + + + + @@ -933,14 +978,11 @@ - - + + - - - @@ -957,15 +999,6 @@ - - - - - - - - - @@ -1023,31 +1056,31 @@ - - + + - - - - - + + - - + + - - + + + + + @@ -1158,6 +1191,18 @@ + + + + + + + + + + + + @@ -1170,14 +1215,11 @@ - - + + - - - @@ -1194,15 +1236,6 @@ - - - - - - - - - @@ -1260,31 +1293,31 @@ - - + + - - - - - + + - - + + - - + + + + + @@ -1371,12 +1404,6 @@ - - - - - - @@ -1386,14 +1413,11 @@ - - + + - - - @@ -1401,6 +1425,15 @@ + + + + + + + + + @@ -1440,8 +1473,8 @@ - - + + @@ -1449,8 +1482,8 @@ - - + + @@ -1482,22 +1515,22 @@ - + - + - + - + - + - + \ No newline at end of file From dab0855e23b6040f9e9367a3af2f589c66ef9447 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 16 Sep 2014 11:00:16 +0530 Subject: [PATCH 049/436] Commiting changes of Metadata service This closes #37 --- .../pom.xml | 164 +++++ .../stratos/metadataservice/Constants.java | 29 + .../metadataservice/ServiceHolder.java | 84 +++ .../apache/stratos/metadataservice/Utils.java | 44 ++ .../annotation/AuthorizationAction.java | 36 ++ .../annotation/SuperTenantService.java | 34 + .../context/AuthenticationContext.java | 40 ++ .../definition/CartridgeMetaData.java | 43 ++ .../definition/PropertyBean.java | 37 ++ .../exception/RestAPIException.java | 70 ++ ...actAuthenticationAuthorizationHandler.java | 56 ++ .../CookieBasedAuthenticationHandler.java | 94 +++ .../handlers/CustomExceptionMapper.java | 47 ++ .../CustomThrowableExceptionMapper.java | 44 ++ .../handlers/GenericExceptionMapper.java | 54 ++ .../handlers/OAuthHandler.java | 95 +++ .../StratosAuthenticationHandler.java | 156 +++++ .../handlers/StratosAuthorizingHandler.java | 333 ++++++++++ .../listener/TopologyAgent.java | 112 ++++ .../listener/TopologyListener.java | 124 ++++ .../oauth2/ValidationServiceClient.java | 65 ++ .../registry/CarbonRegistry.java | 187 ++++++ .../registry/DataRegistryFactory.java | 36 ++ .../metadataservice/registry/DataStore.java | 36 ++ .../registry/GRegRegistry.java | 220 +++++++ .../security/StratosPrincipal.java | 53 ++ .../security/StratosSecurityContext.java | 50 ++ .../services/MetaDataAdmin.java | 87 +++ .../metadataservice/util/ConfUtil.java | 74 +++ .../src/main/resources/axis2_client.xml | 299 +++++++++ .../META-INF/webapp-classloading.xml | 35 + .../WEB-INF/cxf-servlet.xml | 46 ++ .../WEB-INF/web.xml | 40 ++ .../META-INF/webapp-classloading.xml | 35 + .../WEB-INF/cxf-servlet.xml | 79 +++ .../stratosmetadataservice/WEB-INF/web.xml | 42 ++ .../pom.xml | 320 +++++++++ .../src/main/resources/p2.inf | 23 + .../src/main/resources/tomcat/context.xml | 36 ++ .../webapp-classloading-environments.xml | 68 ++ .../resources/tomcat/webapp-classloading.xml | 33 + .../pom.xml | 10 + .../modules/distribution/src/assembly/bin.xml | 12 + .../modules/distribution/src/bin/stratos.sh | 6 +- .../src/main/conf/metadataservice.xml | 37 ++ .../distribution/src/main/license/LICENSE | 4 +- .../stratos/modules/p2-profile-gen/pom.xml | 31 +- products/stratos/pom.xml | 1 + tools/stratos-installer/conf/setup.conf | 5 + .../all/repository/conf/metadataservice.xml | 37 ++ .../config/greg/repository/conf/carbon.xml | 609 ++++++++++++++++++ tools/stratos-installer/setup.sh | 29 + tools/stratos-installer/start-servers.sh | 7 +- 53 files changed, 4339 insertions(+), 9 deletions(-) create mode 100644 components/org.apache.stratos.metadataservice/pom.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml create mode 100644 products/stratos/modules/distribution/src/main/conf/metadataservice.xml create mode 100644 tools/stratos-installer/config/all/repository/conf/metadataservice.xml create mode 100644 tools/stratos-installer/config/greg/repository/conf/carbon.xml diff --git a/components/org.apache.stratos.metadataservice/pom.xml b/components/org.apache.stratos.metadataservice/pom.xml new file mode 100644 index 0000000000..9b05574ed8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/pom.xml @@ -0,0 +1,164 @@ + + + + org.apache.stratos + stratos-components-parent + 4.0.0 + + + 4.0.0 + org.apache.stratos.metadataservice + war + Apache Stratos -Meta Data Service + + + + test + + + env + test + + + + stratosmetadataservice-test + + + + prod + + true + + + stratosmetadataservice + + + + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + 2.3.2 + + + maven-war-plugin + 2.2 + + + + + src/main/webapp/${appName} + + + stratosmetadataservice + + + + + + + + + + + + org.apache.cxf + cxf-bundle + 2.7.7 + provided + + + org.wso2.carbon + org.wso2.carbon.core + 4.2.0 + provided + + + org.wso2.carbon + org.wso2.carbon.utils + 4.2.0 + provided + + + org.wso2.carbon + org.wso2.carbon.identity.oauth.stub + 4.2.0 + provided + + + org.apache.stratos + org.apache.stratos.tenant.mgt + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.common + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.manager + ${project.version} + provided + + + + org.apache.stratos + org.apache.stratos.cloud.controller.service.stub + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.autoscaler.service.stub + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.messaging + ${project.version} + provided + + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + provided + + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + provided + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java new file mode 100644 index 0000000000..bd84c5f3c5 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java @@ -0,0 +1,29 @@ +/* + * 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.metadataservice; + +/** + * Global constants used in this module + */ +public class Constants { + + public static final String SUPER_TENANT_SERVICE = "super.tenant.service"; + public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml"; + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java new file mode 100644 index 0000000000..9b43ca4579 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java @@ -0,0 +1,84 @@ +/* + * 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.metadataservice; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.TenantBillingService; +import org.apache.stratos.tenant.mgt.core.TenantPersistor; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.user.core.tenant.TenantManager; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * Some of the admin services needs objects with states inside the runtime. + * There are + * two mechanisms to get those kind of objects. Either with singleton with or + * via OSGi + * services. OSGi services mechanism is preferred. This is a helper class for + * doing that. + */ +public class ServiceHolder { + private static Log log = LogFactory.getLog(ServiceHolder.class); + + public static TenantManager getTenantManager() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class); + return realmService.getTenantManager(); + } + + public static TenantBillingService getBillingService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + TenantBillingService tenantBillingService = + (TenantBillingService) carbonContext.getOSGiService(TenantBillingService.class); + return tenantBillingService; + } + + public static RealmService getRealmService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class); + return realmService; + } + + public static RegistryService getRegistryService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RegistryService registryService = + (RegistryService) carbonContext.getOSGiService(RegistryService.class); + return registryService; + } + + public static TenantPersistor getTenantPersistor() { + TenantPersistor tenantPersistor = new TenantPersistor(); + return tenantPersistor; + } + + public static ConfigurationContextService getConfigurationContext() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ConfigurationContextService configurationContextService = + (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class); + return configurationContextService; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java new file mode 100644 index 0000000000..42b100a12f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java @@ -0,0 +1,44 @@ +/** + * 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.metadataservice; + +public class Utils { + + public static String buildMessage(int errorCode, String errorMessage) { + String jsonResponse = + "{\"Error\":{" + " \"errorCode\": \" " + errorCode + "\"," + + " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}"; + return jsonResponse; + } + + public static String buildMessage(String errorMessage) { + String jsonResponse = + "{\"Error\":{" + " \"errorCode\": \" " + -1234 + "\"," + + " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}"; + return jsonResponse; + } + + public static String buildAuthenticationSuccessMessage(String jSessionId) { + String jsonResponse = + "{\"Success\":{" + " \"sessionId\": \"" + jSessionId + "\"" + "}" + + "}"; + return jsonResponse; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java new file mode 100644 index 0000000000..a6c8765465 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Carbon kernel handles permissions by means of permission strings. + * Permission strings are defined at the operation level. Here the admin + * service developer has to specify authorization requirements using + * the below annotation + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = ElementType.METHOD) +public @interface AuthorizationAction { + String[] value(); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java new file mode 100644 index 0000000000..761faa422f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java @@ -0,0 +1,34 @@ +/* + * 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.metadataservice.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * In Carbon admin authorization framework there are super-tenant only + * admin services. We use below annotation to mark such admin services. + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = ElementType.METHOD) +public @interface SuperTenantService { + boolean value(); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java new file mode 100644 index 0000000000..7adbff6828 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java @@ -0,0 +1,40 @@ +package org.apache.stratos.metadataservice.context; + +/* + * 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 AuthenticationContext { + // maintaining the authenticated state in threadLocal. We want to skip + // subsequent authentication handlers + // once a request get authenticated by a handler. + private static final ThreadLocal authenticated = new ThreadLocal() { + @Override + protected Boolean initialValue() { + return false; + } + }; + + public static boolean isAthenticated() { + return authenticated.get(); + } + + public static void setAuthenticated(boolean isAuthenticated) { + authenticated.set(isAuthenticated); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java new file mode 100644 index 0000000000..dfecee4b4a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java @@ -0,0 +1,43 @@ +package org.apache.stratos.metadataservice.definition; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "cartridgeMetaData") +public class CartridgeMetaData { + public String applicationName; + + public String displayName; + + public String description; + + public String type; + + public String provider; + + public String host; + + public String version; + + public List property; + + @Override + public String toString() { + + return "applicationName: " + applicationName + ", displayName: " + displayName + + ", description: " + description + ", type: " + type + ", provider: " + provider + + ", host: " + host + ", Version: " + version + ", property: " + getProperties(); + } + + private String getProperties() { + + StringBuilder propertyBuilder = new StringBuilder(); + if (property != null) { + for (PropertyBean propertyBean : property) { + propertyBuilder.append(propertyBean.toString()); + } + } + return propertyBuilder.toString(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java new file mode 100644 index 0000000000..ae4fcf8bc7 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java @@ -0,0 +1,37 @@ +/* + * 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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "property") +public class PropertyBean { + + public String hostname; + + public String username; + public String password; + + @Override + public String toString() { + return " [ hostname: " + hostname + ", username: " + username + ", password: " + password + + "] "; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java new file mode 100644 index 0000000000..df43cc0fdc --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.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.metadataservice.exception; + +import javax.ws.rs.core.Response; + +public class RestAPIException extends Exception { + + private static final long serialVersionUID = 1L; + + private String message; + private Response.Status httpStatusCode; + + public RestAPIException() { + super(); + } + + public RestAPIException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public RestAPIException(Response.Status httpStatusCode, String message, Throwable cause) { + super(message, cause); + this.message = message; + this.httpStatusCode = httpStatusCode; + } + + public RestAPIException(String message) { + super(message); + this.message = message; + } + + public RestAPIException(Response.Status httpStatusCode, String message) { + super(message); + this.message = message; + this.httpStatusCode = httpStatusCode; + } + + public RestAPIException(Throwable cause) { + super(cause); + } + + @Override + public String getMessage() { + return message; + } + + public Response.Status getHTTPStatusCode() { + return httpStatusCode; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java new file mode 100644 index 0000000000..93bf9049a6 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java @@ -0,0 +1,56 @@ +/** + * 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.metadataservice.handlers; + +import java.util.List; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.impl.HttpHeadersImpl; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.context.AuthenticationContext; + +public abstract class AbstractAuthenticationAuthorizationHandler implements RequestHandler { + private final Log log = LogFactory.getLog(AbstractAuthenticationAuthorizationHandler.class); + + @Override + public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) { + HttpHeaders headers = new HttpHeadersImpl(message); + List authHeader = headers.getRequestHeader(HttpHeaders.AUTHORIZATION); + if (log.isDebugEnabled()) { + log.debug("Executing " + this.getClass()); + } + if (!AuthenticationContext.isAthenticated() && authHeader != null && + authHeader.size() > 0 && canHandle(authHeader.get(0).trim().split(" ")[0])) { + return handle(message, classResourceInfo); + } + // give the control to the next handler + return null; + + } + + protected abstract boolean canHandle(String authHeaderPrefix); + + protected abstract Response handle(Message message, ClassResourceInfo classResourceInfo); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java new file mode 100644 index 0000000000..da50e3e76f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java @@ -0,0 +1,94 @@ +/* + * 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.metadataservice.handlers; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +/* + * authenticate an incoming request using the session availability. Session is + * first established using the + * basic auth authentication. This handler will be the last to get executed in + * the current handler chain. Hence failure + * too provide a session would result in an authentication failure. + */ +public class CookieBasedAuthenticationHandler implements RequestHandler { + private final Log log = LogFactory.getLog(CookieBasedAuthenticationHandler.class); + + @Override + public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) { + if (AuthenticationContext.isAthenticated()) { + return null; + } + + HttpServletRequest httpServletRequest = (HttpServletRequest) message.get("HTTP.REQUEST"); + HttpSession httpSession = httpServletRequest.getSession(false); + if (httpSession != null && isUserLoggedIn(httpSession)) { // if sesion + // is + // avaialble + String userName = (String) httpSession.getAttribute("userName"); + String tenantDomain = (String) httpSession.getAttribute("tenantDomain"); + int tenantId = (Integer) httpSession.getAttribute("tenantId"); + // the following will get used by the authorization handler.. + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setUsername(userName); + carbonContext.setTenantDomain(tenantDomain); + carbonContext.setTenantId(tenantId); + + AuthenticationContext.setAuthenticated(true); + if (log.isDebugEnabled()) { + log.debug("authenticated using the " + + CookieBasedAuthenticationHandler.class.getName() + "for username :" + + userName + "tenantDomain : " + tenantDomain + " tenantId : " + tenantId); + } + return null; + + } + return Response.status(Response.Status.FORBIDDEN).type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("The endpoint requires authentication")).build(); + } + + /* + * if the userName and tenantDomain is present in the session, we conclude + * this as an authenticated session. + * Thos params get set by the AuthenticationAdmin endpoint. + */ + private boolean isUserLoggedIn(HttpSession httpSession) { + String userName = (String) httpSession.getAttribute("userName"); + String tenantDomain = (String) httpSession.getAttribute("tenantDomain"); + Integer tenantId = (Integer) httpSession.getAttribute("tenantId"); + if (userName != null && tenantDomain != null && tenantId != null) { + return true; + } + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java new file mode 100644 index 0000000000..0731c99d59 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.metadataservice.handlers; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.exception.RestAPIException; + +public class CustomExceptionMapper implements ExceptionMapper { + @Override + public Response toResponse(RestAPIException restAPIException) { + // if no specific error message specified, spitting out a generaic error + // message + String errorMessage = + (restAPIException.getMessage() != null) + ? restAPIException.getMessage() + : "Error while fullfilling the request"; + // if no specific error specified we are throwing the bad request http + // status code by default + Response.Status httpStatus = + (restAPIException.getHTTPStatusCode() != null) + ? restAPIException.getHTTPStatusCode() + : Response.Status.BAD_REQUEST; + return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(httpStatus.getStatusCode(), errorMessage)) + .build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java new file mode 100644 index 0000000000..fd0e2a5b2a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java @@ -0,0 +1,44 @@ +package org.apache.stratos.metadataservice.handlers; + +/* + * 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 javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Utils; + +public class CustomThrowableExceptionMapper implements ExceptionMapper { + private static Log log = LogFactory.getLog(CustomThrowableExceptionMapper.class); + + @Override + public Response toResponse(Throwable throwable) { + if (log.isDebugEnabled()) { + log.debug("Internal server error", throwable); + } + + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + "Internal server error")).build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java new file mode 100644 index 0000000000..4d2fadb3e2 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java @@ -0,0 +1,54 @@ +/* + * 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.metadataservice.handlers; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Utils; + +/* + * This class maps any exception thrown by the server, which is not mapped by a + * specifi exception mapper + * in to an appropriate format + */ +public class GenericExceptionMapper implements ExceptionMapper { + private static Log log = LogFactory.getLog(GenericExceptionMapper.class); + + @Override + public Response toResponse(WebApplicationException webApplicationException) { + if (log.isDebugEnabled()) { + log.debug("Internal erver error", webApplicationException); + } + // if no specific error message specified, spitting out a generaic error + // message + String errorMessage = + (webApplicationException.getMessage() != null) + ? webApplicationException.getMessage() + : "Internal server error"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + errorMessage)).build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java new file mode 100644 index 0000000000..4dc5573304 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.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.metadataservice.handlers; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.impl.HttpHeadersImpl; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.apache.stratos.metadataservice.oauth2.ValidationServiceClient; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; + +/** + * This class responsible for OAuth based authentication/authorization. A client + * has to bring a valid OAuth token from a + * a OAuth provider. This class intercept the request and calls the + * OAuthTokenValidation endpoint of the provider. + */ +public class OAuthHandler extends AbstractAuthenticationAuthorizationHandler { + private static Log log = LogFactory.getLog(OAuthHandler.class); + private static String SUPPORTED_AUTHENTICATION_TYPE = "Bearer"; + private static String oauthValidationEndpoint; + private static String username; + private static String password; + + public void setOauthValidationEndpoint(String oauthValidationEndpoint) { + OAuthHandler.oauthValidationEndpoint = oauthValidationEndpoint; + } + + public void setUsername(String username) { + OAuthHandler.username = username; + } + + public void setPassword(String password) { + OAuthHandler.password = password; + } + + @Override + public boolean canHandle(String authHeaderPrefix) { + return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix); + } + + @Override + public Response handle(Message message, ClassResourceInfo classResourceInfo) { + try { + OAuth2TokenValidationResponseDTO respDTO; + ValidationServiceClient validationServiceClient = + new ValidationServiceClient( + oauthValidationEndpoint, + username, + password); + HttpHeaders httpHeaders = new HttpHeadersImpl(message); + String header = httpHeaders.getRequestHeaders().getFirst("Authorization"); + // if the authorization token has Bearer.. + if (header.startsWith("Bearer ")) { + String accessToken = header.substring(7).trim(); + respDTO = validationServiceClient.validateAuthenticationRequest(accessToken); // TODO + // : + // send + // scope + // params + boolean valid = respDTO.getValid(); + if (!valid) { + // authorization failure.. + return Response.status(Response.Status.FORBIDDEN).build(); + } + } + } catch (Exception e) { + log.error("Error while validating access token", e); + return Response.status(Response.Status.FORBIDDEN).build(); + } + AuthenticationContext.setAuthenticated(true); + return null; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java new file mode 100644 index 0000000000..fd83b8e85f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java @@ -0,0 +1,156 @@ +/* + * 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.metadataservice.handlers; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.configuration.security.AuthorizationPolicy; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.cxf.security.SecurityContext; +import org.apache.stratos.metadataservice.ServiceHolder; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.apache.stratos.metadataservice.security.StratosSecurityContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.util.AnonymousSessionUtil; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +/** + * Here we are doing the request authentication within a {@link RequestHandler}. + * The request handlers + * are get invoked just before the actual method invocation. This authentication + * handler make use + * of HTTP basic auth headers as the authentication mechanism. + */ +public class StratosAuthenticationHandler extends AbstractAuthenticationAuthorizationHandler { + private static Log log = LogFactory.getLog(StratosAuthenticationHandler.class); + private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic"; + + @Override + public boolean canHandle(String authHeaderPrefix) { + return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix); + } + + /** + * Authenticate the user against the user store. Once authenticate, populate + * the {@link org.wso2.carbon.context.CarbonContext} to be used by the + * downstream code. + * + * @param message + * @param classResourceInfo + * @return + */ + @Override + public Response handle(Message message, ClassResourceInfo classResourceInfo) { + // If Mutual SSL is enabled + HttpServletRequest request = (HttpServletRequest) message.get("HTTP.REQUEST"); + Object certObject = request.getAttribute("javax.servlet.request.X509Certificate"); + + AuthorizationPolicy policy = message.get(AuthorizationPolicy.class); + String username = policy.getUserName().trim(); + String password = policy.getPassword().trim(); + + // sanity check + if ((username == null) || username.equals("")) { + log.error("username is seen as null/empty values."); + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Username cannot be null")).build(); + } else if (certObject == null && ((password == null) || password.equals(""))) { + log.error("password is seen as null/empty values."); + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("password cannot be null")).build(); + } + + try { + RealmService realmService = ServiceHolder.getRealmService(); + RegistryService registryService = ServiceHolder.getRegistryService(); + String tenantDomain = MultitenantUtils.getTenantDomain(username); + int tenantId = realmService.getTenantManager().getTenantId(tenantDomain); + + UserRealm userRealm = null; + if (certObject == null) { + userRealm = + AnonymousSessionUtil.getRealmByTenantDomain(registryService, + realmService, tenantDomain); + if (userRealm == null) { + log.error("Invalid domain or unactivated tenant login"); + // is this the correct HTTP code for this scenario ? (401) + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic") + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Tenant not found")).build(); + } + } + username = MultitenantUtils.getTenantAwareUsername(username); + if (certObject != null || + userRealm.getUserStoreManager().authenticate(username, password)) { // if + // authenticated + + // setting the correct tenant info for downstream code.. + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(tenantDomain); + carbonContext.setTenantId(tenantId); + carbonContext.setUsername(username); + // populate the secuirtyContext of authenticated user + SecurityContext securityContext = new StratosSecurityContext(username); + message.put(SecurityContext.class, securityContext); + + // set the authenticated flag and let the request to continue + AuthenticationContext.setAuthenticated(true); + if (log.isDebugEnabled()) { + log.debug("authenticated using the " + + CookieBasedAuthenticationHandler.class.getName() + "for username :" + + username + "tenantDomain : " + tenantDomain + " tenantId : " + + tenantId); + } + return null; + } else { + log.warn("unable to authenticate the request"); + // authentication failed, request the authetication, add the + // realm name if needed to the value of WWW-Authenticate + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic") + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Authentication failed. Please " + + "check your username/password")) + .build(); + } + } catch (Exception exception) { + log.error("Authentication failed", exception); + // server error in the eyes of the client. Hence 5xx HTTP code. + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Unexpected error. Please contact the system admin")) + .build(); + } + + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java new file mode 100644 index 0000000000..429399f68b --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java @@ -0,0 +1,333 @@ +/* + * 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.metadataservice.handlers; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.common.util.ClassHelper; +import org.apache.cxf.frontend.MethodDispatcher; +import org.apache.cxf.interceptor.security.AccessDeniedException; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.cxf.service.Service; +import org.apache.cxf.service.model.BindingOperationInfo; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +/** + * {@link StratosAuthorizingHandler} authorize resource requests. It collects + * expected permission + * details using annotations present in the service bean. This particular + * implementation is inspired + * by the {@link org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter} + */ +public class StratosAuthorizingHandler implements RequestHandler { + private final Log log = LogFactory.getLog(StratosAuthorizingHandler.class); + + private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic"; + private static final String AUTHORIZATION_ANNOTATION_CLASS_NAME = + "org.apache.stratos.metadataservice.annotation.AuthorizationAction"; + private static final String TENANT_ANNOTATION_CLASS_NAME = + "org.apache.stratos.metadataservice.annotation.SuperTenantService"; + private static final String ACTION_ON_RESOURCE = "ui.execute"; + private static final Set SKIP_METHODS; + private Map authorizationActionMap = Collections.emptyMap(); + private Set superTenantServiceSet = Collections.emptySet(); + + static { + SKIP_METHODS = new HashSet(); + SKIP_METHODS.addAll(Arrays.asList(new String[] { "wait", "notify", "notifyAll", "equals", + "toString", "hashCode" })); + } + + @Override + public Response handleRequest(Message message, ClassResourceInfo resourceClass) { + try { + AuthenticationContext.setAuthenticated(false); // TODO : fix this + // properly + String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (log.isDebugEnabled()) { + log.debug("authorizing the action using" + + StratosAuthorizingHandler.class.getName()); + log.debug("username :" + userName); + log.debug("tenantDomain" + tenantDomain); + log.debug("tenantId :" + tenantId); + } + Method targetMethod = getTargetMethod(message); + if (!authorize(userName, tenantDomain, tenantId, targetMethod)) { + log.warn("User :" + userName + "trying to perform unauthrorized action" + + " against the resource :" + targetMethod); + return Response.status(Response.Status.FORBIDDEN) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("The user does not have required permissions to " + + "perform this operation")).build(); + } + return null; + + } catch (Exception exception) { + log.error("Unexpected error occured while REST api, authorization process", exception); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Unexpected error. Please contact the system admin")) + .build(); + } + } + + private boolean authorize(String userName, String tenantDomain, int tenantId, + Method targetMethod) throws Exception { + // first we try to see whether this is a super.tenant only operation + if (superTenantServiceSet.contains(targetMethod.getName()) && + !isCurrentUserSuperTenant(tenantDomain, tenantId)) { + return false; + } + // authorize using permissionString given as annotation in the service + // class + String permissionString = authorizationActionMap.get(targetMethod.getName()); + + // get the authorization manager for this tenant.. + UserRealm userRealm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); + AuthorizationManager authorizationManager = userRealm.getAuthorizationManager(); + + boolean isAuthorized = + isAuthorized(authorizationManager, userName, permissionString, + ACTION_ON_RESOURCE); + return isAuthorized; + + } + + private boolean isCurrentUserSuperTenant(String tenantDomain, int tenantId) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain) && + MultitenantConstants.SUPER_TENANT_ID == tenantId) { + return true; + } + return false; + } + + private boolean isAuthorized(AuthorizationManager authorizationManager, String username, + String permissionString, String action) throws UserStoreException { + boolean isAuthorized = false; + String[] resourceIds = permissionString.trim().split(","); + for (String resourceId : resourceIds) { + if (authorizationManager.isUserAuthorized(username, resourceId, action)) { + isAuthorized = true; + break; + } + } + return isAuthorized; + } + + /** + * Here we are getting the target invocation method. The method get set as a + * property in the + * message by the + * {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor} + * + * @param message + * incoming message + * @return + */ + protected Method getTargetMethod(Message message) { + BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class); + if (bop != null) { + MethodDispatcher md = + (MethodDispatcher) message.getExchange().get(Service.class) + .get(MethodDispatcher.class.getName()); + return md.getMethod(bop); + } + Method method = (Method) message.get("org.apache.cxf.resource.method"); + if (method != null) { + return method; + } + log.error("The requested resource is not found. Please check the resource path etc.."); + throw new AccessDeniedException("Method is not available : Unauthorized"); + } + + /** + * The instance of the secured bean get injected by the IOC framework + * + * @param securedObject + */ + public void setSecuredObject(Object securedObject) { + Class clazz = ClassHelper.getRealClass(securedObject); + authorizationActionMap = getAuthorizationActionMap(clazz); + superTenantServiceSet = getSuperTenantServiceSet(clazz); + + } + + private Set getSuperTenantServiceSet(Class clazz) { + Set superTenantServiceSet = new HashSet(); + findSuperTenantServices(clazz, superTenantServiceSet); + return superTenantServiceSet; + } + + private Map getAuthorizationActionMap(Class clazz) { + Map authorizationActionMap = new HashMap(); + findAuthorizationActions(clazz, authorizationActionMap); + return authorizationActionMap; + } + + /** + * Goes through the class hierarchy and find the authorization annotations + * attached to a certain + * method. + * + * @param clazz + * class to be scanned + * @param authorizationActionMap + * the map to be populated + */ + private void findAuthorizationActions(Class clazz, Map authorizationActionMap) { + if (clazz == null || clazz == Object.class) { + return; + } + String classAuthorizationActionsAllowed = + getAuthorizationActions(clazz.getAnnotations(), + AUTHORIZATION_ANNOTATION_CLASS_NAME); + for (Method m : clazz.getMethods()) { + if (SKIP_METHODS.contains(m.getName())) { + continue; + } + String methodAuthorizationActionsAllowed = + getAuthorizationActions(m.getAnnotations(), + AUTHORIZATION_ANNOTATION_CLASS_NAME); + String authorizationActions = + methodAuthorizationActionsAllowed != null + ? methodAuthorizationActionsAllowed + : classAuthorizationActionsAllowed; + if (authorizationActions != null) { + authorizationActionMap.put(m.getName(), authorizationActions); + } + } + if (!authorizationActionMap.isEmpty()) { + return; + } + + findAuthorizationActions(clazz.getSuperclass(), authorizationActionMap); + + if (!authorizationActionMap.isEmpty()) { + return; + } + + for (Class interfaceCls : clazz.getInterfaces()) { + findAuthorizationActions(interfaceCls, authorizationActionMap); + } + } + + /** + * Goes through the class hierarchy and figure out the supertenant + * annotations coupled with operations/methods. + * + * @param clazz + * @param superTenantServiceSet + */ + private void findSuperTenantServices(Class clazz, Set superTenantServiceSet) { + if (clazz == null || clazz == Object.class) { + return; + } + for (Method m : clazz.getMethods()) { + if (SKIP_METHODS.contains(m.getName())) { + continue; + } + boolean isSuperTenantService = + getSuperTenantServices(m.getAnnotations(), + TENANT_ANNOTATION_CLASS_NAME); + if (isSuperTenantService) { + superTenantServiceSet.add(m.getName()); + } + } + if (!superTenantServiceSet.isEmpty()) { + return; + } + + findSuperTenantServices(clazz.getSuperclass(), superTenantServiceSet); + + if (!superTenantServiceSet.isEmpty()) { + return; + } + + for (Class interfaceCls : clazz.getInterfaces()) { + findSuperTenantServices(interfaceCls, superTenantServiceSet); + } + } + + private boolean getSuperTenantServices(Annotation[] annotations, + String tenantAnnotationClassName) { + for (Annotation ann : annotations) { + if (ann.annotationType().getName().equals(tenantAnnotationClassName)) { + try { + Method valueMethod = ann.annotationType().getMethod("value", new Class[] {}); + boolean isSuperTenantService = + (Boolean) valueMethod.invoke(ann, + new Object[] {}); + return isSuperTenantService; + } catch (Exception ex) { + // ignore + } + break; + } + } + return false; + } + + private String getAuthorizationActions(Annotation[] annotations, + String authorizationAnnotationClassName) { + for (Annotation ann : annotations) { + if (ann.annotationType().getName().equals(authorizationAnnotationClassName)) { + try { + Method valueMethod = ann.annotationType().getMethod("value", new Class[] {}); + String[] permissions = (String[]) valueMethod.invoke(ann, new Object[] {}); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < permissions.length; i++) { + sb.append(permissions[i]); + if (i + 1 < permissions.length) { + sb.append(","); + } + } + return sb.toString(); + } catch (Exception ex) { + // ignore + } + break; + } + } + return null; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java new file mode 100644 index 0000000000..b8fe9185d1 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -0,0 +1,112 @@ +package org.apache.stratos.metadataservice.listener; + +/* + * + * 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.messaging.event.Event; +import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.MemberSuspendedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.metadataservice.services.MetaDataAdmin; + +/** + * Cartridge agent runnable. + */ +public class TopologyAgent implements Runnable { + + private static final Log log = LogFactory.getLog(TopologyAgent.class); + + private boolean terminated; + + @Override + public void run() { + if (log.isInfoEnabled()) { + log.info("Topology agent started"); + } + + // Start topology event receiver thread + registerTopologyEventListeners(); + + } + + protected void registerTopologyEventListeners() { + if (log.isDebugEnabled()) { + log.debug("Starting topology event message receiver thread"); + } + TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); + + topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + try { + log.info("Member terminated event received"); + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member terminated event received"); + } + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + System.out.println("Terminated event :::::::::::::::::::: " + + memberTerminatedEvent.getServiceName()); + new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member terminated event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { + @Override + protected void onEvent(Event event) { + try { + log.info("Member suspended event received"); + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member suspended event received"); + } + MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member suspended event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + Thread thread = new Thread(topologyEventReceiver); + thread.start(); + if (log.isDebugEnabled()) { + log.info("Cartridge Agent topology receiver thread started"); + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java new file mode 100644 index 0000000000..2f09d3db4a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java @@ -0,0 +1,124 @@ +package org.apache.stratos.metadataservice.listener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.topology.MemberStartedEvent; +import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberSuspendedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.metadataservice.services.MetaDataAdmin; + +public class TopologyListener implements ServletContextListener { + + private static final Log log = LogFactory.getLog(TopologyListener.class); + + private TopologyAgent topologyThread = null; + private Thread thread = null; + + @Override + public void contextInitialized(ServletContextEvent arg0) { + log.info("Topology literner started...."); + if (topologyThread == null) { + // load default agent + topologyThread = new TopologyAgent(); + if (log.isDebugEnabled()) { + log.debug("Loading default Cartridge Agent."); + } + } + // start agent + thread = new Thread(topologyThread); + thread.start(); + + } + + @Override + public void contextDestroyed(ServletContextEvent arg0) { + thread.stop(); + } + + protected void registerTopologyEventListeners() { + if (log.isDebugEnabled()) { + log.debug("Starting topology event message receiver thread"); + } + TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); + + topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member terminated event received"); + } + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + System.out.println("Terminated event :::::::::::::::::::: " + + memberTerminatedEvent.getServiceName()); + new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); + + // extensionHandler.onMemberTerminatedEvent(memberTerminatedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member terminated event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member suspended event received"); + } + MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member suspended event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberStartedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member started event received"); + } + MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event; + // extensionHandler.onMemberStartedEvent(memberStartedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member started event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + Thread thread = new Thread(topologyEventReceiver); + thread.start(); + if (log.isDebugEnabled()) { + log.info("Cartridge Agent topology receiver thread started"); + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java new file mode 100644 index 0000000000..dbc8947560 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java @@ -0,0 +1,65 @@ +/* + * 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.metadataservice.oauth2; + +import java.rmi.RemoteException; + +import org.apache.axis2.AxisFault; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; +import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; + +/** + * Service class wrapper for OAuthTokenValidation endpoint. + */ +public class ValidationServiceClient { + private OAuth2TokenValidationServiceStub stub = null; + private static final Log log = LogFactory.getLog(OAuth2TokenValidationServiceStub.class); + + public ValidationServiceClient(String backendServerURL, String username, String password) + throws Exception { + String serviceURL = backendServerURL + "OAuth2TokenValidationService"; + try { + stub = new OAuth2TokenValidationServiceStub(serviceURL); + CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, + stub._getServiceClient()); + } catch (AxisFault e) { + log.error("Error initializing OAuth2 Client"); + throw new Exception("Error initializing OAuth Client", e); + } + } + + public OAuth2TokenValidationResponseDTO validateAuthenticationRequest(String accessToken) + throws Exception { + OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO(); + oauthReq.setAccessToken(accessToken); + oauthReq.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE); + try { + return stub.validate(oauthReq); + } catch (RemoteException e) { + log.error("Error while validating OAuth2 request"); + throw new Exception("Error while validating OAuth2 request", e); + } + } + +} 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 new file mode 100644 index 0000000000..7d5acd038c --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java @@ -0,0 +1,187 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.metadataservice.registry; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.wso2.carbon.core.AbstractAdmin; +import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Comment; +import org.wso2.carbon.registry.core.service.RegistryService; + +public class CarbonRegistry extends AbstractAdmin implements DataStore { + + private static Log log = LogFactory.getLog(CarbonRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext = null; + + private static String defaultAxis2Repo = "repository/deployment/client"; + private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; + private RegistryService registryService; + + public CarbonRegistry() { + + } + + /* + * Add the meta data to governance registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, + * org.apache.stratos.metadataservice.definition.CartridgeMetaData) + */ + @Override + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + System.out.println("Adding meta data details"); + + Registry tempRegistry = getGovernanceUserRegistry(); + try { + + Resource resource = tempRegistry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("host", cartridgeMetaData.host); + + for (PropertyBean prop : cartridgeMetaData.property) { + resource.addProperty("hostname", prop.hostname); + resource.addProperty("username", prop.username); + resource.addProperty("password", prop.password); + } + + tempRegistry.put(resourcePath, resource); + + System.out.println("A resource added to: " + resourcePath); + + System.out.println(cartridgeMetaData.type); + // registry.rateResource(resourcePath, defaultRank); + + Comment comment = new Comment(); + comment.setText("Added the " + applicationName + " " + type + " cartridge"); + // registry.addComment(resourcePath, comment); + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + + } + System.out.println("Add meta data details"); + return "success"; + } + + /* + * Get the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + try { + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + System.out.println("Resource retrived"); + System.out.println("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + + List lst = new ArrayList(); + PropertyBean prop = new PropertyBean(); + prop.hostname = getResource.getProperty("hostname"); + prop.username = getResource.getProperty("username"); + prop.password = getResource.getProperty("password"); + lst.add(prop); + + cartridgeMetaData.property = lst; + + } + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + + } + return cartridgeMetaData.toString(); + } + + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + registry.delete(resourcePath); + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java new file mode 100644 index 0000000000..25f0053f5a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.registry; + +/* + * Factory for the Data Registry + */ +public class DataRegistryFactory { + + public static DataStore getDataRegistryFactory(String registryName) { + if (registryName.equals("GREG")) { + return new GRegRegistry(); + } else if (registryName.equals("OWN")) { + return new CarbonRegistry(); + } else { + return null; + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java new file mode 100644 index 0000000000..93302b7244 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.registry; + +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; + +/* + * Interface of the Data Store + */ +public interface DataStore { + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception; + + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception; + + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception; + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java new file mode 100644 index 0000000000..080fc60c0b --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -0,0 +1,220 @@ +/* + * 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.metadataservice.registry; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.apache.stratos.metadataservice.util.ConfUtil; +import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Comment; +import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; + +/** + * + * Governance registry implementation for the registry factory + * + */ +public class GRegRegistry implements DataStore { + + private static Log log = LogFactory.getLog(GRegRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext = null; + + private static String defaultAxis2Repo = "repository/deployment/client"; + private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; + + /* + * Registry initiation + */ + private static WSRegistryServiceClient setRegistry() throws Exception { + + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + + String gregUsername = conf.getString("metadataservice.username", defaultUsername); + String gregPassword = conf.getString("metadataservice.password", defaultPassword); + String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); + String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); + String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); + String defaultTrustStore = + "repository" + File.separator + "resources" + File.separator + + "security" + File.separator + "wso2carbon.jks"; + String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); + String trustStorePassword = + conf.getString("metadataservice.trustStorePassword", + "wso2carbon"); + String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); + + System.setProperty("javax.net.ssl.trustStore", trustStorePath); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" + System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" + System.setProperty("carbon.repo.write.mode", "true"); + configContext = + ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, + axis2Conf); + return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); + } + + /* + * Add the meta data to governance registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, + * org.apache.stratos.metadataservice.definition.CartridgeMetaData) + */ + @Override + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + System.out.println("Adding meta data details"); + Registry registry = setRegistry(); + try { + + Resource resource = registry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("host", cartridgeMetaData.host); + + for (PropertyBean prop : cartridgeMetaData.property) { + resource.addProperty("hostname", prop.hostname); + resource.addProperty("username", prop.username); + resource.addProperty("password", prop.password); + } + + registry.put(resourcePath, resource); + + System.out.println("A resource added to: " + resourcePath); + + System.out.println(cartridgeMetaData.type); + registry.rateResource(resourcePath, defaultRank); + + Comment comment = new Comment(); + comment.setText("Added the " + applicationName + " " + type + " cartridge"); + registry.addComment(resourcePath, comment); + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + System.out.println("Add meta data details"); + return "success"; + } + + /* + * Get the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + try { + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + System.out.println("Resource retrived"); + System.out.println("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + + List lst = new ArrayList(); + PropertyBean prop = new PropertyBean(); + prop.hostname = getResource.getProperty("hostname"); + prop.username = getResource.getProperty("username"); + prop.password = getResource.getProperty("password"); + lst.add(prop); + + cartridgeMetaData.property = lst; + + } + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + return cartridgeMetaData.toString(); + } + + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + registry.delete(resourcePath); + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java new file mode 100644 index 0000000000..b0be94aee3 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java @@ -0,0 +1,53 @@ +/* + * 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.metadataservice.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.security.Principal; + +/** + * {@link StratosSecurityContext} make use of principal instance. Here with Stratos + * authentication/authorization framework we only need username as the principal details + */ +public class StratosPrincipal implements Principal { + private Log log = LogFactory.getLog(StratosPrincipal.class); + private String userName; + + public StratosPrincipal(String userName) { + this.userName = userName; + } + + public boolean equals(Object another) { + return userName.equals((another)); + } + + public String toString() { + return userName.toString(); + } + + public int hashCode() { + return userName.hashCode(); + } + + public String getName() { + return userName; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java new file mode 100644 index 0000000000..5cc64f3da8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java @@ -0,0 +1,50 @@ +/* + * 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.metadataservice.security; + +import java.security.Principal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.security.SecurityContext; + +/** + * {@link StratosSecurityContext} is what get passed between authentication + * handlers + * and the authorization handler. + */ +public class StratosSecurityContext implements SecurityContext { + private static Log log = LogFactory.getLog(StratosSecurityContext.class); + Principal principal; + + public StratosSecurityContext(String user) { + this.principal = new StratosPrincipal(user); + } + + @Override + public Principal getUserPrincipal() { + return principal; + } + + @Override + public boolean isUserInRole(String role) { + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java new file mode 100644 index 0000000000..e30ffec22e --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -0,0 +1,87 @@ +package org.apache.stratos.metadataservice.services; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; + +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.annotation.AuthorizationAction; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.exception.RestAPIException; +import org.apache.stratos.metadataservice.registry.DataRegistryFactory; +import org.apache.stratos.metadataservice.util.ConfUtil; + +@Path("/metadataservice/") +public class MetaDataAdmin { + + private static Log log = LogFactory.getLog(MetaDataAdmin.class); + @Context + HttpServletRequest httpServletRequest; + + private final String defaultRegType = "GREG"; + + private XMLConfiguration conf; + + @POST + @Path("/init") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public void initialize() throws RestAPIException { + conf = ConfUtil.getInstance(null).getConfiguration(); + } + + @POST + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public String addCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .addCartridgeMetaDataDetails(applicationName, cartridgeType, + cartridgeMetaData); + + } + + @GET + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public String getCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType) + + throws Exception { + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .getCartridgeMetaDataDetails(applicationName, cartridgeType); + + } + + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .removeCartridgeMetaDataDetails(applicationName, cartridgeType); + + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java new file mode 100644 index 0000000000..bbe20786c0 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -0,0 +1,74 @@ +/* + * 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.metadataservice.util; + +import java.io.File; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Constants; +import org.wso2.carbon.utils.CarbonUtils; + +/** + * This class contains utility methods for read metadata configuration file. + */ +public class ConfUtil { + + private static Log log = LogFactory.getLog(ConfUtil.class); + + private XMLConfiguration config; + + private static ConfUtil instance = null; + + private ConfUtil(String configFilePath) { + log.info("Loading configuration....."); + try { + + File confFile; + if (configFilePath != null && !configFilePath.isEmpty()) { + confFile = new File(configFilePath); + + } else { + confFile = + new File(CarbonUtils.getCarbonConfigDirPath(), + Constants.METADATASERVICE_CONFIG_FILE_NAME); + } + + config = new XMLConfiguration(confFile); + } catch (ConfigurationException e) { + log.error("Unable to load autoscaler configuration file", e); + config = new XMLConfiguration(); // continue with default values + } + } + + public static ConfUtil getInstance(String configFilePath) { + if (instance == null) { + instance = new ConfUtil(configFilePath); + } + return instance; + } + + public XMLConfiguration getConfiguration() { + return config; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml b/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml new file mode 100644 index 0000000000..db07954a47 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml @@ -0,0 +1,299 @@ + + + + + + + true + false + false + + + 500 + + 15000 + + + false + + + + true + + + + + + false + + + admin + axis2 + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6071 + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + 60000 + 60000 + + + HTTP/1.1 + chunked + 60000 + 60000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml new file mode 100644 index 0000000000..c62912d716 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ + + + + + + + + false + + + CXF,Carbon + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..f8b8750046 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + > + + + + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml new file mode 100644 index 0000000000..4a752f67b8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml @@ -0,0 +1,40 @@ + + + + + + S2 Meta Data Admin Endpoint + + + StratosAdminEndpoint + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + + StratosAdminEndpoint + /* + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml new file mode 100644 index 0000000000..c62912d716 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ + + + + + + + + false + + + CXF,Carbon + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..bf40055d77 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + partitions + property + hostNames + memberMap + portMap + partitionGroup + partition + member + hostNames + portMappings + volumes + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml new file mode 100644 index 0000000000..7929bedd95 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + S2 Admin Endpoint + + org.apache.stratos.metadataservice.listener.TopologyListener + + + StratosAdminEndpoint + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + + StratosAdminEndpoint + /* + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml new file mode 100644 index 0000000000..f12fed0bc5 --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml @@ -0,0 +1,320 @@ + + + + + + + org.apache.stratos + stratos-manager-features + 4.0.0 + ../../pom.xml + + + 4.0.0 + org.apache.stratos.metadataservice.feature + pom + Apache Stratos - Meta Data Service feature + This feature packs the Meta Data Service of stratos + + + + + org.apache.cxf + cxf-bundle + 2.7.6 + + + org.apache.cxf.xjcplugins + cxf-xjc-dv + 2.6.2 + + + commons-lang + commons-lang + 2.6 + + + org.apache.cxf.xjc-utils + cxf-xjc-runtime + 2.6.2 + + + org.apache.velocity + velocity + 1.7 + + + org.apache.cxf.xjcplugins + cxf-xjc-ts + 2.6.2 + + + org.apache.cxf.xjcplugins + cxf-xjc-boolean + 2.6.2 + + + org.apache.cxf.xjcplugins + cxf-xjc-bug671 + 2.6.2 + + + net.sf.ehcache + ehcache-core + 2.5.1 + + + org.apache.httpcomponents + httpasyncclient + 4.0-beta3 + + + org.apache.httpcomponents + httpclient + 4.2.5 + + + org.apache.httpcomponents + httpcore + 4.2.4 + + + org.apache.httpcomponents + httpcore-nio + 4.2.4 + + + javax.ws.rs + javax.ws.rs-api + 2.0-m10 + + + com.sun.xml.bind + jaxb-impl + 2.1.13 + + + com.sun.xml.bind + jaxb-xjc + 2.1.13 + + + org.codehaus.woodstox + woodstox-core-asl + 4.2.0 + + + org.codehaus.woodstox + stax2-api + 3.1.1 + + + org.codehaus.jettison + jettison + 1.3.4 + + + org.apache.neethi + neethi + 3.0.2 + + + org.apache.ws.security + wss4j + 1.6.11 + + + xml-resolver + xml-resolver + 1.2 + + + org.apache.ws.xmlschema + xmlschema-core + 2.0.3 + + + org.apache.santuario + xmlsec + 1.5.5 + + + wsdl4j + wsdl4j + 1.6.3 + + + commons-logging + commons-logging + 1.1.1 + + + commons-collections + commons-collections + 3.2.1 + + + aopalliance + aopalliance + 1.0 + + + + org.springframework + spring-aop + 3.0.7.RELEASE + + + org.springframework + spring-asm + 3.0.7.RELEASE + + + org.springframework + spring-beans + 3.0.7.RELEASE + + + org.springframework + spring-context + 3.0.7.RELEASE + + + org.springframework + spring-core + 3.0.7.RELEASE + + + org.springframework + spring-expression + 3.0.7.RELEASE + + + org.springframework + spring-web + 3.0.7.RELEASE + + + org.wso2.carbon.webapp.ext + carbon-cxf + 1.0.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + + + + + + + + + + ${project.build.directory}/runtime/ + + + ${project.build.directory}/web-app/ + + + src/main/resources + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/runtime/cxf + true + + + + pack-REST-webapp + package + + copy + + + + + org.apache.stratos + org.apache.stratos.metadataservice + ${project.version} + war + true + ${project.build.directory}/web-app/web-app + stratosmetadataservice.war + + + + + + + + org.wso2.maven + carbon-p2-plugin + + + p2-feature-generation + package + + p2-feature-gen + + + org.apache.stratos.metadataservice + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.apache.stratos:org.apache.stratos.manager.stub:${project.version} + + + org.wso2.carbon.core:${wso2carbon.version} + + + + + + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..13f9684e35 --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf @@ -0,0 +1,23 @@ +# 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. + +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/cxf,target:${installFolder}/../../../lib/runtimes/cxf,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/web-app/stratosmetadataservice.war,target:${installFolder}/../../deployment/server/webapps/stratosmetadataservice.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading-environments.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading-environments.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/context.xml,target:${installFolder}/../../conf/tomcat/context.xml,overwrite:true);\ diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml new file mode 100644 index 0000000000..a85c9affed --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml new file mode 100644 index 0000000000..7e7dd0ab7c --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + Tomcat + javax.annotation.*,javax.ejb,javax.el,javax.persistence,javax.servlet.*,javax.xml,javax.xml.ws,org.apache.catalina.*,org.apache.coyote.*,org.apache.el.*,com.sun.el.*,org.apache.jasper.*,org.apache.naming.*,org.apache.tomcat.*,org.wso2.carbon.tomcat.jndi.* + + + + Carbon + *,!org.springframework.* + + + + + + + + + + + + + CXF + ${carbon.home}/lib/runtimes/cxf/*.jar;${carbon.home}/lib/runtimes/cxf/ + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml new file mode 100644 index 0000000000..f42616f97d --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml @@ -0,0 +1,33 @@ + + + + + + + + + false + + + Carbon + diff --git a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml index 109a987a28..fd8457b62e 100644 --- a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml +++ b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml @@ -216,6 +216,16 @@ carbon-cxf 1.0.0 + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps/stratosmetadataservice.war + ${pom.artifactId}-${pom.version}/repository/deployment/server/webapps/ + 644 + ../../conf/data-bridge/data-bridge-config.xml diff --git a/products/stratos/modules/distribution/src/bin/stratos.sh b/products/stratos/modules/distribution/src/bin/stratos.sh index 644b8a6c16..eda37301d3 100755 --- a/products/stratos/modules/distribution/src/bin/stratos.sh +++ b/products/stratos/modules/distribution/src/bin/stratos.sh @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. # ---------------------------------------------------------------------------- -# Main Script for the Apache Stratos +# Main Script for the Apache Stratos (incubating) # # Environment Variable Prerequisites # @@ -183,7 +183,7 @@ elif [ "$CMD" = "start" ]; then fi export CARBON_HOME=$CARBON_HOME # using nohup bash to avoid erros in solaris OS.TODO - nohup bash $CARBON_HOME/bin/stratos.sh $args < /dev/null > /dev/null 2>&1 & + nohup bash $CARBON_HOME/bin/stratos.sh $args > /dev/null 2>&1 & exit 0 elif [ "$CMD" = "stop" ]; then export CARBON_HOME=$CARBON_HOME @@ -202,7 +202,7 @@ elif [ "$CMD" = "restart" ]; then done # using nohup bash to avoid erros in solaris OS.TODO - nohup bash $CARBON_HOME/bin/stratos.sh $args < /dev/null > /dev/null 2>&1 & + nohup bash $CARBON_HOME/bin/stratos.sh $args > /dev/null 2>&1 & exit 0 elif [ "$CMD" = "test" ]; then JAVACMD="exec "$JAVACMD"" diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml new file mode 100644 index 0000000000..d871bc0b9f --- /dev/null +++ b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml @@ -0,0 +1,37 @@ + + + + + OWN + https://localhost:9445/services/ + admin + admin + + stratos + repository/deployment/client + repository/conf/axis2/axis2_client.xml + repository/resources/security/wso2carbon.jks + wso2carbon + JKS + + + + + diff --git a/products/stratos/modules/distribution/src/main/license/LICENSE b/products/stratos/modules/distribution/src/main/license/LICENSE index cb34d1dfab..a7e9dc5208 100644 --- a/products/stratos/modules/distribution/src/main/license/LICENSE +++ b/products/stratos/modules/distribution/src/main/license/LICENSE @@ -704,9 +704,6 @@ tcpmon-1.0.jar, xstream-1.4.1.jar, dhtmlHistory.js -Copyright (c) 2010 Terence Parr -All rights reserved. - [The BSD License] Redistribution and use in source and binary forms, with or without modification, @@ -1049,6 +1046,7 @@ Scriptaculous-1.7.0 The MIT License (MIT) + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/products/stratos/modules/p2-profile-gen/pom.xml b/products/stratos/modules/p2-profile-gen/pom.xml index 1500759a91..0db341c58c 100644 --- a/products/stratos/modules/p2-profile-gen/pom.xml +++ b/products/stratos/modules/p2-profile-gen/pom.xml @@ -22,7 +22,11 @@ org.apache.stratos stratos +<<<<<<< HEAD 4.1.0-SNAPSHOT +======= + 4.0.0 +>>>>>>> ba4d11984f33c63ed1332569831889f4892c5351 ../../pom.xml @@ -207,6 +211,7 @@ org.apache.stratos:org.apache.stratos.manager.feature:${project.version} org.apache.stratos:org.apache.stratos.cartridge.mgt.ui.feature:${project.version} org.apache.stratos:org.apache.stratos.rest.endpoint.feature:${project.version} + org.apache.stratos:org.apache.stratos.metadataservice.feature:${project.version} org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.patch.version.4.2.1} org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.patch.version.4.2.2} org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.patch.version.4.2.1} @@ -217,7 +222,7 @@ org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:4.2.1 org.apache.stratos:org.apache.stratos.messaging.feature:${project.version} org.apache.stratos:org.apache.stratos.autoscaler.feature:${project.version} - org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.version}--> + org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.version} org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.version} org.apache.stratos:org.apache.stratos.cloud.controller.feature:${project.version} org.wso2.carbon:org.apache.synapse.wso2.feature:${synapse.version} @@ -411,6 +416,10 @@ org.apache.stratos.rest.endpoint.feature.group ${project.version} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + org.apache.stratos.messaging.feature.group ${project.version} @@ -491,6 +500,14 @@ org.wso2.carbon.registry.resource.properties.feature.group ${carbon.platform.patch.version.4.2.1} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + + + org.apache.stratos.metadataservice.feature.group + ${project.version} + @@ -573,6 +590,10 @@ org.wso2.carbon.event.server.feature.group ${carbon.platform.patch.version.4.2.1} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + @@ -686,6 +707,10 @@ org.apache.stratos.rest.endpoint.feature.group ${project.version} + + + org.apache.stratos.metadataservice.feature.group + ${project.version} org.apache.stratos.messaging.feature.group @@ -808,6 +833,10 @@ org.wso2.carbon.cassandra.common.feature.group ${carbon.platform.version} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + diff --git a/products/stratos/pom.xml b/products/stratos/pom.xml index c13eb9e991..c7be49434c 100755 --- a/products/stratos/pom.xml +++ b/products/stratos/pom.xml @@ -228,6 +228,7 @@ org.apache.stratos.redirector.servlet ${project.version} + org.apache.batik.wso2 batik diff --git a/tools/stratos-installer/conf/setup.conf b/tools/stratos-installer/conf/setup.conf index 9522bc29d7..9d771620ee 100644 --- a/tools/stratos-installer/conf/setup.conf +++ b/tools/stratos-installer/conf/setup.conf @@ -103,3 +103,8 @@ export userstore_db_schema="userstore" export userstore_db_port="3306" export userstore_db_user="root" export userstore_db_pass="root" + + +# GREG +export greg_pack_zip=$stratos_packs/"wso2greg-4.6.0.zip" +export greg_extract_path=$stratos_path/"wso2greg-4.6.0" diff --git a/tools/stratos-installer/config/all/repository/conf/metadataservice.xml b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml new file mode 100644 index 0000000000..690e056579 --- /dev/null +++ b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml @@ -0,0 +1,37 @@ + + + + + GREG + https://localhost:9445/services/ + admin + admin + + stratos + repository/deployment/client + repository/conf/axis2/axis2_client.xml + repository/resources/security/wso2carbon.jks + wso2carbon + JKS + + + + + diff --git a/tools/stratos-installer/config/greg/repository/conf/carbon.xml b/tools/stratos-installer/config/greg/repository/conf/carbon.xml new file mode 100644 index 0000000000..84d97dbb3d --- /dev/null +++ b/tools/stratos-installer/config/greg/repository/conf/carbon.xml @@ -0,0 +1,609 @@ + + + + + + + + + WSO2 Governance Registry + + + Greg + + + 4.6.0 + + + + + + + + + local:/${carbon.context}/services/ + + + + + + + GovernanceRegistry + + + + + + + org.wso2.carbon + + + / + + + + + + 15 + + + + + + + + + 2 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 5672 + + 8672 + + + + + + 10500 + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + false + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + + + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + http://dist.wso2.org/p2/carbon/releases/4.2.0 + + + + + + + + true + + + + + + true + + diff --git a/tools/stratos-installer/setup.sh b/tools/stratos-installer/setup.sh index 9966c69b68..5035af9a6a 100755 --- a/tools/stratos-installer/setup.sh +++ b/tools/stratos-installer/setup.sh @@ -33,6 +33,7 @@ profile="default" config_mb="true" mb_client_lib_path="" auto_start_servers="false" +config_greg="true" function help { echo "" @@ -227,11 +228,24 @@ function cc_setup() { pushd $stratos_extract_path + + + popd echo "End configuring the Cloud Controller" } +# Setup greg +function greg_setup() { + echo "Setup GREG" >> $LOG + echo "Configuring the GREG" + cp -f ./config/all/repository/conf/metadataservice.xml $stratos_extract_path/repository/conf/ + cp -f ./config/greg/repository/conf/carbon.xml $greg_extract_path/repository/conf/ + + + echo "End configuring the GREG" +} # AS related functions # ------------------------------------------------------------------- function as_related_popup() { @@ -508,6 +522,7 @@ if [ "$UID" -ne "0" ]; then fi general_conf_validate + if [[ $profile = "cc" ]]; then cc_conf_validate elif [[ $profile = "as" ]]; then @@ -539,7 +554,21 @@ if [[ ($profile = "default" && $config_mb = "true") ]]; then sed -r -i -e 's@^(\s*)(@g' $stratos_path/apache-activemq-5.9.1/conf/activemq.xml fi +if [[ ($profile = "default" && $config_greg = "true") ]]; then + echo "Extracting wso2 greg" + unzip -q $greg_pack_zip -d $stratos_path + +fi + general_setup + +if [[ ($profile = "default" && $config_greg = "true") ]]; then + echo "Running the GREG" + greg_setup + +fi + + if [[ $profile = "cc" ]]; then cc_setup elif [[ $profile = "as" ]]; then diff --git a/tools/stratos-installer/start-servers.sh b/tools/stratos-installer/start-servers.sh index b709abf9b4..7661d0e956 100755 --- a/tools/stratos-installer/start-servers.sh +++ b/tools/stratos-installer/start-servers.sh @@ -86,9 +86,12 @@ if [[ $profile = "default" ]]; then sleep 10 fi +echo "Starting wso2 greg server ..." >> $LOG +echo "$greg_extract_path/bin/wso2server.sh -Dprofile=$profile start" +$greg_extract_path/bin/wso2server.sh -Dprofile=$profile start +echo "Stratos server started" >> $LOG + echo "Starting Stratos server ..." >> $LOG echo "$stratos_extract_path/bin/stratos.sh -Dprofile=$profile start" $stratos_extract_path/bin/stratos.sh -Dprofile=$profile start echo "Stratos server started" >> $LOG - - From a495dc130bee3152e92253335ff0f31c260456d9 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 16 Sep 2014 11:00:16 +0530 Subject: [PATCH 050/436] Commiting changes of Metadata service This closes #37 --- .../pom.xml | 164 +++++ .../stratos/metadataservice/Constants.java | 29 + .../metadataservice/ServiceHolder.java | 84 +++ .../apache/stratos/metadataservice/Utils.java | 44 ++ .../annotation/AuthorizationAction.java | 36 ++ .../annotation/SuperTenantService.java | 34 + .../context/AuthenticationContext.java | 40 ++ .../definition/CartridgeMetaData.java | 43 ++ .../definition/PropertyBean.java | 37 ++ .../exception/RestAPIException.java | 70 ++ ...actAuthenticationAuthorizationHandler.java | 56 ++ .../CookieBasedAuthenticationHandler.java | 94 +++ .../handlers/CustomExceptionMapper.java | 47 ++ .../CustomThrowableExceptionMapper.java | 44 ++ .../handlers/GenericExceptionMapper.java | 54 ++ .../handlers/OAuthHandler.java | 95 +++ .../StratosAuthenticationHandler.java | 156 +++++ .../handlers/StratosAuthorizingHandler.java | 333 ++++++++++ .../listener/TopologyAgent.java | 112 ++++ .../listener/TopologyListener.java | 124 ++++ .../oauth2/ValidationServiceClient.java | 65 ++ .../registry/CarbonRegistry.java | 187 ++++++ .../registry/DataRegistryFactory.java | 36 ++ .../metadataservice/registry/DataStore.java | 36 ++ .../registry/GRegRegistry.java | 220 +++++++ .../security/StratosPrincipal.java | 53 ++ .../security/StratosSecurityContext.java | 50 ++ .../services/MetaDataAdmin.java | 87 +++ .../metadataservice/util/ConfUtil.java | 74 +++ .../src/main/resources/axis2_client.xml | 299 +++++++++ .../META-INF/webapp-classloading.xml | 35 + .../WEB-INF/cxf-servlet.xml | 46 ++ .../WEB-INF/web.xml | 40 ++ .../META-INF/webapp-classloading.xml | 35 + .../WEB-INF/cxf-servlet.xml | 79 +++ .../stratosmetadataservice/WEB-INF/web.xml | 42 ++ .../pom.xml | 320 +++++++++ .../src/main/resources/p2.inf | 23 + .../src/main/resources/tomcat/context.xml | 36 ++ .../webapp-classloading-environments.xml | 68 ++ .../resources/tomcat/webapp-classloading.xml | 33 + .../pom.xml | 10 + .../modules/distribution/src/assembly/bin.xml | 12 + .../modules/distribution/src/bin/stratos.sh | 6 +- .../src/main/conf/metadataservice.xml | 37 ++ .../distribution/src/main/license/LICENSE | 4 +- .../stratos/modules/p2-profile-gen/pom.xml | 27 +- products/stratos/pom.xml | 1 + tools/stratos-installer/conf/setup.conf | 5 + .../all/repository/conf/metadataservice.xml | 37 ++ .../config/greg/repository/conf/carbon.xml | 609 ++++++++++++++++++ tools/stratos-installer/setup.sh | 29 + tools/stratos-installer/start-servers.sh | 7 +- 53 files changed, 4335 insertions(+), 9 deletions(-) create mode 100644 components/org.apache.stratos.metadataservice/pom.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml create mode 100644 components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml create mode 100644 features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml create mode 100644 products/stratos/modules/distribution/src/main/conf/metadataservice.xml create mode 100644 tools/stratos-installer/config/all/repository/conf/metadataservice.xml create mode 100644 tools/stratos-installer/config/greg/repository/conf/carbon.xml diff --git a/components/org.apache.stratos.metadataservice/pom.xml b/components/org.apache.stratos.metadataservice/pom.xml new file mode 100644 index 0000000000..9b05574ed8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/pom.xml @@ -0,0 +1,164 @@ + + + + org.apache.stratos + stratos-components-parent + 4.0.0 + + + 4.0.0 + org.apache.stratos.metadataservice + war + Apache Stratos -Meta Data Service + + + + test + + + env + test + + + + stratosmetadataservice-test + + + + prod + + true + + + stratosmetadataservice + + + + + + + + + maven-compiler-plugin + + 1.5 + 1.5 + + 2.3.2 + + + maven-war-plugin + 2.2 + + + + + src/main/webapp/${appName} + + + stratosmetadataservice + + + + + + + + + + + + org.apache.cxf + cxf-bundle + 2.7.7 + provided + + + org.wso2.carbon + org.wso2.carbon.core + 4.2.0 + provided + + + org.wso2.carbon + org.wso2.carbon.utils + 4.2.0 + provided + + + org.wso2.carbon + org.wso2.carbon.identity.oauth.stub + 4.2.0 + provided + + + org.apache.stratos + org.apache.stratos.tenant.mgt + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.common + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.manager + ${project.version} + provided + + + + org.apache.stratos + org.apache.stratos.cloud.controller.service.stub + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.autoscaler.service.stub + ${project.version} + provided + + + org.apache.stratos + org.apache.stratos.messaging + ${project.version} + provided + + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + provided + + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + provided + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java new file mode 100644 index 0000000000..bd84c5f3c5 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java @@ -0,0 +1,29 @@ +/* + * 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.metadataservice; + +/** + * Global constants used in this module + */ +public class Constants { + + public static final String SUPER_TENANT_SERVICE = "super.tenant.service"; + public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml"; + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java new file mode 100644 index 0000000000..9b43ca4579 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/ServiceHolder.java @@ -0,0 +1,84 @@ +/* + * 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.metadataservice; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.TenantBillingService; +import org.apache.stratos.tenant.mgt.core.TenantPersistor; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.user.core.tenant.TenantManager; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * Some of the admin services needs objects with states inside the runtime. + * There are + * two mechanisms to get those kind of objects. Either with singleton with or + * via OSGi + * services. OSGi services mechanism is preferred. This is a helper class for + * doing that. + */ +public class ServiceHolder { + private static Log log = LogFactory.getLog(ServiceHolder.class); + + public static TenantManager getTenantManager() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class); + return realmService.getTenantManager(); + } + + public static TenantBillingService getBillingService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + TenantBillingService tenantBillingService = + (TenantBillingService) carbonContext.getOSGiService(TenantBillingService.class); + return tenantBillingService; + } + + public static RealmService getRealmService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RealmService realmService = (RealmService) carbonContext.getOSGiService(RealmService.class); + return realmService; + } + + public static RegistryService getRegistryService() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RegistryService registryService = + (RegistryService) carbonContext.getOSGiService(RegistryService.class); + return registryService; + } + + public static TenantPersistor getTenantPersistor() { + TenantPersistor tenantPersistor = new TenantPersistor(); + return tenantPersistor; + } + + public static ConfigurationContextService getConfigurationContext() { + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + ConfigurationContextService configurationContextService = + (ConfigurationContextService) carbonContext.getOSGiService(ConfigurationContextService.class); + return configurationContextService; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java new file mode 100644 index 0000000000..42b100a12f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Utils.java @@ -0,0 +1,44 @@ +/** + * 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.metadataservice; + +public class Utils { + + public static String buildMessage(int errorCode, String errorMessage) { + String jsonResponse = + "{\"Error\":{" + " \"errorCode\": \" " + errorCode + "\"," + + " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}"; + return jsonResponse; + } + + public static String buildMessage(String errorMessage) { + String jsonResponse = + "{\"Error\":{" + " \"errorCode\": \" " + -1234 + "\"," + + " \"errorMessage\": \" " + errorMessage + "\"" + "}" + "}"; + return jsonResponse; + } + + public static String buildAuthenticationSuccessMessage(String jSessionId) { + String jsonResponse = + "{\"Success\":{" + " \"sessionId\": \"" + jSessionId + "\"" + "}" + + "}"; + return jsonResponse; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java new file mode 100644 index 0000000000..a6c8765465 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/AuthorizationAction.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Carbon kernel handles permissions by means of permission strings. + * Permission strings are defined at the operation level. Here the admin + * service developer has to specify authorization requirements using + * the below annotation + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = ElementType.METHOD) +public @interface AuthorizationAction { + String[] value(); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java new file mode 100644 index 0000000000..761faa422f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/annotation/SuperTenantService.java @@ -0,0 +1,34 @@ +/* + * 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.metadataservice.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * In Carbon admin authorization framework there are super-tenant only + * admin services. We use below annotation to mark such admin services. + */ +@Retention(value = RetentionPolicy.RUNTIME) +@Target(value = ElementType.METHOD) +public @interface SuperTenantService { + boolean value(); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java new file mode 100644 index 0000000000..7adbff6828 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/context/AuthenticationContext.java @@ -0,0 +1,40 @@ +package org.apache.stratos.metadataservice.context; + +/* + * 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 AuthenticationContext { + // maintaining the authenticated state in threadLocal. We want to skip + // subsequent authentication handlers + // once a request get authenticated by a handler. + private static final ThreadLocal authenticated = new ThreadLocal() { + @Override + protected Boolean initialValue() { + return false; + } + }; + + public static boolean isAthenticated() { + return authenticated.get(); + } + + public static void setAuthenticated(boolean isAuthenticated) { + authenticated.set(isAuthenticated); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java new file mode 100644 index 0000000000..dfecee4b4a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java @@ -0,0 +1,43 @@ +package org.apache.stratos.metadataservice.definition; + +import java.util.List; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "cartridgeMetaData") +public class CartridgeMetaData { + public String applicationName; + + public String displayName; + + public String description; + + public String type; + + public String provider; + + public String host; + + public String version; + + public List property; + + @Override + public String toString() { + + return "applicationName: " + applicationName + ", displayName: " + displayName + + ", description: " + description + ", type: " + type + ", provider: " + provider + + ", host: " + host + ", Version: " + version + ", property: " + getProperties(); + } + + private String getProperties() { + + StringBuilder propertyBuilder = new StringBuilder(); + if (property != null) { + for (PropertyBean propertyBean : property) { + propertyBuilder.append(propertyBean.toString()); + } + } + return propertyBuilder.toString(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java new file mode 100644 index 0000000000..ae4fcf8bc7 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java @@ -0,0 +1,37 @@ +/* + * 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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "property") +public class PropertyBean { + + public String hostname; + + public String username; + public String password; + + @Override + public String toString() { + return " [ hostname: " + hostname + ", username: " + username + ", password: " + password + + "] "; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.java new file mode 100644 index 0000000000..df43cc0fdc --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/RestAPIException.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.metadataservice.exception; + +import javax.ws.rs.core.Response; + +public class RestAPIException extends Exception { + + private static final long serialVersionUID = 1L; + + private String message; + private Response.Status httpStatusCode; + + public RestAPIException() { + super(); + } + + public RestAPIException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public RestAPIException(Response.Status httpStatusCode, String message, Throwable cause) { + super(message, cause); + this.message = message; + this.httpStatusCode = httpStatusCode; + } + + public RestAPIException(String message) { + super(message); + this.message = message; + } + + public RestAPIException(Response.Status httpStatusCode, String message) { + super(message); + this.message = message; + this.httpStatusCode = httpStatusCode; + } + + public RestAPIException(Throwable cause) { + super(cause); + } + + @Override + public String getMessage() { + return message; + } + + public Response.Status getHTTPStatusCode() { + return httpStatusCode; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java new file mode 100644 index 0000000000..93bf9049a6 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/AbstractAuthenticationAuthorizationHandler.java @@ -0,0 +1,56 @@ +/** + * 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.metadataservice.handlers; + +import java.util.List; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.impl.HttpHeadersImpl; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.context.AuthenticationContext; + +public abstract class AbstractAuthenticationAuthorizationHandler implements RequestHandler { + private final Log log = LogFactory.getLog(AbstractAuthenticationAuthorizationHandler.class); + + @Override + public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) { + HttpHeaders headers = new HttpHeadersImpl(message); + List authHeader = headers.getRequestHeader(HttpHeaders.AUTHORIZATION); + if (log.isDebugEnabled()) { + log.debug("Executing " + this.getClass()); + } + if (!AuthenticationContext.isAthenticated() && authHeader != null && + authHeader.size() > 0 && canHandle(authHeader.get(0).trim().split(" ")[0])) { + return handle(message, classResourceInfo); + } + // give the control to the next handler + return null; + + } + + protected abstract boolean canHandle(String authHeaderPrefix); + + protected abstract Response handle(Message message, ClassResourceInfo classResourceInfo); +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java new file mode 100644 index 0000000000..da50e3e76f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CookieBasedAuthenticationHandler.java @@ -0,0 +1,94 @@ +/* + * 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.metadataservice.handlers; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +/* + * authenticate an incoming request using the session availability. Session is + * first established using the + * basic auth authentication. This handler will be the last to get executed in + * the current handler chain. Hence failure + * too provide a session would result in an authentication failure. + */ +public class CookieBasedAuthenticationHandler implements RequestHandler { + private final Log log = LogFactory.getLog(CookieBasedAuthenticationHandler.class); + + @Override + public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) { + if (AuthenticationContext.isAthenticated()) { + return null; + } + + HttpServletRequest httpServletRequest = (HttpServletRequest) message.get("HTTP.REQUEST"); + HttpSession httpSession = httpServletRequest.getSession(false); + if (httpSession != null && isUserLoggedIn(httpSession)) { // if sesion + // is + // avaialble + String userName = (String) httpSession.getAttribute("userName"); + String tenantDomain = (String) httpSession.getAttribute("tenantDomain"); + int tenantId = (Integer) httpSession.getAttribute("tenantId"); + // the following will get used by the authorization handler.. + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setUsername(userName); + carbonContext.setTenantDomain(tenantDomain); + carbonContext.setTenantId(tenantId); + + AuthenticationContext.setAuthenticated(true); + if (log.isDebugEnabled()) { + log.debug("authenticated using the " + + CookieBasedAuthenticationHandler.class.getName() + "for username :" + + userName + "tenantDomain : " + tenantDomain + " tenantId : " + tenantId); + } + return null; + + } + return Response.status(Response.Status.FORBIDDEN).type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("The endpoint requires authentication")).build(); + } + + /* + * if the userName and tenantDomain is present in the session, we conclude + * this as an authenticated session. + * Thos params get set by the AuthenticationAdmin endpoint. + */ + private boolean isUserLoggedIn(HttpSession httpSession) { + String userName = (String) httpSession.getAttribute("userName"); + String tenantDomain = (String) httpSession.getAttribute("tenantDomain"); + Integer tenantId = (Integer) httpSession.getAttribute("tenantId"); + if (userName != null && tenantDomain != null && tenantId != null) { + return true; + } + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java new file mode 100644 index 0000000000..0731c99d59 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomExceptionMapper.java @@ -0,0 +1,47 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.metadataservice.handlers; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.exception.RestAPIException; + +public class CustomExceptionMapper implements ExceptionMapper { + @Override + public Response toResponse(RestAPIException restAPIException) { + // if no specific error message specified, spitting out a generaic error + // message + String errorMessage = + (restAPIException.getMessage() != null) + ? restAPIException.getMessage() + : "Error while fullfilling the request"; + // if no specific error specified we are throwing the bad request http + // status code by default + Response.Status httpStatus = + (restAPIException.getHTTPStatusCode() != null) + ? restAPIException.getHTTPStatusCode() + : Response.Status.BAD_REQUEST; + return Response.status(Response.Status.BAD_REQUEST).type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(httpStatus.getStatusCode(), errorMessage)) + .build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java new file mode 100644 index 0000000000..fd0e2a5b2a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/CustomThrowableExceptionMapper.java @@ -0,0 +1,44 @@ +package org.apache.stratos.metadataservice.handlers; + +/* + * 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 javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Utils; + +public class CustomThrowableExceptionMapper implements ExceptionMapper { + private static Log log = LogFactory.getLog(CustomThrowableExceptionMapper.class); + + @Override + public Response toResponse(Throwable throwable) { + if (log.isDebugEnabled()) { + log.debug("Internal server error", throwable); + } + + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + "Internal server error")).build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java new file mode 100644 index 0000000000..4d2fadb3e2 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/GenericExceptionMapper.java @@ -0,0 +1,54 @@ +/* + * 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.metadataservice.handlers; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.ext.ExceptionMapper; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Utils; + +/* + * This class maps any exception thrown by the server, which is not mapped by a + * specifi exception mapper + * in to an appropriate format + */ +public class GenericExceptionMapper implements ExceptionMapper { + private static Log log = LogFactory.getLog(GenericExceptionMapper.class); + + @Override + public Response toResponse(WebApplicationException webApplicationException) { + if (log.isDebugEnabled()) { + log.debug("Internal erver error", webApplicationException); + } + // if no specific error message specified, spitting out a generaic error + // message + String errorMessage = + (webApplicationException.getMessage() != null) + ? webApplicationException.getMessage() + : "Internal server error"; + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), + errorMessage)).build(); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.java new file mode 100644 index 0000000000..4dc5573304 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/OAuthHandler.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.metadataservice.handlers; + +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.jaxrs.impl.HttpHeadersImpl; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.apache.stratos.metadataservice.oauth2.ValidationServiceClient; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; + +/** + * This class responsible for OAuth based authentication/authorization. A client + * has to bring a valid OAuth token from a + * a OAuth provider. This class intercept the request and calls the + * OAuthTokenValidation endpoint of the provider. + */ +public class OAuthHandler extends AbstractAuthenticationAuthorizationHandler { + private static Log log = LogFactory.getLog(OAuthHandler.class); + private static String SUPPORTED_AUTHENTICATION_TYPE = "Bearer"; + private static String oauthValidationEndpoint; + private static String username; + private static String password; + + public void setOauthValidationEndpoint(String oauthValidationEndpoint) { + OAuthHandler.oauthValidationEndpoint = oauthValidationEndpoint; + } + + public void setUsername(String username) { + OAuthHandler.username = username; + } + + public void setPassword(String password) { + OAuthHandler.password = password; + } + + @Override + public boolean canHandle(String authHeaderPrefix) { + return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix); + } + + @Override + public Response handle(Message message, ClassResourceInfo classResourceInfo) { + try { + OAuth2TokenValidationResponseDTO respDTO; + ValidationServiceClient validationServiceClient = + new ValidationServiceClient( + oauthValidationEndpoint, + username, + password); + HttpHeaders httpHeaders = new HttpHeadersImpl(message); + String header = httpHeaders.getRequestHeaders().getFirst("Authorization"); + // if the authorization token has Bearer.. + if (header.startsWith("Bearer ")) { + String accessToken = header.substring(7).trim(); + respDTO = validationServiceClient.validateAuthenticationRequest(accessToken); // TODO + // : + // send + // scope + // params + boolean valid = respDTO.getValid(); + if (!valid) { + // authorization failure.. + return Response.status(Response.Status.FORBIDDEN).build(); + } + } + } catch (Exception e) { + log.error("Error while validating access token", e); + return Response.status(Response.Status.FORBIDDEN).build(); + } + AuthenticationContext.setAuthenticated(true); + return null; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java new file mode 100644 index 0000000000..fd83b8e85f --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthenticationHandler.java @@ -0,0 +1,156 @@ +/* + * 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.metadataservice.handlers; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.configuration.security.AuthorizationPolicy; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.cxf.security.SecurityContext; +import org.apache.stratos.metadataservice.ServiceHolder; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.apache.stratos.metadataservice.security.StratosSecurityContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.util.AnonymousSessionUtil; +import org.wso2.carbon.registry.core.service.RegistryService; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.core.service.RealmService; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +/** + * Here we are doing the request authentication within a {@link RequestHandler}. + * The request handlers + * are get invoked just before the actual method invocation. This authentication + * handler make use + * of HTTP basic auth headers as the authentication mechanism. + */ +public class StratosAuthenticationHandler extends AbstractAuthenticationAuthorizationHandler { + private static Log log = LogFactory.getLog(StratosAuthenticationHandler.class); + private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic"; + + @Override + public boolean canHandle(String authHeaderPrefix) { + return SUPPORTED_AUTHENTICATION_TYPE.equals(authHeaderPrefix); + } + + /** + * Authenticate the user against the user store. Once authenticate, populate + * the {@link org.wso2.carbon.context.CarbonContext} to be used by the + * downstream code. + * + * @param message + * @param classResourceInfo + * @return + */ + @Override + public Response handle(Message message, ClassResourceInfo classResourceInfo) { + // If Mutual SSL is enabled + HttpServletRequest request = (HttpServletRequest) message.get("HTTP.REQUEST"); + Object certObject = request.getAttribute("javax.servlet.request.X509Certificate"); + + AuthorizationPolicy policy = message.get(AuthorizationPolicy.class); + String username = policy.getUserName().trim(); + String password = policy.getPassword().trim(); + + // sanity check + if ((username == null) || username.equals("")) { + log.error("username is seen as null/empty values."); + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Username cannot be null")).build(); + } else if (certObject == null && ((password == null) || password.equals(""))) { + log.error("password is seen as null/empty values."); + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic").type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("password cannot be null")).build(); + } + + try { + RealmService realmService = ServiceHolder.getRealmService(); + RegistryService registryService = ServiceHolder.getRegistryService(); + String tenantDomain = MultitenantUtils.getTenantDomain(username); + int tenantId = realmService.getTenantManager().getTenantId(tenantDomain); + + UserRealm userRealm = null; + if (certObject == null) { + userRealm = + AnonymousSessionUtil.getRealmByTenantDomain(registryService, + realmService, tenantDomain); + if (userRealm == null) { + log.error("Invalid domain or unactivated tenant login"); + // is this the correct HTTP code for this scenario ? (401) + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic") + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Tenant not found")).build(); + } + } + username = MultitenantUtils.getTenantAwareUsername(username); + if (certObject != null || + userRealm.getUserStoreManager().authenticate(username, password)) { // if + // authenticated + + // setting the correct tenant info for downstream code.. + PrivilegedCarbonContext carbonContext = + PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(tenantDomain); + carbonContext.setTenantId(tenantId); + carbonContext.setUsername(username); + // populate the secuirtyContext of authenticated user + SecurityContext securityContext = new StratosSecurityContext(username); + message.put(SecurityContext.class, securityContext); + + // set the authenticated flag and let the request to continue + AuthenticationContext.setAuthenticated(true); + if (log.isDebugEnabled()) { + log.debug("authenticated using the " + + CookieBasedAuthenticationHandler.class.getName() + "for username :" + + username + "tenantDomain : " + tenantDomain + " tenantId : " + + tenantId); + } + return null; + } else { + log.warn("unable to authenticate the request"); + // authentication failed, request the authetication, add the + // realm name if needed to the value of WWW-Authenticate + return Response.status(Response.Status.UNAUTHORIZED) + .header("WWW-Authenticate", "Basic") + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Authentication failed. Please " + + "check your username/password")) + .build(); + } + } catch (Exception exception) { + log.error("Authentication failed", exception); + // server error in the eyes of the client. Hence 5xx HTTP code. + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Unexpected error. Please contact the system admin")) + .build(); + } + + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java new file mode 100644 index 0000000000..429399f68b --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java @@ -0,0 +1,333 @@ +/* + * 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.metadataservice.handlers; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.common.util.ClassHelper; +import org.apache.cxf.frontend.MethodDispatcher; +import org.apache.cxf.interceptor.security.AccessDeniedException; +import org.apache.cxf.jaxrs.ext.RequestHandler; +import org.apache.cxf.jaxrs.model.ClassResourceInfo; +import org.apache.cxf.message.Message; +import org.apache.cxf.service.Service; +import org.apache.cxf.service.model.BindingOperationInfo; +import org.apache.stratos.metadataservice.Utils; +import org.apache.stratos.metadataservice.context.AuthenticationContext; +import org.wso2.carbon.context.CarbonContext; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.user.api.AuthorizationManager; +import org.wso2.carbon.user.api.UserRealm; +import org.wso2.carbon.user.api.UserStoreException; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +/** + * {@link StratosAuthorizingHandler} authorize resource requests. It collects + * expected permission + * details using annotations present in the service bean. This particular + * implementation is inspired + * by the {@link org.apache.cxf.jaxrs.security.SimpleAuthorizingFilter} + */ +public class StratosAuthorizingHandler implements RequestHandler { + private final Log log = LogFactory.getLog(StratosAuthorizingHandler.class); + + private static String SUPPORTED_AUTHENTICATION_TYPE = "Basic"; + private static final String AUTHORIZATION_ANNOTATION_CLASS_NAME = + "org.apache.stratos.metadataservice.annotation.AuthorizationAction"; + private static final String TENANT_ANNOTATION_CLASS_NAME = + "org.apache.stratos.metadataservice.annotation.SuperTenantService"; + private static final String ACTION_ON_RESOURCE = "ui.execute"; + private static final Set SKIP_METHODS; + private Map authorizationActionMap = Collections.emptyMap(); + private Set superTenantServiceSet = Collections.emptySet(); + + static { + SKIP_METHODS = new HashSet(); + SKIP_METHODS.addAll(Arrays.asList(new String[] { "wait", "notify", "notifyAll", "equals", + "toString", "hashCode" })); + } + + @Override + public Response handleRequest(Message message, ClassResourceInfo resourceClass) { + try { + AuthenticationContext.setAuthenticated(false); // TODO : fix this + // properly + String userName = CarbonContext.getThreadLocalCarbonContext().getUsername(); + String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); + int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); + if (log.isDebugEnabled()) { + log.debug("authorizing the action using" + + StratosAuthorizingHandler.class.getName()); + log.debug("username :" + userName); + log.debug("tenantDomain" + tenantDomain); + log.debug("tenantId :" + tenantId); + } + Method targetMethod = getTargetMethod(message); + if (!authorize(userName, tenantDomain, tenantId, targetMethod)) { + log.warn("User :" + userName + "trying to perform unauthrorized action" + + " against the resource :" + targetMethod); + return Response.status(Response.Status.FORBIDDEN) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("The user does not have required permissions to " + + "perform this operation")).build(); + } + return null; + + } catch (Exception exception) { + log.error("Unexpected error occured while REST api, authorization process", exception); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR) + .type(MediaType.APPLICATION_JSON) + .entity(Utils.buildMessage("Unexpected error. Please contact the system admin")) + .build(); + } + } + + private boolean authorize(String userName, String tenantDomain, int tenantId, + Method targetMethod) throws Exception { + // first we try to see whether this is a super.tenant only operation + if (superTenantServiceSet.contains(targetMethod.getName()) && + !isCurrentUserSuperTenant(tenantDomain, tenantId)) { + return false; + } + // authorize using permissionString given as annotation in the service + // class + String permissionString = authorizationActionMap.get(targetMethod.getName()); + + // get the authorization manager for this tenant.. + UserRealm userRealm = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm(); + AuthorizationManager authorizationManager = userRealm.getAuthorizationManager(); + + boolean isAuthorized = + isAuthorized(authorizationManager, userName, permissionString, + ACTION_ON_RESOURCE); + return isAuthorized; + + } + + private boolean isCurrentUserSuperTenant(String tenantDomain, int tenantId) { + if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain) && + MultitenantConstants.SUPER_TENANT_ID == tenantId) { + return true; + } + return false; + } + + private boolean isAuthorized(AuthorizationManager authorizationManager, String username, + String permissionString, String action) throws UserStoreException { + boolean isAuthorized = false; + String[] resourceIds = permissionString.trim().split(","); + for (String resourceId : resourceIds) { + if (authorizationManager.isUserAuthorized(username, resourceId, action)) { + isAuthorized = true; + break; + } + } + return isAuthorized; + } + + /** + * Here we are getting the target invocation method. The method get set as a + * property in the + * message by the + * {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor} + * + * @param message + * incoming message + * @return + */ + protected Method getTargetMethod(Message message) { + BindingOperationInfo bop = message.getExchange().get(BindingOperationInfo.class); + if (bop != null) { + MethodDispatcher md = + (MethodDispatcher) message.getExchange().get(Service.class) + .get(MethodDispatcher.class.getName()); + return md.getMethod(bop); + } + Method method = (Method) message.get("org.apache.cxf.resource.method"); + if (method != null) { + return method; + } + log.error("The requested resource is not found. Please check the resource path etc.."); + throw new AccessDeniedException("Method is not available : Unauthorized"); + } + + /** + * The instance of the secured bean get injected by the IOC framework + * + * @param securedObject + */ + public void setSecuredObject(Object securedObject) { + Class clazz = ClassHelper.getRealClass(securedObject); + authorizationActionMap = getAuthorizationActionMap(clazz); + superTenantServiceSet = getSuperTenantServiceSet(clazz); + + } + + private Set getSuperTenantServiceSet(Class clazz) { + Set superTenantServiceSet = new HashSet(); + findSuperTenantServices(clazz, superTenantServiceSet); + return superTenantServiceSet; + } + + private Map getAuthorizationActionMap(Class clazz) { + Map authorizationActionMap = new HashMap(); + findAuthorizationActions(clazz, authorizationActionMap); + return authorizationActionMap; + } + + /** + * Goes through the class hierarchy and find the authorization annotations + * attached to a certain + * method. + * + * @param clazz + * class to be scanned + * @param authorizationActionMap + * the map to be populated + */ + private void findAuthorizationActions(Class clazz, Map authorizationActionMap) { + if (clazz == null || clazz == Object.class) { + return; + } + String classAuthorizationActionsAllowed = + getAuthorizationActions(clazz.getAnnotations(), + AUTHORIZATION_ANNOTATION_CLASS_NAME); + for (Method m : clazz.getMethods()) { + if (SKIP_METHODS.contains(m.getName())) { + continue; + } + String methodAuthorizationActionsAllowed = + getAuthorizationActions(m.getAnnotations(), + AUTHORIZATION_ANNOTATION_CLASS_NAME); + String authorizationActions = + methodAuthorizationActionsAllowed != null + ? methodAuthorizationActionsAllowed + : classAuthorizationActionsAllowed; + if (authorizationActions != null) { + authorizationActionMap.put(m.getName(), authorizationActions); + } + } + if (!authorizationActionMap.isEmpty()) { + return; + } + + findAuthorizationActions(clazz.getSuperclass(), authorizationActionMap); + + if (!authorizationActionMap.isEmpty()) { + return; + } + + for (Class interfaceCls : clazz.getInterfaces()) { + findAuthorizationActions(interfaceCls, authorizationActionMap); + } + } + + /** + * Goes through the class hierarchy and figure out the supertenant + * annotations coupled with operations/methods. + * + * @param clazz + * @param superTenantServiceSet + */ + private void findSuperTenantServices(Class clazz, Set superTenantServiceSet) { + if (clazz == null || clazz == Object.class) { + return; + } + for (Method m : clazz.getMethods()) { + if (SKIP_METHODS.contains(m.getName())) { + continue; + } + boolean isSuperTenantService = + getSuperTenantServices(m.getAnnotations(), + TENANT_ANNOTATION_CLASS_NAME); + if (isSuperTenantService) { + superTenantServiceSet.add(m.getName()); + } + } + if (!superTenantServiceSet.isEmpty()) { + return; + } + + findSuperTenantServices(clazz.getSuperclass(), superTenantServiceSet); + + if (!superTenantServiceSet.isEmpty()) { + return; + } + + for (Class interfaceCls : clazz.getInterfaces()) { + findSuperTenantServices(interfaceCls, superTenantServiceSet); + } + } + + private boolean getSuperTenantServices(Annotation[] annotations, + String tenantAnnotationClassName) { + for (Annotation ann : annotations) { + if (ann.annotationType().getName().equals(tenantAnnotationClassName)) { + try { + Method valueMethod = ann.annotationType().getMethod("value", new Class[] {}); + boolean isSuperTenantService = + (Boolean) valueMethod.invoke(ann, + new Object[] {}); + return isSuperTenantService; + } catch (Exception ex) { + // ignore + } + break; + } + } + return false; + } + + private String getAuthorizationActions(Annotation[] annotations, + String authorizationAnnotationClassName) { + for (Annotation ann : annotations) { + if (ann.annotationType().getName().equals(authorizationAnnotationClassName)) { + try { + Method valueMethod = ann.annotationType().getMethod("value", new Class[] {}); + String[] permissions = (String[]) valueMethod.invoke(ann, new Object[] {}); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < permissions.length; i++) { + sb.append(permissions[i]); + if (i + 1 < permissions.length) { + sb.append(","); + } + } + return sb.toString(); + } catch (Exception ex) { + // ignore + } + break; + } + } + return null; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java new file mode 100644 index 0000000000..b8fe9185d1 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -0,0 +1,112 @@ +package org.apache.stratos.metadataservice.listener; + +/* + * + * 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.messaging.event.Event; +import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.MemberSuspendedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.metadataservice.services.MetaDataAdmin; + +/** + * Cartridge agent runnable. + */ +public class TopologyAgent implements Runnable { + + private static final Log log = LogFactory.getLog(TopologyAgent.class); + + private boolean terminated; + + @Override + public void run() { + if (log.isInfoEnabled()) { + log.info("Topology agent started"); + } + + // Start topology event receiver thread + registerTopologyEventListeners(); + + } + + protected void registerTopologyEventListeners() { + if (log.isDebugEnabled()) { + log.debug("Starting topology event message receiver thread"); + } + TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); + + topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + try { + log.info("Member terminated event received"); + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member terminated event received"); + } + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + System.out.println("Terminated event :::::::::::::::::::: " + + memberTerminatedEvent.getServiceName()); + new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member terminated event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { + @Override + protected void onEvent(Event event) { + try { + log.info("Member suspended event received"); + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member suspended event received"); + } + MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member suspended event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + Thread thread = new Thread(topologyEventReceiver); + thread.start(); + if (log.isDebugEnabled()) { + log.info("Cartridge Agent topology receiver thread started"); + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java new file mode 100644 index 0000000000..2f09d3db4a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java @@ -0,0 +1,124 @@ +package org.apache.stratos.metadataservice.listener; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.topology.MemberStartedEvent; +import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberSuspendedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.metadataservice.services.MetaDataAdmin; + +public class TopologyListener implements ServletContextListener { + + private static final Log log = LogFactory.getLog(TopologyListener.class); + + private TopologyAgent topologyThread = null; + private Thread thread = null; + + @Override + public void contextInitialized(ServletContextEvent arg0) { + log.info("Topology literner started...."); + if (topologyThread == null) { + // load default agent + topologyThread = new TopologyAgent(); + if (log.isDebugEnabled()) { + log.debug("Loading default Cartridge Agent."); + } + } + // start agent + thread = new Thread(topologyThread); + thread.start(); + + } + + @Override + public void contextDestroyed(ServletContextEvent arg0) { + thread.stop(); + } + + protected void registerTopologyEventListeners() { + if (log.isDebugEnabled()) { + log.debug("Starting topology event message receiver thread"); + } + TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); + + topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member terminated event received"); + } + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + System.out.println("Terminated event :::::::::::::::::::: " + + memberTerminatedEvent.getServiceName()); + new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); + + // extensionHandler.onMemberTerminatedEvent(memberTerminatedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member terminated event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member suspended event received"); + } + MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member suspended event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + topologyEventReceiver.addEventListener(new MemberStartedEventListener() { + @Override + protected void onEvent(Event event) { + try { + TopologyManager.acquireReadLock(); + if (log.isDebugEnabled()) { + log.debug("Member started event received"); + } + MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event; + // extensionHandler.onMemberStartedEvent(memberStartedEvent); + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Error processing member started event", e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); + + Thread thread = new Thread(topologyEventReceiver); + thread.start(); + if (log.isDebugEnabled()) { + log.info("Cartridge Agent topology receiver thread started"); + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java new file mode 100644 index 0000000000..dbc8947560 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/oauth2/ValidationServiceClient.java @@ -0,0 +1,65 @@ +/* + * 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.metadataservice.oauth2; + +import java.rmi.RemoteException; + +import org.apache.axis2.AxisFault; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.rs.security.oauth2.utils.OAuthConstants; +import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; + +/** + * Service class wrapper for OAuthTokenValidation endpoint. + */ +public class ValidationServiceClient { + private OAuth2TokenValidationServiceStub stub = null; + private static final Log log = LogFactory.getLog(OAuth2TokenValidationServiceStub.class); + + public ValidationServiceClient(String backendServerURL, String username, String password) + throws Exception { + String serviceURL = backendServerURL + "OAuth2TokenValidationService"; + try { + stub = new OAuth2TokenValidationServiceStub(serviceURL); + CarbonUtils.setBasicAccessSecurityHeaders(username, password, true, + stub._getServiceClient()); + } catch (AxisFault e) { + log.error("Error initializing OAuth2 Client"); + throw new Exception("Error initializing OAuth Client", e); + } + } + + public OAuth2TokenValidationResponseDTO validateAuthenticationRequest(String accessToken) + throws Exception { + OAuth2TokenValidationRequestDTO oauthReq = new OAuth2TokenValidationRequestDTO(); + oauthReq.setAccessToken(accessToken); + oauthReq.setTokenType(OAuthConstants.BEARER_TOKEN_TYPE); + try { + return stub.validate(oauthReq); + } catch (RemoteException e) { + log.error("Error while validating OAuth2 request"); + throw new Exception("Error while validating OAuth2 request", e); + } + } + +} 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 new file mode 100644 index 0000000000..7d5acd038c --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/CarbonRegistry.java @@ -0,0 +1,187 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.metadataservice.registry; + +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.wso2.carbon.core.AbstractAdmin; +import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Comment; +import org.wso2.carbon.registry.core.service.RegistryService; + +public class CarbonRegistry extends AbstractAdmin implements DataStore { + + private static Log log = LogFactory.getLog(CarbonRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext = null; + + private static String defaultAxis2Repo = "repository/deployment/client"; + private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; + private RegistryService registryService; + + public CarbonRegistry() { + + } + + /* + * Add the meta data to governance registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, + * org.apache.stratos.metadataservice.definition.CartridgeMetaData) + */ + @Override + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + System.out.println("Adding meta data details"); + + Registry tempRegistry = getGovernanceUserRegistry(); + try { + + Resource resource = tempRegistry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("host", cartridgeMetaData.host); + + for (PropertyBean prop : cartridgeMetaData.property) { + resource.addProperty("hostname", prop.hostname); + resource.addProperty("username", prop.username); + resource.addProperty("password", prop.password); + } + + tempRegistry.put(resourcePath, resource); + + System.out.println("A resource added to: " + resourcePath); + + System.out.println(cartridgeMetaData.type); + // registry.rateResource(resourcePath, defaultRank); + + Comment comment = new Comment(); + comment.setText("Added the " + applicationName + " " + type + " cartridge"); + // registry.addComment(resourcePath, comment); + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + + } + System.out.println("Add meta data details"); + return "success"; + } + + /* + * Get the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + try { + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + System.out.println("Resource retrived"); + System.out.println("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + + List lst = new ArrayList(); + PropertyBean prop = new PropertyBean(); + prop.hostname = getResource.getProperty("hostname"); + prop.username = getResource.getProperty("username"); + prop.password = getResource.getProperty("password"); + lst.add(prop); + + cartridgeMetaData.property = lst; + + } + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + + } + return cartridgeMetaData.toString(); + } + + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + registry.delete(resourcePath); + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java new file mode 100644 index 0000000000..25f0053f5a --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.registry; + +/* + * Factory for the Data Registry + */ +public class DataRegistryFactory { + + public static DataStore getDataRegistryFactory(String registryName) { + if (registryName.equals("GREG")) { + return new GRegRegistry(); + } else if (registryName.equals("OWN")) { + return new CarbonRegistry(); + } else { + return null; + } + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java new file mode 100644 index 0000000000..93302b7244 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -0,0 +1,36 @@ +/* + * 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.metadataservice.registry; + +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; + +/* + * Interface of the Data Store + */ +public interface DataStore { + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception; + + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception; + + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception; + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java new file mode 100644 index 0000000000..080fc60c0b --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -0,0 +1,220 @@ +/* + * 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.metadataservice.registry; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; + +import org.apache.axis2.context.ConfigurationContext; +import org.apache.axis2.context.ConfigurationContextFactory; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.apache.stratos.metadataservice.util.ConfUtil; +import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Comment; +import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; + +/** + * + * Governance registry implementation for the registry factory + * + */ +public class GRegRegistry implements DataStore { + + private static Log log = LogFactory.getLog(GRegRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext = null; + + private static String defaultAxis2Repo = "repository/deployment/client"; + private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; + + /* + * Registry initiation + */ + private static WSRegistryServiceClient setRegistry() throws Exception { + + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + + String gregUsername = conf.getString("metadataservice.username", defaultUsername); + String gregPassword = conf.getString("metadataservice.password", defaultPassword); + String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); + String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); + String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); + String defaultTrustStore = + "repository" + File.separator + "resources" + File.separator + + "security" + File.separator + "wso2carbon.jks"; + String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); + String trustStorePassword = + conf.getString("metadataservice.trustStorePassword", + "wso2carbon"); + String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); + + System.setProperty("javax.net.ssl.trustStore", trustStorePath); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" + System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" + System.setProperty("carbon.repo.write.mode", "true"); + configContext = + ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, + axis2Conf); + return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); + } + + /* + * Add the meta data to governance registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, + * org.apache.stratos.metadataservice.definition.CartridgeMetaData) + */ + @Override + public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + System.out.println("Adding meta data details"); + Registry registry = setRegistry(); + try { + + Resource resource = registry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("host", cartridgeMetaData.host); + + for (PropertyBean prop : cartridgeMetaData.property) { + resource.addProperty("hostname", prop.hostname); + resource.addProperty("username", prop.username); + resource.addProperty("password", prop.password); + } + + registry.put(resourcePath, resource); + + System.out.println("A resource added to: " + resourcePath); + + System.out.println(cartridgeMetaData.type); + registry.rateResource(resourcePath, defaultRank); + + Comment comment = new Comment(); + comment.setText("Added the " + applicationName + " " + type + " cartridge"); + registry.addComment(resourcePath, comment); + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + System.out.println("Add meta data details"); + return "success"; + } + + /* + * Get the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + try { + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + System.out.println("Resource retrived"); + System.out.println("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + + List lst = new ArrayList(); + PropertyBean prop = new PropertyBean(); + prop.hostname = getResource.getProperty("hostname"); + prop.username = getResource.getProperty("username"); + prop.password = getResource.getProperty("password"); + lst.add(prop); + + cartridgeMetaData.property = lst; + + } + + } catch (Exception e) { + + System.out.println(e.getMessage()); + e.printStackTrace(); + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + return cartridgeMetaData.toString(); + } + + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + registry.delete(resourcePath); + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java new file mode 100644 index 0000000000..b0be94aee3 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosPrincipal.java @@ -0,0 +1,53 @@ +/* + * 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.metadataservice.security; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.security.Principal; + +/** + * {@link StratosSecurityContext} make use of principal instance. Here with Stratos + * authentication/authorization framework we only need username as the principal details + */ +public class StratosPrincipal implements Principal { + private Log log = LogFactory.getLog(StratosPrincipal.class); + private String userName; + + public StratosPrincipal(String userName) { + this.userName = userName; + } + + public boolean equals(Object another) { + return userName.equals((another)); + } + + public String toString() { + return userName.toString(); + } + + public int hashCode() { + return userName.hashCode(); + } + + public String getName() { + return userName; + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java new file mode 100644 index 0000000000..5cc64f3da8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/security/StratosSecurityContext.java @@ -0,0 +1,50 @@ +/* + * 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.metadataservice.security; + +import java.security.Principal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.cxf.security.SecurityContext; + +/** + * {@link StratosSecurityContext} is what get passed between authentication + * handlers + * and the authorization handler. + */ +public class StratosSecurityContext implements SecurityContext { + private static Log log = LogFactory.getLog(StratosSecurityContext.class); + Principal principal; + + public StratosSecurityContext(String user) { + this.principal = new StratosPrincipal(user); + } + + @Override + public Principal getUserPrincipal() { + return principal; + } + + @Override + public boolean isUserInRole(String role) { + return false; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java new file mode 100644 index 0000000000..e30ffec22e --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -0,0 +1,87 @@ +package org.apache.stratos.metadataservice.services; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; + +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.annotation.AuthorizationAction; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.exception.RestAPIException; +import org.apache.stratos.metadataservice.registry.DataRegistryFactory; +import org.apache.stratos.metadataservice.util.ConfUtil; + +@Path("/metadataservice/") +public class MetaDataAdmin { + + private static Log log = LogFactory.getLog(MetaDataAdmin.class); + @Context + HttpServletRequest httpServletRequest; + + private final String defaultRegType = "GREG"; + + private XMLConfiguration conf; + + @POST + @Path("/init") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public void initialize() throws RestAPIException { + conf = ConfUtil.getInstance(null).getConfiguration(); + } + + @POST + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public String addCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .addCartridgeMetaDataDetails(applicationName, cartridgeType, + cartridgeMetaData); + + } + + @GET + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public String getCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType) + + throws Exception { + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .getCartridgeMetaDataDetails(applicationName, cartridgeType); + + } + + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + return DataRegistryFactory.getDataRegistryFactory(registryType) + .removeCartridgeMetaDataDetails(applicationName, cartridgeType); + + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java new file mode 100644 index 0000000000..bbe20786c0 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -0,0 +1,74 @@ +/* + * 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.metadataservice.util; + +import java.io.File; + +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.Constants; +import org.wso2.carbon.utils.CarbonUtils; + +/** + * This class contains utility methods for read metadata configuration file. + */ +public class ConfUtil { + + private static Log log = LogFactory.getLog(ConfUtil.class); + + private XMLConfiguration config; + + private static ConfUtil instance = null; + + private ConfUtil(String configFilePath) { + log.info("Loading configuration....."); + try { + + File confFile; + if (configFilePath != null && !configFilePath.isEmpty()) { + confFile = new File(configFilePath); + + } else { + confFile = + new File(CarbonUtils.getCarbonConfigDirPath(), + Constants.METADATASERVICE_CONFIG_FILE_NAME); + } + + config = new XMLConfiguration(confFile); + } catch (ConfigurationException e) { + log.error("Unable to load autoscaler configuration file", e); + config = new XMLConfiguration(); // continue with default values + } + } + + public static ConfUtil getInstance(String configFilePath) { + if (instance == null) { + instance = new ConfUtil(configFilePath); + } + return instance; + } + + public XMLConfiguration getConfiguration() { + return config; + } + +} diff --git a/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml b/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml new file mode 100644 index 0000000000..db07954a47 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/resources/axis2_client.xml @@ -0,0 +1,299 @@ + + + + + + + true + false + false + + + 500 + + 15000 + + + false + + + + true + + + + + + false + + + admin + axis2 + + + + + + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6071 + + + + + + + + + + + + + + + + + + + + + + HTTP/1.1 + chunked + 60000 + 60000 + + + HTTP/1.1 + chunked + 60000 + 60000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml new file mode 100644 index 0000000000..c62912d716 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ + + + + + + + + false + + + CXF,Carbon + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..f8b8750046 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/cxf-servlet.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + > + + + + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml new file mode 100644 index 0000000000..4a752f67b8 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice-test/WEB-INF/web.xml @@ -0,0 +1,40 @@ + + + + + + S2 Meta Data Admin Endpoint + + + StratosAdminEndpoint + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + + StratosAdminEndpoint + /* + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml new file mode 100644 index 0000000000..c62912d716 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/META-INF/webapp-classloading.xml @@ -0,0 +1,35 @@ + + + + + + + + false + + + CXF,Carbon + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml new file mode 100644 index 0000000000..bf40055d77 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + partitions + property + hostNames + memberMap + portMap + partitionGroup + partition + member + hostNames + portMappings + volumes + + + + + diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml new file mode 100644 index 0000000000..7929bedd95 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + S2 Admin Endpoint + + org.apache.stratos.metadataservice.listener.TopologyListener + + + StratosAdminEndpoint + org.apache.cxf.transport.servlet.CXFServlet + 1 + + + + StratosAdminEndpoint + /* + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml new file mode 100644 index 0000000000..f12fed0bc5 --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/pom.xml @@ -0,0 +1,320 @@ + + + + + + + org.apache.stratos + stratos-manager-features + 4.0.0 + ../../pom.xml + + + 4.0.0 + org.apache.stratos.metadataservice.feature + pom + Apache Stratos - Meta Data Service feature + This feature packs the Meta Data Service of stratos + + + + + org.apache.cxf + cxf-bundle + 2.7.6 + + + org.apache.cxf.xjcplugins + cxf-xjc-dv + 2.6.2 + + + commons-lang + commons-lang + 2.6 + + + org.apache.cxf.xjc-utils + cxf-xjc-runtime + 2.6.2 + + + org.apache.velocity + velocity + 1.7 + + + org.apache.cxf.xjcplugins + cxf-xjc-ts + 2.6.2 + + + org.apache.cxf.xjcplugins + cxf-xjc-boolean + 2.6.2 + + + org.apache.cxf.xjcplugins + cxf-xjc-bug671 + 2.6.2 + + + net.sf.ehcache + ehcache-core + 2.5.1 + + + org.apache.httpcomponents + httpasyncclient + 4.0-beta3 + + + org.apache.httpcomponents + httpclient + 4.2.5 + + + org.apache.httpcomponents + httpcore + 4.2.4 + + + org.apache.httpcomponents + httpcore-nio + 4.2.4 + + + javax.ws.rs + javax.ws.rs-api + 2.0-m10 + + + com.sun.xml.bind + jaxb-impl + 2.1.13 + + + com.sun.xml.bind + jaxb-xjc + 2.1.13 + + + org.codehaus.woodstox + woodstox-core-asl + 4.2.0 + + + org.codehaus.woodstox + stax2-api + 3.1.1 + + + org.codehaus.jettison + jettison + 1.3.4 + + + org.apache.neethi + neethi + 3.0.2 + + + org.apache.ws.security + wss4j + 1.6.11 + + + xml-resolver + xml-resolver + 1.2 + + + org.apache.ws.xmlschema + xmlschema-core + 2.0.3 + + + org.apache.santuario + xmlsec + 1.5.5 + + + wsdl4j + wsdl4j + 1.6.3 + + + commons-logging + commons-logging + 1.1.1 + + + commons-collections + commons-collections + 3.2.1 + + + aopalliance + aopalliance + 1.0 + + + + org.springframework + spring-aop + 3.0.7.RELEASE + + + org.springframework + spring-asm + 3.0.7.RELEASE + + + org.springframework + spring-beans + 3.0.7.RELEASE + + + org.springframework + spring-context + 3.0.7.RELEASE + + + org.springframework + spring-core + 3.0.7.RELEASE + + + org.springframework + spring-expression + 3.0.7.RELEASE + + + org.springframework + spring-web + 3.0.7.RELEASE + + + org.wso2.carbon.webapp.ext + carbon-cxf + 1.0.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + + + + + + + + + + ${project.build.directory}/runtime/ + + + ${project.build.directory}/web-app/ + + + src/main/resources + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + ${project.build.directory}/runtime/cxf + true + + + + pack-REST-webapp + package + + copy + + + + + org.apache.stratos + org.apache.stratos.metadataservice + ${project.version} + war + true + ${project.build.directory}/web-app/web-app + stratosmetadataservice.war + + + + + + + + org.wso2.maven + carbon-p2-plugin + + + p2-feature-generation + package + + p2-feature-gen + + + org.apache.stratos.metadataservice + ../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.apache.stratos:org.apache.stratos.manager.stub:${project.version} + + + org.wso2.carbon.core:${wso2carbon.version} + + + + + + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..13f9684e35 --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/p2.inf @@ -0,0 +1,23 @@ +# 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. + +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/cxf,target:${installFolder}/../../../lib/runtimes/cxf,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/web-app/stratosmetadataservice.war,target:${installFolder}/../../deployment/server/webapps/stratosmetadataservice.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/webapp-classloading-environments.xml,target:${installFolder}/../../conf/tomcat/webapp-classloading-environments.xml,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.apache.stratos.metadataservice_${feature.version}/tomcat/context.xml,target:${installFolder}/../../conf/tomcat/context.xml,overwrite:true);\ diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml new file mode 100644 index 0000000000..a85c9affed --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/context.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml new file mode 100644 index 0000000000..7e7dd0ab7c --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading-environments.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + Tomcat + javax.annotation.*,javax.ejb,javax.el,javax.persistence,javax.servlet.*,javax.xml,javax.xml.ws,org.apache.catalina.*,org.apache.coyote.*,org.apache.el.*,com.sun.el.*,org.apache.jasper.*,org.apache.naming.*,org.apache.tomcat.*,org.wso2.carbon.tomcat.jndi.* + + + + Carbon + *,!org.springframework.* + + + + + + + + + + + + + CXF + ${carbon.home}/lib/runtimes/cxf/*.jar;${carbon.home}/lib/runtimes/cxf/ + + + + diff --git a/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml new file mode 100644 index 0000000000..f42616f97d --- /dev/null +++ b/features/manager/metadataservice/org.apache.stratos.metadataservice.feature/src/main/resources/tomcat/webapp-classloading.xml @@ -0,0 +1,33 @@ + + + + + + + + + false + + + Carbon + diff --git a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml index 109a987a28..fd8457b62e 100644 --- a/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml +++ b/features/manager/rest-endpoint/org.apache.stratos.rest.endpoint.feature/pom.xml @@ -216,6 +216,16 @@ carbon-cxf 1.0.0 + + org.wso2.carbon + org.wso2.carbon.registry.ws.client + 4.2.0 + + + org.wso2.carbon + org.wso2.carbon.registry.ws.stub + 4.2.0 + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/deployment/server/webapps/stratosmetadataservice.war + ${pom.artifactId}-${pom.version}/repository/deployment/server/webapps/ + 644 + ../../conf/data-bridge/data-bridge-config.xml diff --git a/products/stratos/modules/distribution/src/bin/stratos.sh b/products/stratos/modules/distribution/src/bin/stratos.sh index 644b8a6c16..eda37301d3 100755 --- a/products/stratos/modules/distribution/src/bin/stratos.sh +++ b/products/stratos/modules/distribution/src/bin/stratos.sh @@ -17,7 +17,7 @@ # specific language governing permissions and limitations # under the License. # ---------------------------------------------------------------------------- -# Main Script for the Apache Stratos +# Main Script for the Apache Stratos (incubating) # # Environment Variable Prerequisites # @@ -183,7 +183,7 @@ elif [ "$CMD" = "start" ]; then fi export CARBON_HOME=$CARBON_HOME # using nohup bash to avoid erros in solaris OS.TODO - nohup bash $CARBON_HOME/bin/stratos.sh $args < /dev/null > /dev/null 2>&1 & + nohup bash $CARBON_HOME/bin/stratos.sh $args > /dev/null 2>&1 & exit 0 elif [ "$CMD" = "stop" ]; then export CARBON_HOME=$CARBON_HOME @@ -202,7 +202,7 @@ elif [ "$CMD" = "restart" ]; then done # using nohup bash to avoid erros in solaris OS.TODO - nohup bash $CARBON_HOME/bin/stratos.sh $args < /dev/null > /dev/null 2>&1 & + nohup bash $CARBON_HOME/bin/stratos.sh $args > /dev/null 2>&1 & exit 0 elif [ "$CMD" = "test" ]; then JAVACMD="exec "$JAVACMD"" diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml new file mode 100644 index 0000000000..d871bc0b9f --- /dev/null +++ b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml @@ -0,0 +1,37 @@ + + + + + OWN + https://localhost:9445/services/ + admin + admin + + stratos + repository/deployment/client + repository/conf/axis2/axis2_client.xml + repository/resources/security/wso2carbon.jks + wso2carbon + JKS + + + + + diff --git a/products/stratos/modules/distribution/src/main/license/LICENSE b/products/stratos/modules/distribution/src/main/license/LICENSE index cb34d1dfab..a7e9dc5208 100644 --- a/products/stratos/modules/distribution/src/main/license/LICENSE +++ b/products/stratos/modules/distribution/src/main/license/LICENSE @@ -704,9 +704,6 @@ tcpmon-1.0.jar, xstream-1.4.1.jar, dhtmlHistory.js -Copyright (c) 2010 Terence Parr -All rights reserved. - [The BSD License] Redistribution and use in source and binary forms, with or without modification, @@ -1049,6 +1046,7 @@ Scriptaculous-1.7.0 The MIT License (MIT) + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights diff --git a/products/stratos/modules/p2-profile-gen/pom.xml b/products/stratos/modules/p2-profile-gen/pom.xml index 1500759a91..48161dcba2 100644 --- a/products/stratos/modules/p2-profile-gen/pom.xml +++ b/products/stratos/modules/p2-profile-gen/pom.xml @@ -207,6 +207,7 @@ org.apache.stratos:org.apache.stratos.manager.feature:${project.version} org.apache.stratos:org.apache.stratos.cartridge.mgt.ui.feature:${project.version} org.apache.stratos:org.apache.stratos.rest.endpoint.feature:${project.version} + org.apache.stratos:org.apache.stratos.metadataservice.feature:${project.version} org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.platform.patch.version.4.2.1} org.wso2.carbon:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.platform.patch.version.4.2.2} org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.platform.patch.version.4.2.1} @@ -217,7 +218,7 @@ org.wso2.carbon:org.wso2.carbon.identity.application.authentication.framework.server.feature:4.2.1 org.apache.stratos:org.apache.stratos.messaging.feature:${project.version} org.apache.stratos:org.apache.stratos.autoscaler.feature:${project.version} - org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.version}--> + org.wso2.carbon:org.wso2.carbon.registry.ui.menu.feature:${carbon.version} org.wso2.carbon:org.wso2.carbon.logging.mgt.feature:${carbon.version} org.apache.stratos:org.apache.stratos.cloud.controller.feature:${project.version} org.wso2.carbon:org.apache.synapse.wso2.feature:${synapse.version} @@ -411,6 +412,10 @@ org.apache.stratos.rest.endpoint.feature.group ${project.version} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + org.apache.stratos.messaging.feature.group ${project.version} @@ -491,6 +496,14 @@ org.wso2.carbon.registry.resource.properties.feature.group ${carbon.platform.patch.version.4.2.1} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + + + org.apache.stratos.metadataservice.feature.group + ${project.version} + @@ -573,6 +586,10 @@ org.wso2.carbon.event.server.feature.group ${carbon.platform.patch.version.4.2.1} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + @@ -686,6 +703,10 @@ org.apache.stratos.rest.endpoint.feature.group ${project.version} + + + org.apache.stratos.metadataservice.feature.group + ${project.version} org.apache.stratos.messaging.feature.group @@ -808,6 +829,10 @@ org.wso2.carbon.cassandra.common.feature.group ${carbon.platform.version} + + org.apache.stratos.metadataservice.feature.group + ${project.version} + diff --git a/products/stratos/pom.xml b/products/stratos/pom.xml index c13eb9e991..c7be49434c 100755 --- a/products/stratos/pom.xml +++ b/products/stratos/pom.xml @@ -228,6 +228,7 @@ org.apache.stratos.redirector.servlet ${project.version} + org.apache.batik.wso2 batik diff --git a/tools/stratos-installer/conf/setup.conf b/tools/stratos-installer/conf/setup.conf index 9522bc29d7..9d771620ee 100644 --- a/tools/stratos-installer/conf/setup.conf +++ b/tools/stratos-installer/conf/setup.conf @@ -103,3 +103,8 @@ export userstore_db_schema="userstore" export userstore_db_port="3306" export userstore_db_user="root" export userstore_db_pass="root" + + +# GREG +export greg_pack_zip=$stratos_packs/"wso2greg-4.6.0.zip" +export greg_extract_path=$stratos_path/"wso2greg-4.6.0" diff --git a/tools/stratos-installer/config/all/repository/conf/metadataservice.xml b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml new file mode 100644 index 0000000000..690e056579 --- /dev/null +++ b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml @@ -0,0 +1,37 @@ + + + + + GREG + https://localhost:9445/services/ + admin + admin + + stratos + repository/deployment/client + repository/conf/axis2/axis2_client.xml + repository/resources/security/wso2carbon.jks + wso2carbon + JKS + + + + + diff --git a/tools/stratos-installer/config/greg/repository/conf/carbon.xml b/tools/stratos-installer/config/greg/repository/conf/carbon.xml new file mode 100644 index 0000000000..84d97dbb3d --- /dev/null +++ b/tools/stratos-installer/config/greg/repository/conf/carbon.xml @@ -0,0 +1,609 @@ + + + + + + + + + WSO2 Governance Registry + + + Greg + + + 4.6.0 + + + + + + + + + local:/${carbon.context}/services/ + + + + + + + GovernanceRegistry + + + + + + + org.wso2.carbon + + + / + + + + + + 15 + + + + + + + + + 2 + + + + + 9999 + + 11111 + + + + + + 10389 + + 8000 + + + + + + 5672 + + 8672 + + + + + + 10500 + + + + + + + org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory + + + + + + + + + java + + + + + + + + + + false + + + false + + + 600 + + + + false + false + + + + + + ${carbon.home}/repository/deployment/server/ + + + 15 + + + ${carbon.home}/repository/conf/axis2/axis2.xml + + + 30000 + + + ${carbon.home}/repository/deployment/client/ + + ${carbon.home}/repository/conf/axis2/axis2_client.xml + + true + + + + + + + + + + admin + Default Administrator Role + + + user + Default User Role + + + + + + + + + + + + ${carbon.home}/repository/resources/security/wso2carbon.jks + + JKS + + wso2carbon + + wso2carbon + + wso2carbon + + + + + + ${carbon.home}/repository/resources/security/client-truststore.jks + + JKS + + wso2carbon + + + + + + + + + + + + + + + + + + + UserManager + + + false + + + + + + + ${carbon.home}/tmp/work + + + + + + true + + + 10 + + + 30 + + + + + + 100 + + + + keystore + certificate + * + + org.wso2.carbon.ui.transports.fileupload.AnyFileUploadExecutor + + + + + jarZip + + org.wso2.carbon.ui.transports.fileupload.JarZipUploadExecutor + + + + dbs + + org.wso2.carbon.ui.transports.fileupload.DBSFileUploadExecutor + + + + tools + + org.wso2.carbon.ui.transports.fileupload.ToolsFileUploadExecutor + + + + toolsAny + + org.wso2.carbon.ui.transports.fileupload.ToolsAnyFileUploadExecutor + + + + + + + info + org.wso2.carbon.core.transports.util.InfoProcessor + + + wsdl + org.wso2.carbon.core.transports.util.Wsdl11Processor + + + wsdl2 + org.wso2.carbon.core.transports.util.Wsdl20Processor + + + xsd + org.wso2.carbon.core.transports.util.XsdProcessor + + + + + + false + false + true + svn + http://svnrepo.example.com/repos/ + username + password + true + + + + + + + + + + + + + + + ${require.carbon.servlet} + + + + + true + + + + + + + default repository + http://dist.wso2.org/p2/carbon/releases/4.2.0 + + + + + + + + true + + + + + + true + + diff --git a/tools/stratos-installer/setup.sh b/tools/stratos-installer/setup.sh index 9966c69b68..5035af9a6a 100755 --- a/tools/stratos-installer/setup.sh +++ b/tools/stratos-installer/setup.sh @@ -33,6 +33,7 @@ profile="default" config_mb="true" mb_client_lib_path="" auto_start_servers="false" +config_greg="true" function help { echo "" @@ -227,11 +228,24 @@ function cc_setup() { pushd $stratos_extract_path + + + popd echo "End configuring the Cloud Controller" } +# Setup greg +function greg_setup() { + echo "Setup GREG" >> $LOG + echo "Configuring the GREG" + cp -f ./config/all/repository/conf/metadataservice.xml $stratos_extract_path/repository/conf/ + cp -f ./config/greg/repository/conf/carbon.xml $greg_extract_path/repository/conf/ + + + echo "End configuring the GREG" +} # AS related functions # ------------------------------------------------------------------- function as_related_popup() { @@ -508,6 +522,7 @@ if [ "$UID" -ne "0" ]; then fi general_conf_validate + if [[ $profile = "cc" ]]; then cc_conf_validate elif [[ $profile = "as" ]]; then @@ -539,7 +554,21 @@ if [[ ($profile = "default" && $config_mb = "true") ]]; then sed -r -i -e 's@^(\s*)(@g' $stratos_path/apache-activemq-5.9.1/conf/activemq.xml fi +if [[ ($profile = "default" && $config_greg = "true") ]]; then + echo "Extracting wso2 greg" + unzip -q $greg_pack_zip -d $stratos_path + +fi + general_setup + +if [[ ($profile = "default" && $config_greg = "true") ]]; then + echo "Running the GREG" + greg_setup + +fi + + if [[ $profile = "cc" ]]; then cc_setup elif [[ $profile = "as" ]]; then diff --git a/tools/stratos-installer/start-servers.sh b/tools/stratos-installer/start-servers.sh index b709abf9b4..7661d0e956 100755 --- a/tools/stratos-installer/start-servers.sh +++ b/tools/stratos-installer/start-servers.sh @@ -86,9 +86,12 @@ if [[ $profile = "default" ]]; then sleep 10 fi +echo "Starting wso2 greg server ..." >> $LOG +echo "$greg_extract_path/bin/wso2server.sh -Dprofile=$profile start" +$greg_extract_path/bin/wso2server.sh -Dprofile=$profile start +echo "Stratos server started" >> $LOG + echo "Starting Stratos server ..." >> $LOG echo "$stratos_extract_path/bin/stratos.sh -Dprofile=$profile start" $stratos_extract_path/bin/stratos.sh -Dprofile=$profile start echo "Stratos server started" >> $LOG - - From e39473dd79f048e3f97d10b9295a41f09e5840de Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 16 Sep 2014 11:30:57 +0530 Subject: [PATCH 051/436] adding validations --- .../parser/DefaultApplicationParser.java | 10 ++- .../impl/CloudControllerServiceImpl.java | 2 +- .../controller/pojo/GroupDataHolder.java | 67 ------------------- .../controller/topology/TopologyBuilder.java | 7 +- .../ApplicationCreatedMessageProcessor.java | 2 +- 5 files changed, 16 insertions(+), 72 deletions(-) delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 80cf4aec42..8ea89be73c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -226,7 +226,10 @@ private Map getGroupInfo (Set clusters, List topLevelGroupContexts = getTopLevelGroupContexts(groupNameToGroup); @@ -429,7 +432,10 @@ private ClusterDataHolder getClusterInformation (List subsc Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); clusters.add(cluster); - clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()); + if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { + // Application Definition has same cartridge multiple times at the top-level + throw new ApplicationDefinitionException("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); + } } return new ClusterDataHolder(clusterIdMap, clusters); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 2a1c52cad9..34664b07b9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1403,7 +1403,7 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) ApplicationParser applicationParser = new DefaultApplicationParser(); ApplicationDataHolder applicationDataHolder = applicationParser.parse(applicationContext); - TopologyBuilder.handleApplicationDepolyed(applicationDataHolder); + TopologyBuilder.handleApplicationDeployed(applicationDataHolder); } private List restoreConfigCompositeApplication () { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.java deleted file mode 100644 index 534814f700..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/GroupDataHolder.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.cloud.controller.pojo; - -import org.apache.stratos.messaging.domain.topology.Group; - -import java.util.HashMap; -import java.util.Map; - -public class GroupDataHolder { - - // Sub Group Map, key = Group.name - private Map groupMap; - // Cluster Data Holder - private ClusterDataHolder clusterDataHolder; - // nested Group Data - private GroupDataHolder groupDataHolder; - - public GroupDataHolder () { - this.groupMap = new HashMap(); - } - - public void addGroup (Group group) { - groupMap.put(group.getName(), group); - } - - public void addGroups (Map groupNameToGroup) { - groupMap.putAll(groupNameToGroup); - } - - public Map getGroupMap() { - return groupMap; - } - - public ClusterDataHolder getClusterDataHolder() { - return clusterDataHolder; - } - - public GroupDataHolder getGroupDataHolder() { - return groupDataHolder; - } - - public void setGroupDataHolder(GroupDataHolder groupDataHolder) { - this.groupDataHolder = groupDataHolder; - } - - public void setClusterDataHolder(ClusterDataHolder clusterDataHolder) { - this.clusterDataHolder = clusterDataHolder; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 4420b0b84f..2b827bedf4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -613,12 +613,17 @@ public static void handleMemberSuspended() { } } - public static void handleApplicationDepolyed (ApplicationDataHolder applicationDataHolder) { + public static void handleApplicationDeployed(ApplicationDataHolder applicationDataHolder) { Topology topology = TopologyManager.getTopology(); try { TopologyManager.acquireWriteLock(); + if (topology.applicationExists(applicationDataHolder.getApplication().getId())) { + log.warn("Application with id [ " + applicationDataHolder.getApplication().getId() + " ] already exists in Topology"); + return; + } + for (Cluster cluster : applicationDataHolder.getClusters()) { String cartridgeType = cluster.getServiceName(); topology.getService(cartridgeType).addCluster(cluster); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 701807706b..6f86839626 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -67,7 +67,7 @@ public boolean process(String type, String message, Object object) { // check if an Application with same name exists in topology if (topology.applicationExists(appCreatedEvent.getApplication().getId())) { - log.error("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); + log.warn("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); return false; } From 9f7975dfb13c44c4628b08cd85931abecba38f48 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 16 Sep 2014 11:31:45 +0530 Subject: [PATCH 052/436] fixing pom conflict --- products/stratos/modules/p2-profile-gen/pom.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/products/stratos/modules/p2-profile-gen/pom.xml b/products/stratos/modules/p2-profile-gen/pom.xml index 0db341c58c..48161dcba2 100644 --- a/products/stratos/modules/p2-profile-gen/pom.xml +++ b/products/stratos/modules/p2-profile-gen/pom.xml @@ -22,11 +22,7 @@ org.apache.stratos stratos -<<<<<<< HEAD 4.1.0-SNAPSHOT -======= - 4.0.0 ->>>>>>> ba4d11984f33c63ed1332569831889f4892c5351 ../../pom.xml From ecc7d98dca6b7b55294cd52d1ee4bc8694c93529 Mon Sep 17 00:00:00 2001 From: gayan Date: Tue, 16 Sep 2014 12:52:47 +0530 Subject: [PATCH 053/436] updates the pom with meta data service --- components/pom.xml | 2 ++ features/manager/pom.xml | 1 + 2 files changed, 3 insertions(+) diff --git a/components/pom.xml b/components/pom.xml index 15d0ee539d..0b41eb7a4b 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -102,6 +102,8 @@ org.apache.stratos.rest.endpoint org.apache.stratos.manager.styles + + org.apache.stratos.metadataservice diff --git a/features/manager/pom.xml b/features/manager/pom.xml index 0a0fbdb0a7..9426ad0f26 100644 --- a/features/manager/pom.xml +++ b/features/manager/pom.xml @@ -48,6 +48,7 @@ logging-mgt rest-endpoint/org.apache.stratos.rest.endpoint.feature styles/org.apache.stratos.manager.styles.feature + metadataservice/org.apache.stratos.metadataservice.feature From 1422611dec3a618adf711ddaea66d5e551130316 Mon Sep 17 00:00:00 2001 From: Reka Date: Tue, 16 Sep 2014 14:15:52 +0530 Subject: [PATCH 054/436] adding monitor support for grouping feature --- .../stratos/autoscaler/AutoscalerContext.java | 42 +- .../grouping/DependencyBuilder.java | 26 + .../AutoscalerHealthStatEventReceiver.java | 27 +- .../AutoscalerTopologyEventReceiver.java | 468 ++++++------------ ...nitor.java => AbstractClusterMonitor.java} | 10 +- ...teApplicationMonitor.java => Monitor.java} | 219 ++++---- .../application/ApplicationMonitor.java | 142 ++++++ .../monitor/{ => cluster}/ClusterMonitor.java | 84 +++- .../{ => cluster}/LbClusterMonitor.java | 7 +- .../monitor/group/GroupMonitor.java | 48 ++ .../status/checker/ClusterStatusChecker.java | 39 ++ .../status/checker/GroupStatusChecker.java | 37 ++ .../status/checker/StatusChecker.java | 48 ++ .../autoscaler/util/AutoscalerUtil.java | 26 +- 14 files changed, 741 insertions(+), 482 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{AbstractMonitor.java => AbstractClusterMonitor.java} (96%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{CompositeApplicationMonitor.java => Monitor.java} (52%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/ClusterMonitor.java (80%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/LbClusterMonitor.java (96%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index ed54eb8dd3..4ea6b287cc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -22,9 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.monitor.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.CompositeApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import java.util.HashMap; import java.util.Map; @@ -49,20 +50,30 @@ private AutoscalerContext() { // Map private Map lbMonitors; - private Map appMonitors; + private Map groupMonitors; - public Map getAppMonitors() { + private Map appMonitors; + + public Map getAppMonitors() { return appMonitors; } - public CompositeApplicationMonitor getAppMonitor(String applicationId) { + public ApplicationMonitor getAppMonitor(String applicationId) { return appMonitors.get(applicationId); } - public void setAppMonitors(Map appMonitors) { + public void setAppMonitors(Map appMonitors) { this.appMonitors = appMonitors; } + public Map getGroupMonitors() { + return groupMonitors; + } + + public void setGroupMonitors(Map groupMonitors) { + this.groupMonitors = groupMonitors; + } + private static class Holder { private static final AutoscalerContext INSTANCE = new AutoscalerContext(); @@ -83,6 +94,14 @@ public ClusterMonitor getMonitor(String clusterId) { public boolean monitorExist(String clusterId) { return monitors.containsKey(clusterId); } + + public void addAppMonitor(ApplicationMonitor appMonitor) { + appMonitors.put(appMonitor.getId(), appMonitor); + } + + public boolean appMonitorExist(String appId) { + return appMonitors.containsKey(appId); + } public boolean lbMonitorExist(String clusterId) { return lbMonitors.containsKey(clusterId); @@ -126,11 +145,7 @@ public void addLbMonitor(LbClusterMonitor monitor) { lbMonitors.put(monitor.getClusterId(), monitor); } - public void addAppMonitor(CompositeApplicationMonitor monitor) { - appMonitors.put(monitor.getAppId(), monitor); - } - - public CompositeApplicationMonitor removeAppMonitor(String appId) { + public ApplicationMonitor removeAppMonitor(String appId) { if(!appMonitorExist(appId)) { log.fatal("LB monitor not found for App id: "+ appId); return null; @@ -139,7 +154,4 @@ public CompositeApplicationMonitor removeAppMonitor(String appId) { return appMonitors.remove(appId); } - public boolean appMonitorExist(String appId) { - return appMonitors.containsKey(appId); - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java new file mode 100644 index 0000000000..0566e49b6d --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -0,0 +1,26 @@ +/* + * 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.autoscaler.grouping; + +/** + * This is to build the startup/termination dependencies + * across all the groups and clusters + */ +public class DependencyBuilder { +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index 52952c342c..9ffe66d74d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -26,7 +26,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.exception.TerminationException; -import org.apache.stratos.autoscaler.monitor.AbstractMonitor; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.policy.model.LoadAverage; import org.apache.stratos.autoscaler.policy.model.MemoryConsumption; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -94,7 +94,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -136,7 +136,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -178,7 +178,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -218,7 +218,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -259,7 +259,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -299,7 +299,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -340,7 +340,6 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { , floatValue)); } } - } }); @@ -461,7 +460,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -502,7 +501,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -542,7 +541,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { clusterId, networkPartitionId, floatValue)); } AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -584,7 +583,7 @@ private LoadAverage findLoadAverage(String memberId) { String clusterId = member.getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); @@ -628,7 +627,7 @@ private MemoryConsumption findMemoryConsumption(String memberId) { } return null; } - AbstractMonitor monitor = AutoscalerContext.getInstance().getMonitor(member.getClusterId()); + AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(member.getClusterId()); if(null == monitor){ monitor = AutoscalerContext.getInstance().getLBMonitor(member.getClusterId()); @@ -692,7 +691,7 @@ private Member findMember(String memberId) { private void handleMemberFaultEvent(String clusterId, String memberId) { try { AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ monitor = asCtx.getMonitor(clusterId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 2ac006b05c..9ada44e084 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -24,26 +24,20 @@ import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.exception.TerminationException; -import org.apache.stratos.autoscaler.monitor.AbstractMonitor; -import org.apache.stratos.autoscaler.monitor.CompositeApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import org.apache.stratos.autoscaler.util.AutoscalerUtil; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; 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 org.drools.runtime.StatefulKnowledgeSession; -import org.drools.runtime.rule.FactHandle; import java.util.List; @@ -92,11 +86,10 @@ private void addEventListeners() { topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() { @Override protected void onEvent(Event event) { - try { TopologyManager.acquireReadLock(); - for (CompositeApplication compositeApplication : TopologyManager.getTopology().getCompositeApplication()) { - + for (Application application : TopologyManager.getTopology().getApplications()) { + startApplicationMonitor(application); } } catch (Exception e) { log.error("Error processing event", e); @@ -109,27 +102,22 @@ protected void onEvent(Event event) { }); - topologyEventReceiver.addEventListener(new CompositeApplicationCreatedEventListener() { + topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterCreatedEventListener] Received: " + event.getClass()); - - CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = (CompositeApplicationCreatedEvent) event; + log.info("[ApplicationCreatedEventListener] Received: " + event.getClass()); - ConfigCompositeApplication configCompositeApplication = - compositeApplicationCreatedEvent.getCompositeApplication(); + ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; //acquire read lock TopologyManager.acquireReadLock(); try { - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - CompositeApplication compositeApplication = - builder.buildCompositeApplication(TopologyManager.getTopology(), - configCompositeApplication.getAlias()); - //start the app monitor + //TODO build dependency and organize the application + //start the application monitor + startApplicationMonitor(applicationCreatedEvent.getApplication()); } finally { //release read lock @@ -139,48 +127,56 @@ protected void onEvent(Event event) { } }); -// topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { -// @Override -// protected void onEvent(Event event) { -// try { -// log.info("Event received: " + event); -// ClusterCreatedEvent e = (ClusterCreatedEvent) event; -// TopologyManager.acquireReadLock(); -// Service service = TopologyManager.getTopology().getService(e.getServiceName()); -// Cluster cluster = service.getCluster(e.getClusterId()); -// startClusterMonitor(cluster); -// } catch (Exception e) { -// log.error("Error processing event", e); -// } finally { -// TopologyManager.releaseReadLock(); -// } -// } -// -// }); + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationCreatedEventListener] Received: " + event.getClass()); + + ApplicationRemovedEvent applicationCreatedEvent = (ApplicationRemovedEvent) event; + + //acquire read lock + TopologyManager.acquireReadLock(); + + try { + //TODO build dependency and organize the application + + //remove monitors by checking the termination + + } finally { + //release read lock + TopologyManager.releaseReadLock(); + } + + } + }); topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { @Override protected void onEvent(Event event) { try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent)event; + MemberReadyToShutdownEvent memberReadyToShutdownEvent = + (MemberReadyToShutdownEvent) event; AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; String clusterId = memberReadyToShutdownEvent.getClusterId(); String memberId = memberReadyToShutdownEvent.getMemberId(); - if(asCtx.monitorExist(clusterId)){ + if (asCtx.monitorExist(clusterId)) { monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ + } else if (asCtx.lbMonitorExist(clusterId)) { monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + } else { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found " + + "in autoscaler context [cluster] %s", clusterId)); } return; } NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); + nwPartitionCtxt = monitor.getNetworkPartitionCtxt( + memberReadyToShutdownEvent.getNetworkPartitionId()); // start a new member in the same Partition String partitionId = monitor.getPartitionOfMember(memberId); @@ -195,7 +191,8 @@ protected void onEvent(Event event) { partitionCtxt.removeActiveMemberById(memberId); if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", + log.info(String.format("Member is terminated and removed from the active " + + "members list: [member] %s [partition] %s [cluster] %s ", memberId, partitionId, clusterId)); } } catch (TerminationException e) { @@ -215,10 +212,13 @@ protected void onEvent(Event event) { TopologyManager.acquireReadLock(); Service service = TopologyManager.getTopology().getService(e.getServiceName()); Cluster cluster = service.getCluster(e.getClusterId()); - if(AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getMonitor(e.getClusterId()).setStatus(e.getStatus()); - } else if (AutoscalerContext.getInstance().lbMonitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getLBMonitor(e.getClusterId()).setStatus(e.getStatus()); + if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { + AutoscalerContext.getInstance().getMonitor(e.getClusterId()). + setStatus(e.getStatus()); + } else if (AutoscalerContext.getInstance(). + lbMonitorExist((cluster.getClusterId()))) { + AutoscalerContext.getInstance().getLBMonitor(e.getClusterId()). + setStatus(e.getStatus()); } else { log.error("cluster monitor not exists for the cluster: " + cluster.toString()); } @@ -242,10 +242,11 @@ protected void onEvent(Event event) { String clusterId = e.getClusterId(); String deploymentPolicy = e.getDeploymentPolicy(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if (e.isLbCluster()) { - DeploymentPolicy depPolicy = PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicy); + DeploymentPolicy depPolicy = PolicyManager.getInstance(). + getDeploymentPolicy(deploymentPolicy); if (depPolicy != null) { List lbHolders = PartitionManager.getInstance() .getNetworkPartitionLbHolders(depPolicy); @@ -308,7 +309,7 @@ protected void onEvent(Event event) { String networkPartitionId = e.getNetworkPartitionId(); String clusterId = e.getClusterId(); String partitionId = e.getPartitionId(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist(clusterId)) { monitor = AutoscalerContext.getInstance().getMonitor(clusterId); @@ -317,28 +318,35 @@ protected void onEvent(Event event) { monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); } - NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); + NetworkPartitionContext networkPartitionContext = monitor. + getNetworkPartitionCtxt(networkPartitionId); - PartitionContext partitionContext = networkPartitionContext.getPartitionCtxt(partitionId); + PartitionContext partitionContext = networkPartitionContext. + getPartitionCtxt(partitionId); String memberId = e.getMemberId(); partitionContext.removeMemberStatsContext(memberId); if (partitionContext.removeTerminationPendingMember(memberId)) { if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from termination pending members list: [member] %s", memberId)); + log.debug(String.format("Member is removed from termination pending " + + "members list: [member] %s", memberId)); } } else if (partitionContext.removePendingMember(memberId)) { if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from pending members list: [member] %s", memberId)); + log.debug(String.format("Member is removed from pending members list: " + + "[member] %s", memberId)); } } else if (partitionContext.removeActiveMemberById(memberId)) { - log.warn(String.format("Member is in the wrong list and it is removed from active members list", memberId)); + log.warn(String.format("Member is in the wrong list and it is removed " + + "from active members list", memberId)); } else { - log.warn(String.format("Member is not available in any of the list active, pending and termination pending", memberId)); + log.warn(String.format("Member is not available in any of the list " + + "active, pending and termination pending", memberId)); } if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been removed successfully: [member] %s", memberId)); + log.info(String.format("Member stat context has been removed " + + " successfully: [member] %s", memberId)); } // partitionContext.decrementCurrentActiveMemberCount(1); @@ -361,37 +369,16 @@ protected void onEvent(Event event) { MemberActivatedEvent e = (MemberActivatedEvent) event; String memberId = e.getMemberId(); - String partitionId = e.getPartitionId(); - String networkPartitionId = e.getNetworkPartitionId(); - String applicationId = e.getApplicationId(); PartitionContext partitionContext = null; - String clusterId = e.getClusterId(); - CompositeApplicationMonitor appMonitor; - AbstractMonitor clusterMonitor; - - if (AutoscalerContext.getInstance().appMonitorExist(applicationId)) { - appMonitor = AutoscalerContext.getInstance().getAppMonitor(applicationId); - if((appMonitor).clusterMonitorExists(clusterId)) { - clusterMonitor = appMonitor.getClusterMonitor(clusterId); - partitionContext = clusterMonitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); - } - else if(appMonitor.lbMonitorExists(clusterId)) { - clusterMonitor = appMonitor.getLBclusterMonitor(clusterId); - partitionContext = clusterMonitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); - } else { - log.error(String.format("Couldn't find the Cluster [monitor] %s for the [member] %s", clusterId, memberId)); - return; - } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - //starting the pending clusters which are waiting for this member activation in a cluster - appMonitor.registerClusterMonitor(); - } else { - log.error(String.format("Couldn't find the Application [monitor] %s for the [member] %s", applicationId, memberId)); - return; - } + + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); + // TODO starting the pending clusters which are waiting for this member activation in a cluster + + if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added successfully: [member] %s", memberId)); + log.info(String.format("Member stat context has been added " + + "successfully: [member] %s", memberId)); } // partitionContext.incrementCurrentActiveMemberCount(1); partitionContext.movePendingMemberToActiveMembers(memberId); @@ -408,25 +395,28 @@ else if(appMonitor.lbMonitorExists(clusterId)) { @Override protected void onEvent(Event event) { try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent)event; + MemberReadyToShutdownEvent memberReadyToShutdownEvent = + (MemberReadyToShutdownEvent) event; AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; String clusterId = memberReadyToShutdownEvent.getClusterId(); String memberId = memberReadyToShutdownEvent.getMemberId(); - if(asCtx.monitorExist(clusterId)){ + if (asCtx.monitorExist(clusterId)) { monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ + } else if (asCtx.lbMonitorExist(clusterId)) { monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + } else { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler " + + "context [cluster] %s", clusterId)); } return; } NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent.getNetworkPartitionId()); + nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent. + getNetworkPartitionId()); // start a new member in the same Partition String partitionId = monitor.getPartitionOfMember(memberId); @@ -441,7 +431,8 @@ protected void onEvent(Event event) { partitionCtxt.removeActiveMemberById(memberId); if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", + log.info(String.format("Member is terminated and removed from the active " + + "members list: [member] %s [partition] %s [cluster] %s ", memberId, partitionId, clusterId)); } } catch (TerminationException e) { @@ -466,18 +457,21 @@ protected void onEvent(Event event) { PartitionContext partitionContext; String clusterId = e.getClusterId(); - AbstractMonitor monitor; + AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist(clusterId)) { monitor = AutoscalerContext.getInstance().getMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). + getPartitionCtxt(partitionId); } else { monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId).getPartitionCtxt(partitionId); + partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). + getPartitionCtxt(partitionId); } partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isDebugEnabled()) { - log.debug(String.format("Member has been moved as pending termination: [member] %s", memberId)); + log.debug(String.format("Member has been moved as pending termination: " + + "[member] %s", memberId)); } partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); @@ -488,93 +482,48 @@ protected void onEvent(Event event) { } } }); + } - topologyEventReceiver.addEventListener(new ServiceRemovedEventListener() { - @Override - protected void onEvent(Event event) { -// try { -// TopologyManager.acquireReadLock(); -// -// // Remove all clusters of given service from context -// ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent)event; -// for(Service service : TopologyManager.getTopology().getServices()) { -// for(Cluster cluster : service.getClusters()) { -// removeMonitor(cluster.getHostName()); -// } -// } -// } -// finally { -// TopologyManager.releaseReadLock(); -// } - } - }); - - - + /** + * Terminate load balancer topology receiver thread. + */ + public void terminate() { + topologyEventReceiver.terminate(); + terminated = true; + } + protected synchronized void startApplicationMonitor(Application application) { + Thread th = null; + if (!AutoscalerContext.getInstance() + .appMonitorExist(application.getId())) { + th = new Thread( + new ApplicationMonitorAdder(application)); + } + if (th != null) { + th.start(); + try { + th.join(); + } catch (InterruptedException ignore) { + } + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread has been started successfully: " + + "[application] %s ", application.getId())); + } + } } -// private class LBClusterMonitorAdder implements Runnable { -// private Cluster cluster; -// -// public LBClusterMonitorAdder(Cluster cluster) { -// this.cluster = cluster; -// } -// -// public void run() { -// LbClusterMonitor monitor = null; -// int retries = 5; -// boolean success = false; -// do { -// try { -// Thread.sleep(5000); -// } catch (InterruptedException e1) { -// } -// try { -// monitor = AutoscalerUtil.getLBClusterMonitor(cluster); -// success = true; -// -// } catch (PolicyValidationException e) { -// String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); -// log.debug(msg, e); -// retries--; -// -// } catch (PartitionValidationException e) { -// String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); -// log.debug(msg, e); -// retries--; -// } -// } while (!success && retries <= 0); -// -// if (monitor == null) { -// String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " -// + "for cluster: " + cluster.getClusterId(); -// log.error(msg); -// throw new RuntimeException(msg); -// } -// -// Thread th = new Thread(monitor); -// th.start(); -// AutoscalerContext.getInstance().addLbMonitor(monitor); -// if (log.isInfoEnabled()) { -// log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", -// cluster.getClusterId())); -// } -// } -// } - - - private class AppMonitorAdder implements Runnable { - private CompositeApplication compositeApplication; - - public AppMonitorAdder(CompositeApplication compositeApplication) { - this.compositeApplication = compositeApplication; + private class ApplicationMonitorAdder implements Runnable { + private Application application; + + public ApplicationMonitorAdder(Application application) { + this.application = application; } public void run() { - CompositeApplicationMonitor monitor = null; + ApplicationMonitor applicationMonitor = null; int retries = 5; boolean success = false; do { @@ -582,149 +531,36 @@ public void run() { Thread.sleep(5000); } catch (InterruptedException e1) { } - monitor = new CompositeApplicationMonitor(compositeApplication); - success = true; - } while (!success && retries <= 0); + try { + applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); + success = true; + //TODO exception handling + } catch (Exception e) { + String msg = "Application monitor creation failed for Application: " + + application.getId(); + log.debug(msg, e); + retries--; + + } + } while (!success && retries != 0); - if (monitor == null) { - String msg = "App monitor creation failed, even after retrying for 5 times, " - + "for Composite Application: " + compositeApplication.getAlias(); + if (applicationMonitor == null) { + String msg = "Application monitor creation failed, even after retrying for 5 times, " + + "for Application: " + applicationMonitor.getId(); log.error(msg); throw new RuntimeException(msg); } - Thread th = new Thread(monitor); + Thread th = new Thread(applicationMonitor); th.start(); - AutoscalerContext.getInstance().addAppMonitor(monitor); + if (log.isInfoEnabled()) { - log.info(String.format("App monitor has been added successfully: [Composite Application] %s", - compositeApplication.getAlias())); + log.info(String.format("Application monitor has been added successfully: " + + "[application] %s", applicationMonitor.getId())); } } } -// -// -// private class ClusterMonitorAdder implements Runnable { -// private Cluster cluster; -// -// public ClusterMonitorAdder(Cluster cluster) { -// this.cluster = cluster; -// } -// -// public void run() { -// ClusterMonitor monitor = null; -// int retries = 5; -// boolean success = false; -// do { -// try { -// Thread.sleep(5000); -// } catch (InterruptedException e1) { -// } -// -// try { -// monitor = AutoscalerUtil.getClusterMonitor(cluster); -// success = true; -// -// } catch (PolicyValidationException e) { -// String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); -// log.debug(msg, e); -// retries--; -// -// } catch (PartitionValidationException e) { -// String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); -// log.debug(msg, e); -// retries--; -// } -// } while (!success && retries != 0); -// -// if (monitor == null) { -// String msg = "Cluster monitor creation failed, even after retrying for 5 times, " -// + "for cluster: " + cluster.getClusterId(); -// log.error(msg); -// throw new RuntimeException(msg); -// } -// -// Thread th = new Thread(monitor); -// th.start(); -// AutoscalerContext.getInstance().addMonitor(monitor); -// if (log.isInfoEnabled()) { -// log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", -// cluster.getClusterId())); -// } -// } -// } - - @SuppressWarnings("unused") - private void runTerminateAllRule(AbstractMonitor monitor) { - - FactHandle terminateAllFactHandle = null; - - StatefulKnowledgeSession terminateAllKnowledgeSession = null; - - for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { - terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll(terminateAllKnowledgeSession - , terminateAllFactHandle, networkPartitionContext); - } - } - - /** - * Terminate load balancer topology receiver thread. - */ - public void terminate() { - topologyEventReceiver.terminate(); - terminated = true; - } -// protected synchronized void startClusterMonitor(Cluster cluster) { -// Thread th = null; -// if (cluster.isLbCluster() -// && !AutoscalerContext.getInstance() -// .lbMonitorExist( -// cluster.getClusterId())) { -// th = new Thread(new LBClusterMonitorAdder( -// cluster)); -// } else if (!cluster.isLbCluster() && !AutoscalerContext.getInstance() -// .monitorExist(cluster.getClusterId())) { -// th = new Thread( -// new ClusterMonitorAdder(cluster)); -// } -// if (th != null) { -// th.start(); -// try { -// th.join(); -// } catch (InterruptedException ignore) { -// } -// -// if (log.isDebugEnabled()) { -// log.debug(String -// .format("Cluster monitor thread has been started successfully: [cluster] %s ", -// cluster.getClusterId())); -// } -// } -// } - - protected synchronized void startAppMonitor(CompositeApplication compositeApplication) { - Thread th = null; - if (AutoscalerContext.getInstance() - .appMonitorExist( - compositeApplication.getAlias())) { - th = new Thread(new AppMonitorAdder( - compositeApplication)); - } - if (th != null) { - th.start(); - try { - th.join(); - } catch (InterruptedException ignore) { - } - - if (log.isDebugEnabled()) { - log.debug(String - .format("Composite Application monitor thread has been started successfully: [Composite Application] %s ", - compositeApplication.getAlias())); - } - } - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java similarity index 96% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 3c95c9100d..4bf8b7f271 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; @@ -38,16 +37,14 @@ import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; -import java.util.Map; - /** * Is responsible for monitoring a service cluster. This runs periodically * and perform minimum instance check and scaling check using the underlying * rules engine. */ -abstract public class AbstractMonitor implements Runnable{ +abstract public class AbstractClusterMonitor implements Runnable { - private static final Log log = LogFactory.getLog(AbstractMonitor.class); + private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); // Map protected Map networkPartitionCtxts; protected DeploymentPolicy deploymentPolicy; @@ -71,7 +68,7 @@ abstract public class AbstractMonitor implements Runnable{ // time intereval between two runs of the Monitor. Default is 90000ms. protected int monitorInterval; - public AbstractMonitor() { + public AbstractClusterMonitor() { readConfigurations(); } @@ -87,7 +84,6 @@ private void readConfigurations () { @Override public void run() { // TODO Auto-generated method stub - } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java similarity index 52% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index c685cd3d2c..f375e1af3e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/CompositeApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -1,113 +1,92 @@ /* - * 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 + * 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 + * 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. + * 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.autoscaler.monitor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.ComplexApplicationContext; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.domain.topology.Group; -import java.util.List; import java.util.Map; +import java.util.Observable; +import java.util.Observer; -public class CompositeApplicationMonitor extends AbstractMonitor { - private static final Log log = LogFactory.getLog(CompositeApplicationMonitor.class); - private CompositeApplication compositeApplication; - private Map clusterMonitors; - //private Map activeClusterMonitors; - //private Map pausedClusterMonitors; - //cluster ids need to be checked upon the instance activation or group activation - private List clusterIds; +/** + * Monitor is to monitor it's child monitors and + * control them according to the dependencies respectively. + */ +public abstract class Monitor implements Observer, Runnable { + + private static final Log log = LogFactory.getLog(Monitor.class); + protected String id; - private Map lbClusterMonitors; - private String appId; + protected Map groupMonitors; + protected Map abstractClusterMonitors; + protected Map statusCheckers; - public CompositeApplicationMonitor(CompositeApplication compositeApplication) { - this.compositeApplication = compositeApplication; + public Map getGroupMonitors() { + return groupMonitors; } - public void registerClusterMonitor() { - clusterIds = compositeApplication.getClusterIds(); - for (String clusterId : clusterIds) { - if (ComplexApplicationContext.checkStartupDependencies(clusterId)) { - startClusterMonitor(TopologyManager.getTopology().getService("").getCluster(clusterId)); - clusterIds.remove(clusterId); - } else { - //need to wait as it has start up dependency - } - } + public void setGroupMonitors(Map groupMonitors) { + this.groupMonitors = groupMonitors; } - @Override - public void run() { + public Map getAbstractClusterMonitors() { + return abstractClusterMonitors; + } - try { - // TODO make this configurable, - // this is the delay the min check of normal cluster monitor to wait until LB monitor is added - Thread.sleep(60000); - } catch (InterruptedException ignore) { - } - while (!isDestroyed()) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } - try { - if(clusterIds.size() > 0) { - registerClusterMonitor(); - } - deRegisterClusterMonitorOnTermination(); - } catch (Exception e) { - log.error("Cluster monitor: Monitor failed." + this.toString(), e); - } - try { - // TODO make this configurable - Thread.sleep(30000); - } catch (InterruptedException ignore) { - } - } + public void setAbstractClusterMonitors(Map abstractClusterMonitors) { + this.abstractClusterMonitors = abstractClusterMonitors; } - public void deRegisterClusterMonitorOnTermination() { - //need to remove the cluster monitor and add it to the pending list + public abstract void monitor(); + + @Override + public void update(Observable observable, Object o) { + } - public String getAppId() { - return appId; + public String getId() { + return this.id; } - public void setAppId(String appId) { - this.appId = appId; + public void setId(String id) { + this.id = id; } + protected synchronized void startClusterMonitor(Cluster cluster) { Thread th = null; if (cluster.isLbCluster() - && !this.lbClusterMonitors.containsKey(cluster.getClusterId())) { + && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { th = new Thread(new LBClusterMonitorAdder( cluster)); - } else if (!cluster.isLbCluster() && !this.clusterMonitors.containsKey(cluster.getClusterId())) { + } else if (!cluster.isLbCluster() && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { th = new Thread( new ClusterMonitorAdder(cluster)); } @@ -126,29 +105,28 @@ protected synchronized void startClusterMonitor(Cluster cluster) { } } - public void setLbClusterMonitors(Map lbClusterMonitors) { - this.lbClusterMonitors = lbClusterMonitors; - } - - public void setClusterMonitors(Map clusterMonitors) { - clusterMonitors = clusterMonitors; - } + protected synchronized void startGroupMonitor(Group group) { + Thread th = null; + if (!this.groupMonitors.containsKey(group.getAlias())) { + th = new Thread( + new GroupMonitorAdder(group)); + } - public boolean clusterMonitorExists(String clusterId) { - return clusterMonitors.containsKey(clusterId); - } + if (th != null) { + th.start(); + try { + th.join(); + } catch (InterruptedException ignore) { + } - public boolean lbMonitorExists(String clusterId) { - return lbClusterMonitors.containsKey(clusterId); + if (log.isDebugEnabled()) { + log.debug(String + .format("Group monitor thread has been started successfully: [group] %s ", + group.getAlias())); + } + } } - public LbClusterMonitor getLBclusterMonitor(String clusterId) { - return lbClusterMonitors.get(clusterId); - } - - public ClusterMonitor getClusterMonitor(String clusterId) { - return clusterMonitors.get(clusterId); - } private class ClusterMonitorAdder implements Runnable { private Cluster cluster; @@ -170,7 +148,7 @@ public void run() { try { monitor = AutoscalerUtil.getClusterMonitor(cluster); success = true; - + //TODO start the status checker } catch (PolicyValidationException e) { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); log.debug(msg, e); @@ -192,8 +170,9 @@ public void run() { Thread th = new Thread(monitor); th.start(); + //AutoscalerContext.getInstance().addMonitor(monitor); - clusterMonitors.put(cluster.getClusterId(), monitor); + abstractClusterMonitors.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); @@ -201,6 +180,53 @@ public void run() { } } + private class GroupMonitorAdder implements Runnable { + private Group group; + + public GroupMonitorAdder(Group group) { + this.group = group; + } + + public void run() { + GroupMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + + try { + monitor = AutoscalerUtil.getGroupMonitor(group); + success = true; + + } catch (Exception e) { + String msg = "Group monitor creation failed for group: " + group.getAlias(); + log.debug(msg, e); + retries--; + + } + } while (!success && retries != 0); + + if (monitor == null) { + String msg = "Group monitor creation failed, even after retrying for 5 times, " + + "for group: " + group.getAlias(); + log.error(msg); + throw new RuntimeException(msg); + } + + Thread th = new Thread(monitor); + th.start(); + + groupMonitors.put(group.getAlias(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("Group monitor has been added successfully: [group] %s", + group.getAlias())); + } + } + } + private class LBClusterMonitorAdder implements Runnable { private Cluster cluster; @@ -243,7 +269,7 @@ public void run() { Thread th = new Thread(monitor); th.start(); //AutoscalerContext.getInstance().addLbMonitor(monitor); - lbClusterMonitors.put(cluster.getClusterId(), monitor); + abstractClusterMonitors.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); @@ -251,4 +277,5 @@ public void run() { } } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java new file mode 100644 index 0000000000..7e27fa6273 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -0,0 +1,142 @@ +/* + * 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.autoscaler.monitor.application; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +import java.util.*; + +public class ApplicationMonitor extends Monitor { + private static final Log log = LogFactory.getLog(ApplicationMonitor.class); + private Application application; + private Queue preOrderTraverse = new LinkedList(); + private Queue clusters = new LinkedList(); + Map statusCheckerMap = new HashMap(); + + private Queue groups = new LinkedList(); + + + public ApplicationMonitor(Application application) { + this.application = application; + //TODO build dependencies and keep them here + DependencyOrder dependencyOrder = application.getDependencyOrder(); + Set startupOrderSet = dependencyOrder.getStartupOrders(); + for(StartupOrder startupOrder: startupOrderSet) { + + String start = startupOrder.getStart(); + String after = startupOrder.getAfter(); + + if (!preOrderTraverse.contains(start)) { + preOrderTraverse.add(start); + if (!preOrderTraverse.contains(after)) { + preOrderTraverse.add(after); + + } else { + //TODO throw exception since after is there before start + } + } else { + if (!preOrderTraverse.contains(after)) { + preOrderTraverse.add(after); + } else { + //TODO throw exception since start and after already there + } + } + } + + //TODO find out the parallel ones + + //start the first dependency + String dependency = preOrderTraverse.poll(); + if(dependency.contains("group")) { + startGroupMonitor(application.getGroup(dependency)); + } else if(dependency.contains("cartridge")) { + String clusterId = application.getClusterId(dependency); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if(cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } + } + } + + + //start the least dependent cluster monitor as part of the applicationCreatedEvent + public void registerFirstClusterMonitor() { + //build dependency tree + + + + + //traverse dependency tree and find the clusters to be started and + // register the correct GroupMonitor or ClusterMonitor + //startGroupMonitor(groups.peek()); + //groups.poll(); + + + + + + + + } + + public void startMonitor() { + + } + + @Override + public void run() { + while (true ) { //TODO add the correct status + if (log.isDebugEnabled()) { + log.debug("App monitor is running.. " + this.toString()); + } + + + + try { + // TODO make this configurable + Thread.sleep(30000); + } catch (InterruptedException ignore) { + } + } + } + + + @Override + public void monitor() { + + } + + public Queue getPreOrderTraverse() { + return preOrderTraverse; + } + + public void setPreOrderTraverse(Queue preOrderTraverse) { + this.preOrderTraverse = preOrderTraverse; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java similarity index 80% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index a17bf55948..9558384977 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -16,19 +16,21 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Group; import java.util.ArrayList; import java.util.List; @@ -39,12 +41,13 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ -public class ClusterMonitor extends AbstractMonitor { +public class ClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(ClusterMonitor.class); private String lbReferenceType; private boolean hasPrimary; private ClusterStatus status; + private Group parent; public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { @@ -68,34 +71,36 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo @Override public void run() { - try { - // TODO make this configurable, + /*try { + // TODO make this configurable(**Remove this as LB will be a seperate monitor), // this is the delay the min check of normal cluster monitor to wait until LB monitor is added Thread.sleep(60000); } catch (InterruptedException ignore) { - } - - while (!isDestroyed()) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } - try { - if(!ClusterStatus.In_Maintenance.equals(status)) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + }*/ + this.status = ClusterStatus.Running; + while (!isDestroyed() && status.getCode() >= ClusterStatus.Running.getCode()) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } + try { + if(!ClusterStatus.In_Maintenance.equals(status)) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is suspended as the cluster is in " + + ClusterStatus.In_Maintenance + " mode......"); + } } + } catch (Exception e) { + log.error("Cluster monitor: Monitor failed." + this.toString(), e); + } + try { + Thread.sleep(monitorInterval); + } catch (InterruptedException ignore) { } - } catch (Exception e) { - log.error("Cluster monitor: Monitor failed." + this.toString(), e); - } - try { - Thread.sleep(monitorInterval); - } catch (InterruptedException ignore) { } - } + + } private boolean isPrimaryMember(MemberContext memberContext){ @@ -117,12 +122,35 @@ private boolean isPrimaryMember(MemberContext memberContext){ return false; } - private void monitor() { + public void monitor() { //TODO make this concurrent + /*final ClusterMonitor clusterMonitor = this; + + Runnable checkClusterStatus = new Runnable() { + @Override + public void run() { + boolean clusterActive = false; + for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { + //minimum check per partition + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + if(partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { + clusterActive = true; + } + clusterActive = false; + } + + } + // if active then notify upper layer + + if(clusterActive) { + clusterMonitor.setStatus(ClusterStatus.Active); + } + + } + };*/ for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { // store primary members in the network partition context List primaryMemberListInNetworkPartition = new ArrayList(); - //minimum check per partition for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { // store primary members in the partition context @@ -133,6 +161,7 @@ private void monitor() { primaryMemberListInPartition.add(memberContext.getMemberId()); } } + // get pending primary members in this partition context for (MemberContext memberContext : partitionContext.getPendingMembers()) { if (isPrimaryMember(memberContext)){ @@ -152,6 +181,9 @@ private void monitor() { minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession , minCheckFactHandle, partitionContext); + //checking the status of the cluster + + } //terminate dependency per partition diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java similarity index 96% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index ee1161c0a3..31c7ff7a33 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -16,13 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.topology.ClusterStatus; @@ -34,7 +35,7 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ -public class LbClusterMonitor extends AbstractMonitor { +public class LbClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(LbClusterMonitor.class); private ClusterStatus status; @@ -122,4 +123,6 @@ public ClusterStatus getStatus() { public void setStatus(ClusterStatus status) { this.status = status; } + + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java new file mode 100644 index 0000000000..185442ea36 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.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.autoscaler.monitor.group; + +import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.messaging.domain.topology.Group; + +import java.util.List; +import java.util.Map; + +/** + * This is GroupMonitor to monitor the group which consists of + * groups and clusters + */ +public class GroupMonitor extends Monitor { + + public GroupMonitor(Group group) { + + } + + //monitor the status of the cluster and the groups + public void monitor() { + + + } + + + @Override + public void run() { + + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java new file mode 100644 index 0000000000..dd417674c9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.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.autoscaler.status.checker; + +/** + * Cluster status checker will periodically check the cluster status + * and notify the interested parties + */ +public class ClusterStatusChecker extends StatusChecker { + private String appId; + private String groupId; + private String clsuterId; + + public ClusterStatusChecker(String appId, String groupId, String clusterId) { + this.appId = appId; + this.groupId = groupId; + this.clsuterId = clusterId; + } + @Override + public void run() { + + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java new file mode 100644 index 0000000000..ea8e56cb93 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java @@ -0,0 +1,37 @@ +/* + * 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.autoscaler.status.checker; + +/** + * Group status checker will check the group status and + * notify the interested parties on behalf of the status changes + */ +public class GroupStatusChecker extends StatusChecker { + private String groupId; + private String appId; + + public GroupStatusChecker(String groupId, String appId) { + this.groupId = groupId; + this.appId = appId; + } + @Override + public void run() { + + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java new file mode 100644 index 0000000000..154de32671 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.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.autoscaler.status.checker; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.listener.EventListener; + +import java.util.Observable; + +/** + * This will be used to evaluate the status of a group + * and notify the interested parties about the status changes. + */ +public abstract class StatusChecker extends Observable implements Runnable { + + private static final Log log = LogFactory.getLog(StatusChecker.class); + + public void addObserver(EventListener eventListener) { + addObserver(eventListener); + } + + public void notifyObservers(Monitor monitor) { + if(log.isDebugEnabled()) { + log.debug(String.format("Notifying the observers: [monitor] %s", monitor.getClass().getName())); + } + setChanged(); + notifyObservers(monitor); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 8eaf1ddd2b..bc9d450553 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -30,8 +30,10 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.monitor.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; @@ -40,10 +42,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Member; -import org.apache.stratos.messaging.domain.topology.MemberStatus; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.util.Constants; import javax.xml.namespace.QName; @@ -315,6 +314,20 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic return clusterMonitor; } + public static GroupMonitor getGroupMonitor(Group group) { + GroupMonitor groupMonitor = + new GroupMonitor(group); + return groupMonitor; + + } + + public static ApplicationMonitor getApplicationMonitor(Application application) { + ApplicationMonitor applicationMonitor = + new ApplicationMonitor(application); + return applicationMonitor; + + } + public static Properties getProperties(final OMElement elt) { Iterator it = elt.getChildrenWithName(new QName(AutoScalerConstants.PROPERTY_ELEMENT)); @@ -415,4 +428,5 @@ public static Properties getProperties(final OMElement elt) { // } // return null; // } + } From 0d1272d3513351d26ff4fb1edad3ca44efa2a2cb Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 16 Sep 2014 16:11:23 +0530 Subject: [PATCH 055/436] refacter properties --- .../definition/CartridgeMetaData.java | 8 ++++---- .../metadataservice/definition/PropertyBean.java | 2 +- .../handlers/StratosAuthorizingHandler.java | 2 +- .../metadataservice/registry/CarbonRegistry.java | 14 ++++++-------- .../metadataservice/registry/GRegRegistry.java | 6 +++--- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java index dfecee4b4a..fbe15ba9e1 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java @@ -20,21 +20,21 @@ public class CartridgeMetaData { public String version; - public List property; + public List properties; @Override public String toString() { return "applicationName: " + applicationName + ", displayName: " + displayName + ", description: " + description + ", type: " + type + ", provider: " + provider + - ", host: " + host + ", Version: " + version + ", property: " + getProperties(); + ", host: " + host + ", Version: " + version + ", properties: " + getProperties(); } private String getProperties() { StringBuilder propertyBuilder = new StringBuilder(); - if (property != null) { - for (PropertyBean propertyBean : property) { + if (properties != null) { + for (PropertyBean propertyBean : properties) { propertyBuilder.append(propertyBean.toString()); } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java index ae4fcf8bc7..0ecc8d919d 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/PropertyBean.java @@ -21,7 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name = "property") +@XmlRootElement(name = "properties") public class PropertyBean { public String hostname; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java index 429399f68b..46f1fd0d73 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/handlers/StratosAuthorizingHandler.java @@ -155,7 +155,7 @@ private boolean isAuthorized(AuthorizationManager authorizationManager, String u /** * Here we are getting the target invocation method. The method get set as a - * property in the + * properties in the * message by the * {@link org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor} * 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 7d5acd038c..0ba238a5b2 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 @@ -67,7 +67,7 @@ public CarbonRegistry() { @Override public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, CartridgeMetaData cartridgeMetaData) throws Exception { - System.out.println("Adding meta data details"); + log.debug("Adding meta data details"); Registry tempRegistry = getGovernanceUserRegistry(); try { @@ -88,7 +88,7 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid resource.addProperty("Version", cartridgeMetaData.version); resource.addProperty("host", cartridgeMetaData.host); - for (PropertyBean prop : cartridgeMetaData.property) { + for (PropertyBean prop : cartridgeMetaData.properties) { resource.addProperty("hostname", prop.hostname); resource.addProperty("username", prop.username); resource.addProperty("password", prop.password); @@ -96,10 +96,8 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid tempRegistry.put(resourcePath, resource); - System.out.println("A resource added to: " + resourcePath); - - System.out.println(cartridgeMetaData.type); - // registry.rateResource(resourcePath, defaultRank); + if(log.isDebugEnabled()) + log.debug(String.format("A resource added to: %s", resourcePath)); Comment comment = new Comment(); comment.setText("Added the " + applicationName + " " + type + " cartridge"); @@ -113,7 +111,7 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid // Close the session } - System.out.println("Add meta data details"); + return "success"; } @@ -153,7 +151,7 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid prop.password = getResource.getProperty("password"); lst.add(prop); - cartridgeMetaData.property = lst; + cartridgeMetaData.properties = lst; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 080fc60c0b..fb1522f689 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -121,7 +121,7 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid resource.addProperty("Version", cartridgeMetaData.version); resource.addProperty("host", cartridgeMetaData.host); - for (PropertyBean prop : cartridgeMetaData.property) { + for (PropertyBean prop : cartridgeMetaData.properties) { resource.addProperty("hostname", prop.hostname); resource.addProperty("username", prop.username); resource.addProperty("password", prop.password); @@ -146,7 +146,7 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid // Close the session ((WSRegistryServiceClient) registry).logut(); } - System.out.println("Add meta data details"); + log.info("Add meta data details"); return "success"; } @@ -186,7 +186,7 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid prop.password = getResource.getProperty("password"); lst.add(prop); - cartridgeMetaData.property = lst; + cartridgeMetaData.properties = lst; } From 3463763a4a185e81d5104ccacb86cdac4825eadd Mon Sep 17 00:00:00 2001 From: gayan Date: Tue, 16 Sep 2014 16:19:03 +0530 Subject: [PATCH 056/436] remove unnecssary logs --- .../listener/TopologyAgent.java | 4 ++- .../listener/TopologyListener.java | 6 ++-- .../registry/CarbonRegistry.java | 28 +++++++++---------- .../registry/GRegRegistry.java | 26 +++++++++-------- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java index b8fe9185d1..8e3936489c 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -67,8 +67,10 @@ protected void onEvent(Event event) { log.debug("Member terminated event received"); } MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; - System.out.println("Terminated event :::::::::::::::::::: " + + if(log.isDebugEnabled()){ + log.debug("Terminated event :::::::::::::::::::: " + memberTerminatedEvent.getServiceName()); + } new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); } catch (Exception e) { diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java index 2f09d3db4a..fbca388a94 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java @@ -59,8 +59,10 @@ protected void onEvent(Event event) { log.debug("Member terminated event received"); } MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; - System.out.println("Terminated event :::::::::::::::::::: " + - memberTerminatedEvent.getServiceName()); + if(log.isDebugEnabled()){ + log.info("Terminated event :::::::::::::::::::: " + + memberTerminatedEvent.getServiceName()); + } new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); // extensionHandler.onMemberTerminatedEvent(memberTerminatedEvent); 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 7d5acd038c..054db317b7 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 @@ -67,7 +67,7 @@ public CarbonRegistry() { @Override public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, CartridgeMetaData cartridgeMetaData) throws Exception { - System.out.println("Adding meta data details"); + Registry tempRegistry = getGovernanceUserRegistry(); try { @@ -96,24 +96,24 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid tempRegistry.put(resourcePath, resource); - System.out.println("A resource added to: " + resourcePath); - - System.out.println(cartridgeMetaData.type); - // registry.rateResource(resourcePath, defaultRank); + if(log.isDebugEnabled()){ + log.debug("A resource added to: " + resourcePath); + } + Comment comment = new Comment(); comment.setText("Added the " + applicationName + " " + type + " cartridge"); // registry.addComment(resourcePath, comment); } catch (Exception e) { - - System.out.println(e.getMessage()); - e.printStackTrace(); + if (log.isErrorEnabled()) { + log.error("addCartridgeMetaDataDetails", e); + } } finally { // Close the session } - System.out.println("Add meta data details"); + return "success"; } @@ -134,10 +134,7 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid if (registry.resourceExists(resourcePath)) { Resource getResource = registry.get(resourcePath); - System.out.println("Resource retrived"); - System.out.println("Printing retrieved resource content: " + - new String((byte[]) getResource.getContent())); - + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); cartridgeMetaData.description = getResource.getProperty("Description"); @@ -159,8 +156,9 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); + if (log.isErrorEnabled()) { + log.error("getCartridgeMetaDataDetails", e); + } } finally { // Close the session diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 080fc60c0b..2d655c95eb 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -101,7 +101,7 @@ private static WSRegistryServiceClient setRegistry() throws Exception { @Override public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, CartridgeMetaData cartridgeMetaData) throws Exception { - System.out.println("Adding meta data details"); + Registry registry = setRegistry(); try { @@ -129,9 +129,7 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid registry.put(resourcePath, resource); - System.out.println("A resource added to: " + resourcePath); - - System.out.println(cartridgeMetaData.type); + registry.rateResource(resourcePath, defaultRank); Comment comment = new Comment(); @@ -140,13 +138,14 @@ public String addCartridgeMetaDataDetails(String applicationName, String cartrid } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); + if (log.isErrorEnabled()) { + log.error("addCartridgeMetaDataDetails", e); + } } finally { // Close the session ((WSRegistryServiceClient) registry).logut(); } - System.out.println("Add meta data details"); + return "success"; } @@ -167,9 +166,11 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid if (registry.resourceExists(resourcePath)) { Resource getResource = registry.get(resourcePath); - System.out.println("Resource retrived"); - System.out.println("Printing retrieved resource content: " + - new String((byte[]) getResource.getContent())); + if(log.isDebugEnabled()){ + log.debug("Resource retrived"); + log.debug("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + } cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); @@ -192,8 +193,9 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid } catch (Exception e) { - System.out.println(e.getMessage()); - e.printStackTrace(); + if (log.isErrorEnabled()) { + log.error("getCartridgeMetaDataDetails", e); + } } finally { // Close the session ((WSRegistryServiceClient) registry).logut(); From bd9825b68ec12f4d33999b2f5cf1c0f4c6b986c4 Mon Sep 17 00:00:00 2001 From: Reka Date: Tue, 16 Sep 2014 17:02:17 +0530 Subject: [PATCH 057/436] updating cluster status --- .../stratos/messaging/domain/topology/ClusterStatus.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java index b3301c88d1..9556c4d528 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -21,7 +21,10 @@ public enum ClusterStatus { Created(1), In_Maintenance(2), - Removed(3); + terminating(3), + Removed(4), + Running(5), + Active(6); private int code; From ea9f4042e556c266ae2df122fabeb876e55b13a7 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 16 Sep 2014 17:21:55 +0530 Subject: [PATCH 058/436] Status for Group and Application --- .../domain/topology/Application.java | 11 ++++++ .../messaging/domain/topology/Group.java | 11 ++++++ .../messaging/domain/topology/Status.java | 37 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index e4429969f3..2d5383324c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -38,10 +38,13 @@ public class Application implements SubscribableBehavior { private Map groupMap; // Cluster Id map, key = service name private Map clusterIdMap; + // Application status + private Status status; public Application (String id) { this.id = id; this.key = RandomStringUtils.randomAlphanumeric(16); + this.status = Status.Created; groupMap = new HashMap(); clusterIdMap = new HashMap(); } @@ -103,4 +106,12 @@ public String getId() { public String getKey() { return key; } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 16ec77595f..fd13970426 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -40,10 +40,13 @@ public class Group implements SubscribableBehavior { private Map groupMap; // Cluster id map, key = service name private Map clusterIdMap; + // Group status + private Status status; public Group (String name, String alias) { this.name = name; this.alias = alias; + this.status = Status.Created; groupMap = new HashMap(); clusterIdMap = new HashMap(); } @@ -138,4 +141,12 @@ public boolean equals(Object other) { public int hashCode () { return name.hashCode() + alias.hashCode(); } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java new file mode 100644 index 0000000000..806c113b0b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -0,0 +1,37 @@ +/* + * 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.messaging.domain.topology; + +public enum Status { + + Created(1), + In_Maintenance(2), + Activated(3); + + private int code; + + private Status(int code) { + this.code = code; + } + + public int getCode() { + return code; + } +} From 6f5dc14ca23c87a6da4e487650b5f9c2b8ef539a Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 16 Sep 2014 19:57:20 +0530 Subject: [PATCH 059/436] renaming a class: SubscribableBehavior to ParentBehavior --- .../apache/stratos/messaging/domain/topology/Application.java | 2 +- .../org/apache/stratos/messaging/domain/topology/Group.java | 2 +- .../topology/{SubscribableBehavior.java => ParentBehavior.java} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/{SubscribableBehavior.java => ParentBehavior.java} (96%) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 2d5383324c..1af8e3eefc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Map; -public class Application implements SubscribableBehavior { +public class Application implements ParentBehavior { private static final long serialVersionUID = -5092959597171649688L; // Unique id for the Application, defined in Application Definition diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index fd13970426..1d5244e33f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; -public class Group implements SubscribableBehavior { +public class Group implements ParentBehavior { private static final long serialVersionUID = 8347096598203655846L; // Name of the Group, specified in Group Definition diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java similarity index 96% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index b66b0c7552..4daaa270ac 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/SubscribableBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -23,7 +23,7 @@ import java.util.Collection; import java.util.Map; -public interface SubscribableBehavior extends Serializable { +public interface ParentBehavior extends Serializable { public void addGroup (Group group); From 1d474ae4530ca22df1e748820c1b83804bbb526a Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 16 Sep 2014 18:06:36 -0700 Subject: [PATCH 060/436] adding dupliate cartridge type, subgroup check, getServiceGroup-Dependencies, SubGroups, Cartridges APIs to CC --- .../impl/CloudControllerServiceImpl.java | 38 +- .../interfaces/CloudControllerService.java | 4 +- .../client/CloudControllerServiceClient.java | 12 + .../deployer/DefaultServiceGroupDeployer.java | 54 +- .../resources/CloudControllerService.wsdl | 640 +++++++++--------- 5 files changed, 419 insertions(+), 329 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 34664b07b9..4d20c826f6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -288,6 +288,14 @@ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceG log.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName()); } + String [] subGroups = servicegroup.getCartridges(); + + + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups.length); + } + + Dependencies dependencies = servicegroup.getDependencies(); if(log.isDebugEnabled()) { @@ -353,16 +361,34 @@ public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupExce return serviceGroup; } - public String []getServiceGroupSubGroups (String name) throws InvalidServiceGroupException { - return null; + public String [] getServiceGroupSubGroups (String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + + return serviceGroup.getSubGroups(); } - public Dependencies getServiceGroupCartridges (String name) throws InvalidServiceGroupException { - return null; + /** + * + */ + public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + String [] cs = serviceGroup.getCartridges(); + return cs; + } - public Dependencies getServiceGroupDepenencies (String name) throws InvalidServiceGroupException { - return null; + public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + return serviceGroup.getDependencies(); } @Override diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 53821dd7ad..ff36c830b1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -55,9 +55,9 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) public String []getServiceGroupSubGroups (String name) throws InvalidServiceGroupException; - public Dependencies getServiceGroupCartridges (String name) throws InvalidServiceGroupException; + public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException; - public Dependencies getServiceGroupDepenencies (String name) throws InvalidServiceGroupException; + public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException; /** * Validate a given {@link Partition} for basic property existence. 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 92b9da7bd8..fb8075d416 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 @@ -95,6 +95,18 @@ public void undeployServiceGroup (String name)throws RemoteException, CloudContr stub.undeployServiceGroup(name); } + public String [] getServiceGroupSubGroups(String name) throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + return stub.getServiceGroupSubGroups(name); + } + + public String [] getServiceGroupCartridges(String name) throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + return stub.getServiceGroupCartridges(name); + } + + public Dependencies getServiceGroupDependencies (String name)throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { + return stub.getServiceGroupDependencies(name); + } + public ServiceGroup getServiceGroup(String name) throws RemoteException, CloudControllerServiceInvalidServiceGroupExceptionException { return stub.getServiceGroup(name); } 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 index 8735ab3600..f944288953 100644 --- 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 @@ -38,7 +38,9 @@ import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class DefaultServiceGroupDeployer implements ServiceGroupDeployer { @@ -83,6 +85,20 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro } List cartridgeTypes = serviceGroupDefinition.getCartridges(); + + Set 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; @@ -116,6 +132,20 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro } List subGroupNames = serviceGroupDefinition.getSubGroups(); + + Set duplicates = this.findDuplicates(subGroupNames); + + 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 : subGroupNames) { if (getServiceGroupDefinition(subGroupName) == null) { @@ -165,6 +195,7 @@ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefi ServiceGroup serviceGroup = ccServiceClient.getServiceGroup(serviceGroupDefinitionName); ServiceGroupDefinition serviceGroupDef = populateServiceGroupDefinitionPojo(serviceGroup); + return serviceGroupDef; } catch (AxisFault axisFault) { @@ -287,4 +318,25 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup return servicegroupDef; } -} + + + /** + * returns any duplicates in a List + * @param checkedList + * @return + */ + private Set findDuplicates(List checkedList) + { + final Set retVals = new HashSet(); + final Set set1 = new HashSet(); + + for (String val : checkedList) { + + if (!set1.add(val)) { + retVals.add(val); + } + } + return retVals; + } + + } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index af7bc272ed..ebca4bdb12 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,21 +6,21 @@ - - + + - - - + + + - + @@ -34,9 +34,9 @@ - + - + @@ -58,282 +58,282 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -349,124 +349,139 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + - + + - - + - - - - - - - - - - - - - + + - + - - - - - - - - - + + + + + + + - + @@ -481,41 +496,15 @@ - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - + + + - + - @@ -523,42 +512,51 @@ - + + - - - + + + - + - + + + + + + + + + + - + - - + - + - - - + + + - - + + @@ -569,14 +567,14 @@ - + - + @@ -585,64 +583,66 @@ - + - - - - - - - - - - - - - - - - - + + + + - + - - - - - - - - - - - + + - + - + + - + - - - + + + + + + + + + + + + + - - - - + - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -689,6 +689,18 @@ + + + + + + + + + + + + @@ -704,11 +716,8 @@ - - - - - + + @@ -716,9 +725,6 @@ - - - @@ -758,12 +764,6 @@ - - - - - - @@ -803,6 +803,16 @@ + + + + + + + + + + @@ -813,20 +823,15 @@ - - - - + + + - - - - @@ -858,11 +863,6 @@ - - - - - @@ -942,8 +942,8 @@ - - + + @@ -966,6 +966,18 @@ + + + + + + + + + + + + @@ -978,15 +990,6 @@ - - - - - - - - - @@ -999,6 +1002,15 @@ + + + + + + + + + @@ -1056,18 +1068,6 @@ - - - - - - - - - - - - @@ -1179,8 +1179,8 @@ - - + + @@ -1203,6 +1203,18 @@ + + + + + + + + + + + + @@ -1215,15 +1227,6 @@ - - - - - - - - - @@ -1236,6 +1239,15 @@ + + + + + + + + + @@ -1293,18 +1305,6 @@ - - - - - - - - - - - - @@ -1395,8 +1395,8 @@ - - + + @@ -1413,14 +1413,17 @@ - - + + + + + - - + + @@ -1434,6 +1437,12 @@ + + + + + + @@ -1473,15 +1482,6 @@ - - - - - - - - - @@ -1515,22 +1515,22 @@ - + - + - + - + - + - + \ No newline at end of file From d8c84bfab40fa75da794dfab1d7647ec4bcdf144 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 17 Sep 2014 09:55:01 +0530 Subject: [PATCH 061/436] logging errors before throwing --- .../parser/DefaultApplicationParser.java | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 8ea89be73c..44edc49f96 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -51,15 +51,16 @@ public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionExcep } if (applicationCtxt == null) { - throw new ApplicationDefinitionException("Invalid Composite Application Definition"); + handleError("Invalid Composite Application Definition"); } + assert applicationCtxt != null; if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) { - throw new ApplicationDefinitionException("Invalid alias specified"); + handleError("Invalid alias specified"); } if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) { - throw new ApplicationDefinitionException("Invalid Composite App id specified"); + handleError("Invalid Composite App id specified"); } // get the defined groups @@ -85,7 +86,7 @@ public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionExcep } if (subscribablesInfo == null) { - throw new ApplicationDefinitionException("Invalid Composite Application Definition, no Subscribable Information specified"); + handleError("Invalid Composite Application Definition, no Subscribable Information specified"); } return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); @@ -105,23 +106,23 @@ private Map getDefinedGroups (ApplicationContext appCtxt) // check validity of group name if (groupContext.getName() == null || groupContext.getName().isEmpty()) { - throw new ApplicationDefinitionException("Invalid Group name specified"); + handleError("Invalid Group name specified"); } // check if group is deployed if(!isGroupDeployed(groupContext.getName())) { - throw new ApplicationDefinitionException("Group with name " + groupContext.getName() + " not deployed"); + handleError("Group with name " + groupContext.getName() + " not deployed"); } // check validity of group alias if (groupContext.getAlias() == null || groupContext.getAlias().isEmpty() || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { - throw new ApplicationDefinitionException("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); + handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); } // check if a group is already defined under the same alias if(definedGroups.get(groupContext.getAlias()) != null) { // a group with same alias already exists, can't continue - throw new ApplicationDefinitionException("A Group with alias " + groupContext.getAlias() + " already exists"); + handleError("A Group with alias " + groupContext.getAlias() + " already exists"); } definedGroups.put(groupContext.getAlias(), groupContext); @@ -148,13 +149,13 @@ private Map getSubscribableInformation (Applica if (subscribableInfoCtxt.getAlias() == null || subscribableInfoCtxt.getAlias().isEmpty() || !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) { - throw new ApplicationDefinitionException("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); + handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); } // check if a group is already defined under the same alias if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) { // a group with same alias already exists, can't continue - throw new ApplicationDefinitionException("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists"); + handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists"); } subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt); @@ -228,7 +229,7 @@ private Map getGroupInfo (Set clusters, List clusters, GroupContext groupCtxt, Map getStartupOrderForGroup(String serviceGroupName) throw ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); if (serviceGroup == null) { - throw new ApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + handleError("Service Group Definition not found for name " + serviceGroupName); } + assert serviceGroup != null; if (serviceGroup.getDependencies() != null) { if (serviceGroup.getDependencies().getStartupOrder() != null) { return ParserUtils.convert(serviceGroup.getDependencies().getStartupOrder()); @@ -359,9 +361,10 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); if (serviceGroup == null) { - throw new ApplicationDefinitionException("Service Group Definition not found for name " + serviceGroupName); + handleError("Service Group Definition not found for name " + serviceGroupName); } + assert serviceGroup != null; if (serviceGroup.getDependencies() != null) { return serviceGroup.getDependencies().getKillBehaviour(); } @@ -413,20 +416,20 @@ private ClusterDataHolder getClusterInformation (List subsc // check is there is a related Subscribable Information SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); if (subscribableInfoCtxt == null) { - throw new ApplicationDefinitionException("Related Subscribable Information Ctxt not found for Subscribable with alias: " + handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: " + subscribableCtxt.getAlias()); } // check if Cartridge Type is valid if (subscribableCtxt.getType() == null || subscribableCtxt.getType().isEmpty()) { - throw new ApplicationDefinitionException ("Invalid Cartridge Type specified : [ " + handleError("Invalid Cartridge Type specified : [ " + subscribableCtxt.getType() + " ]"); } // check if a cartridge with relevant type is already deployed. else, can't continue Cartridge cartridge = getCartridge(subscribableCtxt.getType()); if (cartridge == null) { - throw new ApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + + handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + " ] for Composite Application"); } @@ -434,7 +437,7 @@ private ClusterDataHolder getClusterInformation (List subsc clusters.add(cluster); if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { // Application Definition has same cartridge multiple times at the top-level - throw new ApplicationDefinitionException("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); + handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); } } @@ -487,4 +490,9 @@ private Cartridge getCartridge (String cartridgeType) { return FasterLookUpDataHolder.getInstance().getCartridge(cartridgeType); } + private void handleError (String errorMsg) throws ApplicationDefinitionException { + log.error(errorMsg); + throw new ApplicationDefinitionException(errorMsg); + } + } From 2ca08d46112bf311dfb6bb61b91dee72e530c44f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 17 Sep 2014 14:50:44 +0530 Subject: [PATCH 062/436] adding a method to get Group by alias in an Application recursively --- .../domain/topology/Application.java | 23 +++++++++++++++++++ .../messaging/domain/topology/Group.java | 23 +++++++++++++++++++ .../domain/topology/ParentBehavior.java | 2 ++ 3 files changed, 48 insertions(+) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 1af8e3eefc..035b52a97e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -64,6 +64,29 @@ public Group getGroup(String groupName) { return groupMap.get(groupName); } + @Override + public Group getGroupRecursively(String groupAlias) { + + return travereAndCheckRecursively(groupMap.values(), groupAlias); + } + + private Group travereAndCheckRecursively (Collection groups, String groupAlias) { + + for (Group group : groups) { + // check if alias is equal, if so, return + if (groupAlias.equals(group.getAlias())) { + return group; + } else { + // check if this Group has nested sub Groups. If so, traverse them as well + if (group.getGroups() != null) { + return travereAndCheckRecursively(group.getGroups(), groupAlias); + } + } + } + + return null; + } + @Override public Collection getGroups() { return groupMap.values(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 1d5244e33f..8640aca2b4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -66,6 +66,29 @@ public Group getGroup(String groupName) { return groupMap.get(groupName); } + @Override + public Group getGroupRecursively(String groupAlias) { + + return travereAndCheckRecursively(groupMap.values(), groupAlias); + } + + private Group travereAndCheckRecursively (Collection groups, String groupAlias) { + + for (Group group : groups) { + // check if alias is equal, if so, return + if (groupAlias.equals(group.getAlias())) { + return group; + } else { + // check if this Group has nested sub Groups. If so, traverse them as well + if (group.getGroups() != null) { + return travereAndCheckRecursively(group.getGroups(), groupAlias); + } + } + } + + return null; + } + @Override public Collection getGroups() { return groupMap.values(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index 4daaa270ac..99a626bb84 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -31,6 +31,8 @@ public interface ParentBehavior extends Serializable { public Group getGroup (String groupName); + public Group getGroupRecursively (String groupAlias); + public Collection getGroups (); public void setDependencyOrder (DependencyOrder dependencyOrder); From bfb5d00ec7af054d020b9b750bf8ce574d8446fc Mon Sep 17 00:00:00 2001 From: Reka Date: Wed, 17 Sep 2014 16:40:45 +0530 Subject: [PATCH 063/436] adding group events and cluster events --- .../event/topology/ClusterActivatedEvent.java | 58 +++++++++++++++++++ .../event/topology/GroupActivatedEvent.java | 34 +++++++++++ .../ClusterActivatedEventListener.java | 27 +++++++++ .../topology/GroupActivatedEventListener.java | 27 +++++++++ .../topology/ClusterActivatedProcessor.java | 36 ++++++++++++ .../topology/GroupActivatedProcessor.java | 36 ++++++++++++ .../TopologyMessageProcessorChain.java | 13 ++++- 7 files changed, 230 insertions(+), 1 deletion(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java new file mode 100644 index 0000000000..f041358207 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java @@ -0,0 +1,58 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.ClusterStatus; + +/** + * Cluster activated event will be sent by Autoscaler + */ +public class ClusterActivatedEvent { + + private final String serviceName; + private final String clusterId; + private ClusterStatus status; + + public ClusterActivatedEvent(String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + + status.toString() + "]"; + } + + public String getClusterId() { + return clusterId; + } + + public ClusterStatus getStatus() { + return status; + } + + public void setStatus(ClusterStatus status) { + this.status = status; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java new file mode 100644 index 0000000000..2081e3df09 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java @@ -0,0 +1,34 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent by Autoscaler + */ +public class GroupActivatedEvent extends Event { + private String appId; + private String groupId; + + public GroupActivatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java new file mode 100644 index 0000000000..9514541e5a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/17/14. + */ +public abstract class ClusterActivatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java new file mode 100644 index 0000000000..d19d013f26 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered by the groups activation processor after processing the event + */ +public abstract class GroupActivatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java new file mode 100644 index 0000000000..9c8ebf53ec --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -0,0 +1,36 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.stratos.messaging.message.processor.MessageProcessor; + +/** + * This processor will act upon the cluster activated event + */ +public class ClusterActivatedProcessor extends MessageProcessor { + @Override + public void setNext(MessageProcessor nextProcessor) { + + } + + @Override + public boolean process(String type, String message, Object object) { + return false; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java new file mode 100644 index 0000000000..c2455c4dc4 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -0,0 +1,36 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.stratos.messaging.message.processor.MessageProcessor; + +/** + * This processor will act upon the Group activation events + */ +public class GroupActivatedProcessor extends MessageProcessor { + @Override + public void setNext(MessageProcessor nextProcessor) { + + } + + @Override + public boolean process(String type, String message, Object object) { + return false; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index ca6afb415b..b048cfdbf2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -36,6 +36,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ServiceCreatedMessageProcessor serviceCreatedMessageProcessor; private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor; private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor; + private ClusterActivatedProcessor clusterActivatedProcessor; private ClusterMaintenanceModeMessageProcessor clusterMaintenanceModeMessageProcessor; private ClusterRemovedMessageProcessor clusterRemovedMessageProcessor; private InstanceSpawnedMessageProcessor instanceSpawnedMessageProcessor; @@ -45,6 +46,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor; private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; + private GroupActivatedProcessor groupActivatedProcessor; private CompositeApplicationCreatedMessageProcessor compositeApplicationCreatedMessageProcessor; private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; @@ -64,6 +66,9 @@ public void initialize() { clusterCreatedMessageProcessor = new ClusterCreatedMessageProcessor(); add(clusterCreatedMessageProcessor); + clusterActivatedProcessor = new ClusterActivatedProcessor(); + add(clusterActivatedProcessor); + clusterMaintenanceModeMessageProcessor = new ClusterMaintenanceModeMessageProcessor(); add(clusterMaintenanceModeMessageProcessor); @@ -91,6 +96,9 @@ public void initialize() { memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor(); add(memberTerminatedMessageProcessor); + groupActivatedProcessor = new GroupActivatedProcessor(); + add(groupActivatedProcessor); + applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); add(applicationCreatedMessageProcessor); @@ -118,7 +126,8 @@ public void addEventListener(EventListener eventListener) { completeTopologyMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterCreatedEventListener) { clusterCreatedMessageProcessor.addEventListener(eventListener); - log.info("Messaging: added ClusterCreatedEventListener"); + } else if (eventListener instanceof ClusterActivatedEventListener) { + clusterActivatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterMaintenanceModeEventListener) { clusterMaintenanceModeMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterRemovedEventListener) { @@ -141,6 +150,8 @@ public void addEventListener(EventListener eventListener) { serviceRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof MemberMaintenanceListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupActivatedEventListener) { + groupActivatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationCreatedEventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationRemovedEventListener) { From 265088b30a62fb17319f4b32ef6ebb5d97120704 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 17 Sep 2014 18:00:44 +0530 Subject: [PATCH 064/436] adding tenant info. to Application in Topology --- .../parser/DefaultApplicationParser.java | 6 + .../pojo/application/ApplicationContext.java | 30 + .../domain/topology/Application.java | 30 + .../rest/endpoint/services/ServiceUtils.java | 3 + .../resources/CloudControllerService.wsdl | 589 +++++++++--------- 5 files changed, 365 insertions(+), 293 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 44edc49f96..c6ab42e429 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -179,6 +179,12 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app throws ApplicationDefinitionException { Application application = new Application(appCtxt.getApplicationId()); + + // set tenant related information + application.setTenantId(appCtxt.getTenantId()); + application.setTenantDomain(appCtxt.getTenantDomain()); + application.setTenantAdminUserName(appCtxt.getTeantAdminUsername()); + // following keeps track of all Clusters created for this application Set clusters = new HashSet(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java index 7dfdb441c1..3a8af441d3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java @@ -21,6 +21,12 @@ public class ApplicationContext { + private int tenantId; + + private String tenantDomain; + + private String teantAdminUsername; + private String applicationId; private String alias; @@ -60,4 +66,28 @@ public SubscribableInfoContext[] getSubscribableInfoContext() { public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) { this.subscribableInfoContexts = subscribableInfoContexts; } + + 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; + } + + public String getTeantAdminUsername() { + return teantAdminUsername; + } + + public void setTeantAdminUsername(String teantAdminUsername) { + this.teantAdminUsername = teantAdminUsername; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 035b52a97e..3902947899 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -32,6 +32,12 @@ public class Application implements ParentBehavior { private String id; // Key used for authentication (with metadata service, etc.) private String key; + // tenant id + private int tenantId; + // tenant domain + private String tenantDomain; + // tenant admin user + private String tenantAdminUserName; // Dependency Order private DependencyOrder dependencyOrder; // Group Map, key = Group.name @@ -137,4 +143,28 @@ public Status getStatus() { public void setStatus(Status status) { this.status = status; } + + 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; + } + + public String getTenantAdminUserName() { + return tenantAdminUserName; + } + + public void setTenantAdminUserName(String tenantAdminUserName) { + this.tenantAdminUserName = tenantAdminUserName; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 69d09e0a97..887dbfdc7e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -264,6 +264,9 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit // } ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(compositeAppDefinition); + applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); + applicationContext.setTenantDomain(tenantDomain); + applicationContext.setTeantAdminUsername(userName); try { CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index ebca4bdb12..f7236774d4 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,21 +6,24 @@ - - + + + + + - - - + + + - + @@ -34,9 +37,9 @@ - + - + @@ -58,282 +61,282 @@ - + - + - + - + - + - + - + - + - + - + - + - + + - - + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -349,139 +352,124 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + - + - - - - - - - - - - - - - - - - - + - + - + - - - - - - - + - + + + + + + + + + + + + + - + - - + + + + + + + + + - + @@ -496,15 +484,41 @@ - + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -512,51 +526,42 @@ - - + - - - + + + - + - - - - - + - - - - - - + - + + - + - - - + + + - - + + @@ -567,14 +572,14 @@ - + - + @@ -583,66 +588,64 @@ - - - - - - - - - + - - + + + + + + + + + + + + + + + + + - + - - + + + + + + + + + + + - + - - - - - - - - - - - - - + - + - - - - - - - - + + + - + + + + - - - - - - - - - + + + + + @@ -716,15 +719,15 @@ - - - + + + @@ -823,15 +826,15 @@ - - - - + + + + @@ -942,20 +945,8 @@ - - - - - - - - - - - - - - + + @@ -966,8 +957,8 @@ - - + + @@ -990,16 +981,16 @@ - - + + - - + + @@ -1011,6 +1002,18 @@ + + + + + + + + + + + + @@ -1179,20 +1182,8 @@ - - - - - - - - - - - - - - + + @@ -1203,8 +1194,8 @@ - - + + @@ -1227,16 +1218,16 @@ - - + + - - + + @@ -1248,6 +1239,18 @@ + + + + + + + + + + + + @@ -1395,8 +1398,8 @@ - - + + @@ -1404,8 +1407,8 @@ - - + + @@ -1413,8 +1416,14 @@ - - + + + + + + + + @@ -1422,8 +1431,8 @@ - - + + @@ -1437,12 +1446,6 @@ - - - - - - @@ -1515,22 +1518,22 @@ - + - + - + - + - + - + \ No newline at end of file From 04fa25e6e8d12f8fd63fdd1c861311917c4aa584 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Wed, 17 Sep 2014 18:45:23 -0700 Subject: [PATCH 065/436] Create and Persist Composite Application Subscriptions in SM from the Topology after the ApplicationCreatedEvent --- .../manager/CartridgeSubscriptionManager.java | 22 ++++++++--- .../StratosManagerTopologyEventReceiver.java | 39 +++++++++++++++++++ 2 files changed, 56 insertions(+), 5 deletions(-) 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 index bdf5b377f4..11297d13d2 100644 --- 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 @@ -38,10 +38,6 @@ 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.CartridgeSubscription; -import org.apache.stratos.manager.subscription.PersistenceContext; -import org.apache.stratos.manager.subscription.SubscriptionData; -import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.manager.subscription.factory.CartridgeSubscriptionFactory; import org.apache.stratos.manager.subscription.tenancy.SubscriptionMultiTenantBehaviour; import org.apache.stratos.manager.subscription.tenancy.SubscriptionSingleTenantBehaviour; @@ -95,6 +91,10 @@ public GroupSubscription createGroupSubscription (String groupName, String group public CompositeAppSubscription createCompositeAppSubscription (String appId, int tenantId) throws CompositeAppSubscriptionException { + if (log.isDebugEnabled()) { + log.debug("createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId); + } + DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); CompositeAppSubscription compositeAppSubscription; @@ -102,12 +102,24 @@ public CompositeAppSubscription createCompositeAppSubscription (String appId, in compositeAppSubscription = dataInsertionAndRetrievalMgr.getCompositeAppSubscription(tenantId, appId); } catch (PersistenceManagerException e) { + log.error("failed to createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); throw new CompositeAppSubscriptionException(e); } if (compositeAppSubscription != null) { // Composite App Subscription already exists with same app id - throw new CompositeAppSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); + log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId); + throw new CompositeAppSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); + } else { + // persist + try { + persistCompositeAppSubscription(compositeAppSubscription); + } catch (ADCException e) { + // TODO Auto-generated catch block + log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + + " and tenantId: " + tenantId + " e:" + e); + e.printStackTrace(); + } } return new CompositeAppSubscription(appId); 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 index 94ba4861a0..6d247652ba 100644 --- 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 @@ -21,7 +21,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.manager.exception.ADCException; +import org.apache.stratos.manager.exception.CompositeAppSubscriptionException; +import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; +import org.apache.stratos.manager.exception.CompositeApplicationException; +import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; +import org.apache.stratos.manager.subscription.CompositeAppSubscription; import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; @@ -269,6 +276,38 @@ protected void onEvent(Event event) { } } }); + + //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(); + + // create and persist Application subscritpion + CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); + CompositeAppSubscription compositeAppSubscription; + Application app = appCreateEvent.getApplication(); + String appId = app.getId(); + int tenantId = app.getTenantId(); + try { + compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(appId, tenantId); + cartridgeSubscriptionManager.persistCompositeAppSubscription(compositeAppSubscription); + } catch (CompositeAppSubscriptionException e) { + //throw new CompositeApplicationDefinitionException(e); + } catch (ADCException e) { + //throw new CompositeApplicationException(e); + } + } finally { + TopologyManager.releaseReadLock(); + } + } + }); } From 8db36808bd82dc08da00464e86a33d927a4e954d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 18 Sep 2014 14:06:32 +0530 Subject: [PATCH 066/436] fixing STRATOS-805 and implementing a dumb application undeploy method --- .../impl/CloudControllerServiceImpl.java | 6 + .../interfaces/CloudControllerService.java | 10 +- .../controller/topology/TopologyBuilder.java | 50 +++++- .../topology/TopologyEventPublisher.java | 10 ++ .../client/CloudControllerServiceClient.java | 7 +- .../domain/topology/Application.java | 4 + .../domain/topology/DependencyOrder.java | 3 +- .../messaging/domain/topology/Group.java | 4 + .../domain/topology/ParentBehavior.java | 2 + .../domain/topology/StartupOrder.java | 4 +- .../messaging/domain/topology/Topology.java | 4 + .../ApplicationCreatedMessageProcessor.java | 7 +- .../topology/ClusterActivatedProcessor.java | 7 +- .../topology/GroupActivatedProcessor.java | 7 +- .../rest/endpoint/services/ServiceUtils.java | 47 ++---- .../rest/endpoint/services/StratosAdmin.java | 8 +- .../resources/CloudControllerService.wsdl | 150 +++++++++++------- 17 files changed, 216 insertions(+), 114 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 4d20c826f6..f9dc925903 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1432,6 +1432,12 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) TopologyBuilder.handleApplicationDeployed(applicationDataHolder); } + @Override + public void unDeployApplicationDefinition(String applicationId) throws ApplicationDefinitionException { + + TopologyBuilder.handleApplicationUndeployed(applicationId); + } + private List restoreConfigCompositeApplication () { List apps = this.dataHolder.getConfigCompositeApplication(); if (apps == null) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index ff36c830b1..be98bf1641 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -169,11 +169,19 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit public ClusterContext getClusterContext (String clusterId); /** - * deployed an Application Definition + * deploys an Application Definition * * @param applicationContext {@link org.apache.stratos.cloud.controller.pojo.application.ApplicationContext} object * @throws ApplicationDefinitionException if an error is encountered */ public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException; + /** + * undeploys an Application Definition + * + * @param applicationId Id of the Application to be undeployed + * @throws ApplicationDefinitionException if an error is encountered + */ + public void unDeployApplicationDefinition (String applicationId) throws ApplicationDefinitionException; + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 2b827bedf4..55b9d2c92e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -22,10 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.ClusterContext; -import org.apache.stratos.cloud.controller.pojo.CompositeApplicationDefinition; import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.Registrant; import org.apache.stratos.cloud.controller.pojo.*; @@ -41,10 +39,8 @@ import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; -import org.apache.stratos.messaging.util.Util; import org.apache.stratos.messaging.util.Constants; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -626,10 +622,19 @@ public static void handleApplicationDeployed(ApplicationDataHolder applicationDa for (Cluster cluster : applicationDataHolder.getClusters()) { String cartridgeType = cluster.getServiceName(); - topology.getService(cartridgeType).addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + applicationDataHolder.getApplication().getId()); + Service service = topology.getService(cartridgeType); + if (service != null) { + topology.getService(cartridgeType).addCluster(cluster); + log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + applicationDataHolder.getApplication().getId()); + } else { + log.error("Service " + cartridgeType + " not found"); + return; + } } + // add to Topology and update + topology.addApplication(applicationDataHolder.getApplication()); TopologyManager.updateTopology(topology); + log.info("Application with id [ " + applicationDataHolder.getApplication().getId() + " ] added to Topology successfully"); TopologyEventPublisher.sendApplicationCreatedEvent(applicationDataHolder.getApplication()); @@ -638,6 +643,39 @@ public static void handleApplicationDeployed(ApplicationDataHolder applicationDa } } + public static void handleApplicationUndeployed (String applicationId) { + + Topology topology = TopologyManager.getTopology(); + + try { + TopologyManager.acquireWriteLock(); + + if (!topology.applicationExists(applicationId)) { + log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); + + } else { + Application application = topology.getApplication(applicationId); + // remove clusters + for (Map.Entry clusterIdMapEntry : application.getClusterIdMap().entrySet()) { + Service service = topology.getService(clusterIdMapEntry.getKey()); + service.removeCluster(clusterIdMapEntry.getValue()); + } + + // remove application + topology.removeApplication(applicationId); + + TopologyManager.updateTopology(topology); + + log.info("Removed application [ " + applicationId + " ] from Topology"); + + TopologyEventPublisher.sendApplicationRemovedEvent(applicationId); + } + + } finally { + TopologyManager.releaseWriteLock(); + } + } + public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { Topology topology = TopologyManager.getTopology(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index ee10f9d689..a80ddd468e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -36,6 +36,7 @@ import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.util.Constants; +import org.apache.wml.WMLStrongElement; import java.util.List; import java.util.Properties; @@ -99,6 +100,15 @@ public static void sendApplicationCreatedEvent (Application application) { publishEvent(new ApplicationCreatedEvent(application)); } + public static void sendApplicationRemovedEvent(String applicationId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Application removed event: " + applicationId); + } + + publishEvent(new ApplicationRemovedEvent(applicationId)); + } + public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) { ClusterRemovedEvent clusterRemovedEvent = new ClusterRemovedEvent(ctxt.getCartridgeType(), ctxt.getClusterId(), deploymentPolicy, ctxt.isLbCluster()); 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 fb8075d416..e1e29d6961 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 @@ -138,7 +138,12 @@ public void deployApplicationDefinition(ApplicationContext applicationContext) stub.deployApplicationDefinition(applicationContext); } - + + public void undeployApplicationDefinition (String applicationId) throws CloudControllerServiceApplicationDefinitionExceptionException, + RemoteException { + + stub.unDeployApplicationDefinition(applicationId); + } public void unDeployCompositeApplicationDefinition(String appAlias) throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException { stub.unDeployCompositeApplicationDefinition(appAlias); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 3902947899..34e7a9d19b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -128,6 +128,10 @@ public Collection getClusterIds() { return clusterIdMap.values(); } + public Map getClusterIdMap () { + return clusterIdMap; + } + public String getId() { return id; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java index b5992ada49..5fb694ae2a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -19,10 +19,11 @@ package org.apache.stratos.messaging.domain.topology; +import java.io.Serializable; import java.util.HashSet; import java.util.Set; -public class DependencyOrder { +public class DependencyOrder implements Serializable { private Set startupOrders; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 8640aca2b4..072e55d90c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -124,6 +124,10 @@ public Collection getClusterIds() { return clusterIdMap.values(); } + public Map getClusterIdMap () { + return clusterIdMap; + } + public String getName() { return name; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index 99a626bb84..a21f8ee56e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -46,4 +46,6 @@ public interface ParentBehavior extends Serializable { public String getClusterId (String serviceName); public Collection getClusterIds (); + + public Map getClusterIdMap (); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java index 33a062550c..ba2cc2e5e9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java @@ -19,7 +19,9 @@ package org.apache.stratos.messaging.domain.topology; -public class StartupOrder { +import java.io.Serializable; + +public class StartupOrder implements Serializable { private String start; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index a27dd8ec45..f8b535f5dd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -60,6 +60,10 @@ public Application getApplication (String applicationId) { return applicationMap.get(applicationId); } + public void removeApplication (String applicationId) { + applicationMap.remove(applicationId); + } + public Collection getApplications () { return applicationMap.values(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 6f86839626..5525e7ad62 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -68,11 +68,12 @@ public boolean process(String type, String message, Object object) { // check if an Application with same name exists in topology if (topology.applicationExists(appCreatedEvent.getApplication().getId())) { log.warn("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); - return false; + + } else { + // add to Topology + topology.addApplication(appCreatedEvent.getApplication()); } - // add to Topology - topology.addApplication(appCreatedEvent.getApplication()); notifyEventListeners(appCreatedEvent); return true; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 9c8ebf53ec..02f1b8b6da 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -24,13 +24,16 @@ * This processor will act upon the cluster activated event */ public class ClusterActivatedProcessor extends MessageProcessor { + + private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { - + this.nextProcessor = nextProcessor; } @Override public boolean process(String type, String message, Object object) { - return false; + return nextProcessor.process(type, message, object); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index c2455c4dc4..13ea2e7a93 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -24,13 +24,16 @@ * This processor will act upon the Group activation events */ public class GroupActivatedProcessor extends MessageProcessor { + + private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { - + this.nextProcessor = nextProcessor; } @Override public boolean process(String type, String message, Object object) { - return false; + return nextProcessor.process(type, message, object); } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 887dbfdc7e..368552fb3f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -282,45 +282,18 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit } } - static void unDeployApplication(String configCompositeApplicationAlias, ConfigurationContext ctxt, + static void unDeployApplication(String appId, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { - log.info("Starting to undeploy a composite application definition " + configCompositeApplicationAlias); - - CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); - - if (cloudControllerServiceClient != null) { - try { - if (log.isDebugEnabled()) { - log.debug("trying to undeploy composite application definition " + configCompositeApplicationAlias); - } - cloudControllerServiceClient.unDeployCompositeApplicationDefinition(configCompositeApplicationAlias); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = "Remote ExceptionException"; - log.error(message, e); - throw new RestAPIException(message, e); - } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = "CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException"; - log.error(message, e); - throw new RestAPIException(message, e); - } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = "CloudControllerServiceInvalidIaasProviderExceptionException"; - log.error(message, e); - throw new RestAPIException(message, e); - } - } else { - if (log.isDebugEnabled()) { - log.debug("cloud controller client is null while trying to undeploy composite application definition"); - } - } - - log.info(String.format("[type] %s", configCompositeApplicationAlias)); + try { + CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId); + + } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { + throw new RestAPIException(e); + } catch (RemoteException e) { + throw new RestAPIException(e); + } + } @SuppressWarnings("unused") diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index e9ed346b3c..1972a1b5da 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -168,17 +168,17 @@ public StratosAdminResponse deployApplicationDefinition(CompositeAppDefinition c } */ - @POST - @Path("/application/definition/undeploy") + @DELETE + @Path("/application/definition/{applicationId}") @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) // Grouping - public Response unDeployApplicationDefinition(String alias) + public Response unDeployApplicationDefinition(@PathParam("applicationId") String applicationId) throws RestAPIException { - ServiceUtils.unDeployApplication(alias, getConfigContext(), getUsername(), + ServiceUtils.unDeployApplication(applicationId, getConfigContext(), getUsername(), getTenantDomain()); return Response.noContent().build(); } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index f7236774d4..d685bda12d 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -91,27 +91,27 @@ - + - + - + - + - + @@ -221,6 +221,20 @@ + + + + + + + + + + + + + + @@ -408,13 +422,6 @@ - - - - - - - @@ -692,6 +699,12 @@ + + + + + + @@ -731,9 +744,6 @@ - - - @@ -806,6 +816,10 @@ + + + + @@ -945,16 +959,13 @@ - - + + - - - - - + + @@ -969,20 +980,20 @@ - - + + - - - - - + + + + + - - + + @@ -993,6 +1004,18 @@ + + + + + + + + + + + + @@ -1182,16 +1205,13 @@ - - + + - - - - - + + @@ -1206,20 +1226,20 @@ - - + + - - - - - + + + + + - - + + @@ -1230,6 +1250,18 @@ + + + + + + + + + + + + @@ -1398,14 +1430,11 @@ - - + + - - - @@ -1416,14 +1445,17 @@ - - + + + + + - - + + @@ -1431,6 +1463,12 @@ + + + + + + From 3b713db3a8c93339804d91604906623ae581d780 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 18 Sep 2014 16:21:39 +0530 Subject: [PATCH 067/436] removing an unwanted method in rest EP --- .../AutoscalerTopologyEventReceiver.java | 8 ++--- .../rest/endpoint/services/StratosAdmin.java | 32 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 9ada44e084..d55459aa5f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -88,9 +88,9 @@ private void addEventListeners() { protected void onEvent(Event event) { try { TopologyManager.acquireReadLock(); - for (Application application : TopologyManager.getTopology().getApplications()) { - startApplicationMonitor(application); - } + // for (Application application : TopologyManager.getTopology().getApplications()) { + // startApplicationMonitor(application); + // } } catch (Exception e) { log.error("Error processing event", e); } finally { @@ -117,7 +117,7 @@ protected void onEvent(Event event) { //TODO build dependency and organize the application //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication()); + //startApplicationMonitor(applicationCreatedEvent.getApplication()); } finally { //release read lock diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 1972a1b5da..a3cfa31901 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -184,22 +184,22 @@ public Response unDeployApplicationDefinition(@PathParam("applicationId") String } - - @DELETE - @Path("/application/definition/{applicationAlias}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - @SuperTenantService(true) - // Grouping - public Response unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) - throws RestAPIException { - - ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), - getTenantDomain()); - return Response.noContent().build(); - - } +// +// @DELETE +// @Path("/application/definition/{applicationAlias}") +// @Produces("application/json") +// @Consumes("application/json") +// @AuthorizationAction("/permission/protected/manage/monitor/tenants") +// @SuperTenantService(true) +// // Grouping +// public Response unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) +// throws RestAPIException { +// +// ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), +// getTenantDomain()); +// return Response.noContent().build(); +// +// } From 0e1c582fa6b7b2dc4832b406a0c519762f18efac Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 18 Sep 2014 16:24:44 +0530 Subject: [PATCH 068/436] adding status checker and monitor support for autoscaler --- .../stratos/autoscaler/AutoscalerContext.java | 7 + .../grouping/DependencyBuilder.java | 39 +++++ .../AutoscalerTopologyEventReceiver.java | 34 +++- .../stratos/autoscaler/monitor/Monitor.java | 30 +++- .../application/ApplicationMonitor.java | 125 ++++++++------ .../monitor/cluster/ClusterMonitor.java | 23 --- .../monitor/group/GroupMonitor.java | 8 + .../status/checker/ClusterStatusChecker.java | 30 ++-- .../status/checker/GroupStatusChecker.java | 8 +- .../status/checker/StatusChecker.java | 156 ++++++++++++++++-- .../autoscaler/util/AutoscalerUtil.java | 3 + .../domain/topology/Application.java | 10 ++ .../messaging/domain/topology/Group.java | 10 ++ .../domain/topology/ParentBehavior.java | 4 + .../domain/topology/util/GroupStatus.java | 40 +++++ .../event/topology/ClusterActivatedEvent.java | 12 +- .../event/topology/GroupActivatedEvent.java | 16 ++ .../TopologyMessageProcessorChain.java | 6 - 18 files changed, 444 insertions(+), 117 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 4ea6b287cc..2854f13bb3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -26,6 +26,7 @@ import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import java.util.HashMap; import java.util.Map; @@ -47,6 +48,9 @@ private AutoscalerContext() { // Map private Map monitors; + + // Map + private Map statusCheckers; // Map private Map lbMonitors; @@ -74,6 +78,9 @@ public void setGroupMonitors(Map groupMonitors) { this.groupMonitors = groupMonitors; } + public Map getStatusCheckers() { + return statusCheckers; + } private static class Holder { private static final AutoscalerContext INSTANCE = new AutoscalerContext(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index 0566e49b6d..00bf9b4c2e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -18,9 +18,48 @@ */ package org.apache.stratos.autoscaler.grouping; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.DependencyOrder; +import org.apache.stratos.messaging.domain.topology.StartupOrder; + +import java.util.LinkedList; +import java.util.Queue; +import java.util.Set; + /** * This is to build the startup/termination dependencies * across all the groups and clusters */ public class DependencyBuilder { + + public static Queue getStartupOrder(Application application) { + + Queue startup = new LinkedList(); + DependencyOrder dependencyOrder = application.getDependencyOrder(); + Set startupOrderSet = dependencyOrder.getStartupOrders(); + for (StartupOrder startupOrder : startupOrderSet) { + + String start = startupOrder.getStart(); + String after = startupOrder.getAfter(); + + if (!startup.contains(start)) { + startup.add(start); + if (!startup.contains(after)) { + startup.add(after); + + } else { + //TODO throw exception since after is there before start + } + } else { + if (!startup.contains(after)) { + startup.add(after); + } else { + //TODO throw exception since start and after already there + } + } + } + return startup; + + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 9ada44e084..d86bdb3598 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -117,7 +118,7 @@ protected void onEvent(Event event) { //TODO build dependency and organize the application //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication()); + // startApplicationMonitor(applicationCreatedEvent.getApplication()); } finally { //release read lock @@ -127,6 +128,34 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupActivatedEvent] Received: " + event.getClass()); + GroupActivatedEvent groupActivatedEvent = (GroupActivatedEvent) event; + + //trigger status checker + //StatusChecker.getInstance().onGroupStatusChange(groupActivatedEvent.getGroupId(), + //groupActivatedEvent.getAppId()); + + } + }); + + topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; + + //trigger status checker + /*StatusChecker.getInstance().onClusterStatusChange(clusterActivatedEvent.getClusterId(), + clusterActivatedEvent.getAppId()); +*/ + } + }); + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override protected void onEvent(Event event) { @@ -383,6 +412,9 @@ protected void onEvent(Event event) { // partitionContext.incrementCurrentActiveMemberCount(1); partitionContext.movePendingMemberToActiveMembers(memberId); + //trigger status checker + StatusChecker.getInstance().onMemberStatusChange(e.getClusterId()); + } catch (Exception e) { log.error("Error processing event", e); } finally { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index f375e1af3e..2291c06e54 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; @@ -29,6 +30,7 @@ import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.event.Event; import java.util.Map; import java.util.Observable; @@ -60,6 +62,14 @@ public Map getAbstractClusterMonitors() { return abstractClusterMonitors; } + public void addAbstractMonitor(AbstractClusterMonitor monitor) { + this.abstractClusterMonitors.put(monitor.getClusterId(), monitor); + } + + public AbstractClusterMonitor getAbstractMonitor(String clusterId) { + return this.abstractClusterMonitors.get(clusterId); + } + public void setAbstractClusterMonitors(Map abstractClusterMonitors) { this.abstractClusterMonitors = abstractClusterMonitors; } @@ -67,10 +77,22 @@ public void setAbstractClusterMonitors(Map abstr public abstract void monitor(); @Override - public void update(Observable observable, Object o) { - + public void update(Observable observable, Object arg) { + if(arg instanceof Event) { + Event event = (Event) arg; + if(log.isDebugEnabled()) { + log.debug(String.format("Event received: %s", event.getClass().getName())); + } + onEvent(event); + } } + /** + * Triggered when an event is received. + * @param event + */ + protected abstract void onEvent(Event event); + public String getId() { return this.id; } @@ -171,7 +193,7 @@ public void run() { Thread th = new Thread(monitor); th.start(); - //AutoscalerContext.getInstance().addMonitor(monitor); + AutoscalerContext.getInstance().addMonitor(monitor); abstractClusterMonitors.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", @@ -268,7 +290,7 @@ public void run() { Thread th = new Thread(monitor); th.start(); - //AutoscalerContext.getInstance().addLbMonitor(monitor); + AutoscalerContext.getInstance().addLbMonitor(monitor); abstractClusterMonitors.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 7e27fa6273..0b248f2784 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -20,50 +20,48 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.util.GroupStatus; +import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; +/** + * ApplicationMonitor is to control the child monitors + */ public class ApplicationMonitor extends Monitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); private Application application; private Queue preOrderTraverse = new LinkedList(); - private Queue clusters = new LinkedList(); - Map statusCheckerMap = new HashMap(); - - private Queue groups = new LinkedList(); - public ApplicationMonitor(Application application) { this.application = application; //TODO build dependencies and keep them here - DependencyOrder dependencyOrder = application.getDependencyOrder(); - Set startupOrderSet = dependencyOrder.getStartupOrders(); - for(StartupOrder startupOrder: startupOrderSet) { + startDependency(); - String start = startupOrder.getStart(); - String after = startupOrder.getAfter(); + } - if (!preOrderTraverse.contains(start)) { - preOrderTraverse.add(start); - if (!preOrderTraverse.contains(after)) { - preOrderTraverse.add(after); + @Override + public void update(Observable observable, Object arg) { + if(arg instanceof Event) { - } else { - //TODO throw exception since after is there before start - } - } else { - if (!preOrderTraverse.contains(after)) { - preOrderTraverse.add(after); - } else { - //TODO throw exception since start and after already there - } - } } + } + + @Override + protected void onEvent(Event event) { + + } + + public void startDependency() { + preOrderTraverse = DependencyBuilder.getStartupOrder(application); + //TODO find out the parallel ones //start the first dependency @@ -76,52 +74,73 @@ public ApplicationMonitor(Application application) { TopologyManager.acquireReadLock(); cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); TopologyManager.releaseReadLock(); - if(cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent - } + if(cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } } } + /** + * Find the group monitor by traversing recursively in the hierarchical monitors. + * @param id the unique alias of the Group + * @return the found GroupMonitor + */ + public Monitor findGroupMonitorWithId(String id) { + return findGroupMonitor(id, groupMonitors.values()); - //start the least dependent cluster monitor as part of the applicationCreatedEvent - public void registerFirstClusterMonitor() { - //build dependency tree - - - - - //traverse dependency tree and find the clusters to be started and - // register the correct GroupMonitor or ClusterMonitor - //startGroupMonitor(groups.peek()); - //groups.poll(); - + } + private Monitor findGroupMonitor(String id, Collection monitors) { + for (GroupMonitor monitor : monitors) { + // check if alias is equal, if so, return + if (monitor.equals(id)) { + return monitor; + } else { + // check if this Group has nested sub Groups. If so, traverse them as well + if (monitor.getGroupMonitors() != null) { + return findGroupMonitor(id, monitor.getGroupMonitors().values()); + } + } + } + return null; + } + public Monitor findParentOfGroup(String groupId) { + return findParentMonitor(groupId, this); + } + private Monitor findParentMonitor(String groupId, Monitor monitor) { + //if this monitor has the group, return it as the parent + if(monitor.getGroupMonitors().containsKey(groupId)) { + return monitor; + } else { + if(monitor.getGroupMonitors() != null) { + //check whether the children has the group and find its parent + for(GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + return findParentMonitor(groupId, groupMonitor); + } + } + } + return null; } - public void startMonitor() { - - } @Override public void run() { - while (true ) { //TODO add the correct status + while (true) { if (log.isDebugEnabled()) { - log.debug("App monitor is running.. " + this.toString()); + log.debug("Application monitor is running.. " + this.toString()); } - - - + monitor(); try { - // TODO make this configurable - Thread.sleep(30000); - } catch (InterruptedException ignore) { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); } } } @@ -129,7 +148,9 @@ public void run() { @Override public void monitor() { + startDependency(); + //evaluate dependency } public Queue getPreOrderTraverse() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 9558384977..1cd6d9fcdf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -124,30 +124,7 @@ private boolean isPrimaryMember(MemberContext memberContext){ public void monitor() { //TODO make this concurrent - /*final ClusterMonitor clusterMonitor = this; - - Runnable checkClusterStatus = new Runnable() { - @Override - public void run() { - boolean clusterActive = false; - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - //minimum check per partition - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - if(partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { - clusterActive = true; - } - clusterActive = false; - } - - } - // if active then notify upper layer - if(clusterActive) { - clusterMonitor.setStatus(ClusterStatus.Active); - } - - } - };*/ for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { // store primary members in the network partition context List primaryMemberListInNetworkPartition = new ArrayList(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 185442ea36..1688b8235f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -20,6 +20,7 @@ import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.event.Event; import java.util.List; import java.util.Map; @@ -30,6 +31,8 @@ */ public class GroupMonitor extends Monitor { + + public GroupMonitor(Group group) { } @@ -38,6 +41,11 @@ public GroupMonitor(Group group) { public void monitor() { + } + + @Override + protected void onEvent(Event event) { + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java index dd417674c9..a47ee7f803 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java @@ -18,22 +18,28 @@ */ package org.apache.stratos.autoscaler.status.checker; + +import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.NetworkPartitionContext; +import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.util.GroupStatus; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +import java.util.Collection; +import java.util.Map; + /** * Cluster status checker will periodically check the cluster status * and notify the interested parties */ -public class ClusterStatusChecker extends StatusChecker { - private String appId; - private String groupId; - private String clsuterId; +public class ClusterStatusChecker { + - public ClusterStatusChecker(String appId, String groupId, String clusterId) { - this.appId = appId; - this.groupId = groupId; - this.clsuterId = clusterId; - } - @Override - public void run() { + - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java index ea8e56cb93..f69c2d691c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java @@ -18,11 +18,13 @@ */ package org.apache.stratos.autoscaler.status.checker; +import org.apache.stratos.autoscaler.monitor.Monitor; + /** * Group status checker will check the group status and * notify the interested parties on behalf of the status changes */ -public class GroupStatusChecker extends StatusChecker { +public class GroupStatusChecker { private String groupId; private String appId; @@ -30,8 +32,4 @@ public GroupStatusChecker(String groupId, String appId) { this.groupId = groupId; this.appId = appId; } - @Override - public void run() { - - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 154de32671..06cf2f6239 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -20,29 +20,159 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.monitor.Monitor; -import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.NetworkPartitionContext; +import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.util.GroupStatus; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.Observable; +import java.util.Map; /** * This will be used to evaluate the status of a group * and notify the interested parties about the status changes. */ -public abstract class StatusChecker extends Observable implements Runnable { - +public class StatusChecker { private static final Log log = LogFactory.getLog(StatusChecker.class); - public void addObserver(EventListener eventListener) { - addObserver(eventListener); + + private StatusChecker() { + + } + + private static class Holder { + private static final StatusChecker INSTANCE = new StatusChecker(); + } + + public static StatusChecker getInstance() { + //TODO synchronized + return Holder.INSTANCE; } - public void notifyObservers(Monitor monitor) { - if(log.isDebugEnabled()) { - log.debug(String.format("Notifying the observers: [monitor] %s", monitor.getClass().getName())); + public void onMemberStatusChange(String clusterId1) { + final String clusterId = clusterId1; + Runnable exCluster = new Runnable() { + public void run() { + ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterActive = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { + //minimum check per partition + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + if(partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { + clusterActive = true; + } + clusterActive = false; + } + + } + // if active then notify upper layer + if(clusterActive) { + //send event to cluster status topic + + } + + } + }; + } + + + /** + * + * @param id + * @param appId + */ + public void onGroupStatusChange(final String id, final String appId) { + + Runnable exGroup = new Runnable() { + public void run() { + /** + * + */ + Application application = TopologyManager.getTopology().getApplication(appId); + Map clusterIds = application.getClusterMap(); + Map groups = application.getGroupMap(); + updateChildStatus(id, groups, clusterIds, application); + } + }; + } + + public void onClusterStatusChange(final String id, final String appId) { + + Runnable exGroup = new Runnable() { + public void run() { + Application application = TopologyManager.getTopology().getApplication(appId); + Map clusterIds = application.getClusterMap(); + Map groups = application.getGroupMap(); + updateChildStatus(id, groups, clusterIds, application); + } + }; + } + + private boolean updateChildStatus(String id, Map groups, Map clusterIds, ParentBehavior parent) { + boolean groupActive = false; + boolean clustersActive = false; + boolean groupsActive = false; + boolean childFound = false; + + if(clusterIds.containsValue(id) || groups.containsKey(id)) { + childFound = true; + if(!clusterIds.isEmpty() && !groups.isEmpty()) { + clustersActive = getClusterStatus(clusterIds); + groupsActive = getGroupStatus(groups); + groupActive = clustersActive && groupsActive; + } else if (!groups.isEmpty()){ + groupsActive = getGroupStatus(groups); + groupActive = groupsActive; + } else if (!clusterIds.isEmpty()){ + clustersActive = getClusterStatus(clusterIds); + groupActive = clustersActive; + } else { + //TODO warn log + } + //send the activation event + if(parent instanceof Application && groupActive) { + //TODO send application activated event + } else if(parent instanceof Group && groupActive) { + //TODO send Group activated event + } + return childFound; + } else { + if(!groups.isEmpty()) { + for(Group group: groups.values()) { + return updateChildStatus(id, group.getGroupMap(), group.getClusterMap(), group); + + } + } + } + return childFound; + } + + private boolean getGroupStatus(Map groups) { + boolean groupActiveStatus = false; + for(Group group: groups.values()) { + if(group.getStatus().equals(GroupStatus.Active)) { + groupActiveStatus = true; + } else { + groupActiveStatus = false; + } } - setChanged(); - notifyObservers(monitor); + return groupActiveStatus; + } + + private boolean getClusterStatus(Map clusterIds) { + boolean clusterActiveStatus = false; + for(Map.Entry clusterId: clusterIds.entrySet()) { + Service service = TopologyManager.getTopology().getService(clusterId.getKey()); + if(service.getCluster(clusterId.getValue()).getStatus().equals(ClusterStatus.Active)) { + clusterActiveStatus = true; + } else { + clusterActiveStatus = false; + } + } + return clusterActiveStatus; + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index bc9d450553..e6374513e5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -177,6 +177,9 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal log.debug("Set the lb reference type: "+value); } } + + //register a status Checker + // set hasPrimary property // hasPrimary is true if there are primary members available in that cluster diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 34e7a9d19b..1f838889a4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -70,6 +70,16 @@ public Group getGroup(String groupName) { return groupMap.get(groupName); } + @Override + public Map getGroupMap() { + return this.groupMap; + } + + @Override + public Map getClusterMap() { + return this.clusterIdMap; + } + @Override public Group getGroupRecursively(String groupAlias) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 072e55d90c..c6c1f78338 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -66,6 +66,16 @@ public Group getGroup(String groupName) { return groupMap.get(groupName); } + @Override + public Map getGroupMap() { + return this.groupMap; + } + + @Override + public Map getClusterMap() { + return this.clusterIdMap; + } + @Override public Group getGroupRecursively(String groupAlias) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index a21f8ee56e..a958ea82d0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -31,6 +31,10 @@ public interface ParentBehavior extends Serializable { public Group getGroup (String groupName); + public Map getGroupMap(); + + public Map getClusterMap(); + public Group getGroupRecursively (String groupAlias); public Collection getGroups (); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java new file mode 100644 index 0000000000..e00d4faabd --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java @@ -0,0 +1,40 @@ +/* + * 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.messaging.domain.topology.util; + +public enum GroupStatus { + + Created(1), + In_Maintenance(2), + terminating(3), + Removed(4), + Running(5), + Active(6); + + private int code; + + private GroupStatus(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java index f041358207..c1ce20779e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java @@ -19,15 +19,17 @@ package org.apache.stratos.messaging.event.topology; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.event.Event; /** * Cluster activated event will be sent by Autoscaler */ -public class ClusterActivatedEvent { +public class ClusterActivatedEvent extends Event { private final String serviceName; private final String clusterId; private ClusterStatus status; + private String appId; public ClusterActivatedEvent(String serviceName, String clusterId) { this.serviceName = serviceName; @@ -55,4 +57,12 @@ public ClusterStatus getStatus() { public void setStatus(ClusterStatus status) { this.status = status; } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java index 2081e3df09..b5c8148b98 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java @@ -31,4 +31,20 @@ public GroupActivatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getGroupId() { + return groupId; + } + + public void setGroupId(String groupId) { + this.groupId = groupId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index b048cfdbf2..652ebe40d3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -47,7 +47,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; private GroupActivatedProcessor groupActivatedProcessor; - private CompositeApplicationCreatedMessageProcessor compositeApplicationCreatedMessageProcessor; private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; @@ -105,9 +104,6 @@ public void initialize() { applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor(); add(applicationRemovedMessageProcessor); - compositeApplicationCreatedMessageProcessor = new CompositeApplicationCreatedMessageProcessor(); - add(applicationCreatedMessageProcessor); - compositeApplicationRemovedMessageProcessor = new CompositeApplicationRemovedMessageProcessor(); add(applicationRemovedMessageProcessor); @@ -156,8 +152,6 @@ public void addEventListener(EventListener eventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationRemovedEventListener) { applicationRemovedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof CompositeApplicationCreatedEventListener) { - compositeApplicationCreatedMessageProcessor.addEventListener(eventListener); if (log.isDebugEnabled()) { log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); } From 1788f1b54546070bfcba8d99d7635febb2a22208 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 18 Sep 2014 15:49:13 -0700 Subject: [PATCH 069/436] rename CompositeAppSubscription to ApplicationSubscription --- .../CompositeApplicationManager.java | 12 ++++++------ ...a => ApplicationSubscriptionException.java} | 16 ++++++++++------ .../manager/CartridgeSubscriptionManager.java | 16 ++++++++-------- .../persistence/PersistenceManager.java | 6 +++--- .../RegistryBasedPersistenceManager.java | 14 +++++++------- .../DataInsertionAndRetrievalManager.java | 6 +++--- ...ption.java => ApplicationSubscription.java} | 11 ++++++++--- .../StratosManagerTopologyEventReceiver.java | 18 +++++++++++------- .../stratos/manager/utils/Serializer.java | 4 ++-- 9 files changed, 58 insertions(+), 45 deletions(-) rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/{CompositeAppSubscriptionException.java => ApplicationSubscriptionException.java} (72%) rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/{CompositeAppSubscription.java => ApplicationSubscription.java} (89%) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index c8bfd30e4f..4c115da08c 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -13,7 +13,7 @@ import org.apache.stratos.manager.exception.*; import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.subscription.CartridgeSubscription; -import org.apache.stratos.manager.subscription.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.manager.subscription.SubscriptionData; @@ -39,11 +39,11 @@ public void deployCompositeApplication (CompositeAppDefinition compositeAppDefin + compositeAppDefinition.getAlias() + " ] parsed successfully"); // create the CompositeAppSubscription - CompositeAppSubscription compositeAppSubscription; + ApplicationSubscription compositeAppSubscription; try { - compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(compositeAppContext.getAppId(), tenantId); + compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(compositeAppContext.getAppId(), tenantId); - } catch (CompositeAppSubscriptionException e) { + } catch (ApplicationSubscriptionException e) { throw new CompositeApplicationDefinitionException(e); } @@ -257,7 +257,7 @@ private boolean groupSubscriptionExistsForAlias (Map private synchronized void persistSubscriptions(Collection cartridgeSubscriptions, Collection groupSubscriptions, - CompositeAppSubscription compositeAppSubscription) + ApplicationSubscription compositeAppSubscription) throws CompositeApplicationException { persistCartridgeSubscriptions(cartridgeSubscriptions); @@ -297,7 +297,7 @@ private void persistGroupSubscriptions (Collection groupSubsc } } - private void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws CompositeApplicationException { + private void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws CompositeApplicationException { if (compositeAppSubscription != null) { try { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ApplicationSubscriptionException.java similarity index 72% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ApplicationSubscriptionException.java index 710c5f5d11..9c3430b4d1 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/CompositeAppSubscriptionException.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/exception/ApplicationSubscriptionException.java @@ -19,25 +19,29 @@ package org.apache.stratos.manager.exception; -public class CompositeAppSubscriptionException extends Exception { +public class ApplicationSubscriptionException extends Exception { - private String message; + /** + * + */ + private static final long serialVersionUID = 603387881177162687L; + private String message; - public CompositeAppSubscriptionException() { + public ApplicationSubscriptionException() { super(); } - public CompositeAppSubscriptionException(String message, Throwable cause) { + public ApplicationSubscriptionException(String message, Throwable cause) { super(message, cause); this.message = message; } - public CompositeAppSubscriptionException(String message) { + public ApplicationSubscriptionException(String message) { super(message); this.message = message; } - public CompositeAppSubscriptionException(Throwable cause) { + public ApplicationSubscriptionException(Throwable cause) { super(cause); } 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 index 11297d13d2..2710c9898d 100644 --- 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 @@ -89,27 +89,27 @@ public GroupSubscription createGroupSubscription (String groupName, String group return new GroupSubscription(groupName, groupAlias); } - public CompositeAppSubscription createCompositeAppSubscription (String appId, int tenantId) throws CompositeAppSubscriptionException { + public ApplicationSubscription createApplicationSubscription (String appId, int tenantId) throws ApplicationSubscriptionException { if (log.isDebugEnabled()) { - log.debug("createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId); + log.debug("create Application Subscription for appId: " + appId + " and tenantId: " + tenantId); } DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); - CompositeAppSubscription compositeAppSubscription; + ApplicationSubscription compositeAppSubscription; try { compositeAppSubscription = dataInsertionAndRetrievalMgr.getCompositeAppSubscription(tenantId, appId); } catch (PersistenceManagerException e) { - log.error("failed to createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); - throw new CompositeAppSubscriptionException(e); + log.error("failed to Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); + throw new ApplicationSubscriptionException(e); } if (compositeAppSubscription != null) { // Composite App Subscription already exists with same app id log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId); - throw new CompositeAppSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); + throw new ApplicationSubscriptionException("Composite App Subscription already exists with Id [ " + appId + " ]"); } else { // persist try { @@ -122,7 +122,7 @@ public CompositeAppSubscription createCompositeAppSubscription (String appId, in } } - return new CompositeAppSubscription(appId); + return new ApplicationSubscription(appId); } public CartridgeSubscription createCartridgeSubscription (SubscriptionData subscriptionData) throws ADCException, @@ -185,7 +185,7 @@ public void persistGroupSubscription (GroupSubscription groupSubscription) throw } } - public void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws ADCException { + public void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws ADCException { try { new DataInsertionAndRetrievalManager().persistCompositeAppSubscription(compositeAppSubscription); 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 index 9fba1a0b68..6eaad50dc7 100644 --- 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 @@ -23,7 +23,7 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.subscription.GroupSubscription; import java.util.Collection; @@ -51,10 +51,10 @@ public abstract Collection getCartridgeSubscriptions() public abstract Collection getCartridgeSubscriptions(int tenantId) throws PersistenceManagerException; - public abstract void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) + public abstract void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException; - public abstract CompositeAppSubscription getCompositeAppSubscription (int tenantId, String compositeAppId) + public abstract ApplicationSubscription getCompositeAppSubscription (int tenantId, String compositeAppId) throws PersistenceManagerException; public abstract void removeCompositeAppSubscription (int tenantId, String compositeAppId) 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 index 9bab469d88..3fcfcc4426 100644 --- 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 @@ -26,7 +26,7 @@ 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.CompositeAppSubscription; +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; @@ -365,7 +365,7 @@ public Collection getCartridgeSubscriptions (int tenantId } @Override - public void persistCompositeAppSubscription(CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { + public void persistCompositeAppSubscription(ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException { int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); if (tenantId != MultitenantConstants.SUPER_TENANT_ID) { @@ -387,7 +387,7 @@ public void persistCompositeAppSubscription(CompositeAppSubscription compositeAp } } - private void persistSubscription (int tenantId, CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { + private void persistSubscription (int tenantId, ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException { // persist try { @@ -408,7 +408,7 @@ private void persistSubscription (int tenantId, CompositeAppSubscription composi } @Override - public CompositeAppSubscription getCompositeAppSubscription(int tenantId, String compositeAppId) throws PersistenceManagerException { + 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 @@ -430,7 +430,7 @@ public CompositeAppSubscription getCompositeAppSubscription(int tenantId, String } } - public CompositeAppSubscription getSubscription (int tenantId, String appId) throws PersistenceManagerException { + public ApplicationSubscription getSubscription (int tenantId, String appId) throws PersistenceManagerException { Object byteObj; @@ -455,8 +455,8 @@ public CompositeAppSubscription getSubscription (int tenantId, String appId) thr throw new PersistenceManagerException(e); } - if (compositeAppSubscriptionObj instanceof CompositeAppSubscription) { - return (CompositeAppSubscription) compositeAppSubscriptionObj; + if (compositeAppSubscriptionObj instanceof ApplicationSubscription) { + return (ApplicationSubscription) compositeAppSubscriptionObj; } return null; 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 index 91830cddd9..47709d0462 100644 --- 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 @@ -29,7 +29,7 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; @@ -395,12 +395,12 @@ public void removeGroupSubscription (int tenantId, String groupName, String grou persistenceManager.removeGroupSubscription(tenantId, groupName, groupAlias); } - public void persistCompositeAppSubscription (CompositeAppSubscription compositeAppSubscription) throws PersistenceManagerException { + public void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException { persistenceManager.persistCompositeAppSubscription(compositeAppSubscription); } - public CompositeAppSubscription getCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { + public ApplicationSubscription getCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { return persistenceManager.getCompositeAppSubscription(tenantId, appId); } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java similarity index 89% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java index 2a99842840..ab5e0052bd 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/CompositeAppSubscription.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/subscription/ApplicationSubscription.java @@ -30,9 +30,14 @@ import java.util.Map; import java.util.Set; -public class CompositeAppSubscription implements Serializable { +public class ApplicationSubscription implements Serializable { - private static Log log = LogFactory.getLog(CompositeAppSubscription.class); + /** + * + */ + private static final long serialVersionUID = 3380699449827682550L; + + private static Log log = LogFactory.getLog(ApplicationSubscription.class); private String appId; @@ -40,7 +45,7 @@ public class CompositeAppSubscription implements Serializable { private Set groupSubscriptionAliases; - public CompositeAppSubscription (String appId) { + public ApplicationSubscription (String appId) { this.appId = appId; cartridgeSubscriptionAliases = new HashSet(); 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 index 6d247652ba..dbe1727f87 100644 --- 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 @@ -22,11 +22,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.manager.exception.ADCException; -import org.apache.stratos.manager.exception.CompositeAppSubscriptionException; +import org.apache.stratos.manager.exception.ApplicationSubscriptionException; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.CompositeApplicationException; import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; -import org.apache.stratos.manager.subscription.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -291,17 +291,21 @@ protected void onEvent(Event event) { // create and persist Application subscritpion CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); - CompositeAppSubscription compositeAppSubscription; + ApplicationSubscription compositeAppSubscription; Application app = appCreateEvent.getApplication(); String appId = app.getId(); int tenantId = app.getTenantId(); + + if (log.isDebugEnabled()) { + log.debug("received application created event for app: " + appId + " and tenant: " + tenantId); + } try { - compositeAppSubscription = cartridgeSubscriptionManager.createCompositeAppSubscription(appId, tenantId); + compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(appId, tenantId); cartridgeSubscriptionManager.persistCompositeAppSubscription(compositeAppSubscription); - } catch (CompositeAppSubscriptionException e) { - //throw new CompositeApplicationDefinitionException(e); + } catch (ApplicationSubscriptionException e) { + log.error("failed to persist application subscription, caught exception: " + e); } catch (ADCException e) { - //throw new CompositeApplicationException(e); + log.error("failed to persist application subscription, caught exception: " + e); } } finally { TopologyManager.releaseReadLock(); 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 index 743be4825c..a9fc6fe306 100644 --- 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 @@ -24,7 +24,7 @@ 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.CompositeAppSubscription; +import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.subscription.GroupSubscription; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; @@ -81,7 +81,7 @@ public static byte[] serializeGroupSubscriptionToByteArray (GroupSubscription gr } - public static byte[] serializeCompositeAppSubscriptionToByteArray (CompositeAppSubscription compositeAppSubscription) + public static byte[] serializeCompositeAppSubscriptionToByteArray (ApplicationSubscription compositeAppSubscription) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); From 2dac527966315693f7fe4619a40d9218d20571fa Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 19 Sep 2014 09:42:58 +0530 Subject: [PATCH 070/436] adding simple dependency builder and find out monitors from application monitor --- .../stratos/autoscaler/AutoscalerContext.java | 10 +---- .../grouping/DependencyBuilder.java | 5 ++- .../stratos/autoscaler/monitor/Monitor.java | 41 ++++++++++++++++--- .../application/ApplicationMonitor.java | 31 ++------------ .../monitor/group/GroupMonitor.java | 2 + 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 2854f13bb3..1145204b2c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -41,6 +41,7 @@ private AutoscalerContext() { try { setMonitors(new HashMap()); setLbMonitors(new HashMap()); + setAppMonitors(new HashMap()); } catch (Exception e) { log.error("Rule evaluateMinCheck error", e); } @@ -54,7 +55,6 @@ private AutoscalerContext() { // Map private Map lbMonitors; - private Map groupMonitors; private Map appMonitors; @@ -70,14 +70,6 @@ public void setAppMonitors(Map appMonitors) { this.appMonitors = appMonitors; } - public Map getGroupMonitors() { - return groupMonitors; - } - - public void setGroupMonitors(Map groupMonitors) { - this.groupMonitors = groupMonitors; - } - public Map getStatusCheckers() { return statusCheckers; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index 00bf9b4c2e..a1e2406bdb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -20,6 +20,7 @@ import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.DependencyOrder; +import org.apache.stratos.messaging.domain.topology.ParentBehavior; import org.apache.stratos.messaging.domain.topology.StartupOrder; import java.util.LinkedList; @@ -32,10 +33,10 @@ */ public class DependencyBuilder { - public static Queue getStartupOrder(Application application) { + public static Queue getStartupOrder(ParentBehavior component) { Queue startup = new LinkedList(); - DependencyOrder dependencyOrder = application.getDependencyOrder(); + DependencyOrder dependencyOrder = component.getDependencyOrder(); Set startupOrderSet = dependencyOrder.getStartupOrders(); for (StartupOrder startupOrder : startupOrderSet) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 2291c06e54..6f66db1c58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -23,6 +23,7 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; @@ -30,11 +31,11 @@ import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.ParentBehavior; import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.Map; -import java.util.Observable; -import java.util.Observer; +import java.util.*; /** * Monitor is to monitor it's child monitors and @@ -48,7 +49,16 @@ public abstract class Monitor implements Observer, Runnable { protected Map groupMonitors; protected Map abstractClusterMonitors; - protected Map statusCheckers; + + protected Queue preOrderTraverse = new LinkedList(); + + protected ParentBehavior component; + + public Monitor(ParentBehavior component) { + this.component = component; + startDependency(); + } + public Map getGroupMonitors() { return groupMonitors; @@ -101,7 +111,28 @@ public void setId(String id) { this.id = id; } - + public void startDependency() { + preOrderTraverse = DependencyBuilder.getStartupOrder(component); + + //TODO find out the parallel ones + + //start the first dependency + String dependency = preOrderTraverse.poll(); + if(dependency.contains("group")) { + startGroupMonitor(component.getGroup(dependency)); + } else if(dependency.contains("cartridge")) { + String clusterId = component.getClusterId(dependency); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if(cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } + } + } protected synchronized void startClusterMonitor(Cluster cluster) { Thread th = null; if (cluster.isLbCluster() diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 0b248f2784..1407987707 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -36,14 +36,10 @@ */ public class ApplicationMonitor extends Monitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); - private Application application; - private Queue preOrderTraverse = new LinkedList(); public ApplicationMonitor(Application application) { - this.application = application; - //TODO build dependencies and keep them here - startDependency(); - + super(application); + //TODO keep track of the parallel applications } @Override @@ -59,28 +55,7 @@ protected void onEvent(Event event) { } - public void startDependency() { - preOrderTraverse = DependencyBuilder.getStartupOrder(application); - - //TODO find out the parallel ones - - //start the first dependency - String dependency = preOrderTraverse.poll(); - if(dependency.contains("group")) { - startGroupMonitor(application.getGroup(dependency)); - } else if(dependency.contains("cartridge")) { - String clusterId = application.getClusterId(dependency); - Cluster cluster = null; - TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); - TopologyManager.releaseReadLock(); - if(cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent - } - } - } + /** * Find the group monitor by traversing recursively in the hierarchical monitors. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 1688b8235f..3b4b2f4e89 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -34,6 +34,8 @@ public class GroupMonitor extends Monitor { public GroupMonitor(Group group) { + super(group); + //TODO build dependencies and keep them here } From 448c13e31fedeadd9635a219ae2eeeafb125da1d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 19 Sep 2014 14:21:51 +0530 Subject: [PATCH 071/436] adding the initial implemetation of meta data client --- .../pom.xml | 60 +++++++++++ .../client/DefaultMetaDataServiceClient.java | 80 ++++++++++++++ .../client/MetaDataServiceClient.java | 102 ++++++++++++++++++ .../client/MetaDataServiceClientManager.java | 93 ++++++++++++++++ .../client/data/extractor/DataExtractor.java | 34 ++++++ .../data/extractor/DefaultDataExtractor.java | 40 +++++++ .../exception/DataExtractorException.java | 47 ++++++++ .../MetaDataServiceClientExeption.java | 48 +++++++++ .../client/exception/RestClientException.java | 48 +++++++++ .../metadata/client/pojo/DataContext.java | 58 ++++++++++ .../client/rest/DefaultRestClient.java | 85 +++++++++++++++ .../metadata/client/rest/RestClient.java | 32 ++++++ components/pom.xml | 3 +- 13 files changed, 729 insertions(+), 1 deletion(-) create mode 100644 components/org.apache.stratos.metadata.client/pom.xml create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/RestClientException.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml new file mode 100644 index 0000000000..9c6683cca8 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -0,0 +1,60 @@ + + 4.0.0 + + + org.apache.stratos + stratos-components-parent + 4.1.0-SNAPSHOT + + + org.apache.stratos + org.apache.stratos.metadata.client + 4.0.0-SNAPSHOT + bundle + + Apache Stratos - Metadata Client + + + UTF-8 + + + + + org.apache.httpcomponents + httpclient + 4.3.5 + + + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + + true + + + ${project.artifactId} + ${project.artifactId} + + org.apache.stratos.metadata.client.*, + + + !org.apache.commons.logging, + org.apache.commons.logging; version=0.0.0, + *;resolution:=optional + + * + + + + + + + diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java new file mode 100644 index 0000000000..6f8e9cbd79 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java @@ -0,0 +1,80 @@ +/* + * 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.metadata.client; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.rest.DefaultRestClient; +import org.apache.stratos.metadata.client.rest.RestClient; + +import java.util.Map; +import java.util.Set; + + +public class DefaultMetaDataServiceClient implements MetaDataServiceClient { + + private static Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); + + private RestClient restClient; + private String baseUrl; + + public DefaultMetaDataServiceClient (String baseUrl) { + this.baseUrl = baseUrl; + restClient = new DefaultRestClient(); + } + + public void initialize() { + // initialization, if any + } + + public void addProperty(String appId, String clusterId, String propertyKey, String propertyValue) + throws MetaDataServiceClientExeption { + //To change body of implemented methods use File | Settings | File Templates. + } + +// public void addProperty(String appId, String propertyKey, String propertyValue) +// throws MetaDataServiceClientExeption { +// //To change body of implemented methods use File | Settings | File Templates. +// } + + public Map> getProperties(String appId, String clusterId) + throws MetaDataServiceClientExeption { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + +// public Map> getProperties(String appId) throws MetaDataServiceClientExeption { +// return null; //To change body of implemented methods use File | Settings | File Templates. +// } + + public Set getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Set getProperty(String appId, String clusterId, String propertyKey) + throws MetaDataServiceClientExeption { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + + public void terminate() throws MetaDataServiceClientExeption { + restClient = null; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java new file mode 100644 index 0000000000..ff262643d3 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java @@ -0,0 +1,102 @@ +/* + * 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.metadata.client; + +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; + +import java.util.Map; +import java.util.Set; + +public interface MetaDataServiceClient { + + /** + * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. + * @throws MetaDataServiceClientExeption + */ + public void initialize (); + + /** + * Adds a property key value pair for the relevant cluster of the specified app + * + * @param appId Application id + * @param clusterId Cluster id + * @param propertyKey Key of the Property + * @param propertyValue Value of the Property + * @throws MetaDataServiceClientExeption + */ + public void addProperty (String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; + +// /** +// * Adds a property key value pair for the specified app +// * +// * @param appId Application id +// * @param propertyKey Key of the Property +// * @param propertyValue Value of the Property +// * @throws MetaDataServiceClientExeption +// */ +// public void addProperty (String appId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; +// +// /** +// * Retrieves the property key value pairs for the relevant cluster of the specified app +// * +// * @param appId Application id +// * @param clusterId Cluster id +// * @return Map of Keys and Values for the specified cluster in the relevant app. Each key can have multiple Values. +// * @throws MetaDataServiceClientExeption +// */ + public Map> getProperties (String appId, String clusterId) throws MetaDataServiceClientExeption; + +// /** +// * Retrieves the property key value pairs of the specified app +// * +// * @param appId Application id +// * @return Map of Keys and Values for the specified app. Each key can have multiple Values. +// * @throws MetaDataServiceClientExeption +// */ +// public Map> getProperties (String appId) throws MetaDataServiceClientExeption; +// +// /** +// * Retrieves the property values for the specified key of the relevant app +// * +// * @param appId Application id +// * @param propertyKey Key of the Property +// * @return Set of Values for specified Key of the relevant app. +// * @throws MetaDataServiceClientExeption +// */ + public Set getProperty (String appId, String propertyKey) throws MetaDataServiceClientExeption; + + /** + * Retrieves the property values for the specified key of the relevant cluster and app + * + * @param appId Application id + * @param clusterId Cluster id + * @param propertyKey Key of the Property + * @return Set of Values for specified Key of the relevant cluster in the relevant app. + * @throws MetaDataServiceClientExeption + */ + public Set getProperty (String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption; + + /** + * Shutdown the MetaDataServiceClient. Should be called once after using the client. + * + * @throws MetaDataServiceClientExeption + */ + public void terminate () throws MetaDataServiceClientExeption; +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java new file mode 100644 index 0000000000..e2057d3348 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java @@ -0,0 +1,93 @@ +/* + * 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.metadata.client; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadata.client.data.extractor.DataExtractor; +import org.apache.stratos.metadata.client.data.extractor.DefaultDataExtractor; +import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.pojo.DataContext; + +import java.util.Collection; + +public class MetaDataServiceClientManager { + + private static final Log log = LogFactory.getLog(MetaDataServiceClientManager.class); + + private MetaDataServiceClient metaDataServiceClient; + + private DataExtractor dataExtractor; + + private String baseUrl; + + private String customDataExtractorClassName; + + + public MetaDataServiceClientManager () { + + readConfigurations(); + init(); + this.metaDataServiceClient = new DefaultMetaDataServiceClient(baseUrl); + } + + private void readConfigurations () { + //TODO: read configurations + } + + private void init () { + + metaDataServiceClient.initialize(); + //TODO: load the relevant customized class + // currently only the default DataExtractor is used + dataExtractor = new DefaultDataExtractor(); + } + + public void addExtractedData () { + + Collection dataContexts = null; + + try { + dataContexts = dataExtractor.getData(); + + } catch (DataExtractorException e) { + log.error("Unable to get extracted data", e); + } + + for (DataContext dataContext : dataContexts) { + if (dataContext.getPropertyValues() != null) { + for (String propertyValue : dataContext.getPropertyValues()) { + try { + metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), + dataContext.getPropertyKey(), propertyValue); + + } catch (MetaDataServiceClientExeption e) { + log.error("Unable to add extracted data meta data service", e); + } + } + } + } + } + + public MetaDataServiceClient getMetaDataServiceClient() { + return metaDataServiceClient; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java new file mode 100644 index 0000000000..a3c1428c98 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java @@ -0,0 +1,34 @@ +/* + * 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.metadata.client.data.extractor; + +import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.pojo.DataContext; + +import java.util.Collection; + +public interface DataExtractor { + + public void initialize () throws DataExtractorException; + + public Collection getData () throws DataExtractorException; + + public void terminate () throws DataExtractorException; +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java new file mode 100644 index 0000000000..c7743e8c60 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java @@ -0,0 +1,40 @@ +/* + * 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.metadata.client.data.extractor; + +import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.pojo.DataContext; + +import java.util.Collection; + +public class DefaultDataExtractor implements DataExtractor { + + public void initialize() throws DataExtractorException { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getData() throws DataExtractorException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void terminate() throws DataExtractorException { + //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java new file mode 100644 index 0000000000..835d71d0c6 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.metadata.client.exception; + +public class DataExtractorException extends Exception { + + private String message; + + public DataExtractorException() { + super(); + } + + public DataExtractorException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public DataExtractorException(String message) { + super(message); + this.message = message; + } + + public DataExtractorException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java new file mode 100644 index 0000000000..8ef5e37d96 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.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.metadata.client.exception; + +public class MetaDataServiceClientExeption extends Exception { + + private String message; + + public MetaDataServiceClientExeption() { + super(); + } + + public MetaDataServiceClientExeption(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public MetaDataServiceClientExeption(String message) { + super(message); + this.message = message; + } + + public MetaDataServiceClientExeption(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/RestClientException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/RestClientException.java new file mode 100644 index 0000000000..f52af45f44 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/RestClientException.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.metadata.client.exception; + +public class RestClientException extends Exception { + + private String message; + + public RestClientException() { + super(); + } + + public RestClientException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public RestClientException(String message) { + super(message); + this.message = message; + } + + public RestClientException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } + +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java new file mode 100644 index 0000000000..589c03443a --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java @@ -0,0 +1,58 @@ +/* + * 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.metadata.client.pojo; + +import java.util.Set; + +public class DataContext { + + private String appId; + + private String clusterId; + + private String propertyKey; + + private Set propertyValues; + + + public DataContext (String appId, String propertyKey, Set propertyValues) { + + } + + public DataContext (String appId, String clusterId, String propertyKey, Set propertyValues) { + + } + + public String getAppId() { + return appId; + } + + public String getClusterId() { + return clusterId; + } + + public String getPropertyKey() { + return propertyKey; + } + + public Set getPropertyValues() { + return propertyValues; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java new file mode 100644 index 0000000000..8c767e2f23 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.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.metadata.client.rest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.stratos.metadata.client.exception.RestClientException; + +import java.io.IOException; + +public class DefaultRestClient implements RestClient { + + private static Log log = LogFactory.getLog(DefaultRestClient.class); + + private HttpClient httpClient; + + public DefaultRestClient() { + this.httpClient = new DefaultHttpClient(); + } + + public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException { + + HttpPost post = new HttpPost(resourcePath); + //TODO set params + try { + return httpClient.execute(post); + + } catch (IOException e) { + String errorMsg = "Error while executing POST statement"; + log.error(errorMsg, e); + throw new RestClientException(errorMsg, e); + } + } + + public HttpResponse doGet(String resourcePath) throws RestClientException { + + HttpGet get = new HttpGet(resourcePath); + + try { + return httpClient.execute(get); + + } catch (IOException e) { + String errorMsg = "Error while executing GET statement"; + log.error(errorMsg, e); + throw new RestClientException(errorMsg, e); + } + } + + public HttpResponse doDelete(String resourcePath) throws RestClientException { + + HttpDelete delete = new HttpDelete(resourcePath); + + try { + return httpClient.execute(delete); + + } catch (IOException e) { + String errorMsg = "Error while executing DELETE statement"; + log.error(errorMsg, e); + throw new RestClientException(errorMsg, e); + } + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java new file mode 100644 index 0000000000..502773501f --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java @@ -0,0 +1,32 @@ +/* + * 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.metadata.client.rest; + +import org.apache.http.HttpResponse; +import org.apache.stratos.metadata.client.exception.RestClientException; + +public interface RestClient { + + public HttpResponse doPost (String resourcePath, Object payload) throws RestClientException; + + public HttpResponse doGet (String resourcePath) throws RestClientException; + + public HttpResponse doDelete (String resourcePath) throws RestClientException; +} diff --git a/components/pom.xml b/components/pom.xml index 322ccaed40..d1b1dc4a61 100644 --- a/components/pom.xml +++ b/components/pom.xml @@ -104,7 +104,8 @@ org.apache.stratos.manager.styles org.apache.stratos.metadataservice - + + org.apache.stratos.metadata.client From 2472f2ab0f060a37239b205a7722907a14534205 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 19 Sep 2014 14:43:32 +0530 Subject: [PATCH 072/436] fixing a NPE --- .../stratos/metadata/client/MetaDataServiceClientManager.java | 3 ++- .../stratos/metadata/client/data/extractor/DataExtractor.java | 2 +- .../metadata/client/data/extractor/DefaultDataExtractor.java | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java index e2057d3348..527dfab81c 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java @@ -46,7 +46,6 @@ public MetaDataServiceClientManager () { readConfigurations(); init(); - this.metaDataServiceClient = new DefaultMetaDataServiceClient(baseUrl); } private void readConfigurations () { @@ -55,10 +54,12 @@ private void readConfigurations () { private void init () { + metaDataServiceClient = new DefaultMetaDataServiceClient(baseUrl); metaDataServiceClient.initialize(); //TODO: load the relevant customized class // currently only the default DataExtractor is used dataExtractor = new DefaultDataExtractor(); + dataExtractor.initialize(); } public void addExtractedData () { diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java index a3c1428c98..a79237c038 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java @@ -26,7 +26,7 @@ public interface DataExtractor { - public void initialize () throws DataExtractorException; + public void initialize (); public Collection getData () throws DataExtractorException; diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java index c7743e8c60..b84c9c7670 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java @@ -26,7 +26,7 @@ public class DefaultDataExtractor implements DataExtractor { - public void initialize() throws DataExtractorException { + public void initialize() { //To change body of implemented methods use File | Settings | File Templates. } From 36649e99d88caa81e00d12b5f4a81e924b8fe738 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 19 Sep 2014 19:14:35 +0530 Subject: [PATCH 073/436] improving the meta data client --- .../client/MetaDataServiceClientManager.java | 94 ------------------- .../client/config/MetaDataClientConfig.java | 58 ++++++++++++ .../client/data/extractor/DataExtractor.java | 2 +- .../DefaultDataExtractor.java | 5 +- .../sample/MetaDataServiceClientManager.java | 81 ++++++++++++++++ 5 files changed, 143 insertions(+), 97 deletions(-) delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/{data/extractor => sample}/DefaultDataExtractor.java (86%) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java deleted file mode 100644 index 527dfab81c..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClientManager.java +++ /dev/null @@ -1,94 +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.metadata.client; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadata.client.data.extractor.DataExtractor; -import org.apache.stratos.metadata.client.data.extractor.DefaultDataExtractor; -import org.apache.stratos.metadata.client.exception.DataExtractorException; -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; -import org.apache.stratos.metadata.client.pojo.DataContext; - -import java.util.Collection; - -public class MetaDataServiceClientManager { - - private static final Log log = LogFactory.getLog(MetaDataServiceClientManager.class); - - private MetaDataServiceClient metaDataServiceClient; - - private DataExtractor dataExtractor; - - private String baseUrl; - - private String customDataExtractorClassName; - - - public MetaDataServiceClientManager () { - - readConfigurations(); - init(); - } - - private void readConfigurations () { - //TODO: read configurations - } - - private void init () { - - metaDataServiceClient = new DefaultMetaDataServiceClient(baseUrl); - metaDataServiceClient.initialize(); - //TODO: load the relevant customized class - // currently only the default DataExtractor is used - dataExtractor = new DefaultDataExtractor(); - dataExtractor.initialize(); - } - - public void addExtractedData () { - - Collection dataContexts = null; - - try { - dataContexts = dataExtractor.getData(); - - } catch (DataExtractorException e) { - log.error("Unable to get extracted data", e); - } - - for (DataContext dataContext : dataContexts) { - if (dataContext.getPropertyValues() != null) { - for (String propertyValue : dataContext.getPropertyValues()) { - try { - metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), - dataContext.getPropertyKey(), propertyValue); - - } catch (MetaDataServiceClientExeption e) { - log.error("Unable to add extracted data meta data service", e); - } - } - } - } - } - - public MetaDataServiceClient getMetaDataServiceClient() { - return metaDataServiceClient; - } -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java new file mode 100644 index 0000000000..a44010c476 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -0,0 +1,58 @@ +/* + * 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.metadata.client.config; + +public class MetaDataClientConfig { + + private String metaDataServiceBaseUrl; + + private String customExtractorClassName; + + private static volatile MetaDataClientConfig metaDataClientConfig; + + private MetaDataClientConfig () { + readConfig(); + } + + private void readConfig () { + // TODO: read all configurations; metaDataServiceBaseUrl, customExtractorClassName + } + + public static MetaDataClientConfig getInstance () { + + if (metaDataClientConfig == null) { + synchronized (MetaDataClientConfig.class) { + if (metaDataClientConfig == null) { + metaDataClientConfig = new MetaDataClientConfig(); + } + } + } + + return metaDataClientConfig; + } + + public String getMetaDataServiceBaseUrl() { + return metaDataServiceBaseUrl; + } + + public String getCustomExtractorClassName() { + return customExtractorClassName; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java index a79237c038..af88b22403 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java @@ -28,7 +28,7 @@ public interface DataExtractor { public void initialize (); - public Collection getData () throws DataExtractorException; + public Collection getData (Object object) throws DataExtractorException; public void terminate () throws DataExtractorException; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java similarity index 86% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java index b84c9c7670..030ad8f1da 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DefaultDataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java @@ -17,8 +17,9 @@ * under the License. */ -package org.apache.stratos.metadata.client.data.extractor; +package org.apache.stratos.metadata.client.sample; +import org.apache.stratos.metadata.client.data.extractor.DataExtractor; import org.apache.stratos.metadata.client.exception.DataExtractorException; import org.apache.stratos.metadata.client.pojo.DataContext; @@ -30,7 +31,7 @@ public void initialize() { //To change body of implemented methods use File | Settings | File Templates. } - public Collection getData() throws DataExtractorException { + public Collection getData(Object object) throws DataExtractorException { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java new file mode 100644 index 0000000000..36cecd22b2 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.metadata.client.sample; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient; +import org.apache.stratos.metadata.client.MetaDataServiceClient; +import org.apache.stratos.metadata.client.config.MetaDataClientConfig; +import org.apache.stratos.metadata.client.data.extractor.DataExtractor; + +public class MetaDataServiceClientManager { + + private static final Log log = LogFactory.getLog(MetaDataServiceClientManager.class); + + private MetaDataServiceClient metaDataServiceClient; + + private DataExtractor dataExtractor; + + private MetaDataClientConfig metaDataClientConfig; + + + public MetaDataServiceClientManager () { + initialize(); + } + + private void initialize() { + + metaDataClientConfig = MetaDataClientConfig.getInstance(); + metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig.getMetaDataServiceBaseUrl()); + metaDataServiceClient.initialize(); + //TODO: load the relevant customized class using customDataExtractorClassName + // currently only the default DataExtractor is used + dataExtractor = new DefaultDataExtractor(); + dataExtractor.initialize(); + } + +// public void addExtractedData () { +// +// Collection dataContexts = null; +// +// try { +// dataContexts = dataExtractor.getData(); +// +// } catch (DataExtractorException e) { +// log.error("Unable to get extracted data", e); +// } +// +// for (DataContext dataContext : dataContexts) { +// if (dataContext.getPropertyValues() != null) { +// for (String propertyValue : dataContext.getPropertyValues()) { +// try { +// metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), +// dataContext.getPropertyKey(), propertyValue); +// +// } catch (MetaDataServiceClientExeption e) { +// log.error("Unable to add extracted data meta data service", e); +// } +// } +// } +// } +// } + +} From 8f889e6c72e027642806097ac9ab42c138072ffa Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 19 Sep 2014 19:40:06 +0530 Subject: [PATCH 074/436] improving meta data client --- .../client/config/MetaDataClientConfig.java | 10 +-- .../factory/MetaDataExtractorFactory.java | 52 ++++++++++++++ ....java => MetaDataServiceClientSample.java} | 71 ++++++++++--------- 3 files changed, 95 insertions(+), 38 deletions(-) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/{MetaDataServiceClientManager.java => MetaDataServiceClientSample.java} (51%) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java index a44010c476..a9e8c92470 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -23,7 +23,7 @@ public class MetaDataClientConfig { private String metaDataServiceBaseUrl; - private String customExtractorClassName; + private String extractorClassName; private static volatile MetaDataClientConfig metaDataClientConfig; @@ -31,8 +31,8 @@ private MetaDataClientConfig () { readConfig(); } - private void readConfig () { - // TODO: read all configurations; metaDataServiceBaseUrl, customExtractorClassName + private void readConfig () throws RuntimeException{ + // TODO: read all configurations; metaDataServiceBaseUrl, extractorClassName. cannot be empty } public static MetaDataClientConfig getInstance () { @@ -52,7 +52,7 @@ public String getMetaDataServiceBaseUrl() { return metaDataServiceBaseUrl; } - public String getCustomExtractorClassName() { - return customExtractorClassName; + public String getExtractorClassName() { + return extractorClassName; } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java new file mode 100644 index 0000000000..c9d5fc8b4b --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.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.metadata.client.factory; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadata.client.data.extractor.DataExtractor; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; + +public class MetaDataExtractorFactory { + + private static final Log log = LogFactory.getLog(MetaDataExtractorFactory.class); + + public static DataExtractor getMetaDataServiceClient (String clazzName) throws RuntimeException { + + try { + return (DataExtractor) DataExtractor.class.getClassLoader().loadClass(clazzName).newInstance(); + + } catch (InstantiationException e) { + String errorMsg = "Unable to instatiate class " + clazzName; + log.error(errorMsg, e); + throw new RuntimeException(errorMsg, e); + + } catch (IllegalAccessException e) { + String errorMsg = "Unable to instatiate class " + clazzName; + log.error(errorMsg, e); + throw new RuntimeException(errorMsg, e); + + } catch (ClassNotFoundException e) { + String errorMsg = "Unable to instatiate class " + clazzName; + log.error(errorMsg, e); + throw new RuntimeException(errorMsg, e); + } + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java similarity index 51% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java index 36cecd22b2..3a67768f2f 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientManager.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java @@ -25,10 +25,16 @@ import org.apache.stratos.metadata.client.MetaDataServiceClient; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.data.extractor.DataExtractor; +import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory; +import org.apache.stratos.metadata.client.pojo.DataContext; -public class MetaDataServiceClientManager { +import java.util.Collection; - private static final Log log = LogFactory.getLog(MetaDataServiceClientManager.class); +public class MetaDataServiceClientSample { + + private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class); private MetaDataServiceClient metaDataServiceClient; @@ -37,45 +43,44 @@ public class MetaDataServiceClientManager { private MetaDataClientConfig metaDataClientConfig; - public MetaDataServiceClientManager () { + public MetaDataServiceClientSample() { initialize(); } private void initialize() { metaDataClientConfig = MetaDataClientConfig.getInstance(); - metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig.getMetaDataServiceBaseUrl()); + metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig. + getMetaDataServiceBaseUrl()); metaDataServiceClient.initialize(); - //TODO: load the relevant customized class using customDataExtractorClassName - // currently only the default DataExtractor is used - dataExtractor = new DefaultDataExtractor(); - dataExtractor.initialize(); + dataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. + getExtractorClassName()); } -// public void addExtractedData () { -// -// Collection dataContexts = null; -// -// try { -// dataContexts = dataExtractor.getData(); -// -// } catch (DataExtractorException e) { -// log.error("Unable to get extracted data", e); -// } -// -// for (DataContext dataContext : dataContexts) { -// if (dataContext.getPropertyValues() != null) { -// for (String propertyValue : dataContext.getPropertyValues()) { -// try { -// metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), -// dataContext.getPropertyKey(), propertyValue); -// -// } catch (MetaDataServiceClientExeption e) { -// log.error("Unable to add extracted data meta data service", e); -// } -// } -// } -// } -// } + public void addExtractedData (Object someObj) { + + Collection dataContexts = null; + + try { + dataContexts = dataExtractor.getData(someObj); + + } catch (DataExtractorException e) { + log.error("Unable to get extracted data", e); + } + + for (DataContext dataContext : dataContexts) { + if (dataContext.getPropertyValues() != null) { + for (String propertyValue : dataContext.getPropertyValues()) { + try { + metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), + dataContext.getPropertyKey(), propertyValue); + + } catch (MetaDataServiceClientExeption e) { + log.error("Unable to add extracted data meta data service", e); + } + } + } + } + } } From 5f9f40f28bb7476f396b0a5e1f9b30bb5308212e Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Fri, 19 Sep 2014 10:56:43 -0700 Subject: [PATCH 075/436] fix for STRATOS-806:Sending an ApplicationCreatedEvent throws Exception --- .../manager/CartridgeSubscriptionManager.java | 6 ++++++ .../StratosManagerTopologyEventReceiver.java | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) 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 index 2710c9898d..da820b4650 100644 --- 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 @@ -111,6 +111,12 @@ public ApplicationSubscription createApplicationSubscription (String appId, int log.error("app Id already exists, failed to createCompositeAppSubscription 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 ); + } + + compositeAppSubscription = new ApplicationSubscription(appId); // persist try { persistCompositeAppSubscription(compositeAppSubscription); 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 index dbe1727f87..0ff3dbbcb6 100644 --- 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 @@ -37,6 +37,7 @@ 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 org.wso2.carbon.context.PrivilegedCarbonContext; public class StratosManagerTopologyEventReceiver implements Runnable { @@ -295,17 +296,26 @@ protected void onEvent(Event event) { Application app = appCreateEvent.getApplication(); String appId = app.getId(); int tenantId = app.getTenantId(); + String domain = app.getTenantDomain(); if (log.isDebugEnabled()) { - log.debug("received application created event for app: " + appId + " and tenant: " + tenantId); + 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.persistCompositeAppSubscription(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(); } } finally { TopologyManager.releaseReadLock(); From 406e51a47511961b9765415e1d69dfda744c10de Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 21 Sep 2014 14:20:29 +0530 Subject: [PATCH 076/436] reading config file --- .../pom.xml | 20 +++-- .../client/config/MetaDataClientConfig.java | 75 ++++++++++++++++++- .../client/data/extractor/DataExtractor.java | 4 +- .../metadata/client/pojo/DataContext.java | 29 +++++++ .../client/sample/DefaultDataExtractor.java | 6 +- .../sample/MetaDataServiceClientSample.java | 39 +++++----- .../client/util/MetaDataClientConstants.java | 29 +++++++ 7 files changed, 173 insertions(+), 29 deletions(-) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml index 9c6683cca8..b60e56d43b 100644 --- a/components/org.apache.stratos.metadata.client/pom.xml +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -20,11 +20,18 @@ - - org.apache.httpcomponents - httpclient - 4.3.5 - + + org.apache.httpcomponents + httpclient + 4.3.5 + provided + + + commons-configuration + commons-configuration + 1.9 + provided + @@ -46,8 +53,9 @@ org.apache.stratos.metadata.client.*, - !org.apache.commons.logging, + !org.apache.stratos.metadata.client, org.apache.commons.logging; version=0.0.0, + org.apache.commons.configuration; version=0.0.0, *;resolution:=optional * diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java index a9e8c92470..8bb3cbea28 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -19,11 +19,25 @@ package org.apache.stratos.metadata.client.config; +import org.apache.commons.configuration.ConfigurationException; +import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadata.client.sample.MetaDataServiceClientSample; +import org.apache.stratos.metadata.client.util.MetaDataClientConstants; + + +import java.io.File; + public class MetaDataClientConfig { + private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class); + private String metaDataServiceBaseUrl; - private String extractorClassName; + private String dataExtractorClass; + + private XMLConfiguration config; private static volatile MetaDataClientConfig metaDataClientConfig; @@ -32,7 +46,45 @@ private MetaDataClientConfig () { } private void readConfig () throws RuntimeException{ - // TODO: read all configurations; metaDataServiceBaseUrl, extractorClassName. cannot be empty + + // the config file path is found from a system property + String configFilePath = System.getProperty(MetaDataClientConstants.METADATA_CLIENT_CONFIG_FILE); + if (configFilePath == null) { + throw new RuntimeException("Unable to load the configuration file; no System Property found for " + MetaDataClientConstants.METADATA_CLIENT_CONFIG_FILE); + } + loadConfig(configFilePath); + + // read configurations + metaDataServiceBaseUrl = config.getString(MetaDataClientConstants.METADATA_SERVICE_BASE_URL); + if (metaDataServiceBaseUrl == null) { + throw new RuntimeException("Unable to find metadata service base URL [ " + + MetaDataClientConstants.METADATA_SERVICE_BASE_URL + " ] in the config file"); + } + + dataExtractorClass = config.getString(MetaDataClientConstants.METADATA_CLIENT_DATA_EXTRACTOR_CLASS); + if (dataExtractorClass == null) { + log.info("No custom Data Extractor class detected in the configuration"); + } + } + + private void loadConfig (String configFilePath) { + + try { + + File confFile; + if (configFilePath != null && !configFilePath.isEmpty()) { + confFile = new File(configFilePath); + + } else { + confFile = new File(configFilePath); + } + + config = new XMLConfiguration(confFile); + + } catch (ConfigurationException e) { + String errorMsg = "Unable to load configuration file at " + configFilePath; + throw new RuntimeException(errorMsg); + } } public static MetaDataClientConfig getInstance () { @@ -52,7 +104,22 @@ public String getMetaDataServiceBaseUrl() { return metaDataServiceBaseUrl; } - public String getExtractorClassName() { - return extractorClassName; + public String getDataExtractorClass() { + return dataExtractorClass; } + + +/* +Sample Configuration file: + + + + xx.xx.xx.xx + + + org.foo.MyDataExtractor + + + +*/ } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java index af88b22403..e5280e7cfb 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java @@ -28,7 +28,9 @@ public interface DataExtractor { public void initialize (); - public Collection getData (Object object) throws DataExtractorException; + public Collection getAllData (Object object) throws DataExtractorException; + + public DataContext getData (Object object) throws DataExtractorException; public void terminate () throws DataExtractorException; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java index 589c03443a..93653c7888 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java @@ -31,13 +31,38 @@ public class DataContext { private Set propertyValues; + private String propertyValue; + public DataContext (String appId, String propertyKey, Set propertyValues) { + this.appId = appId; + this.propertyKey = propertyKey; + this.propertyValues = propertyValues; + } public DataContext (String appId, String clusterId, String propertyKey, Set propertyValues) { + this.appId = appId; + this.clusterId = clusterId; + this.propertyKey = propertyKey; + this.propertyValues = propertyValues; + } + + public DataContext (String appId, String propertyKey, String propertyValue) { + + this.appId = appId; + this.propertyKey = propertyKey; + this.propertyValue = propertyValue; + } + + public DataContext (String appId, String clusterId, String propertyKey, String propertyValue) { + + this.appId = appId; + this.clusterId = clusterId; + this.propertyKey = propertyKey; + this.propertyValue = propertyValue; } public String getAppId() { @@ -55,4 +80,8 @@ public String getPropertyKey() { public Set getPropertyValues() { return propertyValues; } + + public String getPropertyValue() { + return propertyValue; + } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java index 030ad8f1da..d2878d2c73 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java @@ -31,7 +31,11 @@ public void initialize() { //To change body of implemented methods use File | Settings | File Templates. } - public Collection getData(Object object) throws DataExtractorException { + public Collection getAllData(Object object) throws DataExtractorException { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public DataContext getData(Object object) throws DataExtractorException { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java index 3a67768f2f..a34adc7b55 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java @@ -26,7 +26,6 @@ import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.data.extractor.DataExtractor; import org.apache.stratos.metadata.client.exception.DataExtractorException; -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory; import org.apache.stratos.metadata.client.pojo.DataContext; @@ -53,34 +52,40 @@ private void initialize() { metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig. getMetaDataServiceBaseUrl()); metaDataServiceClient.initialize(); - dataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. - getExtractorClassName()); + + if (MetaDataClientConfig.getInstance().getDataExtractorClass() != null) { + dataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. + getDataExtractorClass()); + dataExtractor.initialize(); + } } - public void addExtractedData (Object someObj) { + public Collection getAllData (Object someObj) { Collection dataContexts = null; try { - dataContexts = dataExtractor.getData(someObj); + dataContexts = dataExtractor.getAllData(someObj); } catch (DataExtractorException e) { log.error("Unable to get extracted data", e); } - for (DataContext dataContext : dataContexts) { - if (dataContext.getPropertyValues() != null) { - for (String propertyValue : dataContext.getPropertyValues()) { - try { - metaDataServiceClient.addProperty(dataContext.getAppId(), dataContext.getClusterId(), - dataContext.getPropertyKey(), propertyValue); - - } catch (MetaDataServiceClientExeption e) { - log.error("Unable to add extracted data meta data service", e); - } - } - } + return dataContexts; + } + + public DataContext getData (Object someObj) { + + DataContext dataContext = null; + + try { + dataContext = dataExtractor.getData(someObj); + + } catch (DataExtractorException e) { + log.error("Unable to get extracted data", e); } + + return dataContext; } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java new file mode 100644 index 0000000000..1b2baf28f9 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java @@ -0,0 +1,29 @@ +/* + * 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.metadata.client.util; + +public class MetaDataClientConstants { + + public static String METADATA_CLIENT_CONFIG_FILE = "METADATA_CLIENT_CONFIG_FILE"; + + public static String METADATA_SERVICE_BASE_URL = "metadataService.baseUrl"; + + public static String METADATA_CLIENT_DATA_EXTRACTOR_CLASS = "metadataClient.dataExtractorClass"; +} From ee8e5fd710ae232448e42f34b505d4e49bd28cf8 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 21 Sep 2014 15:53:36 +0530 Subject: [PATCH 077/436] renaming some classes properly --- ...taExtractor.java => MetaDataExtractor.java} | 10 +++++----- ...on.java => MetaDataExtractorException.java} | 10 +++++----- .../factory/MetaDataExtractorFactory.java | 7 +++---- ...ctor.java => DefaultMetaDataExtractor.java} | 12 ++++++------ .../sample/MetaDataServiceClientSample.java | 18 +++++++++--------- 5 files changed, 28 insertions(+), 29 deletions(-) rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/{DataExtractor.java => MetaDataExtractor.java} (78%) rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/{DataExtractorException.java => MetaDataExtractorException.java} (79%) rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/{DefaultDataExtractor.java => DefaultMetaDataExtractor.java} (78%) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java similarity index 78% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java index e5280e7cfb..13bc7257c6 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/DataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java @@ -19,18 +19,18 @@ package org.apache.stratos.metadata.client.data.extractor; -import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; import org.apache.stratos.metadata.client.pojo.DataContext; import java.util.Collection; -public interface DataExtractor { +public interface MetaDataExtractor { public void initialize (); - public Collection getAllData (Object object) throws DataExtractorException; + public Collection getAllData (Object object) throws MetaDataExtractorException; - public DataContext getData (Object object) throws DataExtractorException; + public DataContext getData (Object object) throws MetaDataExtractorException; - public void terminate () throws DataExtractorException; + public void terminate () throws MetaDataExtractorException; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java similarity index 79% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java index 835d71d0c6..c1273f50fb 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/DataExtractorException.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java @@ -19,25 +19,25 @@ package org.apache.stratos.metadata.client.exception; -public class DataExtractorException extends Exception { +public class MetaDataExtractorException extends Exception { private String message; - public DataExtractorException() { + public MetaDataExtractorException() { super(); } - public DataExtractorException(String message, Throwable cause) { + public MetaDataExtractorException(String message, Throwable cause) { super(message, cause); this.message = message; } - public DataExtractorException(String message) { + public MetaDataExtractorException(String message) { super(message); this.message = message; } - public DataExtractorException(Throwable cause) { + public MetaDataExtractorException(Throwable cause) { super(cause); } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java index c9d5fc8b4b..90d39d106b 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java @@ -21,17 +21,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadata.client.data.extractor.DataExtractor; -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; public class MetaDataExtractorFactory { private static final Log log = LogFactory.getLog(MetaDataExtractorFactory.class); - public static DataExtractor getMetaDataServiceClient (String clazzName) throws RuntimeException { + public static MetaDataExtractor getMetaDataServiceClient (String clazzName) throws RuntimeException { try { - return (DataExtractor) DataExtractor.class.getClassLoader().loadClass(clazzName).newInstance(); + return (MetaDataExtractor) MetaDataExtractor.class.getClassLoader().loadClass(clazzName).newInstance(); } catch (InstantiationException e) { String errorMsg = "Unable to instatiate class " + clazzName; diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java similarity index 78% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java index d2878d2c73..1594601859 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultDataExtractor.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java @@ -19,27 +19,27 @@ package org.apache.stratos.metadata.client.sample; -import org.apache.stratos.metadata.client.data.extractor.DataExtractor; -import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; +import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; import org.apache.stratos.metadata.client.pojo.DataContext; import java.util.Collection; -public class DefaultDataExtractor implements DataExtractor { +public class DefaultMetaDataExtractor implements MetaDataExtractor { public void initialize() { //To change body of implemented methods use File | Settings | File Templates. } - public Collection getAllData(Object object) throws DataExtractorException { + public Collection getAllData(Object object) throws MetaDataExtractorException { return null; //To change body of implemented methods use File | Settings | File Templates. } - public DataContext getData(Object object) throws DataExtractorException { + public DataContext getData(Object object) throws MetaDataExtractorException { return null; //To change body of implemented methods use File | Settings | File Templates. } - public void terminate() throws DataExtractorException { + public void terminate() throws MetaDataExtractorException { //To change body of implemented methods use File | Settings | File Templates. } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java index a34adc7b55..ad7eb2fae0 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java @@ -24,8 +24,8 @@ import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient; import org.apache.stratos.metadata.client.MetaDataServiceClient; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; -import org.apache.stratos.metadata.client.data.extractor.DataExtractor; -import org.apache.stratos.metadata.client.exception.DataExtractorException; +import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; +import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory; import org.apache.stratos.metadata.client.pojo.DataContext; @@ -37,7 +37,7 @@ public class MetaDataServiceClientSample { private MetaDataServiceClient metaDataServiceClient; - private DataExtractor dataExtractor; + private MetaDataExtractor metaDataExtractor; private MetaDataClientConfig metaDataClientConfig; @@ -54,9 +54,9 @@ private void initialize() { metaDataServiceClient.initialize(); if (MetaDataClientConfig.getInstance().getDataExtractorClass() != null) { - dataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. + metaDataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. getDataExtractorClass()); - dataExtractor.initialize(); + metaDataExtractor.initialize(); } } @@ -65,9 +65,9 @@ public Collection getAllData (Object someObj) { Collection dataContexts = null; try { - dataContexts = dataExtractor.getAllData(someObj); + dataContexts = metaDataExtractor.getAllData(someObj); - } catch (DataExtractorException e) { + } catch (MetaDataExtractorException e) { log.error("Unable to get extracted data", e); } @@ -79,9 +79,9 @@ public DataContext getData (Object someObj) { DataContext dataContext = null; try { - dataContext = dataExtractor.getData(someObj); + dataContext = metaDataExtractor.getData(someObj); - } catch (DataExtractorException e) { + } catch (MetaDataExtractorException e) { log.error("Unable to get extracted data", e); } From 998f57e19fe405673f1112acfbe6494d96ec5ac0 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 22 Sep 2014 00:08:30 +0530 Subject: [PATCH 078/436] correcting metadata client version and adding as a dependency in CC --- components/org.apache.stratos.cloud.controller/pom.xml | 6 ++++++ components/org.apache.stratos.metadata.client/pom.xml | 9 ++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index 6a1ffee040..1f51c7de22 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -76,6 +76,7 @@ org.apache.commons.logging; version=0.0.0, org.apache.commons.io.*, org.wso2.carbon.utils.*, + org.apache.stratos.metadata.client.*; version=0.0.0, *; resolution:=optional @@ -283,6 +284,11 @@ org.wso2.carbon.ntask.core 4.2.0 + + org.apache.stratos + org.apache.stratos.metadata.client + ${project.version} + 2.2 diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml index b60e56d43b..4139219f63 100644 --- a/components/org.apache.stratos.metadata.client/pom.xml +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -1,6 +1,5 @@ - 4.0.0 org.apache.stratos @@ -10,15 +9,11 @@ org.apache.stratos org.apache.stratos.metadata.client - 4.0.0-SNAPSHOT bundle + 4.0.0 Apache Stratos - Metadata Client - - UTF-8 - - org.apache.httpcomponents @@ -43,7 +38,7 @@ org.apache.felix maven-bundle-plugin - + 1.4.0 true From 4b46efe15cdf1bd4062864faa72148881718d8bb Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 22 Sep 2014 14:15:29 +0530 Subject: [PATCH 079/436] adding events support in autoscaler --- .../grouping/topic/StatusEventPublisher.java | 76 ++++++ .../AutoscalerHealthStatEventReceiver.java | 246 ++++++------------ .../AutoscalerTopologyEventReceiver.java | 79 ++---- .../monitor/AbstractClusterMonitor.java | 18 +- .../stratos/autoscaler/monitor/Monitor.java | 63 +++-- .../application/ApplicationMonitor.java | 41 +-- .../monitor/cluster/ClusterMonitor.java | 1 - .../monitor/cluster/LbClusterMonitor.java | 2 + .../monitor/events/ClusterActivatedEvent.java | 7 + .../events/ClusterInMaintenanceEvent.java | 7 + .../monitor/events/GroupActivatedEvent.java | 7 + .../events/GroupInMaintenanceEvent.java | 7 + .../monitor/events/MonitorEvent.java | 9 + .../monitor/group/GroupMonitor.java | 6 - .../status/checker/ClusterStatusChecker.java | 45 ---- .../status/checker/StatusChecker.java | 72 ++++- .../cluster/status/ClusterActivatedEvent.java | 52 ++++ .../status/ClusterMaintenanceModeEvent.java | 46 ++++ .../status/ClusterReadyToShutdownEvent.java | 50 ++++ .../cluster/status/ClusterStatusEvent.java | 31 +++ .../group/status/GroupActivatedEvent.java | 46 ++++ .../status/GroupMaintenanceModeEvent.java} | 25 +- .../status/GroupReadyToShutdownEvent.java | 43 +++ .../event/group/status/GroupStatusEvent.java | 31 +++ .../event/topology/ClusterActivatedEvent.java | 17 +- 25 files changed, 670 insertions(+), 357 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java rename components/{org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java => org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java} (66%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java new file mode 100644 index 0000000000..f7e5b280cb --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -0,0 +1,76 @@ +package org.apache.stratos.autoscaler.grouping.topic; + +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.cluster.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterMaintenanceModeEvent; +import org.apache.stratos.messaging.event.group.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.group.status.GroupMaintenanceModeEvent; +import org.apache.stratos.messaging.util.Constants; + +/** + * Created by reka on 9/21/14. + */ +public class StatusEventPublisher { + private static final Log log = LogFactory.getLog(StatusEventPublisher.class); + + public static void sendClusterActivatedEvent (String appId, String serviceName, String clusterId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Cluster activated event for [application]: " + appId + + " [cluster]: " + clusterId ); + } + + ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId,serviceName, clusterId); + + publishEvent(clusterActivatedEvent); + } + + public static void sendClusterInMaintenanceEvent (String appId, String serviceName, String clusterId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Cluster in_maintenance event for [application]: " + appId + + " [cluster]: " + clusterId ); + } + + ClusterMaintenanceModeEvent clusterInMaintenanceEvent = + new ClusterMaintenanceModeEvent(appId,serviceName, clusterId); + + publishEvent(clusterInMaintenanceEvent); + } + + public static void sendGroupActivatedEvent (String appId, String groupId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Group activated event for [application]: " + appId + + " [group]: " + groupId ); + } + + GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId); + + publishEvent(groupActivatedEvent); + } + + public static void sendGroupInMaintenanceEvent (String appId, String groupId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Group in_maintenance event for [application]: " + appId + + " [group]: " + groupId ); + } + + GroupMaintenanceModeEvent groupMaintenanceModeEvent = + new GroupMaintenanceModeEvent(appId, groupId); + + publishEvent(groupMaintenanceModeEvent); + } + + public static void publishEvent(Event event) { + //TODO change the topics for cluster and group accordingly + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.INSTANCE_STATUS_TOPIC); + eventPublisher.publish(event); + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index 9ffe66d74d..26d3179af4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.policy.model.LoadAverage; import org.apache.stratos.autoscaler.policy.model.MemoryConsumption; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; @@ -93,19 +94,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Avg load avg event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -116,6 +105,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -135,19 +126,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Avg Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); @@ -159,6 +138,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -177,19 +158,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Average Rif event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -200,6 +169,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -217,19 +188,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Grad of load avg event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -240,6 +199,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -258,19 +219,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Grad of Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - }; + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -281,6 +230,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -298,19 +249,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Gradient of Rif event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -321,6 +260,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -459,19 +400,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Second Derivation of load avg event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -482,6 +411,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -500,19 +431,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Second Derivation of Memory Consumption event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -523,6 +442,8 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } @@ -540,19 +461,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { log.debug(String.format("Second derivative of Rif event: [cluster] %s [network-partition] %s [value] %s", clusterId, networkPartitionId, floatValue)); } - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } + AbstractClusterMonitor monitor = getMonitor(clusterId); if(null != monitor){ NetworkPartitionContext networkPartitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId); if(null != networkPartitionContext){ @@ -563,12 +472,31 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { " [network partition] %s", networkPartitionId)); } } + } else { + return; } } }); } + private AbstractClusterMonitor getMonitor(String clusterId) { + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + + if(asCtx.monitorExist(clusterId)){ + monitor = asCtx.getMonitor(clusterId); + }else if(asCtx.lbMonitorExist(clusterId)){ + monitor = asCtx.getLBMonitor(clusterId); + }else{ + if(log.isDebugEnabled()){ + log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); + } + return null; + } + return null; + } + private LoadAverage findLoadAverage(String memberId) { // String memberId = event.getProperties().get("member_id"); @@ -582,26 +510,31 @@ private LoadAverage findLoadAverage(String memberId) { } String clusterId = member.getClusterId(); - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; + AbstractClusterMonitor monitor = getMonitor(clusterId); + MemberStatsContext memberStatsContext; - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } + if(monitor != null) { + memberStatsContext = getMemberStatContext(memberId, monitor, member); + } else { + return null; + } + LoadAverage loadAverage; + if(memberStatsContext == null) { return null; + } else { + loadAverage = memberStatsContext.getLoadAverage(); } + return loadAverage; + } + + private MemberStatsContext getMemberStatContext(String memberId, AbstractClusterMonitor monitor, Member member) { String networkPartitionId = findNetworkPartitionId(memberId); MemberStatsContext memberStatsContext = monitor.getNetworkPartitionCtxt(networkPartitionId) - .getPartitionCtxt(member.getPartitionId()) - .getMemberStatsContext(memberId); + .getPartitionCtxt(member.getPartitionId()) + .getMemberStatsContext(memberId); if(null == memberStatsContext){ if(log.isDebugEnabled()) { - log.debug(String.format("Member context is not available for : [member] %s", memberId)); + log.debug(String.format("Member context is not available for : [member] %s", memberId)); } return null; } @@ -612,9 +545,7 @@ else if(!member.isActive()){ } return null; } - - LoadAverage loadAverage = memberStatsContext.getLoadAverage(); - return loadAverage; + return memberStatsContext; } private MemoryConsumption findMemoryConsumption(String memberId) { @@ -639,23 +570,13 @@ private MemoryConsumption findMemoryConsumption(String memberId) { return null; } - String networkPartitionId = findNetworkPartitionId(memberId); - MemberStatsContext memberStatsContext = monitor.getNetworkPartitionCtxt(networkPartitionId) - .getPartitionCtxt(member.getPartitionId()) - .getMemberStatsContext(memberId); - if(null == memberStatsContext){ - if(log.isDebugEnabled()) { - log.debug(String.format("Member context is not available for : [member] %s", memberId)); - } - return null; - }else if(!member.isActive()){ - if(log.isDebugEnabled()){ - log.debug(String.format("Member activated event has not received for the member %s. Therefore ignoring" + - " the health stat", memberId)); - } + MemberStatsContext memberStatsContext = getMemberStatContext(memberId, monitor, member); + MemoryConsumption memoryConsumption; + if(memberStatsContext == null) { return null; + } else { + memoryConsumption = memberStatsContext.getMemoryConsumption(); } - MemoryConsumption memoryConsumption = memberStatsContext.getMemoryConsumption(); return memoryConsumption; } @@ -690,21 +611,8 @@ private Member findMember(String memberId) { private void handleMemberFaultEvent(String clusterId, String memberId) { try { - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - - if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); - }else if(asCtx.lbMonitorExist(clusterId)){ - monitor = asCtx.getLBMonitor(clusterId); - }else{ - if(log.isDebugEnabled()){ - log.debug(String.format("A cluster monitor is not found in autoscaler context [cluster] %s", clusterId)); - } - return; - } - - NetworkPartitionContext nwPartitionCtxt; + AbstractClusterMonitor monitor = getMonitor(clusterId); + NetworkPartitionContext nwPartitionCtxt; try{ TopologyManager.acquireReadLock(); Member member = findMember(memberId); @@ -719,9 +627,12 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { } return; } - - nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member); - + if(monitor != null) { + nwPartitionCtxt = monitor.getNetworkPartitionCtxt(member); + } else { + return; + } + }finally{ TopologyManager.releaseReadLock(); } @@ -741,6 +652,9 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { // remove from active member list partitionCtxt.removeActiveMemberById(memberId); + //Check the clusterStatus as part of the member fault event + StatusChecker.getInstance().onMemberFaultEvent(clusterId, "appId", partitionCtxt); + if (log.isInfoEnabled()) { log.info(String.format("Faulty member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index d55459aa5f..ad54152c4e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -26,9 +26,11 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -106,7 +108,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ApplicationCreatedEventListener] Received: " + event.getClass()); + log.info("[ApplicationCreatedEvent] Received: " + event.getClass()); ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; @@ -127,6 +129,25 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + + ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; + String appId = clusterActivatedEvent.getAppId(); + String clusterId = clusterActivatedEvent.getClusterId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + Monitor monitor = appMonitor.findParentMonitorOfCluster(clusterId); + monitor.notify(); + //starting the status checker to decide on the status of it's parent + StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override protected void onEvent(Event event) { @@ -391,58 +412,6 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = - (MemberReadyToShutdownEvent) event; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - String memberId = memberReadyToShutdownEvent.getMemberId(); - - if (asCtx.monitorExist(clusterId)) { - monitor = asCtx.getMonitor(clusterId); - } else if (asCtx.lbMonitorExist(clusterId)) { - monitor = asCtx.getLBMonitor(clusterId); - } else { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler " + - "context [cluster] %s", clusterId)); - } - return; - } - - NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = monitor.getNetworkPartitionCtxt(memberReadyToShutdownEvent. - getNetworkPartitionId()); - - // start a new member in the same Partition - String partitionId = monitor.getPartitionOfMember(memberId); - PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); - - - // terminate the shutdown ready member - CloudControllerClient ccClient = CloudControllerClient.getInstance(); - ccClient.terminate(memberId); - - // remove from active member list - partitionCtxt.removeActiveMemberById(memberId); - - if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active " + - "members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); - } - } catch (TerminationException e) { - log.error(e); - } - } - - }); - - topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { @Override protected void onEvent(Event event) { @@ -552,8 +521,8 @@ public void run() { throw new RuntimeException(msg); } - Thread th = new Thread(applicationMonitor); - th.start(); + AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); + //TODO should start the appMonitor if (log.isInfoEnabled()) { log.info(String.format("Application monitor has been added successfully: " + diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 4bf8b7f271..cb93886c30 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -21,6 +21,8 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import java.util.Map; +import java.util.Observable; +import java.util.Observer; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; @@ -42,7 +44,7 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ -abstract public class AbstractClusterMonitor implements Runnable { +abstract public class AbstractClusterMonitor extends Observable implements Observer, Runnable { private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); // Map @@ -62,6 +64,7 @@ abstract public class AbstractClusterMonitor implements Runnable { protected String clusterId; protected String serviceId; + protected String appId; protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; @@ -159,6 +162,14 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + public Map getNetworkPartitionCtxts() { return networkPartitionCtxts; } @@ -217,6 +228,11 @@ public void setTerminateDependencyFactHandle( this.terminateDependencyFactHandle = terminateDependencyFactHandle; } + @Override + public void update(Observable observable, Object o) { + + } + public int getMonitorInterval() { return monitorInterval; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 6f66db1c58..7471703592 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -41,7 +41,7 @@ * Monitor is to monitor it's child monitors and * control them according to the dependencies respectively. */ -public abstract class Monitor implements Observer, Runnable { +public abstract class Monitor extends Observable implements Observer { private static final Log log = LogFactory.getLog(Monitor.class); @@ -117,20 +117,25 @@ public void startDependency() { //TODO find out the parallel ones //start the first dependency - String dependency = preOrderTraverse.poll(); - if(dependency.contains("group")) { - startGroupMonitor(component.getGroup(dependency)); - } else if(dependency.contains("cartridge")) { - String clusterId = component.getClusterId(dependency); - Cluster cluster = null; - TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); - TopologyManager.releaseReadLock(); - if(cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent + if(!preOrderTraverse.isEmpty()) { + String dependency = preOrderTraverse.poll(); + if (dependency.contains("group")) { + startGroupMonitor(this, dependency, component); + } else if (dependency.contains("cartridge")) { + String clusterId = component.getClusterId(dependency); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if (cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } } + } else { + //all the groups/clusters have been started and waiting for activation + log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); } } protected synchronized void startClusterMonitor(Cluster cluster) { @@ -158,11 +163,11 @@ protected synchronized void startClusterMonitor(Cluster cluster) { } } - protected synchronized void startGroupMonitor(Group group) { + protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentBehavior component) { Thread th = null; - if (!this.groupMonitors.containsKey(group.getAlias())) { + if (!this.groupMonitors.containsKey(dependency)) { th = new Thread( - new GroupMonitorAdder(group)); + new GroupMonitorAdder(parent, dependency, component)); } if (th != null) { @@ -175,7 +180,7 @@ protected synchronized void startGroupMonitor(Group group) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor thread has been started successfully: [group] %s ", - group.getAlias())); + dependency)); } } } @@ -234,10 +239,14 @@ public void run() { } private class GroupMonitorAdder implements Runnable { - private Group group; + private ParentBehavior group; + private String dependency; + private Monitor parent; - public GroupMonitorAdder(Group group) { + public GroupMonitorAdder(Monitor parent, String dependency, ParentBehavior group) { this.group = group; + this.dependency = dependency; + this.parent = parent; } public void run() { @@ -251,11 +260,12 @@ public void run() { } try { - monitor = AutoscalerUtil.getGroupMonitor(group); + monitor = AutoscalerUtil.getGroupMonitor(group.getGroup(dependency)); + monitor.addObserver(parent); success = true; } catch (Exception e) { - String msg = "Group monitor creation failed for group: " + group.getAlias(); + String msg = "Group monitor creation failed for group: " + dependency; log.debug(msg, e); retries--; @@ -264,18 +274,17 @@ public void run() { if (monitor == null) { String msg = "Group monitor creation failed, even after retrying for 5 times, " - + "for group: " + group.getAlias(); + + "for group: " + dependency; log.error(msg); throw new RuntimeException(msg); } - Thread th = new Thread(monitor); - th.start(); + groupMonitors.put(dependency, monitor); + parent.addObserver(monitor); - groupMonitors.put(group.getAlias(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Group monitor has been added successfully: [group] %s", - group.getAlias())); + dependency)); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 1407987707..d3c4113dd4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.DependencyBuilder; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; @@ -37,9 +38,9 @@ public class ApplicationMonitor extends Monitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); - public ApplicationMonitor(Application application) { + public ApplicationMonitor(ParentBehavior application) { super(application); - //TODO keep track of the parallel applications + //keep } @Override @@ -83,11 +84,11 @@ private Monitor findGroupMonitor(String id, Collection monitors) { } - public Monitor findParentOfGroup(String groupId) { - return findParentMonitor(groupId, this); + public Monitor findParentMonitorOfGroup(String groupId) { + return findParentMonitorForGroup(groupId, this); } - private Monitor findParentMonitor(String groupId, Monitor monitor) { + private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { //if this monitor has the group, return it as the parent if(monitor.getGroupMonitors().containsKey(groupId)) { return monitor; @@ -95,7 +96,7 @@ private Monitor findParentMonitor(String groupId, Monitor monitor) { if(monitor.getGroupMonitors() != null) { //check whether the children has the group and find its parent for(GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { - return findParentMonitor(groupId, groupMonitor); + return findParentMonitorForGroup(groupId, groupMonitor); } } @@ -104,22 +105,26 @@ private Monitor findParentMonitor(String groupId, Monitor monitor) { } + public Monitor findParentMonitorOfCluster(String clusterId) { + return findParentMonitorForCluster(clusterId, this); + } - @Override - public void run() { - while (true) { - if (log.isDebugEnabled()) { - log.debug("Application monitor is running.. " + this.toString()); - } - monitor(); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); + private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { + //if this monitor has the group, return it as the parent + if(monitor.getAbstractClusterMonitors().containsKey(clusterId)) { + return monitor; + } else { + if(monitor.getGroupMonitors() != null) { + //check whether the children has the group and find its parent + for(GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + return findParentMonitorForCluster(clusterId, groupMonitor); + + } } } - } + return null; + } @Override public void monitor() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 1cd6d9fcdf..3fa9ada297 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -47,7 +47,6 @@ public class ClusterMonitor extends AbstractClusterMonitor { private String lbReferenceType; private boolean hasPrimary; private ClusterStatus status; - private Group parent; public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index 31c7ff7a33..45142c2a60 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import java.util.Observable; import java.util.concurrent.ConcurrentHashMap; /** @@ -125,4 +126,5 @@ public void setStatus(ClusterStatus status) { } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java new file mode 100644 index 0000000000..e35fe744d4 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java @@ -0,0 +1,7 @@ +package org.apache.stratos.autoscaler.monitor.events; + +/** + * Created by reka on 9/21/14. + */ +public class ClusterActivatedEvent extends MonitorEvent { +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java new file mode 100644 index 0000000000..f227195de9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java @@ -0,0 +1,7 @@ +package org.apache.stratos.autoscaler.monitor.events; + +/** + * Created by reka on 9/21/14. + */ +public class ClusterInMaintenanceEvent extends MonitorEvent { +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java new file mode 100644 index 0000000000..448df651bc --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java @@ -0,0 +1,7 @@ +package org.apache.stratos.autoscaler.monitor.events; + +/** + * Created by reka on 9/21/14. + */ +public class GroupActivatedEvent extends MonitorEvent { +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java new file mode 100644 index 0000000000..e7b0605f6f --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java @@ -0,0 +1,7 @@ +package org.apache.stratos.autoscaler.monitor.events; + +/** + * Created by reka on 9/21/14. + */ +public class GroupInMaintenanceEvent extends MonitorEvent { +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java new file mode 100644 index 0000000000..8fcf78296e --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java @@ -0,0 +1,9 @@ +package org.apache.stratos.autoscaler.monitor.events; + +import java.io.Serializable; + +/** + * Created by reka on 9/21/14. + */ +public abstract class MonitorEvent implements Serializable{ +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 3b4b2f4e89..28662c6a58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -49,10 +49,4 @@ public void monitor() { protected void onEvent(Event event) { } - - - @Override - public void run() { - - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.java deleted file mode 100644 index a47ee7f803..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/ClusterStatusChecker.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.autoscaler.status.checker; - - -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.util.GroupStatus; -import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; - -import java.util.Collection; -import java.util.Map; - -/** - * Cluster status checker will periodically check the cluster status - * and notify the interested parties - */ -public class ClusterStatusChecker { - - - - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 06cf2f6239..79da514bf9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -23,6 +23,7 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.GroupStatus; @@ -62,14 +63,18 @@ public void run() { for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { if(partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { clusterActive = true; + } else if (partitionContext.getActiveMemberCount() > partitionContext.getMinimumMemberCount()) { + log.info("cluster already activated..."); + clusterActive = true; } clusterActive = false; } - } // if active then notify upper layer if(clusterActive) { //send event to cluster status topic + StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), + monitor.getServiceId(), monitor.getClusterId()); } @@ -80,36 +85,75 @@ public void run() { /** * - * @param id + * @param groupId * @param appId */ - public void onGroupStatusChange(final String id, final String appId) { + public void onGroupStatusChange(final String groupId, final String appId) { + updateChild(groupId, appId); + } + + /** + * + * @param clusterId + * @param appId + */ + public void onClusterStatusChange(final String clusterId, final String appId) { + updateChild(clusterId, appId); + } + private void updateChild(final String clusterId, final String appId) { Runnable exGroup = new Runnable() { public void run() { - /** - * - */ Application application = TopologyManager.getTopology().getApplication(appId); Map clusterIds = application.getClusterMap(); Map groups = application.getGroupMap(); - updateChildStatus(id, groups, clusterIds, application); + updateChildStatus(clusterId, groups, clusterIds, application); } }; } - public void onClusterStatusChange(final String id, final String appId) { - - Runnable exGroup = new Runnable() { + /** + * + * @param clusterId + * @param appId + * @param partitionContext is to decide in which partition has less members while others have active members + */ + public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { + Runnable exCluster = new Runnable() { public void run() { - Application application = TopologyManager.getTopology().getApplication(appId); - Map clusterIds = application.getClusterMap(); - Map groups = application.getGroupMap(); - updateChildStatus(id, groups, clusterIds, application); + ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterActive = false; + boolean clusterInMaintenance = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { + for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { + if(partitionContext.getPartitionId().equals(partition.getPartitionId()) && + partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { + clusterInMaintenance = true; + } else { + log.info(String.format("Hence the [partition] %s, in [networkpartition], " + + "%s has exceeded the [minimum], %d with current active " + + "[members], %d the [cluster], %s is still in active mode." + , partition.getPartitionId(), partition.getNetworkPartitionId(), + partition.getMinimumMemberCount(), partition.getActiveMemberCount(), clusterId)); + } + if(partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) { + clusterActive = true; + } + clusterActive = false; + } + + } + // if in maintenance then notify upper layer + if(clusterActive && clusterInMaintenance) { + //send clusterInmaintenance event to cluster status topic + + } + } }; } + private boolean updateChildStatus(String id, Map groups, Map clusterIds, ParentBehavior parent) { boolean groupActive = false; boolean clustersActive = false; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java new file mode 100644 index 0000000000..ecc8c7ab26 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.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.messaging.event.cluster.status; + +import java.io.Serializable; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class ClusterActivatedEvent extends ClusterStatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterActivatedEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java new file mode 100644 index 0000000000..691e77e2a7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java @@ -0,0 +1,46 @@ +/* + * 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.messaging.event.cluster.status; + +import java.io.Serializable; + +public class ClusterMaintenanceModeEvent extends ClusterStatusEvent implements Serializable { + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java new file mode 100644 index 0000000000..2832a89643 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.cluster.status; + +import java.io.Serializable; + +/** + * This event is fired by cartridge agent when it has cleaned up the data and + * ready to shutdown. + */ +public class ClusterReadyToShutdownEvent extends ClusterStatusEvent implements Serializable { + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java new file mode 100644 index 0000000000..42a430b27a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java @@ -0,0 +1,31 @@ +/* + * 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.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + +/** + * Represents all instance status events. + */ +public abstract class ClusterStatusEvent extends Event implements Serializable { + private static final long serialVersionUID = -4790128084271867615L; +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java new file mode 100644 index 0000000000..c1075a0fac --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java @@ -0,0 +1,46 @@ +/* + * 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.messaging.event.group.status; + +import java.io.Serializable; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class GroupActivatedEvent extends GroupStatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public GroupActivatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId(String groupId) { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java similarity index 66% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java index f69c2d691c..a301da4cb6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/GroupStatusChecker.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java @@ -7,7 +7,7 @@ * "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 + * 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 @@ -16,20 +16,25 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.status.checker; +package org.apache.stratos.messaging.event.group.status; -import org.apache.stratos.autoscaler.monitor.Monitor; +import java.io.Serializable; -/** - * Group status checker will check the group status and - * notify the interested parties on behalf of the status changes - */ -public class GroupStatusChecker { +public class GroupMaintenanceModeEvent extends GroupStatusEvent implements Serializable { private String groupId; private String appId; - public GroupStatusChecker(String groupId, String appId) { - this.groupId = groupId; + public GroupMaintenanceModeEvent(String appId, String groupId) { this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId(String groupId) { + return this.groupId; + } + + public String getAppId() { + return appId; } + } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java new file mode 100644 index 0000000000..70b44aa1cd --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.group.status; + +import java.io.Serializable; + +/** + * This event is fired by cartridge agent when it has cleaned up the data and + * ready to shutdown. + */ +public class GroupReadyToShutdownEvent extends GroupStatusEvent implements Serializable { + private String groupId; + private String appId; + + public GroupReadyToShutdownEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId(String groupId) { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java new file mode 100644 index 0000000000..44ae0a9fa9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java @@ -0,0 +1,31 @@ +/* + * 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.messaging.event.group.status; + +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + +/** + * Represents all instance status events. + */ +public abstract class GroupStatusEvent extends Event implements Serializable { + private static final long serialVersionUID = -4790128084271867615L; +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java index c1ce20779e..db2ac44ee4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterActivatedEvent.java @@ -28,12 +28,12 @@ public class ClusterActivatedEvent extends Event { private final String serviceName; private final String clusterId; - private ClusterStatus status; private String appId; - public ClusterActivatedEvent(String serviceName, String clusterId) { + public ClusterActivatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; + this.appId = appId; } public String getServiceName() { @@ -43,26 +43,15 @@ public String getServiceName() { @Override public String toString() { return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + - status.toString() + "]"; + "]"; } public String getClusterId() { return clusterId; } - public ClusterStatus getStatus() { - return status; - } - - public void setStatus(ClusterStatus status) { - this.status = status; - } - public String getAppId() { return appId; } - public void setAppId(String appId) { - this.appId = appId; - } } From 4fc28dbbaf91d88da54c01478ce9be3deae0cf07 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 22 Sep 2014 15:03:18 +0530 Subject: [PATCH 080/436] adding grouping details in metadata service --- .../definition/ApplicationBean.java | 70 ++++ .../definition/ClusterBean.java | 59 ++++ .../definition/NewProperty.java | 68 ++++ .../registry/CarbonRegistry.java | 149 ++++++++- .../metadataservice/registry/DataStore.java | 17 + .../registry/GRegRegistry.java | 27 ++ .../services/MetaDataAdmin.java | 309 +++++++++++++++++- .../WEB-INF/cxf-servlet.xml | 1 + 8 files changed, 694 insertions(+), 6 deletions(-) create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java new file mode 100644 index 0000000000..8ef19076a1 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name="application") +public class ApplicationBean { + private String appId; + private List clusters; + + public ApplicationBean(){ + this.clusters = new ArrayList(); + } + + public ApplicationBean(String appId){ + this.appId = appId; + this.clusters = new ArrayList(); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public List getClusters() { + return clusters; + } + + public ClusterBean getCluster(String clusterId){ + + for(ClusterBean clusterBean : clusters){ + if(clusterBean.getClusterId().equals(clusterId)){ + return clusterBean; + } + } + + return null; + } + + public void setClusters(List clusters) { + this.clusters = clusters; + } + + public void addCluster(ClusterBean cluster){ + this.clusters.add(cluster); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java new file mode 100644 index 0000000000..5c5187af81 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java @@ -0,0 +1,59 @@ +package org.apache.stratos.metadataservice.definition; +/** + * 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 javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name="clusters") +public class ClusterBean { + + private String clusterId; + private List properties; + + public ClusterBean(){ + this.setProperties(new ArrayList()); + } + + public ClusterBean(String id){ + this.setClusterId(id); + this.setProperties(new ArrayList()); + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public void addProperty(NewProperty property){ + this.properties.add(property); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java new file mode 100644 index 0000000000..552d29f791 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@XmlRootElement(name="properties") +public class NewProperty implements Serializable{ + + private String key; + private List values = new ArrayList(); + + public NewProperty(){} + public NewProperty(String key, String value){ + this.key=key; + this.values.add(value); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String[] getValues(){ + String[] values = new String[this.values.size()]; + values = this.values.toArray(values); + return values; + } + + public void setValues(String[] values) { + this.values.addAll(Arrays.asList(values)); + } + + + public void setValues(String value) { + this.values.add(value); + } + + public void addValue(String value){ + this.values.add(value); + } +} 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 71e3b708fc..94cdc52fd4 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 @@ -18,8 +18,7 @@ */ package org.apache.stratos.metadataservice.registry; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; @@ -27,10 +26,10 @@ import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; -import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.apache.stratos.metadataservice.definition.*; 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.Resource; import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.core.service.RegistryService; @@ -181,4 +180,146 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car return false; } + + + public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + if(!tempRegistry.resourceExists(resourcePath)){ + return null; + //throw new RegistryException("Cluster does not exist at " + resourcePath); + } + Resource regResource = tempRegistry.get(resourcePath); + + ArrayList newProperties = new ArrayList(); + + Properties props = regResource.getProperties(); + Enumeration x = props.propertyNames(); + while(x.hasMoreElements()) + { + String key = (String) x.nextElement(); + List values = regResource.getPropertyValues(key); + NewProperty property = new NewProperty(); + property.setKey(key); + String[] valueArr = new String[values.size()]; + property.setValues(values.toArray(valueArr)); + + newProperties.add(property); + + } + + return newProperties; + } + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId + "/" + clusterId; + Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + + regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); + tempRegistry.put(regResource.getPath(), regResource); + + } + + @Override + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + Resource regResource; + regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + try { + for(NewProperty property : properties){ + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + + } + tempRegistry.put(resourcePath, regResource); + if(log.isDebugEnabled()){ + log.debug("A resource added to: " + resourcePath); + } + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("addCartridgeMetaDataDetails", e); + } + } finally { + // Close the session + + } + } + + public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); + + for(NewProperty property : properties){ + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + + } + tempRegistry.put(resourcePath, regResource); + } + + public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + } + + public List getPropertiesOfApplication(String applicationId) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + if(!tempRegistry.resourceExists(resourcePath)){ + return null; + //throw new RegistryException("Cluster does not exist at " + resourcePath); + } + Resource regResource = tempRegistry.get(resourcePath); + + ArrayList newProperties = new ArrayList(); + + Properties props = regResource.getProperties(); + Enumeration x = props.propertyNames(); + while(x.hasMoreElements()) + { + String key = (String) x.nextElement(); + List values = regResource.getPropertyValues(key); + NewProperty property = new NewProperty(); + property.setKey(key); + String[] valueArr = new String[values.size()]; + property.setValues(values.toArray(valueArr)); + + newProperties.add(property); + + } + if(newProperties.size() == 0){ + return null; + } + return newProperties; + } + + + private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException { + Resource regResource; + if(tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + }else{ + regResource = tempRegistry.newCollection(); + } + return regResource; + } + + private Resource createOrGetResourceforCluster(Registry tempRegistry, String resourcePath) throws RegistryException { + + int index = resourcePath.lastIndexOf('/'); + String applicationResourcePath = resourcePath.substring(0,index); + createOrGetResourceforApplication(tempRegistry, applicationResourcePath); + Resource regResource; + if(tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + }else{ + regResource = tempRegistry.newResource(); + } + return regResource; + } + } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index 93302b7244..51cb5875ac 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,7 +18,12 @@ */ package org.apache.stratos.metadataservice.registry; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.NewProperty; +import org.wso2.carbon.registry.api.RegistryException; + +import java.util.List; /* * Interface of the Data Store @@ -33,4 +38,16 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception; + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + throws Exception; + public List getPropertiesOfCluster(String applicationName, String clusterId) + throws Exception; + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; + + void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException; + + void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException; + + List getPropertiesOfApplication(String applicationId) throws RegistryException; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 3829303a8c..ec464c8037 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -30,10 +30,13 @@ import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.definition.PropertyBean; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; @@ -219,4 +222,28 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car return false; } + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + + } + + public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + return null; + } + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { + + } + + public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { + + } + + public void addPropertyToApplication(String applicationId, NewProperty property) { + + } + + public List getPropertiesOfApplication(String applicationId) throws RegistryException { + return null; + } + } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index e30ffec22e..670c01bfed 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -8,18 +8,30 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.ClusterBean; +import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; import org.apache.stratos.metadataservice.util.ConfUtil; +import org.wso2.carbon.registry.api.RegistryException; -@Path("/metadataservice/") +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +@Path("/") public class MetaDataAdmin { + @Context + UriInfo uriInfo; private static Log log = LogFactory.getLog(MetaDataAdmin.class); @Context @@ -52,7 +64,7 @@ public String addCartridgeMetaDataDetails(@PathParam("applicationname") String a defaultRegType); return DataRegistryFactory.getDataRegistryFactory(registryType) .addCartridgeMetaDataDetails(applicationName, cartridgeType, - cartridgeMetaData); + cartridgeMetaData); } @@ -84,4 +96,297 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car .removeCartridgeMetaDataDetails(applicationName, cartridgeType); } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty[] propertiesArr = null; + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + if(properties != null) { + propertiesArr = new NewProperty[properties.size()]; + propertiesArr = properties.toArray(propertiesArr); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(propertiesArr == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(propertiesArr); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getApplicationProperties(@PathParam("application_id") String applicationId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty[] propertiesArr = null; + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfApplication(applicationId); + if(properties != null) { + propertiesArr = new NewProperty[properties.size()]; + propertiesArr = properties.toArray(propertiesArr); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(propertiesArr == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(propertiesArr); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/property/{property_name}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getApplicationProperty(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfApplication(applicationId); + if(properties == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + for(NewProperty p : properties){ + if(propertyName.equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + for(NewProperty p : properties){ + if(propertyName.equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + if(properties == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + for(NewProperty p : properties){ + if("dependencies".equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + + @POST + @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) throws RestAPIException { + + if(!property.getKey().equals("dependencies")){ + throw new RestAPIException("Property name should be dependencies"); + } + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); + } catch (RegistryException e) { + e.printStackTrace(); + } + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/property") + @Produces("application/json") + @Consumes("applicsetPropertyation/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertyToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) + throws RestAPIException { + + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); + } catch (RegistryException e) { + e.printStackTrace(); + } + + return Response.created(url).build(); + + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty[] properties) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertiesToApplication(@PathParam("application_id") String applicationId,NewProperty[] properties) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/property") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertyToApplication(@PathParam("application_id") String applicationId, NewProperty property) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } } diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml index bf40055d77..e0153019e2 100644 --- a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml @@ -59,6 +59,7 @@ + partitions From ee4c201618f888c3ba81e6f83e07223c1af5c124 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 22 Sep 2014 15:03:18 +0530 Subject: [PATCH 081/436] adding grouping details in metadata service --- .../definition/ApplicationBean.java | 70 ++++ .../definition/ClusterBean.java | 59 ++++ .../definition/NewProperty.java | 68 ++++ .../registry/CarbonRegistry.java | 149 ++++++++- .../metadataservice/registry/DataStore.java | 17 + .../registry/GRegRegistry.java | 27 ++ .../services/MetaDataAdmin.java | 309 +++++++++++++++++- .../WEB-INF/cxf-servlet.xml | 1 + 8 files changed, 694 insertions(+), 6 deletions(-) create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.java new file mode 100644 index 0000000000..828fa4d341 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ApplicationBean.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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name="applications") +public class ApplicationBean { + private String appId; + private List clusters; + + public ApplicationBean(){ + this.clusters = new ArrayList(); + } + + public ApplicationBean(String appId){ + this.appId = appId; + this.clusters = new ArrayList(); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public List getClusters() { + return clusters; + } + + public ClusterBean getCluster(String clusterId){ + + for(ClusterBean clusterBean : clusters){ + if(clusterBean.getClusterId().equals(clusterId)){ + return clusterBean; + } + } + + return null; + } + + public void setClusters(List clusters) { + this.clusters = clusters; + } + + public void addCluster(ClusterBean cluster){ + this.clusters.add(cluster); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java new file mode 100644 index 0000000000..5c5187af81 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/ClusterBean.java @@ -0,0 +1,59 @@ +package org.apache.stratos.metadataservice.definition; +/** + * 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 javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.List; + +@XmlRootElement(name="clusters") +public class ClusterBean { + + private String clusterId; + private List properties; + + public ClusterBean(){ + this.setProperties(new ArrayList()); + } + + public ClusterBean(String id){ + this.setClusterId(id); + this.setProperties(new ArrayList()); + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + public void addProperty(NewProperty property){ + this.properties.add(property); + } +} diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.java new file mode 100644 index 0000000000..552d29f791 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/NewProperty.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.metadataservice.definition; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@XmlRootElement(name="properties") +public class NewProperty implements Serializable{ + + private String key; + private List values = new ArrayList(); + + public NewProperty(){} + public NewProperty(String key, String value){ + this.key=key; + this.values.add(value); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String[] getValues(){ + String[] values = new String[this.values.size()]; + values = this.values.toArray(values); + return values; + } + + public void setValues(String[] values) { + this.values.addAll(Arrays.asList(values)); + } + + + public void setValues(String value) { + this.values.add(value); + } + + public void addValue(String value){ + this.values.add(value); + } +} 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 71e3b708fc..94cdc52fd4 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 @@ -18,8 +18,7 @@ */ package org.apache.stratos.metadataservice.registry; -import java.util.ArrayList; -import java.util.List; +import java.util.*; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; @@ -27,10 +26,10 @@ import org.apache.axis2.context.ConfigurationContext; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; -import org.apache.stratos.metadataservice.definition.PropertyBean; +import org.apache.stratos.metadataservice.definition.*; 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.Resource; import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.core.service.RegistryService; @@ -181,4 +180,146 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car return false; } + + + public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + if(!tempRegistry.resourceExists(resourcePath)){ + return null; + //throw new RegistryException("Cluster does not exist at " + resourcePath); + } + Resource regResource = tempRegistry.get(resourcePath); + + ArrayList newProperties = new ArrayList(); + + Properties props = regResource.getProperties(); + Enumeration x = props.propertyNames(); + while(x.hasMoreElements()) + { + String key = (String) x.nextElement(); + List values = regResource.getPropertyValues(key); + NewProperty property = new NewProperty(); + property.setKey(key); + String[] valueArr = new String[values.size()]; + property.setValues(values.toArray(valueArr)); + + newProperties.add(property); + + } + + return newProperties; + } + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId + "/" + clusterId; + Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + + regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); + tempRegistry.put(regResource.getPath(), regResource); + + } + + @Override + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + clusterId; + Resource regResource; + regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); + try { + for(NewProperty property : properties){ + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + + } + tempRegistry.put(resourcePath, regResource); + if(log.isDebugEnabled()){ + log.debug("A resource added to: " + resourcePath); + } + + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("addCartridgeMetaDataDetails", e); + } + } finally { + // Close the session + + } + } + + public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); + + for(NewProperty property : properties){ + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + + } + tempRegistry.put(resourcePath, regResource); + } + + public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + } + + public List getPropertiesOfApplication(String applicationId) throws RegistryException { + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + if(!tempRegistry.resourceExists(resourcePath)){ + return null; + //throw new RegistryException("Cluster does not exist at " + resourcePath); + } + Resource regResource = tempRegistry.get(resourcePath); + + ArrayList newProperties = new ArrayList(); + + Properties props = regResource.getProperties(); + Enumeration x = props.propertyNames(); + while(x.hasMoreElements()) + { + String key = (String) x.nextElement(); + List values = regResource.getPropertyValues(key); + NewProperty property = new NewProperty(); + property.setKey(key); + String[] valueArr = new String[values.size()]; + property.setValues(values.toArray(valueArr)); + + newProperties.add(property); + + } + if(newProperties.size() == 0){ + return null; + } + return newProperties; + } + + + private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException { + Resource regResource; + if(tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + }else{ + regResource = tempRegistry.newCollection(); + } + return regResource; + } + + private Resource createOrGetResourceforCluster(Registry tempRegistry, String resourcePath) throws RegistryException { + + int index = resourcePath.lastIndexOf('/'); + String applicationResourcePath = resourcePath.substring(0,index); + createOrGetResourceforApplication(tempRegistry, applicationResourcePath); + Resource regResource; + if(tempRegistry.resourceExists(resourcePath)) { + regResource = tempRegistry.get(resourcePath); + }else{ + regResource = tempRegistry.newResource(); + } + return regResource; + } + } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index 93302b7244..51cb5875ac 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,7 +18,12 @@ */ package org.apache.stratos.metadataservice.registry; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.NewProperty; +import org.wso2.carbon.registry.api.RegistryException; + +import java.util.List; /* * Interface of the Data Store @@ -33,4 +38,16 @@ public String getCartridgeMetaDataDetails(String applicationName, String cartrid public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception; + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) + throws Exception; + public List getPropertiesOfCluster(String applicationName, String clusterId) + throws Exception; + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; + + void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException; + + void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException; + + List getPropertiesOfApplication(String applicationId) throws RegistryException; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 3829303a8c..ec464c8037 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -30,10 +30,13 @@ import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.definition.PropertyBean; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.Registry; +import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; @@ -219,4 +222,28 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car return false; } + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + + } + + public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + return null; + } + + public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { + + } + + public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { + + } + + public void addPropertyToApplication(String applicationId, NewProperty property) { + + } + + public List getPropertiesOfApplication(String applicationId) throws RegistryException { + return null; + } + } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index e30ffec22e..c41f56f95d 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -8,18 +8,30 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; +import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; +import org.apache.stratos.metadataservice.definition.ClusterBean; +import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; import org.apache.stratos.metadataservice.util.ConfUtil; +import org.wso2.carbon.registry.api.RegistryException; -@Path("/metadataservice/") +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +@Path("/") public class MetaDataAdmin { + @Context + UriInfo uriInfo; private static Log log = LogFactory.getLog(MetaDataAdmin.class); @Context @@ -52,7 +64,7 @@ public String addCartridgeMetaDataDetails(@PathParam("applicationname") String a defaultRegType); return DataRegistryFactory.getDataRegistryFactory(registryType) .addCartridgeMetaDataDetails(applicationName, cartridgeType, - cartridgeMetaData); + cartridgeMetaData); } @@ -84,4 +96,297 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car .removeCartridgeMetaDataDetails(applicationName, cartridgeType); } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty[] propertiesArr = null; + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + if(properties != null) { + propertiesArr = new NewProperty[properties.size()]; + propertiesArr = properties.toArray(propertiesArr); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(propertiesArr == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(propertiesArr); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/property/{property_name}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + for(NewProperty p : properties){ + if(propertyName.equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfCluster(applicationId, clusterId); + if(properties == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + for(NewProperty p : properties){ + if("dependencies".equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getApplicationProperties(@PathParam("application_id") String applicationId){ + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty[] propertiesArr = null; + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfApplication(applicationId); + if(properties != null) { + propertiesArr = new NewProperty[properties.size()]; + propertiesArr = properties.toArray(propertiesArr); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(propertiesArr == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(propertiesArr); + } + return rb.build(); + } + + @GET + @Path("/application/{application_id}/property/{property_name}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getApplicationProperty(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName){ + conf = ConfUtil.getInstance(null).getConfiguration(); + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + List properties = null; + NewProperty property = null; + + try { + properties = DataRegistryFactory.getDataRegistryFactory(registryType) + .getPropertiesOfApplication(applicationId); + if(properties == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + for(NewProperty p : properties){ + if(propertyName.equals(p.getKey())){ + property = p; + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + + Response.ResponseBuilder rb=null; + if(property == null){ + rb = Response.status(Response.Status.NOT_FOUND); + }else{ + rb = Response.ok().entity(property); + } + return rb.build(); + } + + + @POST + @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) throws RestAPIException { + + if(!property.getKey().equals("dependencies")){ + throw new RestAPIException("Property name should be dependencies"); + } + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); + } catch (RegistryException e) { + e.printStackTrace(); + } + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/property") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertyToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) + throws RestAPIException { + + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); + } catch (RegistryException e) { + e.printStackTrace(); + } + + return Response.created(url).build(); + + } + + @POST + @Path("application/{application_id}/cluster/{cluster_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty[] properties) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/properties") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertiesToApplication(@PathParam("application_id") String applicationId,NewProperty[] properties) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } + + @POST + @Path("application/{application_id}/property") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addPropertyToApplication(@PathParam("application_id") String applicationId, NewProperty property) + throws RestAPIException { + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); + + conf = ConfUtil.getInstance(null).getConfiguration(); + + String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + try { + DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property); + } catch (Exception e) { + e.printStackTrace(); + } + + + return Response.created(url).build(); + } } diff --git a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml index bf40055d77..e0153019e2 100644 --- a/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml +++ b/components/org.apache.stratos.metadataservice/src/main/webapp/stratosmetadataservice/WEB-INF/cxf-servlet.xml @@ -59,6 +59,7 @@ + partitions From b5c29697b18c21d6d6f9e32342449b55ad4efc2b Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 22 Sep 2014 18:21:23 +0530 Subject: [PATCH 082/436] adding application status topic support in AS and CC --- .../grouping/DependencyBuilder.java | 51 +++--- .../grouping/topic/StatusEventPublisher.java | 8 +- .../AutoscalerTopologyEventReceiver.java | 2 +- .../stratos/autoscaler/monitor/Monitor.java | 6 +- .../monitor/cluster/ClusterMonitor.java | 10 +- .../monitor/cluster/LbClusterMonitor.java | 8 +- .../autoscaler/util/AutoscalerUtil.java | 4 +- .../parser/DefaultApplicationParser.java | 2 +- .../ApplicationStatusTopicReceiver.java | 88 ++++++++++ .../controller/topology/TopologyBuilder.java | 76 ++++++++- .../topology/TopologyEventPublisher.java | 19 ++- .../messaging/domain/topology/Cluster.java | 6 +- .../messaging/domain/topology/Status.java | 3 +- .../status/ClusterActivatedEvent.java | 2 +- .../status/ClusterMaintenanceModeEvent.java | 2 +- .../status/ClusterReadyToShutdownEvent.java | 2 +- .../status/ClusterStatusEvent.java | 2 +- .../status/GroupActivatedEvent.java | 4 +- .../status/GroupMaintenanceModeEvent.java | 2 +- .../status/GroupReadyToShutdownEvent.java | 2 +- .../status/GroupStatusEvent.java | 2 +- .../topology/ClusterMaintenanceModeEvent.java | 8 +- .../status/ClusterActivatedEventListener.java | 24 +++ .../status/GroupActivatedEventListener.java | 27 ++++ ...tatusClusterActivatedMessageProcessor.java | 57 +++++++ ...nStatusGroupActivatedMessageProcessor.java | 58 +++++++ ...pplicationStatusMessageProcessorChain.java | 59 +++++++ .../topology/ClusterActivatedProcessor.java | 84 +++++++++- ...lusterMaintenanceModeMessageProcessor.java | 7 +- .../topology/GroupActivatedProcessor.java | 59 ++++++- ...pplicationStatusEventMessageDelegator.java | 151 ++++++++++++++++++ ...ApplicationStatusEventMessageListener.java | 54 +++++++ .../ApplicationStatusEventMessageQueue.java | 26 +++ .../ApplicationStatusEventReceiver.java | 83 ++++++++++ .../stratos/messaging/util/Constants.java | 1 + 35 files changed, 931 insertions(+), 68 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{cluster => application}/status/ClusterActivatedEvent.java (96%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{cluster => application}/status/ClusterMaintenanceModeEvent.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{cluster => application}/status/ClusterReadyToShutdownEvent.java (96%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{cluster => application}/status/ClusterStatusEvent.java (94%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{group => application}/status/GroupActivatedEvent.java (93%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{group => application}/status/GroupMaintenanceModeEvent.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{group => application}/status/GroupReadyToShutdownEvent.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{group => application}/status/GroupStatusEvent.java (94%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index a1e2406bdb..ebb683cc20 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -18,10 +18,7 @@ */ package org.apache.stratos.autoscaler.grouping; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.DependencyOrder; -import org.apache.stratos.messaging.domain.topology.ParentBehavior; -import org.apache.stratos.messaging.domain.topology.StartupOrder; +import org.apache.stratos.messaging.domain.topology.*; import java.util.LinkedList; import java.util.Queue; @@ -37,28 +34,44 @@ public static Queue getStartupOrder(ParentBehavior component) { Queue startup = new LinkedList(); DependencyOrder dependencyOrder = component.getDependencyOrder(); - Set startupOrderSet = dependencyOrder.getStartupOrders(); - for (StartupOrder startupOrder : startupOrderSet) { + if(dependencyOrder != null) { + Set startupOrderSet = dependencyOrder.getStartupOrders(); + for (StartupOrder startupOrder : startupOrderSet) { - String start = startupOrder.getStart(); - String after = startupOrder.getAfter(); + String start = startupOrder.getStart(); + String after = startupOrder.getAfter(); - if (!startup.contains(start)) { - startup.add(start); - if (!startup.contains(after)) { - startup.add(after); + if (!startup.contains(start)) { + startup.add(start); + if (!startup.contains(after)) { + startup.add(after); + } else { + //TODO throw exception since after is there before start + } } else { - //TODO throw exception since after is there before start - } - } else { - if (!startup.contains(after)) { - startup.add(after); - } else { - //TODO throw exception since start and after already there + if (!startup.contains(after)) { + startup.add(after); + } else { + //TODO throw exception since start and after already there + } } } } + //TODO adding all the missed groups or clusters as the top child to the list + for(Group group: component.getGroupMap().values()) { + if(!startup.contains(group.getAlias())) { + startup.add(group.getAlias()); + } + } + + for(String clusterId: component.getClusterIdMap().values()) { + if(!startup.contains(clusterId)) { + startup.add(clusterId); + } + } + + return startup; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index f7e5b280cb..da8dff8513 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -5,10 +5,10 @@ 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.cluster.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.cluster.status.ClusterMaintenanceModeEvent; -import org.apache.stratos.messaging.event.group.status.GroupActivatedEvent; -import org.apache.stratos.messaging.event.group.status.GroupMaintenanceModeEvent; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupMaintenanceModeEvent; import org.apache.stratos.messaging.util.Constants; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index ad54152c4e..238d64eb7f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -119,7 +119,7 @@ protected void onEvent(Event event) { //TODO build dependency and organize the application //start the application monitor - //startApplicationMonitor(applicationCreatedEvent.getApplication()); + startApplicationMonitor(applicationCreatedEvent.getApplication()); } finally { //release read lock diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 7471703592..ef0d750b73 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -112,9 +112,11 @@ public void setId(String id) { } public void startDependency() { - preOrderTraverse = DependencyBuilder.getStartupOrder(component); + //Need to get the order every time as group/cluster might already been started + //TODO breadth first search in a tree and find the parallel one + //TODO build up the tree with ordered manner - //TODO find out the parallel ones + preOrderTraverse = DependencyBuilder.getStartupOrder(component); //start the first dependency if(!preOrderTraverse.isEmpty()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 3fa9ada297..eb94ffddf2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -30,7 +30,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; import java.util.List; @@ -46,7 +46,7 @@ public class ClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(ClusterMonitor.class); private String lbReferenceType; private boolean hasPrimary; - private ClusterStatus status; + private Status status; public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { @@ -76,7 +76,7 @@ public void run() { Thread.sleep(60000); } catch (InterruptedException ignore) { }*/ - this.status = ClusterStatus.Running; + this.status = Status.Running; while (!isDestroyed() && status.getCode() >= ClusterStatus.Running.getCode()) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); @@ -242,11 +242,11 @@ public void setHasPrimary(boolean hasPrimary) { this.hasPrimary = hasPrimary; } - public ClusterStatus getStatus() { + public Status getStatus() { return status; } - public void setStatus(ClusterStatus status) { + public void setStatus(Status status) { this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index 45142c2a60..0335db9170 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -27,8 +27,8 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Status; -import java.util.Observable; import java.util.concurrent.ConcurrentHashMap; /** @@ -39,7 +39,7 @@ public class LbClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(LbClusterMonitor.class); - private ClusterStatus status; + private Status status; public LbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { @@ -117,11 +117,11 @@ public String toString() { } - public ClusterStatus getStatus() { + public Status getStatus() { return status; } - public void setStatus(ClusterStatus status) { + public void setStatus(Status status) { this.status = status; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index e6374513e5..690b44e313 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -111,7 +111,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(), deploymentPolicy, policy); - clusterMonitor.setStatus(ClusterStatus.Created); + clusterMonitor.setStatus(Status.Created); for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){ @@ -235,7 +235,7 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic new LbClusterMonitor(clusterId, cluster.getServiceName(), deploymentPolicy, policy); - clusterMonitor.setStatus(ClusterStatus.Created); + clusterMonitor.setStatus(Status.Created); // partition group = network partition context for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index c6ab42e429..fa6882ea93 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -469,7 +469,7 @@ private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableIn cluster.addHostName(hostname); cluster.setLbCluster(false); - cluster.setStatus(ClusterStatus.Created); + cluster.setStatus(Status.Created); return cluster; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java new file mode 100644 index 0000000000..9abdbbbeb9 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.cloud.controller.application.status.receiver; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.topology.TopologyBuilder; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; +import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; + +public class ApplicationStatusTopicReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationStatusTopicReceiver.class); + + private ApplicationStatusEventReceiver statusEventReceiver; + private boolean terminated; + + public ApplicationStatusTopicReceiver() { + this.statusEventReceiver = new ApplicationStatusEventReceiver(); + addEventListeners(); + } + + @Override + public void run() { + //FIXME this activated before autoscaler deployer activated. + try { + Thread.sleep(15000); + } catch (InterruptedException ignore) { + } + Thread thread = new Thread(statusEventReceiver); + thread.start(); + if (log.isInfoEnabled()) { + log.info("Cloud controller application status thread started"); + } + + // Keep the thread live until terminated + while (!terminated) { + try { + Thread.sleep(1000); + } catch (InterruptedException ignore) { + } + } + if (log.isInfoEnabled()) { + log.info("Cloud controller application status thread terminated"); + } + + } + + private void addEventListeners() { + // Listen to topology events that affect clusters + statusEventReceiver.addEventListener(new ClusterActivatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleClusterActivatedEvent((ClusterActivatedEvent) event); + } + }); + + statusEventReceiver.addEventListener(new GroupActivatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event); + + } + }); + + + } + +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 55b9d2c92e..df667f4e80 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -32,6 +32,8 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -150,7 +152,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { } cluster.setProperties(props); cluster.setLbCluster(isLb); - cluster.setStatus(ClusterStatus.Created); + cluster.setStatus(Status.Created); service.addCluster(cluster); } TopologyManager.updateTopology(topology); @@ -209,7 +211,7 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { try { TopologyManager.acquireWriteLock(); Cluster cluster = service.getCluster(ctxt.getClusterId()); - cluster.setStatus(ClusterStatus.In_Maintenance); + cluster.setStatus(Status.In_Maintenance); TopologyManager.updateTopology(topology); } finally { TopologyManager.releaseWriteLock(); @@ -700,6 +702,76 @@ public static void handleCompositeApplicationRemoved(String alias) { TopologyEventPublisher.sendConfigApplicationRemovedEventEvent(alias); } + public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActivatedEvent) { + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(clusterActivatedEvent.getServiceName()); + //update the status of the cluster + if (service == null) { + log.warn(String.format("Service %s does not exist", + clusterActivatedEvent.getServiceName())); + return; + } + + Cluster cluster = service.getCluster(clusterActivatedEvent.getClusterId()); + if (cluster == null) { + log.warn(String.format("Cluster %s does not exist", + clusterActivatedEvent.getClusterId())); + return; + } + + org.apache.stratos.messaging.event.topology.ClusterActivatedEvent clusterActivatedEvent1 = + new org.apache.stratos.messaging.event.topology.ClusterActivatedEvent( + clusterActivatedEvent.getAppId(), + clusterActivatedEvent.getServiceName(), + clusterActivatedEvent.getClusterId()); + try { + TopologyManager.acquireWriteLock(); + cluster.setStatus(Status.Activated); + log.info("Cluster activated adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1); + } + + public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(groupActivatedEvent.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + groupActivatedEvent.getAppId())); + return; + } + + Group group = application.getGroup(groupActivatedEvent.getGroupId()); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupActivatedEvent.getGroupId())); + return; + } + + org.apache.stratos.messaging.event.topology.GroupActivatedEvent groupActivatedEvent1 = + new org.apache.stratos.messaging.event.topology.GroupActivatedEvent( + groupActivatedEvent.getAppId(), + groupActivatedEvent.getGroupId()); + try { + TopologyManager.acquireWriteLock(); + group.setStatus(Status.Activated); + log.info("Group activated adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1); + } + + /*public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { ConfigCompositeApplication messApp = new ConfigCompositeApplication(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index a80ddd468e..0cb93066d5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -36,7 +36,6 @@ import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.util.Constants; -import org.apache.wml.WMLStrongElement; import java.util.List; import java.util.Properties; @@ -123,7 +122,7 @@ public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymen public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) { ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = new ClusterMaintenanceModeEvent(ctxt.getCartridgeType(), ctxt.getClusterId()); - clusterMaintenanceModeEvent.setStatus(ClusterStatus.In_Maintenance); + clusterMaintenanceModeEvent.setStatus(Status.In_Maintenance); if(log.isInfoEnabled()) { log.info(String.format("Publishing cluster maintenance mode event: [service] %s [cluster] %s", clusterMaintenanceModeEvent.getServiceName(), clusterMaintenanceModeEvent.getClusterId())); @@ -196,6 +195,22 @@ public static void sendMemberMaintenanceModeEvent(MemberMaintenanceModeEvent mem publishEvent(memberMaintenanceModeEvent); } + public static void sendGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing group activated event: [appId] %s [group] %s", + groupActivatedEvent.getAppId(), groupActivatedEvent.getGroupId())); + } + publishEvent(groupActivatedEvent); + } + + public static void sendClusterActivatedEvent(ClusterActivatedEvent clusterActivatedEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing cluster activated event: [service] %s [cluster] %s [appId] %s", + clusterActivatedEvent.getServiceName(), clusterActivatedEvent.getClusterId() , clusterActivatedEvent.getAppId())); + } + publishEvent(clusterActivatedEvent); + } + public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, Properties properties, String groupId) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 80a2277e03..957fce4827 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -49,7 +49,7 @@ public class Cluster implements Serializable { @XmlJavaTypeAdapter(MapAdapter.class) private Map memberMap; - private ClusterStatus status; + private Status status; private String loadBalanceAlgorithmName; @XmlJavaTypeAdapter(MapAdapter.class) @@ -203,11 +203,11 @@ public Collection findPartitionIds() { return partitionIds.keySet(); } - public ClusterStatus getStatus() { + public Status getStatus() { return status; } - public void setStatus(ClusterStatus status) { + public void setStatus(Status status) { this.status = status; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java index 806c113b0b..fafb4e87f1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -23,7 +23,8 @@ public enum Status { Created(1), In_Maintenance(2), - Activated(3); + Running(3), + Activated(4); private int code; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java similarity index 96% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java index ecc8c7ab26..334ea15440 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.cluster.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java index 691e77e2a7..12ab74fc15 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.cluster.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java similarity index 96% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java index 2832a89643..33326186fd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.cluster.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java similarity index 94% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java index 42a430b27a..73eecb535e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.cluster.status; +package org.apache.stratos.messaging.event.application.status; import org.apache.stratos.messaging.event.Event; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java similarity index 93% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java index c1075a0fac..05d646d622 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.group.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; @@ -36,7 +36,7 @@ public GroupActivatedEvent(String appId, String groupId) { this.groupId = groupId; } - public String getGroupId(String groupId) { + public String getGroupId() { return this.groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java index a301da4cb6..7b9a09b150 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.group.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java index 70b44aa1cd..4e1d7764ce 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.group.status; +package org.apache.stratos.messaging.event.application.status; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java similarity index 94% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java index 44ae0a9fa9..08b9116d18 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/group/status/GroupStatusEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.group.status; +package org.apache.stratos.messaging.event.application.status; import org.apache.stratos.messaging.event.Event; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java index 76e58208e2..9b31a134ba 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Status; import java.io.Serializable; @@ -27,7 +27,7 @@ public class ClusterMaintenanceModeEvent extends TopologyEvent implements Serial private final String serviceName; private final String clusterId; - private ClusterStatus status; + private Status status; public ClusterMaintenanceModeEvent(String serviceName, String clusterId) { this.serviceName = serviceName; @@ -48,11 +48,11 @@ public String getClusterId() { return clusterId; } - public ClusterStatus getStatus() { + public Status getStatus() { return status; } - public void setStatus(ClusterStatus status) { + public void setStatus(Status status) { this.status = status; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java new file mode 100644 index 0000000000..383b379035 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterActivatedEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java new file mode 100644 index 0000000000..83e5a7a3f7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/22/14. + */ +public abstract class GroupActivatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java new file mode 100644 index 0000000000..249a6da6f1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java @@ -0,0 +1,57 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class ApplicationStatusClusterActivatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ApplicationStatusClusterActivatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (ClusterActivatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ClusterActivatedEvent event = (ClusterActivatedEvent) Util.jsonToObject(message, ClusterActivatedEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received ClusterActivatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java new file mode 100644 index 0000000000..52415f0410 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java @@ -0,0 +1,58 @@ +/* + * 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.messaging.message.processor.application.status; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ApplicationStatusGroupActivatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ApplicationStatusGroupActivatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (ClusterActivatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + GroupActivatedEvent event = (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received GroupActivatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process group activated message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java new file mode 100644 index 0000000000..96fbc69e28 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; +import org.apache.stratos.messaging.message.processor.MessageProcessorChain; + +/** + * Application Status processor chain is to handle the list processors to parse the application + * status. + */ +public class ApplicationStatusMessageProcessorChain extends MessageProcessorChain { + private static final Log log = LogFactory.getLog(ApplicationStatusMessageProcessorChain.class); + + private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; + private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; + + public void initialize() { + // Add instance notifier event processors + clusterActivatedMessageProcessor = new ApplicationStatusClusterActivatedMessageProcessor(); + add(clusterActivatedMessageProcessor); + groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); + add(groupActivatedMessageProcessor); + + if (log.isDebugEnabled()) { + log.debug("Instance notifier message processor chain initialized"); + } + } + + public void addEventListener(EventListener eventListener) { + if (eventListener instanceof ClusterActivatedEventListener) { + clusterActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupActivatedEventListener) { + groupActivatedMessageProcessor.addEventListener(eventListener); + } else { + throw new RuntimeException("Unknown event listener"); + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 02f1b8b6da..52de45b5e1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -18,13 +18,24 @@ */ package org.apache.stratos.messaging.message.processor.topology; +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.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; /** * This processor will act upon the cluster activated event */ public class ClusterActivatedProcessor extends MessageProcessor { - + private static final Log log = LogFactory.getLog(ClusterActivatedProcessor.class); private MessageProcessor nextProcessor; @Override @@ -34,6 +45,75 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - return nextProcessor.process(type, message, object); + Topology topology = (Topology) object; + + if (ClusterActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ClusterActivatedEvent event = (ClusterActivatedEvent) Util. + jsonToObject(message, ClusterActivatedEvent.class); + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + // Apply changes to the topology + cluster.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster updated as activated : %s", + cluster.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 0300b24641..f125c54f9c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -20,10 +20,7 @@ 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.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; @@ -92,7 +89,7 @@ public boolean process(String type, String message, Object object) { } } else { // Apply changes to the topology - cluster.setStatus(ClusterStatus.In_Maintenance); + cluster.setStatus(Status.In_Maintenance); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as maintenance mode: %s", cluster.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 13ea2e7a93..627d9a99aa 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -18,13 +18,21 @@ */ package org.apache.stratos.messaging.message.processor.topology; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; /** * This processor will act upon the Group activation events */ public class GroupActivatedProcessor extends MessageProcessor { - + private static final Log log = LogFactory.getLog(ClusterActivatedProcessor.class); private MessageProcessor nextProcessor; @Override @@ -34,6 +42,53 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - return nextProcessor.process(type, message, object); + Topology topology = (Topology) object; + + if (GroupActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + GroupActivatedEvent event = (GroupActivatedEvent) Util. + jsonToObject(message, GroupActivatedEvent.class); + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroup(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + group.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Group updated as activated : %s", + group.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java new file mode 100644 index 0000000000..ccf9dd3ae8 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java @@ -0,0 +1,151 @@ +/* + * 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.messaging.message.receiver.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.message.processor.MessageProcessorChain; +import org.apache.stratos.messaging.message.processor.application.status.ApplicationStatusMessageProcessorChain; + +import javax.jms.TextMessage; + +public class ApplicationStatusEventMessageDelegator implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageDelegator.class); + + private ApplicationStatusEventMessageQueue messageQueue; + private MessageProcessorChain processorChain; + private boolean terminated; + + public ApplicationStatusEventMessageDelegator(ApplicationStatusEventMessageQueue messageQueue) { + this.messageQueue = messageQueue; + this.processorChain = new ApplicationStatusMessageProcessorChain(); + } + + public void addEventListener(EventListener eventListener) { + processorChain.addEventListener(eventListener); + } + + @Override + public void run() { + try { + if (log.isInfoEnabled()) { + log.info("Application status event message delegator started"); + } + + while (!terminated) { + try { + TextMessage message = messageQueue.take(); + + String messageText = message.getText(); + if (log.isDebugEnabled()) { + log.debug("Application status event message received: [message] " + messageText); + } + EventMessage eventMessage = jsonToEventMessage(messageText); + if(eventMessage == null){ + log.error("Error occurred while extracting message"); + continue; + } + String type = eventMessage.getEventName(); + String json = eventMessage.getMessage(); + + if (log.isDebugEnabled()) { + log.debug(String.format("Application status event message received from queue: %s", type)); + } + + // Delegate message to message processor chain + if (log.isDebugEnabled()) { + log.debug(String.format("Delegating application status event message: %s", type)); + } + processorChain.process(type, json, null); + } catch (Exception e) { + log.error("Failed to retrieve application status event message", e); + } + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Application status event message delegator failed", e); + } + } + } + + /** + * Terminate topology event message delegator thread. + */ + public void terminate() { + terminated = true; + } + + + private EventMessage jsonToEventMessage(String json) { + + EventMessage event = new EventMessage(); + String message; + + //split the message to 3 parts using ':' first is class name, second contains the text 'message' and the third contains + //message + String[] MessageParts = json.split(":", 3); + + String eventType = MessageParts[0].trim(); + eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\"")); + if(log.isDebugEnabled()){ + log.debug(String.format("Extracted [event type] %s", eventType)); + } + + event.setEventName(eventType); + String messageTag = MessageParts[1]; + messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\"")); + + if("message".equals(messageTag)){ + message = MessageParts[2].trim(); + //Remove trailing bracket twice to get the message + message = message.substring(0, message.lastIndexOf("}")).trim(); + message = message.substring(0, message.lastIndexOf("}")).trim(); + if(message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1){ + if(log.isDebugEnabled()) { + log.debug(String.format("[Extracted message] %s ", message)); + } + event.setMessage(message); + return event; + } + } + return null; + } + + private class EventMessage { + private String eventName; + private String message; + + private String getEventName() { + return eventName; + } + + private void setEventName(String eventName) { + this.eventName = eventName; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java new file mode 100644 index 0000000000..93eeb542fc --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java @@ -0,0 +1,54 @@ +/* + * 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.messaging.message.receiver.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; + +public class ApplicationStatusEventMessageListener implements MessageListener { + private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class); + + private ApplicationStatusEventMessageQueue messageQueue; + + public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue messageQueue) { + this.messageQueue = messageQueue; + } + + @Override + public void onMessage(Message message) { + if (message instanceof TextMessage) { + TextMessage receivedMessage = (TextMessage) message; + try { + if (log.isDebugEnabled()) { + log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText())); + } + // Add received message to the queue + messageQueue.add(receivedMessage); + + } catch (JMSException e) { + log.error(e.getMessage(), e); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java new file mode 100644 index 0000000000..ba455c9cbd --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.message.receiver.application.status; + + +import javax.jms.TextMessage; +import java.util.concurrent.LinkedBlockingQueue; + +public class ApplicationStatusEventMessageQueue extends LinkedBlockingQueue { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java new file mode 100644 index 0000000000..0b6cada6c6 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.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.messaging.message.receiver.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.util.Constants; + +public class ApplicationStatusEventReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationStatusEventReceiver.class); + + private ApplicationStatusEventMessageDelegator messageDelegator; + private ApplicationStatusEventMessageListener messageListener; + private TopicSubscriber topicSubscriber; + private boolean terminated; + + public ApplicationStatusEventReceiver() { + ApplicationStatusEventMessageQueue messageQueue = new ApplicationStatusEventMessageQueue(); + this.messageDelegator = new ApplicationStatusEventMessageDelegator(messageQueue); + this.messageListener = new ApplicationStatusEventMessageListener(messageQueue); + } + + public void addEventListener(EventListener eventListener) { + messageDelegator.addEventListener(eventListener); + } + + @Override + public void run() { + try { + // Start topic subscriber thread + topicSubscriber = new TopicSubscriber(Constants.APPLICATION_STATUS_TOPIC); + topicSubscriber.setMessageListener(messageListener); + Thread subscriberThread = new Thread(topicSubscriber); + subscriberThread.start(); + if (log.isDebugEnabled()) { + log.debug("Application status event message receiver thread started"); + } + + // Start Application status event message delegator thread + Thread receiverThread = new Thread(messageDelegator); + receiverThread.start(); + if (log.isDebugEnabled()) { + log.debug("Application status event message delegator thread started"); + } + + // Keep the thread live until terminated + while (!terminated) { + try { + Thread.sleep(1000); + } catch (InterruptedException ignore) { + } + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Application status failed", e); + } + } + } + + public void terminate() { + topicSubscriber.terminate(); + messageDelegator.terminate(); + terminated = true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index 5991e25fb8..33f2f22206 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -24,6 +24,7 @@ public class Constants { public static final String HEALTH_STAT_TOPIC = "summarized-health-stats"; public static final String INSTANCE_STATUS_TOPIC = "instance-status"; public static final String INSTANCE_NOTIFIER_TOPIC = "instance-notifier"; + public static final String APPLICATION_STATUS_TOPIC = "application-status"; public static final String PING_TOPIC = "ping"; public static final String TENANT_TOPIC = "tenant"; public static final String TENANT_RANGE_ALL = "*"; From 6171d23e856c2028e72905f82083a04c2bc2828b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 22 Sep 2014 18:47:21 +0530 Subject: [PATCH 083/436] collecting payload information to publish to meta data service --- .../application/ApplicationUtils.java | 89 +++++++++++++++++++ .../parser/DefaultApplicationParser.java | 69 ++++++++++---- .../impl/CloudControllerServiceImpl.java | 3 + .../pojo/ApplicationDataHolder.java | 11 +++ .../controller/pojo/ClusterDataHolder.java | 14 +++ .../pojo/payload/PayloadDataHolder.java | 88 ++++++++++++++++++ .../metadata/client/pojo/DataContext.java | 1 + 7 files changed, 256 insertions(+), 19 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 3cd3a0ef10..ff7ef9f831 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -19,6 +19,14 @@ package org.apache.stratos.cloud.controller.application; +import org.apache.stratos.cloud.controller.pojo.Cartridge; +import org.apache.stratos.cloud.controller.pojo.PortMapping; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; +import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; +import org.apache.stratos.messaging.domain.topology.Cluster; + +import java.util.*; import java.util.regex.Pattern; public class ApplicationUtils { @@ -39,4 +47,85 @@ public static boolean isValid (String arg) { return true; } } + + public static Properties getGlobalPayloadData () { + + Properties globalProperties = new Properties(); + + if (System.getProperty("puppet.ip") != null) { + globalProperties.setProperty("PUPPET_IP", System.getProperty("puppet.ip")); + } + if (System.getProperty("puppet.hostname") != null) { + globalProperties.setProperty("PUPPET_HOSTNAME", System.getProperty("puppet.hostname")); + } + if (System.getProperty("puppet.env") != null) { + globalProperties.setProperty("PUPPET_ENV", System.getProperty("puppet.env")); + } + if (System.getProperty("puppet.dns.available") != null) { + globalProperties.setProperty("PUPPET_DNS_AVAILABLE", System.getProperty("puppet.dns.available")); + } + + return globalProperties; + } + + public static PayloadDataHolder getClusterLevelPayloadData (String appId, Cluster cluster, + SubscribableContext subscribableCtxt, + SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) { + + PayloadDataHolder payloadDataHolder = new PayloadDataHolder(appId, subscribableCtxt.getType(), cluster.getClusterId()); + + Properties clusterLevelPayloadProperties = new Properties(); + // service name + if (subscribableCtxt.getType() != null) { + clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType()); + } + // host name + if (cluster.getHostNames().get(0) != null) { + clusterLevelPayloadProperties.put("HOST_NAME", cluster.getHostNames().get(0)); + } + // multi tenant + clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant())); + // tenant range + if (cluster.getTenantRange() != null) { + clusterLevelPayloadProperties.put("TENANT_RANGE", cluster.getTenantRange()); + } + // cartridge alias + if (subscribableCtxt.getAlias() != null) { + clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias()); + } + // cluster id + if (cluster.getClusterId() != null) { + clusterLevelPayloadProperties.put("CLUSTER_ID", cluster.getClusterId()); + } + // repo url + if (subscribableInfoCtxt.getRepoUrl() != null) { + clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl()); + } + // ports + if (createPortMappingPayloadString(cartridge) != null) { + clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge)); + } + // provider + if (cartridge.getProvider() != null) { + clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider()); + } + + payloadDataHolder.setProperties(clusterLevelPayloadProperties); + return payloadDataHolder; + } + + private static String createPortMappingPayloadString (Cartridge cartridge) { + + // port mappings + StringBuilder portMapBuilder = new StringBuilder(); + List portMappings = cartridge.getPortMappings(); + for (PortMapping portMapping : portMappings) { + String port = portMapping.getPort(); + portMapBuilder.append(port).append("|"); + } + + // remove last "|" character + + return portMapBuilder.toString().replaceAll("\\|$", ""); + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index c6ab42e429..8a487da742 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -27,15 +27,16 @@ import org.apache.stratos.cloud.controller.application.STClusterInformation; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; -import org.apache.stratos.cloud.controller.pojo.ApplicationDataHolder; +import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.ClusterDataHolder; -import org.apache.stratos.cloud.controller.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.pojo.application.*; +import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.StartupOrder; import java.util.*; +import java.util.Properties; public class DefaultApplicationParser implements ApplicationParser { @@ -186,19 +187,23 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app application.setTenantAdminUserName(appCtxt.getTeantAdminUsername()); // following keeps track of all Clusters created for this application - Set clusters = new HashSet(); + //Set clusters = new HashSet(); + ClusterDataHolder clusterDataHolder = null; if (appCtxt.getComponents() != null) { // get top level Subscribables if (appCtxt.getComponents().getSubscribableContexts() != null) { - ClusterDataHolder clusterDataHolder = getClusterInformation(Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); + clusterDataHolder = getClusterInformation(appCtxt.getApplicationId(), + Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); application.setClusterIds(clusterDataHolder.getClusterIdMap()); - clusters.addAll(clusterDataHolder.getClusters()); + //clusters.addAll(clusterDataHolder.getClusters()); } // get Groups if (appCtxt.getComponents().getGroupContexts() != null) { - application.setGroups(getGroupInfo(clusters, Arrays.asList(appCtxt.getComponents().getGroupContexts()), subscribableInfoCtxts, definedGroupCtxts)); + application.setGroups(getGroupInfo(appCtxt.getApplicationId(), clusterDataHolder, + Arrays.asList(appCtxt.getComponents().getGroupContexts()), subscribableInfoCtxts, + definedGroupCtxts)); } // get top level Dependency definitions @@ -217,14 +222,23 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); + // collect and set application level payload information + Properties appLevelProperties = new Properties(); + appLevelProperties.setProperty("TENANT_ID", String.valueOf(appCtxt.getTenantId())); + appLevelProperties.setProperty("CARTRIDGE_KEY", application.getKey()); + // get global payload data + appLevelProperties.putAll(ApplicationUtils.getGlobalPayloadData()); + ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); - applicationDataHolder.setClusters(clusters); + assert clusterDataHolder != null; + applicationDataHolder.setClusters(clusterDataHolder.getClusters()); + applicationDataHolder.setPayloadDataHolders(clusterDataHolder.getPayloadDataHolders()); applicationDataHolder.setApplication(application); return applicationDataHolder; } - private Map getGroupInfo (Set clusters, List groupCtxts, + private Map getGroupInfo (String appId, ClusterDataHolder clusterDataHolder, List groupCtxts, Map subscribableInformation, Map definedGroupCtxts) throws ApplicationDefinitionException { @@ -232,7 +246,7 @@ private Map getGroupInfo (Set clusters, List groupNameToGroup = new HashMap(); for (GroupContext groupCtxt : groupCtxts) { - Group group = getGroup(clusters, groupCtxt, subscribableInformation, definedGroupCtxts); + Group group = getGroup(appId, clusterDataHolder, groupCtxt, subscribableInformation, definedGroupCtxts); if(groupNameToGroup.put(group.getName(), group) != null) { // Application Definition has same Group multiple times at the top-level handleError("Group [ " + group.getName() + " ] appears twice in the Application Definition's top level"); @@ -279,8 +293,9 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr } } - private Group getGroup(Set clusters, GroupContext groupCtxt, Map subscribableInfoCtxts, - Map definedGroupCtxts) throws ApplicationDefinitionException { + private Group getGroup(String appId, ClusterDataHolder clusterDataHolder, GroupContext groupCtxt, Map subscribableInfoCtxts, Map definedGroupCtxts) + throws ApplicationDefinitionException { // check if are in the defined Group set GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias()); @@ -302,13 +317,21 @@ private Group getGroup(Set clusters, GroupContext groupCtxt, Map clusters, GroupContext groupCtxt, Map subscribableCtxts, + private ClusterDataHolder getClusterInformation (String appId, List subscribableCtxts, Map subscribableInfoCtxts) throws ApplicationDefinitionException { Map clusterIdMap = new HashMap(); Set clusters = new HashSet(); + Set payloadDataHolders = new HashSet(); for (SubscribableContext subscribableCtxt : subscribableCtxts) { // check is there is a related Subscribable Information @@ -445,12 +470,18 @@ private ClusterDataHolder getClusterInformation (List subsc // Application Definition has same cartridge multiple times at the top-level handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); } + + payloadDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, cluster, subscribableCtxt, subscribableInfoCtxt, cartridge)); } - return new ClusterDataHolder(clusterIdMap, clusters); + ClusterDataHolder clusterDataHolder = new ClusterDataHolder(clusterIdMap, clusters); + clusterDataHolder.setPayloadDataHolders(payloadDataHolders); + + return clusterDataHolder; } private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) + throws ApplicationDefinitionException { // get hostname and cluster id diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index f9dc925903..8308c67ff6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1429,6 +1429,9 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) ApplicationParser applicationParser = new DefaultApplicationParser(); ApplicationDataHolder applicationDataHolder = applicationParser.parse(applicationContext); + //TODO: publish the data to the meta data service + applicationDataHolder.getPayloadDataHolders(); + TopologyBuilder.handleApplicationDeployed(applicationDataHolder); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java index 0007ab8352..c1fa44b507 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java @@ -19,6 +19,7 @@ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -30,6 +31,8 @@ public class ApplicationDataHolder { private Set clusters; + private Set payloadDataHolders; + public Application getApplication() { return application; } @@ -45,4 +48,12 @@ public Set getClusters() { public void setClusters(Set clusters) { this.clusters = clusters; } + + public Set getPayloadDataHolders() { + return payloadDataHolders; + } + + public void setPayloadDataHolders(Set payloadDataHolders) { + this.payloadDataHolders = payloadDataHolders; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java index bc4f7ebc39..313265e1a8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java @@ -19,7 +19,9 @@ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.metadata.client.pojo.DataContext; import java.util.Map; import java.util.Set; @@ -32,6 +34,9 @@ public class ClusterDataHolder { // Cluster object collection private Set clusters; + // payload related information + private Set payloadDataHolders; + public ClusterDataHolder (Map clusterIdMap, Set clusters) { this.clusterIdMap = clusterIdMap; this.clusters = clusters; @@ -44,4 +49,13 @@ public Map getClusterIdMap() { public Set getClusters() { return clusters; } + + + public Set getPayloadDataHolders() { + return payloadDataHolders; + } + + public void setPayloadDataHolders(Set payloadDataHolders) { + this.payloadDataHolders = payloadDataHolders; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java new file mode 100644 index 0000000000..f7d2cd0ad1 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo.payload; + +import java.util.Properties; + +/** + * Holds payload/meta data related to a cluster + */ + +public class PayloadDataHolder { + + private String appId; + + private String groupName; + + private String clusterId; + + private Properties properties; + + public PayloadDataHolder (String appId) { + + this.appId = appId; + } + + public PayloadDataHolder (String appId, String groupName, String clusterId) { + + this.appId = appId; + this.groupName = groupName; + this.clusterId = clusterId; + } + + public String getAppId() { + return appId; + } + + public String getGroupName() { + return groupName; + } + + public String getClusterId() { + return clusterId; + } + + public boolean equals(Object other) { + + if(other == null || !(other instanceof PayloadDataHolder)) { + return false; + } + + if(this == other) { + return true; + } + + PayloadDataHolder that = (PayloadDataHolder)other; + return this.appId.equals(that.appId) && this.groupName.equals(that.groupName) && + this.clusterId.equals(that.clusterId); + } + + public int hashCode () { + return appId.hashCode() + groupName.hashCode() + clusterId.hashCode(); + } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java index 93653c7888..f5194c8225 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java @@ -84,4 +84,5 @@ public Set getPropertyValues() { public String getPropertyValue() { return propertyValue; } + } From ab136724059e86f760e491b556ad427448bcc3fb Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 22 Sep 2014 19:43:36 +0530 Subject: [PATCH 084/436] change exceptions in metadata service --- .../exception/MetadataException.java | 11 +++++++ .../registry/CarbonRegistry.java | 29 +++++++------------ .../metadataservice/registry/DataStore.java | 4 +-- .../registry/GRegRegistry.java | 6 ++-- .../services/MetaDataAdmin.java | 3 ++ 5 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java new file mode 100644 index 0000000000..4252b46481 --- /dev/null +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java @@ -0,0 +1,11 @@ +package org.apache.stratos.metadataservice.exception; + +/** + * Created by udara on 9/22/14. + */ +public class MetadataException extends Exception { + + public MetadataException(String message, Throwable cause) { + super(message, cause); + } +} 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 94cdc52fd4..9886c97d5c 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 @@ -182,7 +182,7 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car - public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; if(!tempRegistry.resourceExists(resourcePath)){ @@ -205,7 +205,6 @@ public List getPropertiesOfCluster(String applicationName, String c property.setValues(values.toArray(valueArr)); newProperties.add(property); - } return newProperties; @@ -222,29 +221,20 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp } @Override - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; Resource regResource; regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); - try { - for(NewProperty property : properties){ - regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); - - } - tempRegistry.put(resourcePath, regResource); - if(log.isDebugEnabled()){ - log.debug("A resource added to: " + resourcePath); - } - - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("addCartridgeMetaDataDetails", e); - } - } finally { - // Close the session + + for(NewProperty property : properties){ + regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); } + tempRegistry.put(resourcePath, regResource); + if(log.isDebugEnabled()){ + log.debug("A resource added to: " + resourcePath); + } } public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { @@ -264,6 +254,7 @@ public void addPropertyToApplication(String applicationId, NewProperty property) String resourcePath = mainResource + applicationId; Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); + tempRegistry.put(regResource.getPath(), regResource); } public List getPropertiesOfApplication(String applicationId) throws RegistryException { diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index 51cb5875ac..f7cac250cf 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -39,9 +39,9 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car throws Exception; public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) - throws Exception; + throws RegistryException; public List getPropertiesOfCluster(String applicationName, String clusterId) - throws Exception; + throws RegistryException; public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index ec464c8037..c454631a2f 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -222,11 +222,11 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car return false; } - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws Exception { + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { } - public List getPropertiesOfCluster(String applicationName, String clusterId) throws Exception { + public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { return null; } @@ -238,7 +238,7 @@ public void addPropertiesToApplication(String applicationId, NewProperty[] prope } - public void addPropertyToApplication(String applicationId, NewProperty property) { + public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index 051e46cb51..11d927f757 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -146,6 +146,9 @@ public Response getClusterProperty(@PathParam("application_id") String applicati try { properties = DataRegistryFactory.getDataRegistryFactory(registryType) .getPropertiesOfCluster(applicationId, clusterId); + if(properties == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } for(NewProperty p : properties){ if(propertyName.equals(p.getKey())){ property = p; From f29d9814c6486bf877725b8a8a9c0ed27ccfa95c Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Mon, 22 Sep 2014 17:53:29 -0700 Subject: [PATCH 085/436] adding improvements to application peristence, application remove event --- .../impl/CloudControllerServiceImpl.java | 4 +- .../interfaces/CloudControllerService.java | 2 +- .../controller/topology/TopologyBuilder.java | 7 +- .../topology/TopologyEventPublisher.java | 10 +- .../client/CloudControllerServiceClient.java | 4 +- .../CompositeApplicationManager.java | 2 +- .../manager/CartridgeSubscriptionManager.java | 68 ++- .../DataInsertionAndRetrievalManager.java | 6 +- .../StratosManagerTopologyEventReceiver.java | 44 +- .../topology/ApplicationRemovedEvent.java | 20 +- .../ApplicationRemovedMessageProcessor.java | 70 ++- .../rest/endpoint/services/ServiceUtils.java | 21 +- .../resources/CloudControllerService.wsdl | 546 +++++++++--------- 13 files changed, 501 insertions(+), 303 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 8308c67ff6..f0971c3ab6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1436,9 +1436,9 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) } @Override - public void unDeployApplicationDefinition(String applicationId) throws ApplicationDefinitionException { + public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - TopologyBuilder.handleApplicationUndeployed(applicationId); + TopologyBuilder.handleApplicationUndeployed(applicationId, tenantId, tenantDomain); } private List restoreConfigCompositeApplication () { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index be98bf1641..5301b14946 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -182,6 +182,6 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit * @param applicationId Id of the Application to be undeployed * @throws ApplicationDefinitionException if an error is encountered */ - public void unDeployApplicationDefinition (String applicationId) throws ApplicationDefinitionException; + public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index df667f4e80..3974d55240 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -645,15 +645,16 @@ public static void handleApplicationDeployed(ApplicationDataHolder applicationDa } } - public static void handleApplicationUndeployed (String applicationId) { + public static void handleApplicationUndeployed (String applicationId, int tenantId, String tenantDomain) { Topology topology = TopologyManager.getTopology(); - + try { TopologyManager.acquireWriteLock(); if (!topology.applicationExists(applicationId)) { log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); + TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); } else { Application application = topology.getApplication(applicationId); @@ -670,7 +671,7 @@ public static void handleApplicationUndeployed (String applicationId) { log.info("Removed application [ " + applicationId + " ] from Topology"); - TopologyEventPublisher.sendApplicationRemovedEvent(applicationId); + TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); } } finally { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 0cb93066d5..0cbec9b1df 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -99,13 +99,13 @@ public static void sendApplicationCreatedEvent (Application application) { publishEvent(new ApplicationCreatedEvent(application)); } - public static void sendApplicationRemovedEvent(String applicationId) { + public static void sendApplicationRemovedEvent(String applicationId, int tenantId, String tenantDomain) { - if(log.isInfoEnabled()) { - log.info("Publishing Application removed event: " + applicationId); + if(log.isInfoEnabled() || log.isDebugEnabled()) { + log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId); } - - publishEvent(new ApplicationRemovedEvent(applicationId)); + + publishEvent(new ApplicationRemovedEvent(applicationId, tenantId, tenantDomain)); } public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) { 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 e1e29d6961..efe7de1681 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 @@ -139,10 +139,10 @@ public void deployApplicationDefinition(ApplicationContext applicationContext) } - public void undeployApplicationDefinition (String applicationId) throws CloudControllerServiceApplicationDefinitionExceptionException, + public void undeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws CloudControllerServiceApplicationDefinitionExceptionException, RemoteException { - stub.unDeployApplicationDefinition(applicationId); + stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain); } public void unDeployCompositeApplicationDefinition(String appAlias) throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 4c115da08c..9dce3037aa 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -301,7 +301,7 @@ private void persistCompositeAppSubscription (ApplicationSubscription compositeA if (compositeAppSubscription != null) { try { - cartridgeSubscriptionManager.persistCompositeAppSubscription(compositeAppSubscription); + cartridgeSubscriptionManager.persistApplicationSubscription(compositeAppSubscription); } catch (ADCException e) { throw new CompositeApplicationException(e); 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 index da820b4650..c3b27c7bab 100644 --- 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 @@ -96,19 +96,19 @@ public ApplicationSubscription createApplicationSubscription (String appId, int } DataInsertionAndRetrievalManager dataInsertionAndRetrievalMgr = new DataInsertionAndRetrievalManager(); - ApplicationSubscription compositeAppSubscription; + ApplicationSubscription appSubscription; try { - compositeAppSubscription = dataInsertionAndRetrievalMgr.getCompositeAppSubscription(tenantId, appId); + 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); } - if (compositeAppSubscription != null) { + if (appSubscription != null) { // Composite App Subscription already exists with same app id - log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + " and tenantId: " + tenantId); + 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 { @@ -116,10 +116,10 @@ public ApplicationSubscription createApplicationSubscription (String appId, int log.debug("creating new application subscription for app:" + appId ); } - compositeAppSubscription = new ApplicationSubscription(appId); + appSubscription = new ApplicationSubscription(appId); // persist try { - persistCompositeAppSubscription(compositeAppSubscription); + this.persistApplicationSubscription(appSubscription); } catch (ADCException e) { // TODO Auto-generated catch block log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + @@ -130,6 +130,58 @@ public ApplicationSubscription createApplicationSubscription (String appId, int 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, @@ -191,10 +243,10 @@ public void persistGroupSubscription (GroupSubscription groupSubscription) throw } } - public void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws ADCException { + public void persistApplicationSubscription (ApplicationSubscription compositeAppSubscription) throws ADCException { try { - new DataInsertionAndRetrievalManager().persistCompositeAppSubscription(compositeAppSubscription); + new DataInsertionAndRetrievalManager().persistApplicationSubscription(compositeAppSubscription); } catch (PersistenceManagerException e) { throw new ADCException(e); 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 index 47709d0462..e4fb669206 100644 --- 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 @@ -395,17 +395,17 @@ public void removeGroupSubscription (int tenantId, String groupName, String grou persistenceManager.removeGroupSubscription(tenantId, groupName, groupAlias); } - public void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException { + public void persistApplicationSubscription (ApplicationSubscription compositeAppSubscription) throws PersistenceManagerException { persistenceManager.persistCompositeAppSubscription(compositeAppSubscription); } - public ApplicationSubscription getCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { + public ApplicationSubscription getApplicationSubscription (int tenantId, String appId) throws PersistenceManagerException { return persistenceManager.getCompositeAppSubscription(tenantId, appId); } - public void removeCompositeAppSubscription (int tenantId, String appId) throws PersistenceManagerException { + public void removeApplicationSubscription (int tenantId, String appId) throws PersistenceManagerException { persistenceManager.removeCompositeAppSubscription(tenantId, appId); } 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 index 0ff3dbbcb6..c3a57190ea 100644 --- 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 @@ -309,7 +309,7 @@ protected void onEvent(Event event) { carbonContext.setTenantId(tenantId); // create Application Subscription and persist compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(appId, tenantId); - cartridgeSubscriptionManager.persistCompositeAppSubscription(compositeAppSubscription); + cartridgeSubscriptionManager.persistApplicationSubscription(compositeAppSubscription); } catch (ApplicationSubscriptionException e) { log.error("failed to persist application subscription, caught exception: " + e); } catch (ADCException e) { @@ -322,6 +322,48 @@ protected void onEvent(Event event) { } } }); + + //add listener + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { + @Override + protected void onEvent(Event event) { + + ApplicationRemovedEvent appRemovedEvent = (ApplicationRemovedEvent) event; + + log.info("[ApplicationRemovedEventListener] Received: " + event.getClass()); + + try { + TopologyManager.acquireReadLock(); + + // create and persist Application subscritpion + CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); + String appId = appRemovedEvent.getApplicationId(); + + 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(); + } + } + }); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java index c025fe6d5a..1e51321d31 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java @@ -21,13 +21,29 @@ public class ApplicationRemovedEvent extends TopologyEvent { - private String applicationId; + /** + * + */ + private static final long serialVersionUID = -5499420725533165623L; + private String applicationId; + private String tenantDomain; + private int tenantId; - public ApplicationRemovedEvent (String applicationId) { + public ApplicationRemovedEvent (String applicationId, int tenantId, String tenantDomain) { this.applicationId = applicationId; + this.tenantId = tenantId; + this.tenantDomain = tenantDomain; } public String getApplicationId() { return applicationId; } + + public int getTenantId() { + return tenantId; + } + + public String getTenantDomain() { + return tenantDomain; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java index e16e84e229..c9dbb07820 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -19,17 +19,83 @@ package org.apache.stratos.messaging.message.processor.topology; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; public class ApplicationRemovedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); + + private MessageProcessor nextProcessor; @Override public void setNext(MessageProcessor nextProcessor) { - //To change body of implemented methods use File | Settings | File Templates. + this.nextProcessor = nextProcessor; } @Override public boolean process(String type, String message, Object object) { - return false; //To change body of implemented methods use File | Settings | File Templates. + + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor processing " + object); + } + + Topology topology = (Topology) object; + + if (ApplicationRemovedEvent.class.getName().equals(type)) { + if (!topology.isInitialized()) { + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor topology not initialized ... " + object); + } + return false; + } + + ApplicationRemovedEvent appRemovedEvent = (ApplicationRemovedEvent) Util.jsonToObject(message, ApplicationRemovedEvent.class); + if (appRemovedEvent == null) { + log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); + return false; + } + + // check if required properties are available + if (appRemovedEvent.getApplicationId() == null) { + String errorMsg = "Application Id of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (appRemovedEvent.getTenantDomain()== null) { + String errorMsg = "Application tenant domain of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + String appId = appRemovedEvent.getApplicationId(); + if (topology.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); + topology.removeApplication(appId); + } + + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor notifying listener " + object); + } + + notifyEventListeners(appRemovedEvent); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 368552fb3f..4f102e3354 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -263,10 +263,28 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit // throw new RestAPIException(e); // } + // check if an application with same id already exists + + ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(compositeAppDefinition); applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); + + // check if application with same appId / tenant already exists + CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager(); + int tenantId = ApplicationManagementUtil.getTenantId(ctxt); + String appId = applicationContext.getApplicationId(); + + + try { + if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) { + String msg = "Duplicate application appId: " + appId + " for tenant " + tenantId; + throw new RestAPIException(msg); + } + } catch (ApplicationSubscriptionException e1) { + throw new RestAPIException(e1); + } try { CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); @@ -286,7 +304,8 @@ static void unDeployApplication(String appId, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { try { - CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId); + int tenantId = ApplicationManagementUtil.getTenantId(ctxt); + CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain); } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { throw new RestAPIException(e); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index d685bda12d..876fcd8bb2 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,8 +6,8 @@ - - + + @@ -15,15 +15,15 @@ - - - + + + - + @@ -37,9 +37,9 @@ - + - + @@ -61,251 +61,246 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + + + - + - + - + - + - + + + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -322,161 +317,204 @@ - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + - + + + + + + - + + + + + - + - - - - - - - - - - - - - + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + @@ -491,24 +529,11 @@ - - - - - - - - - - - - - + - - - - + + + @@ -520,55 +545,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + @@ -579,14 +564,14 @@ - + - + @@ -595,8 +580,9 @@ - + + @@ -604,55 +590,71 @@ - - + - - - + + + - + - - - - - + - - - - - - + - + + + + - + - - - + + - - - - + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -732,15 +734,15 @@ + + + - - - @@ -840,15 +842,15 @@ + + + + - - - - @@ -1016,15 +1018,6 @@ - - - - - - - - - @@ -1037,6 +1030,15 @@ + + + + + + + + + @@ -1262,15 +1264,6 @@ - - - - - - - - - @@ -1283,6 +1276,15 @@ + + + + + + + + + @@ -1469,12 +1471,6 @@ - - - - - - @@ -1484,6 +1480,12 @@ + + + + + + @@ -1556,22 +1558,22 @@ - + - + - + - + - + - + \ No newline at end of file From de369d9ac8475ba0f3a10c5d9d4884cb3334ac49 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 23 Sep 2014 12:59:35 +0530 Subject: [PATCH 086/436] temp. implementation of collecting payload data for each cluster --- .../pom.xml | 1 - .../application/ApplicationUtils.java | 38 +++++- .../parser/DefaultApplicationParser.java | 114 +++++++++++++++--- .../pojo/payload/PayloadDataHolder.java | 21 ++-- 4 files changed, 144 insertions(+), 30 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index 1f51c7de22..ce3c635395 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -76,7 +76,6 @@ org.apache.commons.logging; version=0.0.0, org.apache.commons.io.*, org.wso2.carbon.utils.*, - org.apache.stratos.metadata.client.*; version=0.0.0, *; resolution:=optional diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index ff7ef9f831..43f978611f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -25,6 +25,7 @@ import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import java.util.*; import java.util.regex.Pattern; @@ -68,13 +69,21 @@ public static Properties getGlobalPayloadData () { return globalProperties; } - public static PayloadDataHolder getClusterLevelPayloadData (String appId, Cluster cluster, + public static PayloadDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key, + Cluster cluster, SubscribableContext subscribableCtxt, - SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) { + SubscribableInfoContext subscribableInfoCtxt, + Cartridge cartridge) { PayloadDataHolder payloadDataHolder = new PayloadDataHolder(appId, subscribableCtxt.getType(), cluster.getClusterId()); Properties clusterLevelPayloadProperties = new Properties(); + // app id + clusterLevelPayloadProperties.setProperty("APP_ID", appId); + // group name + if (groupName != null) { + clusterLevelPayloadProperties.setProperty("GROUP_NAME", groupName); + } // service name if (subscribableCtxt.getType() != null) { clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType()); @@ -109,6 +118,12 @@ public static PayloadDataHolder getClusterLevelPayloadData (String appId, Cluste if (cartridge.getProvider() != null) { clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider()); } + // tenant id + clusterLevelPayloadProperties.setProperty("TENANT_ID", String.valueOf(tenantId)); + // cartridge key + clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key); + // get global payload params + clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); payloadDataHolder.setProperties(clusterLevelPayloadProperties); return payloadDataHolder; @@ -128,4 +143,23 @@ private static String createPortMappingPayloadString (Cartridge cartridge) { return portMapBuilder.toString().replaceAll("\\|$", ""); } + + public static StringBuilder getTextPayload (String appId, String groupName, String clusterId) { + + StringBuilder payloadBuilder = new StringBuilder(); + payloadBuilder.append("APP_ID=" + appId); + if (groupName != null) { + payloadBuilder.append(","); + payloadBuilder.append("GROUP_NAME=" + groupName); + } + payloadBuilder.append(","); + payloadBuilder.append("CLUSTER_ID=" + clusterId); + // meta data endpoint + if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { + payloadBuilder.append(","); + payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); + } + + return payloadBuilder; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 225fab9837..e1cd35c566 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -26,14 +26,18 @@ import org.apache.stratos.cloud.controller.application.MTClusterInformation; import org.apache.stratos.cloud.controller.application.STClusterInformation; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.exception.CloudControllerException; import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.application.*; import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; +import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.StartupOrder; +import org.apache.stratos.messaging.util.Constants; +import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; import java.util.Properties; @@ -42,6 +46,8 @@ public class DefaultApplicationParser implements ApplicationParser { private static Log log = LogFactory.getLog(DefaultApplicationParser.class); + private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); + @Override public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionException { @@ -193,15 +199,17 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app if (appCtxt.getComponents() != null) { // get top level Subscribables if (appCtxt.getComponents().getSubscribableContexts() != null) { - clusterDataHolder = getClusterInformation(appCtxt.getApplicationId(), - Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); + clusterDataHolder = getClusterInformation(appCtxt.getApplicationId(), appCtxt.getTenantId(), + application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), + subscribableInfoCtxts); application.setClusterIds(clusterDataHolder.getClusterIdMap()); //clusters.addAll(clusterDataHolder.getClusters()); } // get Groups if (appCtxt.getComponents().getGroupContexts() != null) { - application.setGroups(getGroupInfo(appCtxt.getApplicationId(), clusterDataHolder, + application.setGroups(getGroupInfo(appCtxt.getApplicationId(), appCtxt.getTenantId(), + application.getKey(), clusterDataHolder, Arrays.asList(appCtxt.getComponents().getGroupContexts()), subscribableInfoCtxts, definedGroupCtxts)); } @@ -222,23 +230,20 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); - // collect and set application level payload information - Properties appLevelProperties = new Properties(); - appLevelProperties.setProperty("TENANT_ID", String.valueOf(appCtxt.getTenantId())); - appLevelProperties.setProperty("CARTRIDGE_KEY", application.getKey()); - // get global payload data - appLevelProperties.putAll(ApplicationUtils.getGlobalPayloadData()); - ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); assert clusterDataHolder != null; applicationDataHolder.setClusters(clusterDataHolder.getClusters()); applicationDataHolder.setPayloadDataHolders(clusterDataHolder.getPayloadDataHolders()); applicationDataHolder.setApplication(application); + // persist the information in FasterLookUpDataHolder + persist(dataHolder); + return applicationDataHolder; } - private Map getGroupInfo (String appId, ClusterDataHolder clusterDataHolder, List groupCtxts, + private Map getGroupInfo (String appId, int tenantId, String key, + ClusterDataHolder clusterDataHolder, List groupCtxts, Map subscribableInformation, Map definedGroupCtxts) throws ApplicationDefinitionException { @@ -246,7 +251,7 @@ private Map getGroupInfo (String appId, ClusterDataHolder cluster Map groupNameToGroup = new HashMap(); for (GroupContext groupCtxt : groupCtxts) { - Group group = getGroup(appId, clusterDataHolder, groupCtxt, subscribableInformation, definedGroupCtxts); + Group group = getGroup(appId, tenantId, key, clusterDataHolder, groupCtxt, subscribableInformation, definedGroupCtxts); if(groupNameToGroup.put(group.getName(), group) != null) { // Application Definition has same Group multiple times at the top-level handleError("Group [ " + group.getName() + " ] appears twice in the Application Definition's top level"); @@ -293,8 +298,9 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr } } - private Group getGroup(String appId, ClusterDataHolder clusterDataHolder, GroupContext groupCtxt, Map subscribableInfoCtxts, Map definedGroupCtxts) + private Group getGroup(String appId, int tenantId, String key, ClusterDataHolder clusterDataHolder, + GroupContext groupCtxt, Map subscribableInfoCtxts, + Map definedGroupCtxts) throws ApplicationDefinitionException { // check if are in the defined Group set @@ -321,7 +327,7 @@ private Group getGroup(String appId, ClusterDataHolder clusterDataHolder, GroupC // get group level Subscribables if (groupCtxt.getSubscribableContexts() != null) { - clusterDataHolderOfGroup = getClusterInformation(appId, + clusterDataHolderOfGroup = getClusterInformation(appId, tenantId, key, groupCtxt.getName(), Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); group.setClusterIds(clusterDataHolderOfGroup.getClusterIdMap()); //clusters.addAll(clusterDataHolderOfGroup.getClusters()); @@ -341,7 +347,8 @@ private Group getGroup(String appId, ClusterDataHolder clusterDataHolder, GroupC for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) { // get the complete Group Definition subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); - Group nestedGroup = getGroup(appId, clusterDataHolder, subGroupCtxt, subscribableInfoCtxts, + Group nestedGroup = getGroup(appId, tenantId, key, clusterDataHolder, subGroupCtxt, + subscribableInfoCtxts, definedGroupCtxts); nestedGroups.put(nestedGroup.getName(), nestedGroup); } @@ -435,8 +442,9 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi // return subscribableContexts; // } - private ClusterDataHolder getClusterInformation (String appId, List subscribableCtxts, - Map subscribableInfoCtxts) + private ClusterDataHolder getClusterInformation (String appId, int tenantId, String key, String groupName, + List subscribableCtxts, + Map subscribableInfoCtxts) throws ApplicationDefinitionException { Map clusterIdMap = new HashMap(); @@ -471,7 +479,10 @@ private ClusterDataHolder getClusterInformation (String appId, List Date: Tue, 23 Sep 2014 17:56:56 +0530 Subject: [PATCH 087/436] fix registry resource null exception --- .../apache/stratos/metadataservice/registry/CarbonRegistry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9886c97d5c..8078f91b1b 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 @@ -254,7 +254,7 @@ public void addPropertyToApplication(String applicationId, NewProperty property) String resourcePath = mainResource + applicationId; Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); - tempRegistry.put(regResource.getPath(), regResource); + tempRegistry.put(resourcePath, regResource); } public List getPropertiesOfApplication(String applicationId) throws RegistryException { From f6584b46fda8486a6b95df26032baa8cad656009 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 23 Sep 2014 19:21:17 +0530 Subject: [PATCH 088/436] allowing multiple same type Cartridges and Groups at the top level --- .../grouping/DependencyBuilder.java | 10 ++- .../stratos/autoscaler/monitor/Monitor.java | 23 ++--- .../status/checker/StatusChecker.java | 25 +++--- .../parser/DefaultApplicationParser.java | 34 ++++++-- .../controller/pojo/ClusterDataHolder.java | 8 +- .../controller/topology/TopologyBuilder.java | 11 ++- .../domain/topology/Application.java | 86 ++++++++++--------- .../messaging/domain/topology/Group.java | 86 ++++++++++--------- .../domain/topology/ParentBehavior.java | 15 ++-- .../topology/ApplicationCreatedEvent.java | 2 +- 10 files changed, 166 insertions(+), 134 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index ebb683cc20..a021ce3685 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -59,15 +59,17 @@ public static Queue getStartupOrder(ParentBehavior component) { } } //TODO adding all the missed groups or clusters as the top child to the list - for(Group group: component.getGroupMap().values()) { + for(Group group: component.getAliasToGroupMap().values()) { if(!startup.contains(group.getAlias())) { startup.add(group.getAlias()); } } - for(String clusterId: component.getClusterIdMap().values()) { - if(!startup.contains(clusterId)) { - startup.add(clusterId); + for(Set clusterIds: component.getServiceNameToClusterIdsMap().values()) { + for (String clusterId : clusterIds) { + if(!startup.contains(clusterId)) { + startup.add(clusterId); + } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index ef0d750b73..6b299ef3e0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -27,10 +27,8 @@ import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.ParentBehavior; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -124,15 +122,18 @@ public void startDependency() { if (dependency.contains("group")) { startGroupMonitor(this, dependency, component); } else if (dependency.contains("cartridge")) { - String clusterId = component.getClusterId(dependency); - Cluster cluster = null; - TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); - TopologyManager.releaseReadLock(); - if (cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent + + Set clusterIds = component.getClusterIds(dependency); + for (String clusterId : clusterIds) { + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if (cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } } } } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 79da514bf9..e410259a32 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.Map; +import java.util.Set; /** * This will be used to evaluate the status of a group @@ -105,8 +106,8 @@ private void updateChild(final String clusterId, final String appId) { Runnable exGroup = new Runnable() { public void run() { Application application = TopologyManager.getTopology().getApplication(appId); - Map clusterIds = application.getClusterMap(); - Map groups = application.getGroupMap(); + Map> clusterIds = application.getClusterMap(); + Map groups = application.getAliasToGroupMap(); updateChildStatus(clusterId, groups, clusterIds, application); } }; @@ -154,7 +155,7 @@ public void run() { } - private boolean updateChildStatus(String id, Map groups, Map clusterIds, ParentBehavior parent) { + private boolean updateChildStatus(String id, Map groups, Map> clusterIds, ParentBehavior parent) { boolean groupActive = false; boolean clustersActive = false; boolean groupsActive = false; @@ -185,7 +186,7 @@ private boolean updateChildStatus(String id, Map groups, Map groups) { } - private boolean getClusterStatus(Map clusterIds) { + private boolean getClusterStatus(Map> clusterIds) { boolean clusterActiveStatus = false; - for(Map.Entry clusterId: clusterIds.entrySet()) { - Service service = TopologyManager.getTopology().getService(clusterId.getKey()); - if(service.getCluster(clusterId.getValue()).getStatus().equals(ClusterStatus.Active)) { - clusterActiveStatus = true; - } else { - clusterActiveStatus = false; + for(Map.Entry> clusterIdsEntry: clusterIds.entrySet()) { + Service service = TopologyManager.getTopology().getService(clusterIdsEntry.getKey()); + for (String clusterId : clusterIdsEntry.getValue()) { + if(service.getCluster(clusterId).getStatus().equals(ClusterStatus.Active)) { + clusterActiveStatus = true; + } else { + clusterActiveStatus = false; + } } } return clusterActiveStatus; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index e1cd35c566..a6939422f1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -252,10 +252,11 @@ private Map getGroupInfo (String appId, int tenantId, String key, for (GroupContext groupCtxt : groupCtxts) { Group group = getGroup(appId, tenantId, key, clusterDataHolder, groupCtxt, subscribableInformation, definedGroupCtxts); - if(groupNameToGroup.put(group.getName(), group) != null) { - // Application Definition has same Group multiple times at the top-level - handleError("Group [ " + group.getName() + " ] appears twice in the Application Definition's top level"); - } + groupNameToGroup.put(group.getName(), group); +// if(groupNameToGroup.put(group.getName(), group) != null) { +// // Application Definition has same Group multiple times at the top-level +// handleError("Group [ " + group.getName() + " ] appears twice in the Application Definition's top level"); +// } } //Set topLevelGroupContexts = getTopLevelGroupContexts(groupNameToGroup); @@ -447,7 +448,7 @@ private ClusterDataHolder getClusterInformation (String appId, int tenantId, Str Map subscribableInfoCtxts) throws ApplicationDefinitionException { - Map clusterIdMap = new HashMap(); + Map> clusterIdMap = new HashMap>(); Set clusters = new HashSet(); Set payloadDataHolders = new HashSet(); @@ -473,11 +474,13 @@ private ClusterDataHolder getClusterInformation (String appId, int tenantId, Str } Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); + addClusterId(clusterIdMap, subscribableCtxt.getType(), cluster.getClusterId()); + //clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()); clusters.add(cluster); - if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { - // Application Definition has same cartridge multiple times at the top-level - handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); - } +// if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { +// // Application Definition has same cartridge multiple times at the top-level +// handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); +// } payloadDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, cluster, subscribableCtxt, subscribableInfoCtxt, cartridge)); @@ -491,6 +494,19 @@ private ClusterDataHolder getClusterInformation (String appId, int tenantId, Str return clusterDataHolder; } + public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { + + if (serviceNameToClusterIdsMap.get(serviceName) == null) { + // not found, create + Set clusterIds = new HashSet(); + clusterIds.add(clusterId); + serviceNameToClusterIdsMap.put(serviceName, clusterIds); + } else { + // the cluster id set already exists, update + serviceNameToClusterIdsMap.get(serviceName).add(clusterId); + } + } + private void createClusterContext (String appId, String groupName, String serviceType, String clusterId, String hostName) throws ApplicationDefinitionException { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java index 313265e1a8..af81c8e061 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java @@ -28,8 +28,8 @@ public class ClusterDataHolder { - // Cluster Id map, key = service name - private Map clusterIdMap; + // Cluster Ids map, key = service name + private Map> clusterIdMap; // Cluster object collection private Set clusters; @@ -37,12 +37,12 @@ public class ClusterDataHolder { // payload related information private Set payloadDataHolders; - public ClusterDataHolder (Map clusterIdMap, Set clusters) { + public ClusterDataHolder (Map> clusterIdMap, Set clusters) { this.clusterIdMap = clusterIdMap; this.clusters = clusters; } - public Map getClusterIdMap() { + public Map> getClusterIdMap() { return clusterIdMap; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 3974d55240..c958ec2aa8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -46,6 +46,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.Set; /** * this is to manipulate the received events by cloud controller @@ -659,14 +660,16 @@ public static void handleApplicationUndeployed (String applicationId, int tenant } else { Application application = topology.getApplication(applicationId); // remove clusters - for (Map.Entry clusterIdMapEntry : application.getClusterIdMap().entrySet()) { - Service service = topology.getService(clusterIdMapEntry.getKey()); - service.removeCluster(clusterIdMapEntry.getValue()); + for (Map.Entry> serviceNameToClusterIdEntry: + application.getServiceNameToClusterIdsMap().entrySet()) { + Service service = topology.getService(serviceNameToClusterIdEntry.getKey()); + for (String clusterId : serviceNameToClusterIdEntry.getValue()) { + service.removeCluster(clusterId); + } } // remove application topology.removeApplication(applicationId); - TopologyManager.updateTopology(topology); log.info("Removed application [ " + applicationId + " ] from Topology"); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 1f838889a4..55e37e65ee 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -21,9 +21,7 @@ import org.apache.commons.lang3.RandomStringUtils; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class Application implements ParentBehavior { @@ -40,10 +38,10 @@ public class Application implements ParentBehavior { private String tenantAdminUserName; // Dependency Order private DependencyOrder dependencyOrder; - // Group Map, key = Group.name - private Map groupMap; + // Group Map, key = Group.alias + private Map aliasToGroupMap; // Cluster Id map, key = service name - private Map clusterIdMap; + private Map> serviceNameToClusterIdsMap; // Application status private Status status; @@ -51,53 +49,53 @@ public Application (String id) { this.id = id; this.key = RandomStringUtils.randomAlphanumeric(16); this.status = Status.Created; - groupMap = new HashMap(); - clusterIdMap = new HashMap(); + aliasToGroupMap = new HashMap(); + serviceNameToClusterIdsMap = new HashMap>(); } @Override public void addGroup(Group group) { - groupMap.put(group.getName(), group); + aliasToGroupMap.put(group.getName(), group); } @Override public void setGroups(Map groupNameToGroup) { - groupMap.putAll(groupNameToGroup); + aliasToGroupMap.putAll(groupNameToGroup); } @Override public Group getGroup(String groupName) { - return groupMap.get(groupName); + return aliasToGroupMap.get(groupName); } @Override - public Map getGroupMap() { - return this.groupMap; + public Map getAliasToGroupMap() { + return this.aliasToGroupMap; } @Override - public Map getClusterMap() { - return this.clusterIdMap; + public Map> getClusterMap() { + return this.serviceNameToClusterIdsMap; } @Override public Group getGroupRecursively(String groupAlias) { - return travereAndCheckRecursively(groupMap.values(), groupAlias); + return travereAndCheckRecursively(aliasToGroupMap, groupAlias); } - private Group travereAndCheckRecursively (Collection groups, String groupAlias) { + private Group travereAndCheckRecursively (Map aliasToGroupMap, String groupAlias) { - for (Group group : groups) { - // check if alias is equal, if so, return - if (groupAlias.equals(group.getAlias())) { - return group; - } else { - // check if this Group has nested sub Groups. If so, traverse them as well - if (group.getGroups() != null) { - return travereAndCheckRecursively(group.getGroups(), groupAlias); + if (aliasToGroupMap.containsKey(groupAlias)) { + synchronized (aliasToGroupMap) { + if (aliasToGroupMap.containsKey(groupAlias)) { + return aliasToGroupMap.get(groupAlias); } } + } else { + for (Group group : aliasToGroupMap.values()) { + travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); + } } return null; @@ -105,7 +103,7 @@ private Group travereAndCheckRecursively (Collection groups, String group @Override public Collection getGroups() { - return groupMap.values(); + return aliasToGroupMap.values(); } @Override @@ -118,28 +116,34 @@ public DependencyOrder getDependencyOrder() { return dependencyOrder; } - @Override - public void addClusterId(String serviceName, String clusterId) { - clusterIdMap.put(serviceName, clusterId); - } - - @Override - public void setClusterIds(Map serviceNameToClusterId) { - clusterIdMap.putAll(serviceNameToClusterId); - } +// @Override +// public void addClusterId(String serviceName, String clusterId) { +// +// synchronized (serviceNameToClusterIdsMap) { +// if (serviceNameToClusterIdsMap.get(serviceName) == null) { +// // not found, create +// Set clusterIds = new HashSet(); +// clusterIds.add(clusterId); +// serviceNameToClusterIdsMap.put(serviceName, clusterIds); +// } else { +// // the cluster id set already exists, update +// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); +// } +// } +// } @Override - public String getClusterId(String serviceName) { - return clusterIdMap.get(serviceName); + public void setClusterIds(Map> serviceNameToClusterIds) { + serviceNameToClusterIdsMap.putAll(serviceNameToClusterIds); } @Override - public Collection getClusterIds() { - return clusterIdMap.values(); + public Set getClusterIds(String serviceName) { + return serviceNameToClusterIdsMap.get(serviceName); } - public Map getClusterIdMap () { - return clusterIdMap; + public Map> getServiceNameToClusterIdsMap() { + return serviceNameToClusterIdsMap; } public String getId() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index c6c1f78338..548aabdc60 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -19,9 +19,7 @@ package org.apache.stratos.messaging.domain.topology; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public class Group implements ParentBehavior { @@ -36,10 +34,10 @@ public class Group implements ParentBehavior { private String autoscalingPolicy; // Dependency Order private DependencyOrder dependencyOrder; - // Sub Group Map, key = Group.name - private Map groupMap; + // Sub Group Map, key = Group.alias + private Map aliasToGroupMap; // Cluster id map, key = service name - private Map clusterIdMap; + private Map> serviceNameToClusterIdsMap; // Group status private Status status; @@ -47,53 +45,53 @@ public Group (String name, String alias) { this.name = name; this.alias = alias; this.status = Status.Created; - groupMap = new HashMap(); - clusterIdMap = new HashMap(); + aliasToGroupMap = new HashMap(); + serviceNameToClusterIdsMap = new HashMap>(); } @Override public void addGroup(Group group) { - groupMap.put(group.name, group); + aliasToGroupMap.put(group.name, group); } @Override public void setGroups(Map groupNameToGroup) { - groupMap.putAll(groupNameToGroup); + aliasToGroupMap.putAll(groupNameToGroup); } @Override public Group getGroup(String groupName) { - return groupMap.get(groupName); + return aliasToGroupMap.get(groupName); } @Override - public Map getGroupMap() { - return this.groupMap; + public Map getAliasToGroupMap() { + return this.aliasToGroupMap; } @Override - public Map getClusterMap() { - return this.clusterIdMap; + public Map> getClusterMap() { + return this.serviceNameToClusterIdsMap; } @Override public Group getGroupRecursively(String groupAlias) { - return travereAndCheckRecursively(groupMap.values(), groupAlias); + return travereAndCheckRecursively(aliasToGroupMap, groupAlias); } - private Group travereAndCheckRecursively (Collection groups, String groupAlias) { + private Group travereAndCheckRecursively (Map aliasToGroupMap, String groupAlias) { - for (Group group : groups) { - // check if alias is equal, if so, return - if (groupAlias.equals(group.getAlias())) { - return group; - } else { - // check if this Group has nested sub Groups. If so, traverse them as well - if (group.getGroups() != null) { - return travereAndCheckRecursively(group.getGroups(), groupAlias); + if (aliasToGroupMap.containsKey(groupAlias)) { + synchronized (aliasToGroupMap) { + if (aliasToGroupMap.containsKey(groupAlias)) { + return aliasToGroupMap.get(groupAlias); } } + } else { + for (Group group : aliasToGroupMap.values()) { + travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); + } } return null; @@ -101,7 +99,7 @@ private Group travereAndCheckRecursively (Collection groups, String group @Override public Collection getGroups() { - return groupMap.values(); + return aliasToGroupMap.values(); } @Override @@ -114,28 +112,34 @@ public DependencyOrder getDependencyOrder() { return dependencyOrder; } - @Override - public void addClusterId(String serviceName, String clusterId) { - clusterIdMap.put(serviceName, clusterId); - } - - @Override - public void setClusterIds(Map serviceNameToClusterId) { - clusterIdMap.putAll(serviceNameToClusterId); - } +// @Override +// public void addClusterId(String serviceName, String clusterId) { +// +// synchronized (serviceNameToClusterIdsMap) { +// if (serviceNameToClusterIdsMap.get(serviceName) == null) { +// // not found, create +// Set clusterIds = new HashSet(); +// clusterIds.add(clusterId); +// serviceNameToClusterIdsMap.put(serviceName, clusterIds); +// } else { +// // the cluster id set already exists, update +// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); +// } +// } +// } @Override - public String getClusterId(String serviceName) { - return clusterIdMap.get(serviceName); + public void setClusterIds(Map> serviceNameToClusterIds) { + serviceNameToClusterIdsMap.putAll(serviceNameToClusterIds); } @Override - public Collection getClusterIds() { - return clusterIdMap.values(); + public Set getClusterIds(String serviceName) { + return serviceNameToClusterIdsMap.get(serviceName); } - public Map getClusterIdMap () { - return clusterIdMap; + public Map> getServiceNameToClusterIdsMap() { + return serviceNameToClusterIdsMap; } public String getName() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index a958ea82d0..bfad2aeade 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -22,6 +22,7 @@ import java.io.Serializable; import java.util.Collection; import java.util.Map; +import java.util.Set; public interface ParentBehavior extends Serializable { @@ -31,9 +32,9 @@ public interface ParentBehavior extends Serializable { public Group getGroup (String groupName); - public Map getGroupMap(); + public Map getAliasToGroupMap(); - public Map getClusterMap(); + public Map> getClusterMap(); public Group getGroupRecursively (String groupAlias); @@ -43,13 +44,11 @@ public interface ParentBehavior extends Serializable { public DependencyOrder getDependencyOrder (); - public void addClusterId (String serviceName, String clusterId); +// public void addClusterId (String serviceName, String clusterId); - public void setClusterIds (Map serviceNameToClusterId); + public void setClusterIds (Map> serviceNameToClusterIds); - public String getClusterId (String serviceName); + public Set getClusterIds(String serviceName); - public Collection getClusterIds (); - - public Map getClusterIdMap (); + public Map> getServiceNameToClusterIdsMap(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index b336d9ac46..3674eb3cee 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -35,6 +35,6 @@ public Application getApplication() { public String toString() { return "ApplicationCreatedEvent [app id= " + application.getId() + ", groups= " + application.getGroups() + ", clusters= " + - application.getClusterIds() + "]"; + application.getClusterMap().values() + "]"; } } From 0434c2ffd39238a79cdd9ad735d84d8310cba9f6 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 01:09:15 +0530 Subject: [PATCH 089/436] refactoring App definition parsing logic - part 1 --- .../application/ApplicationUtils.java | 31 +- .../parser/DefaultApplicationParser.java | 363 ++++++++++-------- .../impl/CloudControllerServiceImpl.java | 18 +- .../interfaces/ApplicationParser.java | 11 +- .../internal/CloudControllerDSComponent.java | 2 + .../pojo/ApplicationClusterContext.java | 116 ++++++ .../pojo/ApplicationDataHolder.java | 12 +- .../controller/pojo/ClusterDataHolder.java | 122 +++--- ...oadDataHolder.java => MetaDataHolder.java} | 8 +- .../controller/topology/TopologyBuilder.java | 36 +- 10 files changed, 456 insertions(+), 263 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/{PayloadDataHolder.java => MetaDataHolder.java} (90%) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 43f978611f..ce9b112157 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -23,8 +23,7 @@ import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; -import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; -import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import java.util.*; @@ -69,13 +68,13 @@ public static Properties getGlobalPayloadData () { return globalProperties; } - public static PayloadDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key, - Cluster cluster, + public static MetaDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key, + String hostname, String tenantRange, String clusterId, SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) { - PayloadDataHolder payloadDataHolder = new PayloadDataHolder(appId, subscribableCtxt.getType(), cluster.getClusterId()); + MetaDataHolder metaDataHolder = new MetaDataHolder(appId, subscribableCtxt.getType(), clusterId); Properties clusterLevelPayloadProperties = new Properties(); // app id @@ -89,22 +88,22 @@ public static PayloadDataHolder getClusterLevelPayloadData (String appId, String clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType()); } // host name - if (cluster.getHostNames().get(0) != null) { - clusterLevelPayloadProperties.put("HOST_NAME", cluster.getHostNames().get(0)); + if (hostname != null) { + clusterLevelPayloadProperties.put("HOST_NAME", hostname); } // multi tenant clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant())); // tenant range - if (cluster.getTenantRange() != null) { - clusterLevelPayloadProperties.put("TENANT_RANGE", cluster.getTenantRange()); + if (tenantRange != null) { + clusterLevelPayloadProperties.put("TENANT_RANGE", tenantRange); } // cartridge alias if (subscribableCtxt.getAlias() != null) { clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias()); } // cluster id - if (cluster.getClusterId() != null) { - clusterLevelPayloadProperties.put("CLUSTER_ID", cluster.getClusterId()); + if (clusterId != null) { + clusterLevelPayloadProperties.put("CLUSTER_ID", clusterId); } // repo url if (subscribableInfoCtxt.getRepoUrl() != null) { @@ -125,8 +124,8 @@ public static PayloadDataHolder getClusterLevelPayloadData (String appId, String // get global payload params clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); - payloadDataHolder.setProperties(clusterLevelPayloadProperties); - return payloadDataHolder; + metaDataHolder.setProperties(clusterLevelPayloadProperties); + return metaDataHolder; } private static String createPortMappingPayloadString (Cartridge cartridge) { @@ -156,9 +155,11 @@ public static StringBuilder getTextPayload (String appId, String groupName, Stri payloadBuilder.append("CLUSTER_ID=" + clusterId); // meta data endpoint if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { - payloadBuilder.append(","); - payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); + // TODO + //payloadBuilder.append(","); + //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); } + payloadBuilder.append(","); return payloadBuilder; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index a6939422f1..341f42aa5d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -26,30 +26,35 @@ import org.apache.stratos.cloud.controller.application.MTClusterInformation; import org.apache.stratos.cloud.controller.application.STClusterInformation; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.exception.CloudControllerException; import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.application.*; -import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; -import org.apache.stratos.cloud.controller.registry.RegistryManager; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.StartupOrder; -import org.apache.stratos.messaging.util.Constants; -import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; -import java.util.Properties; public class DefaultApplicationParser implements ApplicationParser { private static Log log = LogFactory.getLog(DefaultApplicationParser.class); - private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); +// private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); + + private Set applicationClusterContexts; + + private Set metaDataHolders; + + public DefaultApplicationParser () { + + this.applicationClusterContexts = new HashSet(); + this.metaDataHolders = new HashSet(); + } @Override - public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionException { + public Application parse(Object obj) throws ApplicationDefinitionException { ApplicationContext applicationCtxt = null; @@ -99,6 +104,16 @@ public ApplicationDataHolder parse(Object obj) throws ApplicationDefinitionExcep return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); } + @Override + public Set getApplicationClusterContexts() throws ApplicationDefinitionException { + return applicationClusterContexts; + } + + @Override + public Set getPayloadData() throws ApplicationDefinitionException { + return metaDataHolders; + } + private Map getDefinedGroups (ApplicationContext appCtxt) throws ApplicationDefinitionException { @@ -180,7 +195,7 @@ private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefi return FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName) != null; } - private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext appCtxt, + private Application buildCompositeAppStructure (ApplicationContext appCtxt, Map definedGroupCtxts, Map subscribableInfoCtxts) throws ApplicationDefinitionException { @@ -194,24 +209,24 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app // following keeps track of all Clusters created for this application //Set clusters = new HashSet(); - ClusterDataHolder clusterDataHolder = null; + //ClusterDataHolder clusterDataHolder = null; + Map> serviceNameToClusterIds; if (appCtxt.getComponents() != null) { // get top level Subscribables if (appCtxt.getComponents().getSubscribableContexts() != null) { - clusterDataHolder = getClusterInformation(appCtxt.getApplicationId(), appCtxt.getTenantId(), + serviceNameToClusterIds = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); - application.setClusterIds(clusterDataHolder.getClusterIdMap()); - //clusters.addAll(clusterDataHolder.getClusters()); + application.setClusterIds(serviceNameToClusterIds); + //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); } // get Groups if (appCtxt.getComponents().getGroupContexts() != null) { - application.setGroups(getGroupInfo(appCtxt.getApplicationId(), appCtxt.getTenantId(), - application.getKey(), clusterDataHolder, - Arrays.asList(appCtxt.getComponents().getGroupContexts()), subscribableInfoCtxts, - definedGroupCtxts)); + application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(), + application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()), + subscribableInfoCtxts, definedGroupCtxts)); } // get top level Dependency definitions @@ -230,41 +245,38 @@ private ApplicationDataHolder buildCompositeAppStructure (ApplicationContext app log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); - ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); - assert clusterDataHolder != null; - applicationDataHolder.setClusters(clusterDataHolder.getClusters()); - applicationDataHolder.setPayloadDataHolders(clusterDataHolder.getPayloadDataHolders()); - applicationDataHolder.setApplication(application); + return application; + + //ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); + //assert clusterDataHolder != null; + //applicationDataHolder.setClusters(clusterDataHolder.getApplicationClusterContexts()); + //applicationDataHolder.setPayloadDataHolders(clusterDataHolder.getPayloadDataHolders()); + //applicationDataHolder.setApplication(application); // persist the information in FasterLookUpDataHolder - persist(dataHolder); + //persist(dataHolder); - return applicationDataHolder; + //return applicationDataHolder; } - private Map getGroupInfo (String appId, int tenantId, String key, - ClusterDataHolder clusterDataHolder, List groupCtxts, - Map subscribableInformation, - Map definedGroupCtxts) + private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, + Map subscribableInformation, + Map definedGroupCtxts) throws ApplicationDefinitionException { - Map groupNameToGroup = new HashMap(); + Map groupAliasToGroup = new HashMap(); for (GroupContext groupCtxt : groupCtxts) { - Group group = getGroup(appId, tenantId, key, clusterDataHolder, groupCtxt, subscribableInformation, definedGroupCtxts); - groupNameToGroup.put(group.getName(), group); -// if(groupNameToGroup.put(group.getName(), group) != null) { -// // Application Definition has same Group multiple times at the top-level -// handleError("Group [ " + group.getName() + " ] appears twice in the Application Definition's top level"); -// } + Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts); + groupAliasToGroup.put(group.getAlias(), group); } - //Set topLevelGroupContexts = getTopLevelGroupContexts(groupNameToGroup); + //Set topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup); Set nestedGroups = new HashSet(); - getNestedGroupContexts(nestedGroups, groupNameToGroup.values()); - filterDuplicatedGroupContexts(groupNameToGroup.values(), nestedGroups); + getNestedGroupContexts(nestedGroups, groupAliasToGroup.values()); + filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups); - return groupNameToGroup; + return groupAliasToGroup; } private void getNestedGroupContexts (Set nestedGroups, Collection groups) { @@ -299,9 +311,9 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr } } - private Group getGroup(String appId, int tenantId, String key, ClusterDataHolder clusterDataHolder, - GroupContext groupCtxt, Map subscribableInfoCtxts, - Map definedGroupCtxts) + private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, + Map subscribableInfoCtxts, + Map definedGroupCtxts) throws ApplicationDefinitionException { // check if are in the defined Group set @@ -324,21 +336,22 @@ private Group getGroup(String appId, int tenantId, String key, ClusterDataHolder dependencyOrder.setKillbehavior(getKillbehaviour(groupCtxt.getName())); group.setDependencyOrder(dependencyOrder); - ClusterDataHolder clusterDataHolderOfGroup; + //ClusterDataHolder clusterDataHolderOfGroup; + Map> serviceNameToClusterIds; // get group level Subscribables if (groupCtxt.getSubscribableContexts() != null) { - clusterDataHolderOfGroup = getClusterInformation(appId, tenantId, key, groupCtxt.getName(), + serviceNameToClusterIds = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); - group.setClusterIds(clusterDataHolderOfGroup.getClusterIdMap()); - //clusters.addAll(clusterDataHolderOfGroup.getClusters()); - if (clusterDataHolder == null) { - clusterDataHolder = clusterDataHolderOfGroup; - } else { - clusterDataHolder.getClusters().addAll(clusterDataHolderOfGroup.getClusters()); - clusterDataHolder.getClusterIdMap().putAll(clusterDataHolderOfGroup.getClusterIdMap()); - clusterDataHolder.getPayloadDataHolders().addAll(clusterDataHolderOfGroup.getPayloadDataHolders()); - } + group.setClusterIds(serviceNameToClusterIds); + //clusters.addAll(clusterDataHolderOfGroup.getApplicationClusterContexts()); +// if (clusterDataHolder == null) { +// clusterDataHolder = clusterDataHolderOfGroup; +// } else { +// clusterDataHolder.getApplicationClusterContexts().addAll(clusterDataHolderOfGroup.getApplicationClusterContexts()); +// clusterDataHolder.getClusterIdMap().putAll(clusterDataHolderOfGroup.getClusterIdMap()); +// //clusterDataHolder.getPayloadDataHolders().addAll(clusterDataHolderOfGroup.getPayloadDataHolders()); +// } } // get nested groups @@ -348,7 +361,7 @@ private Group getGroup(String appId, int tenantId, String key, ClusterDataHolder for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) { // get the complete Group Definition subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); - Group nestedGroup = getGroup(appId, tenantId, key, clusterDataHolder, subGroupCtxt, + Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, subscribableInfoCtxts, definedGroupCtxts); nestedGroups.put(nestedGroup.getName(), nestedGroup); @@ -443,16 +456,17 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi // return subscribableContexts; // } - private ClusterDataHolder getClusterInformation (String appId, int tenantId, String key, String groupName, - List subscribableCtxts, - Map subscribableInfoCtxts) + private Map> parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, + List subscribableCtxts, + Map subscribableInfoCtxts) throws ApplicationDefinitionException { Map> clusterIdMap = new HashMap>(); - Set clusters = new HashSet(); - Set payloadDataHolders = new HashSet(); +// Set clusters = new HashSet(); + //Set payloadDataHolders = new HashSet(); for (SubscribableContext subscribableCtxt : subscribableCtxts) { + // check is there is a related Subscribable Information SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); if (subscribableInfoCtxt == null) { @@ -473,25 +487,56 @@ private ClusterDataHolder getClusterInformation (String appId, int tenantId, Str " ] for Composite Application"); } - Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); - addClusterId(clusterIdMap, subscribableCtxt.getType(), cluster.getClusterId()); + // get hostname and cluster id + ClusterInformation clusterInfo; + assert cartridge != null; + if (cartridge.isMultiTenant()) { + clusterInfo = new MTClusterInformation(); + } else { + clusterInfo = new STClusterInformation(); + } + + String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); + String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); + + // create and collect this cluster's information + assert subscribableInfoCtxt != null; + ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(subscribableCtxt.getType(), + appId, groupName, clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false); + this.applicationClusterContexts.add(appClusterCtxt); + + // create cluster level meta data + this.metaDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, + hostname, appClusterCtxt.getTenantRange(), clusterId, subscribableCtxt, subscribableInfoCtxt, cartridge)); + //////////// + //Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); + addClusterId(clusterIdMap, subscribableCtxt.getType(), clusterId); //clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()); - clusters.add(cluster); + //clusters.add(cluster); // if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { // // Application Definition has same cartridge multiple times at the top-level // handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); // } + /////////////// - payloadDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, cluster, - subscribableCtxt, subscribableInfoCtxt, cartridge)); - createClusterContext(appId, groupName, subscribableCtxt.getType(), cluster.getClusterId(), - cluster.getHostNames().get(0)); +// createClusterContext(appId, groupName, subscribableCtxt.getType(), cluster.getClusterId(), +// cluster.getHostNames().get(0)); } - ClusterDataHolder clusterDataHolder = new ClusterDataHolder(clusterIdMap, clusters); - clusterDataHolder.setPayloadDataHolders(payloadDataHolders); + return clusterIdMap; + //return new ClusterDataHolder(clusterIdMap, clusters); + //clusterDataHolder.setPayloadDataHolders(payloadDataHolders); + } + + private ApplicationClusterContext createApplicationClusterContext (String serviceType, String appId, + String groupName, String clusterId, + String hostname, String deploymentPolicy, + boolean isLB) { - return clusterDataHolder; + // Create text payload + String textPayload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); + + return new ApplicationClusterContext(serviceType, clusterId, hostname, textPayload, deploymentPolicy, isLB); } public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { @@ -507,95 +552,95 @@ public void addClusterId (Map> serviceNameToClusterIdsMap, S } } - private void createClusterContext (String appId, String groupName, String serviceType, String clusterId, - String hostName) throws ApplicationDefinitionException { - - Cartridge cartridge; - if ((cartridge = dataHolder.getCartridge(serviceType)) == null) { - - String msg = "Unregistered Cartridge type: " + serviceType; - log.error(msg); - throw new ApplicationDefinitionException(msg); - } - - //Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); - //String property = props.getProperty(Constants.IS_LOAD_BALANCER); - //boolean isLb = property != null ? Boolean.parseBoolean(property) : false; - String payload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); - - ClusterContext ctxt = buildClusterContext(cartridge, clusterId, - payload, hostName, null, false, null); - - dataHolder.addClusterContext(ctxt); - } - - private void persist(FasterLookUpDataHolder dataHolder) { - try { - RegistryManager.getInstance().persist( - dataHolder); - } catch (RegistryException e) { - - String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; - log.fatal(msg); - throw new CloudControllerException(msg, e); - } - } - - private ClusterContext buildClusterContext(Cartridge cartridge, - String clusterId, String payload, String hostName, - Properties props, boolean isLb, Persistence persistence) { - - - // initialize ClusterContext - ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, - hostName, isLb); - - String property = null; - if (props != null) { - property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); - } - - long timeout = property != null ? Long.parseLong(property) : 30000; - - boolean persistanceRequired = false; - if(persistence != null){ - persistanceRequired = persistence.isPersistanceRequired(); - } - - if(persistanceRequired){ - ctxt.setVolumes(persistence.getVolumes()); - ctxt.setVolumeRequired(true); - }else{ - ctxt.setVolumeRequired(false); - } - ctxt.setTimeoutInMillis(timeout); - return ctxt; - } - - private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) - - throws ApplicationDefinitionException { - - // get hostname and cluster id - ClusterInformation clusterInfo; - if (cartridge.isMultiTenant()) { - clusterInfo = new MTClusterInformation(); - } else { - clusterInfo = new STClusterInformation(); - } - - String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); - String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); - - Cluster cluster = new Cluster(subscribableCtxt.getType(), clusterId, subscribableInfoCtxt.getDeploymentPolicy(), - subscribableInfoCtxt.getAutoscalingPolicy()); - - cluster.addHostName(hostname); - cluster.setLbCluster(false); - cluster.setStatus(Status.Created); - - return cluster; - } +// private void createClusterContext (String appId, String groupName, String serviceType, String clusterId, +// String hostName) throws ApplicationDefinitionException { +// +// Cartridge cartridge; +// if ((cartridge = dataHolder.getCartridge(serviceType)) == null) { +// +// String msg = "Unregistered Cartridge type: " + serviceType; +// log.error(msg); +// throw new ApplicationDefinitionException(msg); +// } +// +// //Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); +// //String property = props.getProperty(Constants.IS_LOAD_BALANCER); +// //boolean isLb = property != null ? Boolean.parseBoolean(property) : false; +// String payload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); +// +// ClusterContext ctxt = buildClusterContext(cartridge, clusterId, +// payload, hostName, null, false, null); +// +// dataHolder.addClusterContext(ctxt); +// } +// +// private void persist(FasterLookUpDataHolder dataHolder) { +// try { +// RegistryManager.getInstance().persist( +// dataHolder); +// } catch (RegistryException e) { +// +// String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; +// log.fatal(msg); +// throw new CloudControllerException(msg, e); +// } +// } +// +// private ClusterContext buildClusterContext(Cartridge cartridge, +// String clusterId, String payload, String hostName, +// Properties props, boolean isLb, Persistence persistence) { +// +// +// // initialize ClusterContext +// ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, +// hostName, isLb); +// +// String property = null; +// if (props != null) { +// property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); +// } +// +// long timeout = property != null ? Long.parseLong(property) : 30000; +// +// boolean persistanceRequired = false; +// if(persistence != null){ +// persistanceRequired = persistence.isPersistanceRequired(); +// } +// +// if(persistanceRequired){ +// ctxt.setVolumes(persistence.getVolumes()); +// ctxt.setVolumeRequired(true); +// }else{ +// ctxt.setVolumeRequired(false); +// } +// ctxt.setTimeoutInMillis(timeout); +// return ctxt; +// } +// +// private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) +// +// throws ApplicationDefinitionException { +// +// // get hostname and cluster id +// ClusterInformation clusterInfo; +// if (cartridge.isMultiTenant()) { +// clusterInfo = new MTClusterInformation(); +// } else { +// clusterInfo = new STClusterInformation(); +// } +// +// String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); +// String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); +// +// Cluster cluster = new Cluster(subscribableCtxt.getType(), clusterId, subscribableInfoCtxt.getDeploymentPolicy(), +// subscribableInfoCtxt.getAutoscalingPolicy()); +// Clo +// cluster.addHostName(hostname); +// cluster.setLbCluster(false); +// cluster.setStatus(Status.Created); +// +// return cluster; +// } // private GroupDataHolder getGroupInformation (List groupCtxts, // Map subscribableInformation, @@ -605,7 +650,7 @@ private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableIn // Set groupContexts = new HashSet(); // // for (GroupContext groupCtxt : groupCtxts) { -// groupContexts.add(getGroup(groupCtxt, subscribableInformation, definedGroupCtxts)); +// groupContexts.add(parseGroup(groupCtxt, subscribableInformation, definedGroupCtxts)); // } // // //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index f0971c3ab6..6f72e63676 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -43,6 +43,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; @@ -1427,12 +1428,21 @@ public ClusterContext getClusterContext (String clusterId) { public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationDataHolder applicationDataHolder = applicationParser.parse(applicationContext); + Application application = applicationParser.parse(applicationContext); - //TODO: publish the data to the meta data service - applicationDataHolder.getPayloadDataHolders(); + for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { + dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), + applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), + applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); + } + + //TODO: publish data to meta data service + applicationParser.getPayloadData(); - TopologyBuilder.handleApplicationDeployed(applicationDataHolder); + TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), + applicationParser.getPayloadData()); + + persist(); } @Override diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java index 48bae4f1a4..77cbe332ea 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java @@ -20,10 +20,17 @@ package org.apache.stratos.cloud.controller.interfaces; import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.pojo.ApplicationDataHolder; +import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.messaging.domain.topology.Application; +import java.util.Set; + public interface ApplicationParser { - public ApplicationDataHolder parse (Object obj) throws ApplicationDefinitionException; + public Application parse (Object obj) throws ApplicationDefinitionException; + + public Set getApplicationClusterContexts() throws ApplicationDefinitionException; + + public Set getPayloadData () throws ApplicationDefinitionException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index b1d6c6d63d..572e619490 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -89,6 +89,8 @@ protected void activate(ComponentContext context) { TopologySynchronizerTaskScheduler .schedule(ServiceReferenceHolder.getInstance() .getTaskService()); + + } catch (Throwable e) { log.error("******* Cloud Controller Service bundle is failed to activate ****", e); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java new file mode 100644 index 0000000000..fb37d99b0e --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.pojo; + +public class ApplicationClusterContext { + + // cluster id + private String clusterId; + // cartridge type + private String cartridgeType; + // payload as a String + private String textPayload; + // host name + private String hostName; + // flag to indicate LB cluster + private boolean isLbCluster; + // autoscaling policy + private String autoscalePolicyName; + // deployment policy + private String deploymentPolicyName; + // tenant rance + private String tenantRange; + + public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName, + String textPayload, String deploymentPolicyName, boolean isLbCluster) { + + this.cartridgeType = cartridgeType; + this.clusterId = clusterId; + this.hostName = hostName; + this.textPayload = textPayload; + this.deploymentPolicyName = deploymentPolicyName; + this.isLbCluster = isLbCluster; + this.tenantRange = "*"; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getCartridgeType() { + return cartridgeType; + } + + public void setCartridgeType(String cartridgeType) { + this.cartridgeType = cartridgeType; + } + + public String getTextPayload() { + return textPayload; + } + + public void setTextPayload(String textPayload) { + this.textPayload = textPayload; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public boolean isLbCluster() { + return isLbCluster; + } + + public void setLbCluster(boolean lbCluster) { + isLbCluster = lbCluster; + } + + public String getAutoscalePolicyName() { + return autoscalePolicyName; + } + + public void setAutoscalePolicyName(String autoscalePolicyName) { + this.autoscalePolicyName = autoscalePolicyName; + } + + public String getDeploymentPolicyName() { + return deploymentPolicyName; + } + + public void setDeploymentPolicyName(String deploymentPolicyName) { + this.deploymentPolicyName = deploymentPolicyName; + } + + public String getTenantRange() { + return tenantRange; + } + + public void setTenantRange(String tenantRange) { + this.tenantRange = tenantRange; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java index c1fa44b507..601f6257fa 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java @@ -19,7 +19,7 @@ package org.apache.stratos.cloud.controller.pojo; -import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -31,7 +31,7 @@ public class ApplicationDataHolder { private Set clusters; - private Set payloadDataHolders; + private Set metaDataHolders; public Application getApplication() { return application; @@ -49,11 +49,11 @@ public void setClusters(Set clusters) { this.clusters = clusters; } - public Set getPayloadDataHolders() { - return payloadDataHolders; + public Set getMetaDataHolders() { + return metaDataHolders; } - public void setPayloadDataHolders(Set payloadDataHolders) { - this.payloadDataHolders = payloadDataHolders; + public void setMetaDataHolders(Set metaDataHolders) { + this.metaDataHolders = metaDataHolders; } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java index af81c8e061..874d18e606 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java @@ -1,61 +1,61 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo; - -import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.metadata.client.pojo.DataContext; - -import java.util.Map; -import java.util.Set; - -public class ClusterDataHolder { - - // Cluster Ids map, key = service name - private Map> clusterIdMap; - - // Cluster object collection - private Set clusters; - - // payload related information - private Set payloadDataHolders; - - public ClusterDataHolder (Map> clusterIdMap, Set clusters) { - this.clusterIdMap = clusterIdMap; - this.clusters = clusters; - } - - public Map> getClusterIdMap() { - return clusterIdMap; - } - - public Set getClusters() { - return clusters; - } - - - public Set getPayloadDataHolders() { - return payloadDataHolders; - } - - public void setPayloadDataHolders(Set payloadDataHolders) { - this.payloadDataHolders = payloadDataHolders; - } -} +///* +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// */ +// +//package org.apache.stratos.cloud.controller.pojo; +// +//import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; +//import org.apache.stratos.messaging.domain.topology.Cluster; +//import org.apache.stratos.metadata.client.pojo.DataContext; +// +//import java.util.Map; +//import java.util.Set; +// +//public class ClusterDataHolder { +// +// // Cluster Ids map, key = service name +// private Map> clusterIdMap; +// +// // Cluster object collection +// private Set clusters; +// +//// // payload related information +//// private Set payloadDataHolders; +// +// public ClusterDataHolder (Map> clusterIdMap, Set clusters) { +// this.clusterIdMap = clusterIdMap; +// this.clusters = clusters; +// } +// +// public Map> getClusterIdMap() { +// return clusterIdMap; +// } +// +// public Set getApplicationClusterContexts() { +// return clusters; +// } +// +// +//// public Set getPayloadDataHolders() { +//// return payloadDataHolders; +//// } +//// +//// public void setPayloadDataHolders(Set payloadDataHolders) { +//// this.payloadDataHolders = payloadDataHolders; +//// } +//} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java similarity index 90% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java index 6f744534fb..8ab745ed65 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/PayloadDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java @@ -25,7 +25,7 @@ * Holds payload/meta data related to a cluster */ -public class PayloadDataHolder { +public class MetaDataHolder { private String appId; @@ -35,7 +35,7 @@ public class PayloadDataHolder { private Properties properties; - public PayloadDataHolder (String appId, String groupName, String clusterId) { + public MetaDataHolder(String appId, String groupName, String clusterId) { this.appId = appId; this.groupName = groupName; @@ -56,7 +56,7 @@ public String getClusterId() { public boolean equals(Object other) { - if(other == null || !(other instanceof PayloadDataHolder)) { + if(other == null || !(other instanceof MetaDataHolder)) { return false; } @@ -64,7 +64,7 @@ public boolean equals(Object other) { return true; } - PayloadDataHolder that = (PayloadDataHolder)other; + MetaDataHolder that = (MetaDataHolder)other; if (this.groupName == null || that.groupName == null) { return this.appId.equals(that.appId) && this.clusterId.equals(that.clusterId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index c958ec2aa8..a926411078 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -27,6 +27,7 @@ import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.Registrant; import org.apache.stratos.cloud.controller.pojo.*; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; @@ -612,34 +613,45 @@ public static void handleMemberSuspended() { } } - public static void handleApplicationDeployed(ApplicationDataHolder applicationDataHolder) { + public static void handleApplicationDeployed(Application application, + Set applicationClusterContexts, + Set metaDataHolders) { + + Topology topology = TopologyManager.getTopology(); try { TopologyManager.acquireWriteLock(); - if (topology.applicationExists(applicationDataHolder.getApplication().getId())) { - log.warn("Application with id [ " + applicationDataHolder.getApplication().getId() + " ] already exists in Topology"); + if (topology.applicationExists(application.getId())) { + log.warn("Application with id [ " + application.getId() + " ] already exists in Topology"); return; } - for (Cluster cluster : applicationDataHolder.getClusters()) { - String cartridgeType = cluster.getServiceName(); - Service service = topology.getService(cartridgeType); + for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { + Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), + applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), + applicationClusterContext.getAutoscalePolicyName()); + cluster.setStatus(Status.Created); + cluster.addHostName(applicationClusterContext.getHostName()); + cluster.setTenantRange(applicationClusterContext.getTenantRange()); + + Service service = topology.getService(applicationClusterContext.getCartridgeType()); if (service != null) { - topology.getService(cartridgeType).addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + applicationDataHolder.getApplication().getId()); + service.addCluster(cluster); + log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getId()); } else { - log.error("Service " + cartridgeType + " not found"); + log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); return; } } + // add to Topology and update - topology.addApplication(applicationDataHolder.getApplication()); + topology.addApplication(application); TopologyManager.updateTopology(topology); - log.info("Application with id [ " + applicationDataHolder.getApplication().getId() + " ] added to Topology successfully"); + log.info("Application with id [ " + application.getId() + " ] added to Topology successfully"); - TopologyEventPublisher.sendApplicationCreatedEvent(applicationDataHolder.getApplication()); + TopologyEventPublisher.sendApplicationCreatedEvent(application); } finally { TopologyManager.releaseWriteLock(); From fcf76766182a6c72343fe873fdd76e3edad91909 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 23 Sep 2014 19:46:09 -0700 Subject: [PATCH 090/436] Dynamic and Static ServiceGroup properties --- .../impl/CloudControllerServiceImpl.java | 22 +- .../interfaces/CloudControllerService.java | 4 + .../cloud/controller/pojo/ServiceGroup.java | 20 ++ .../definitions/ServiceGroupDefinition.java | 20 ++ .../grouping/definitions/StaticProperty.java | 54 ++++ .../deployer/DefaultServiceGroupDeployer.java | 31 +++ .../resources/CloudControllerService.wsdl | 248 +++++++++++++----- 7 files changed, 331 insertions(+), 68 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 6f72e63676..1a7df3ed0f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -56,7 +56,7 @@ import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; -import java.util.Properties; +//import ; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -391,6 +391,22 @@ public Dependencies getServiceGroupDependencies (String name) throws InvalidServ } return serviceGroup.getDependencies(); } + + public String [] getServiceGroupDynamicProperties (String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + return serviceGroup.getDynamicProperties(); + } + + public org.apache.stratos.cloud.controller.pojo.Property [] getServiceGroupStaticProperties (String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + return serviceGroup.getStaticProperties(); + } @Override public MemberContext startInstance(MemberContext memberContext) throws @@ -1071,7 +1087,7 @@ public boolean registerService(Registrant registrant) throw new UnregisteredCartridgeException(msg); } - Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); + java.util.Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; @@ -1091,7 +1107,7 @@ public boolean registerService(Registrant registrant) private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, - Properties props, boolean isLb, Persistence persistence) { + java.util.Properties props, boolean isLb, Persistence persistence) { // initialize ClusterContext diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 5301b14946..be3db2df16 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -58,6 +58,10 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException; public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException; + + public String [] getServiceGroupDynamicProperties (String name) throws InvalidServiceGroupException; + + public org.apache.stratos.cloud.controller.pojo.Property [] getServiceGroupStaticProperties (String name) throws InvalidServiceGroupException; /** * Validate a given {@link Partition} for basic property existence. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java index 45957f59cb..b630937404 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java @@ -34,6 +34,10 @@ public class ServiceGroup implements Serializable { private String [] cartridges; private Dependencies dependencies; + + private String [] dynamicProperties; + + private Property [] staticProperties; public String getName() { return name; @@ -66,4 +70,20 @@ public Dependencies getDependencies() { public void setDependencies(Dependencies dependencies) { this.dependencies = dependencies; } + + public String[] getDynamicProperties() { + return dynamicProperties; + } + + public void setDynamicProperties(String[] dynamicProperties) { + this.dynamicProperties = dynamicProperties; + } + + public Property[] getStaticProperties() { + return staticProperties; + } + + public void setStaticProperties(Property[] staticProperties) { + this.staticProperties = staticProperties; + } } 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 index ac8321ff19..3ff1e01ea8 100644 --- 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 @@ -31,6 +31,10 @@ public class ServiceGroupDefinition implements Serializable { private List subGroups; private List cartridges; + + private List dynamicProperties; + + private List staticProperties; private DependencyDefinitions dependencies; @@ -65,4 +69,20 @@ public DependencyDefinitions getDependencies() { public void setDependencies(DependencyDefinitions dependencies) { this.dependencies = dependencies; } + + public List getDynamicProperties() { + return dynamicProperties; + } + + public void setDynamicProperties(List dynamicProperties) { + this.dynamicProperties = dynamicProperties; + } + + public List getStaticProperties() { + return staticProperties; + } + + public void setStaticProperties(List staticProperties) { + this.staticProperties = staticProperties; + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java new file mode 100644 index 0000000000..3dbce8e0d1 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java @@ -0,0 +1,54 @@ +/* + * 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 = "staticProperty") +public class StaticProperty implements Serializable { + + /** + * + */ + private static final long serialVersionUID = -3404671418913923858L; + + 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; + } + + +} 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 index f944288953..b352e95606 100644 --- 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 @@ -26,6 +26,7 @@ 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.StaticProperty; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; @@ -241,6 +242,8 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro servicegroup.setName(serviceGroupDefinition.getName()); List subGroupsDef = serviceGroupDefinition.getSubGroups(); List cartridgesDef = serviceGroupDefinition.getCartridges(); + List dynamicPropertiesDef = serviceGroupDefinition.getDynamicProperties(); + List staticPropertiesDef = serviceGroupDefinition.getStaticProperties(); if (subGroupsDef == null) { subGroupsDef = new ArrayList(0); @@ -252,12 +255,15 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro String [] subGroups = new String[subGroupsDef.size()]; String [] cartridges = new String[cartridgesDef.size()]; + String [] dynamicProperties = new String[dynamicPropertiesDef.size()]; subGroups = subGroupsDef.toArray(subGroups); cartridges = cartridgesDef.toArray(cartridges); + dynamicProperties = dynamicPropertiesDef.toArray(dynamicProperties); servicegroup.setSubGroups(subGroups); servicegroup.setCartridges(cartridges); + servicegroup.setDynamicProperties(dynamicProperties); DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies(); if (depDefs != null) { @@ -278,6 +284,20 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro deps.setKillBehaviour(depDefs.getKillBehaviour()); servicegroup.setDependencies(deps); } + + List propDefs = serviceGroupDefinition.getStaticProperties(); + org.apache.stratos.cloud.controller.stub.pojo.Property[] props = + new org.apache.stratos.cloud.controller.stub.pojo.Property [propDefs.size()]; + + int i = 0; + for (StaticProperty propDef : propDefs) { + org.apache.stratos.cloud.controller.stub.pojo.Property prop = + new org.apache.stratos.cloud.controller.stub.pojo.Property(); + prop.setName(propDef.getName()); + prop.setValue(propDef.getValue()); + props[i] = prop; + } + servicegroup.setStaticProperties(props); return servicegroup; } @@ -288,6 +308,7 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup String [] cartridges = serviceGroup.getCartridges(); String [] subGroups = serviceGroup.getSubGroups(); Dependencies deps = serviceGroup.getDependencies(); + org.apache.stratos.cloud.controller.stub.pojo.Property [] props = serviceGroup.getStaticProperties(); if (deps != null) { DependencyDefinitions depsDef = new DependencyDefinitions(); @@ -309,6 +330,16 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup depsDef.setKillBehaviour(deps.getKillBehaviour()); servicegroupDef.setDependencies(depsDef); } + + if (props != null) { + List propDefs = new ArrayList(); + for (org.apache.stratos.cloud.controller.stub.pojo.Property prop : props) { + StaticProperty propDef = new StaticProperty(); + propDef.setName(prop.getName()); + propDef.setValue(prop.getValue()); + } + servicegroupDef.setStaticProperties(propDefs); + } List cartridgesDef = new ArrayList(Arrays.asList(cartridges)); List subGroupsDef = new ArrayList(Arrays.asList(subGroups)); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 876fcd8bb2..de633d1c32 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,8 +6,8 @@ - - + + @@ -15,15 +15,15 @@ - - - + + + - + @@ -37,9 +37,9 @@ - + - + @@ -117,10 +117,10 @@ - + - + @@ -129,13 +129,6 @@ - - - - - - - @@ -162,7 +155,14 @@ - + + + + + + + + @@ -176,7 +176,7 @@ - + @@ -190,7 +190,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -317,21 +317,49 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -389,38 +417,38 @@ - + - + - + - + - + - + - + - + - + @@ -439,7 +467,7 @@ - + @@ -455,12 +483,12 @@ - - + + - - - + + + @@ -475,16 +503,16 @@ - + - + - + @@ -496,7 +524,7 @@ - + @@ -507,14 +535,14 @@ - + - + @@ -545,15 +573,15 @@ - + - - + + @@ -564,14 +592,14 @@ - + - + @@ -582,7 +610,7 @@ - + @@ -590,11 +618,11 @@ - + - - - + + + @@ -610,15 +638,17 @@ - + + + - + @@ -640,7 +670,7 @@ - + @@ -652,8 +682,8 @@ - - + + @@ -668,6 +698,15 @@ + + + + + + + + + @@ -683,9 +722,6 @@ - - - @@ -743,6 +779,12 @@ + + + + + + @@ -797,6 +839,11 @@ + + + + + @@ -851,6 +898,11 @@ + + + + + @@ -910,6 +962,18 @@ + + + + + + + + + + + + @@ -1048,6 +1112,18 @@ + + + + + + + + + + + + @@ -1156,6 +1232,18 @@ + + + + + + + + + + + + @@ -1294,6 +1382,18 @@ + + + + + + + + + + + + @@ -1399,6 +1499,15 @@ + + + + + + + + + @@ -1492,6 +1601,15 @@ + + + + + + + + + From 718445a8a7ea0449c7ae03b0704649f1aab02a3b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 11:14:50 +0530 Subject: [PATCH 091/436] Revert "Dynamic and Static ServiceGroup properties" This reverts commit fcf76766182a6c72343fe873fdd76e3edad91909. --- .../impl/CloudControllerServiceImpl.java | 22 +- .../interfaces/CloudControllerService.java | 4 - .../cloud/controller/pojo/ServiceGroup.java | 20 -- .../definitions/ServiceGroupDefinition.java | 20 -- .../grouping/definitions/StaticProperty.java | 54 ---- .../deployer/DefaultServiceGroupDeployer.java | 31 --- .../resources/CloudControllerService.wsdl | 248 +++++------------- 7 files changed, 68 insertions(+), 331 deletions(-) delete mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 1a7df3ed0f..6f72e63676 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -56,7 +56,7 @@ import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; -//import ; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -391,22 +391,6 @@ public Dependencies getServiceGroupDependencies (String name) throws InvalidServ } return serviceGroup.getDependencies(); } - - public String [] getServiceGroupDynamicProperties (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - return serviceGroup.getDynamicProperties(); - } - - public org.apache.stratos.cloud.controller.pojo.Property [] getServiceGroupStaticProperties (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - return serviceGroup.getStaticProperties(); - } @Override public MemberContext startInstance(MemberContext memberContext) throws @@ -1087,7 +1071,7 @@ public boolean registerService(Registrant registrant) throw new UnregisteredCartridgeException(msg); } - java.util.Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); + Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; @@ -1107,7 +1091,7 @@ public boolean registerService(Registrant registrant) private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, - java.util.Properties props, boolean isLb, Persistence persistence) { + Properties props, boolean isLb, Persistence persistence) { // initialize ClusterContext diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index be3db2df16..5301b14946 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -58,10 +58,6 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException; public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException; - - public String [] getServiceGroupDynamicProperties (String name) throws InvalidServiceGroupException; - - public org.apache.stratos.cloud.controller.pojo.Property [] getServiceGroupStaticProperties (String name) throws InvalidServiceGroupException; /** * Validate a given {@link Partition} for basic property existence. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java index b630937404..45957f59cb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ServiceGroup.java @@ -34,10 +34,6 @@ public class ServiceGroup implements Serializable { private String [] cartridges; private Dependencies dependencies; - - private String [] dynamicProperties; - - private Property [] staticProperties; public String getName() { return name; @@ -70,20 +66,4 @@ public Dependencies getDependencies() { public void setDependencies(Dependencies dependencies) { this.dependencies = dependencies; } - - public String[] getDynamicProperties() { - return dynamicProperties; - } - - public void setDynamicProperties(String[] dynamicProperties) { - this.dynamicProperties = dynamicProperties; - } - - public Property[] getStaticProperties() { - return staticProperties; - } - - public void setStaticProperties(Property[] staticProperties) { - this.staticProperties = staticProperties; - } } 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 index 3ff1e01ea8..ac8321ff19 100644 --- 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 @@ -31,10 +31,6 @@ public class ServiceGroupDefinition implements Serializable { private List subGroups; private List cartridges; - - private List dynamicProperties; - - private List staticProperties; private DependencyDefinitions dependencies; @@ -69,20 +65,4 @@ public DependencyDefinitions getDependencies() { public void setDependencies(DependencyDefinitions dependencies) { this.dependencies = dependencies; } - - public List getDynamicProperties() { - return dynamicProperties; - } - - public void setDynamicProperties(List dynamicProperties) { - this.dynamicProperties = dynamicProperties; - } - - public List getStaticProperties() { - return staticProperties; - } - - public void setStaticProperties(List staticProperties) { - this.staticProperties = staticProperties; - } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.java deleted file mode 100644 index 3dbce8e0d1..0000000000 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/StaticProperty.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.grouping.definitions; - -import javax.xml.bind.annotation.XmlRootElement; -import java.io.Serializable; - -@XmlRootElement(name = "staticProperty") -public class StaticProperty implements Serializable { - - /** - * - */ - private static final long serialVersionUID = -3404671418913923858L; - - 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; - } - - -} 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 index b352e95606..f944288953 100644 --- 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 @@ -26,7 +26,6 @@ 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.StaticProperty; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; @@ -242,8 +241,6 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro servicegroup.setName(serviceGroupDefinition.getName()); List subGroupsDef = serviceGroupDefinition.getSubGroups(); List cartridgesDef = serviceGroupDefinition.getCartridges(); - List dynamicPropertiesDef = serviceGroupDefinition.getDynamicProperties(); - List staticPropertiesDef = serviceGroupDefinition.getStaticProperties(); if (subGroupsDef == null) { subGroupsDef = new ArrayList(0); @@ -255,15 +252,12 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro String [] subGroups = new String[subGroupsDef.size()]; String [] cartridges = new String[cartridgesDef.size()]; - String [] dynamicProperties = new String[dynamicPropertiesDef.size()]; subGroups = subGroupsDef.toArray(subGroups); cartridges = cartridgesDef.toArray(cartridges); - dynamicProperties = dynamicPropertiesDef.toArray(dynamicProperties); servicegroup.setSubGroups(subGroups); servicegroup.setCartridges(cartridges); - servicegroup.setDynamicProperties(dynamicProperties); DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies(); if (depDefs != null) { @@ -284,20 +278,6 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro deps.setKillBehaviour(depDefs.getKillBehaviour()); servicegroup.setDependencies(deps); } - - List propDefs = serviceGroupDefinition.getStaticProperties(); - org.apache.stratos.cloud.controller.stub.pojo.Property[] props = - new org.apache.stratos.cloud.controller.stub.pojo.Property [propDefs.size()]; - - int i = 0; - for (StaticProperty propDef : propDefs) { - org.apache.stratos.cloud.controller.stub.pojo.Property prop = - new org.apache.stratos.cloud.controller.stub.pojo.Property(); - prop.setName(propDef.getName()); - prop.setValue(propDef.getValue()); - props[i] = prop; - } - servicegroup.setStaticProperties(props); return servicegroup; } @@ -308,7 +288,6 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup String [] cartridges = serviceGroup.getCartridges(); String [] subGroups = serviceGroup.getSubGroups(); Dependencies deps = serviceGroup.getDependencies(); - org.apache.stratos.cloud.controller.stub.pojo.Property [] props = serviceGroup.getStaticProperties(); if (deps != null) { DependencyDefinitions depsDef = new DependencyDefinitions(); @@ -330,16 +309,6 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup depsDef.setKillBehaviour(deps.getKillBehaviour()); servicegroupDef.setDependencies(depsDef); } - - if (props != null) { - List propDefs = new ArrayList(); - for (org.apache.stratos.cloud.controller.stub.pojo.Property prop : props) { - StaticProperty propDef = new StaticProperty(); - propDef.setName(prop.getName()); - propDef.setValue(prop.getValue()); - } - servicegroupDef.setStaticProperties(propDefs); - } List cartridgesDef = new ArrayList(Arrays.asList(cartridges)); List subGroupsDef = new ArrayList(Arrays.asList(subGroups)); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index de633d1c32..876fcd8bb2 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,8 +6,8 @@ - - + + @@ -15,15 +15,15 @@ - - - + + + - + @@ -37,9 +37,9 @@ - + - + @@ -117,10 +117,10 @@ - + - + @@ -129,6 +129,13 @@ + + + + + + + @@ -155,14 +162,7 @@ - - - - - - - - + @@ -176,7 +176,7 @@ - + @@ -190,7 +190,7 @@ - + @@ -211,7 +211,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -317,49 +317,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -417,38 +389,38 @@ - + - + - + - + - + - + - + - + - + @@ -467,7 +439,7 @@ - + @@ -483,12 +455,12 @@ - - + + - - - + + + @@ -503,16 +475,16 @@ - + - + - + @@ -524,7 +496,7 @@ - + @@ -535,14 +507,14 @@ - + - + @@ -573,15 +545,15 @@ - + - - + + @@ -592,14 +564,14 @@ - + - + @@ -610,7 +582,7 @@ - + @@ -618,11 +590,11 @@ - + - - - + + + @@ -638,17 +610,15 @@ - - + - - + @@ -670,7 +640,7 @@ - + @@ -682,8 +652,8 @@ - - + + @@ -698,15 +668,6 @@ - - - - - - - - - @@ -722,6 +683,9 @@ + + + @@ -779,12 +743,6 @@ - - - - - - @@ -839,11 +797,6 @@ - - - - - @@ -898,11 +851,6 @@ - - - - - @@ -962,18 +910,6 @@ - - - - - - - - - - - - @@ -1112,18 +1048,6 @@ - - - - - - - - - - - - @@ -1232,18 +1156,6 @@ - - - - - - - - - - - - @@ -1382,18 +1294,6 @@ - - - - - - - - - - - - @@ -1499,15 +1399,6 @@ - - - - - - - - - @@ -1601,15 +1492,6 @@ - - - - - - - - - From 077fb4073ab285fe6fb82606add6998d17f977f5 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 13:11:02 +0530 Subject: [PATCH 092/436] refactoring the Application Topolopgy model - added Map [alias -> ClusterDataHolder] --- .../grouping/DependencyBuilder.java | 11 ++-- .../stratos/autoscaler/monitor/Monitor.java | 20 +++--- .../status/checker/StatusChecker.java | 27 ++++---- .../application/ApplicationUtils.java | 7 ++- .../parser/DefaultApplicationParser.java | 55 +++++++++-------- .../pojo/ApplicationDataHolder.java | 59 ------------------ .../controller/pojo/ClusterDataHolder.java | 61 ------------------- .../pojo/payload/MetaDataHolder.java | 5 ++ .../controller/topology/TopologyBuilder.java | 9 ++- .../domain/topology/Application.java | 34 +++++------ .../domain/topology/ClusterDataHolder.java | 44 +++++++++++++ .../messaging/domain/topology/Group.java | 22 +++---- .../domain/topology/ParentBehavior.java | 10 +-- .../topology/ApplicationCreatedEvent.java | 2 +- 14 files changed, 144 insertions(+), 222 deletions(-) delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index a021ce3685..4bd47a166c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -20,6 +20,7 @@ import org.apache.stratos.messaging.domain.topology.*; +import java.util.Collection; import java.util.LinkedList; import java.util.Queue; import java.util.Set; @@ -65,11 +66,11 @@ public static Queue getStartupOrder(ParentBehavior component) { } } - for(Set clusterIds: component.getServiceNameToClusterIdsMap().values()) { - for (String clusterId : clusterIds) { - if(!startup.contains(clusterId)) { - startup.add(clusterId); - } + Collection clusterDataHolders = component.getClusterDataMap().values(); + + for(ClusterDataHolder clusterDataHolder : clusterDataHolders) { + if(!startup.contains(clusterDataHolder.getClusterId())) { + startup.add(clusterDataHolder.getClusterId()); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 6b299ef3e0..198074f40a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -123,17 +123,15 @@ public void startDependency() { startGroupMonitor(this, dependency, component); } else if (dependency.contains("cartridge")) { - Set clusterIds = component.getClusterIds(dependency); - for (String clusterId : clusterIds) { - Cluster cluster = null; - TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); - TopologyManager.releaseReadLock(); - if (cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent - } + String clusterId = component.getClusterData(dependency).getClusterId(); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if (cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent } } } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index e410259a32..0f7d023816 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -106,7 +106,7 @@ private void updateChild(final String clusterId, final String appId) { Runnable exGroup = new Runnable() { public void run() { Application application = TopologyManager.getTopology().getApplication(appId); - Map> clusterIds = application.getClusterMap(); + Map clusterIds = application.getClusterDataMap(); Map groups = application.getAliasToGroupMap(); updateChildStatus(clusterId, groups, clusterIds, application); } @@ -155,23 +155,23 @@ public void run() { } - private boolean updateChildStatus(String id, Map groups, Map> clusterIds, ParentBehavior parent) { + private boolean updateChildStatus(String id, Map groups, Map clusterData, ParentBehavior parent) { boolean groupActive = false; boolean clustersActive = false; boolean groupsActive = false; boolean childFound = false; - if(clusterIds.containsValue(id) || groups.containsKey(id)) { + if(clusterData.containsValue(id) || groups.containsKey(id)) { childFound = true; - if(!clusterIds.isEmpty() && !groups.isEmpty()) { - clustersActive = getClusterStatus(clusterIds); + if(!clusterData.isEmpty() && !groups.isEmpty()) { + clustersActive = getClusterStatus(clusterData); groupsActive = getGroupStatus(groups); groupActive = clustersActive && groupsActive; } else if (!groups.isEmpty()){ groupsActive = getGroupStatus(groups); groupActive = groupsActive; - } else if (!clusterIds.isEmpty()){ - clustersActive = getClusterStatus(clusterIds); + } else if (!clusterData.isEmpty()){ + clustersActive = getClusterStatus(clusterData); groupActive = clustersActive; } else { //TODO warn log @@ -186,7 +186,7 @@ private boolean updateChildStatus(String id, Map groups, Map groups) { } - private boolean getClusterStatus(Map> clusterIds) { + private boolean getClusterStatus(Map clusterData) { boolean clusterActiveStatus = false; - for(Map.Entry> clusterIdsEntry: clusterIds.entrySet()) { - Service service = TopologyManager.getTopology().getService(clusterIdsEntry.getKey()); - for (String clusterId : clusterIdsEntry.getValue()) { - if(service.getCluster(clusterId).getStatus().equals(ClusterStatus.Active)) { + for(Map.Entry clusterDataHolderEntry: clusterData.entrySet()) { + Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); + if(service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). + getStatus().equals(ClusterStatus.Active)) { clusterActiveStatus = true; } else { clusterActiveStatus = false; } - } } return clusterActiveStatus; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index ce9b112157..8559e008a3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -74,7 +74,12 @@ public static MetaDataHolder getClusterLevelPayloadData (String appId, String gr SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) { - MetaDataHolder metaDataHolder = new MetaDataHolder(appId, subscribableCtxt.getType(), clusterId); + MetaDataHolder metaDataHolder; + if (groupName != null) { + metaDataHolder = new MetaDataHolder(appId, groupName, clusterId); + } else { + metaDataHolder = new MetaDataHolder(appId); + } Properties clusterLevelPayloadProperties = new Properties(); // app id diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 341f42aa5d..2dcf955096 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -210,15 +210,15 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, // following keeps track of all Clusters created for this application //Set clusters = new HashSet(); //ClusterDataHolder clusterDataHolder = null; - Map> serviceNameToClusterIds; + Map clusterDataMap; if (appCtxt.getComponents() != null) { // get top level Subscribables if (appCtxt.getComponents().getSubscribableContexts() != null) { - serviceNameToClusterIds = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), + clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), subscribableInfoCtxts); - application.setClusterIds(serviceNameToClusterIds); + application.setClusterData(clusterDataMap); //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); } @@ -336,14 +336,13 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g dependencyOrder.setKillbehavior(getKillbehaviour(groupCtxt.getName())); group.setDependencyOrder(dependencyOrder); - //ClusterDataHolder clusterDataHolderOfGroup; - Map> serviceNameToClusterIds; + Map clusterDataMap; // get group level Subscribables if (groupCtxt.getSubscribableContexts() != null) { - serviceNameToClusterIds = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), + clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); - group.setClusterIds(serviceNameToClusterIds); + group.setClusterData(clusterDataMap); //clusters.addAll(clusterDataHolderOfGroup.getApplicationClusterContexts()); // if (clusterDataHolder == null) { // clusterDataHolder = clusterDataHolderOfGroup; @@ -456,12 +455,12 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi // return subscribableContexts; // } - private Map> parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, + private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, List subscribableCtxts, Map subscribableInfoCtxts) throws ApplicationDefinitionException { - Map> clusterIdMap = new HashMap>(); + Map clusterDataMap = new HashMap(); // Set clusters = new HashSet(); //Set payloadDataHolders = new HashSet(); @@ -508,12 +507,16 @@ private Map> parseLeafLevelSubscriptions (String appId, int // create cluster level meta data this.metaDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, hostname, appClusterCtxt.getTenantRange(), clusterId, subscribableCtxt, subscribableInfoCtxt, cartridge)); + + // add relevant information to the map + clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId)); + //////////// //Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); - addClusterId(clusterIdMap, subscribableCtxt.getType(), clusterId); - //clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()); + //addClusterId(clusterDataMap, subscribableCtxt.getType(), clusterId); + //clusterDataMap.put(subscribableCtxt.getType(), cluster.getClusterId()); //clusters.add(cluster); -// if (clusterIdMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { +// if (clusterDataMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { // // Application Definition has same cartridge multiple times at the top-level // handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); // } @@ -523,8 +526,8 @@ private Map> parseLeafLevelSubscriptions (String appId, int // cluster.getHostNames().get(0)); } - return clusterIdMap; - //return new ClusterDataHolder(clusterIdMap, clusters); + return clusterDataMap; + //return new ClusterDataHolder(clusterDataMap, clusters); //clusterDataHolder.setPayloadDataHolders(payloadDataHolders); } @@ -539,18 +542,18 @@ private ApplicationClusterContext createApplicationClusterContext (String servic return new ApplicationClusterContext(serviceType, clusterId, hostname, textPayload, deploymentPolicy, isLB); } - public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { - - if (serviceNameToClusterIdsMap.get(serviceName) == null) { - // not found, create - Set clusterIds = new HashSet(); - clusterIds.add(clusterId); - serviceNameToClusterIdsMap.put(serviceName, clusterIds); - } else { - // the cluster id set already exists, update - serviceNameToClusterIdsMap.get(serviceName).add(clusterId); - } - } +// public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { +// +// if (serviceNameToClusterIdsMap.get(serviceName) == null) { +// // not found, create +// Set clusterIds = new HashSet(); +// clusterIds.add(clusterId); +// serviceNameToClusterIdsMap.put(serviceName, clusterIds); +// } else { +// // the cluster id set already exists, update +// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); +// } +// } // private void createClusterContext (String appId, String groupName, String serviceType, String clusterId, // String hostName) throws ApplicationDefinitionException { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.java deleted file mode 100644 index 601f6257fa..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationDataHolder.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.cloud.controller.pojo; - -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Cluster; - -import java.util.Set; - -public class ApplicationDataHolder { - - private Application application; - - private Set clusters; - - private Set metaDataHolders; - - public Application getApplication() { - return application; - } - - public void setApplication(Application application) { - this.application = application; - } - - public Set getClusters() { - return clusters; - } - - public void setClusters(Set clusters) { - this.clusters = clusters; - } - - public Set getMetaDataHolders() { - return metaDataHolders; - } - - public void setMetaDataHolders(Set metaDataHolders) { - this.metaDataHolders = metaDataHolders; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java deleted file mode 100644 index 874d18e606..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterDataHolder.java +++ /dev/null @@ -1,61 +0,0 @@ -///* -// * Licensed to the Apache Software Foundation (ASF) under one -// * or more contributor license agreements. See the NOTICE file -// * distributed with this work for additional information -// * regarding copyright ownership. The ASF licenses this file -// * to you under the Apache License, Version 2.0 (the -// * "License"); you may not use this file except in compliance -// * with the License. You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, -// * software distributed under the License is distributed on an -// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// * KIND, either express or implied. See the License for the -// * specific language governing permissions and limitations -// * under the License. -// */ -// -//package org.apache.stratos.cloud.controller.pojo; -// -//import org.apache.stratos.cloud.controller.pojo.payload.PayloadDataHolder; -//import org.apache.stratos.messaging.domain.topology.Cluster; -//import org.apache.stratos.metadata.client.pojo.DataContext; -// -//import java.util.Map; -//import java.util.Set; -// -//public class ClusterDataHolder { -// -// // Cluster Ids map, key = service name -// private Map> clusterIdMap; -// -// // Cluster object collection -// private Set clusters; -// -//// // payload related information -//// private Set payloadDataHolders; -// -// public ClusterDataHolder (Map> clusterIdMap, Set clusters) { -// this.clusterIdMap = clusterIdMap; -// this.clusters = clusters; -// } -// -// public Map> getClusterIdMap() { -// return clusterIdMap; -// } -// -// public Set getApplicationClusterContexts() { -// return clusters; -// } -// -// -//// public Set getPayloadDataHolders() { -//// return payloadDataHolders; -//// } -//// -//// public void setPayloadDataHolders(Set payloadDataHolders) { -//// this.payloadDataHolders = payloadDataHolders; -//// } -//} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java index 8ab745ed65..59bf380085 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java @@ -35,6 +35,11 @@ public class MetaDataHolder { private Properties properties; + public MetaDataHolder (String appId) { + + this.appId = appId; + } + public MetaDataHolder(String appId, String groupName, String clusterId) { this.appId = appId; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index a926411078..25dc0273db 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -672,11 +672,10 @@ public static void handleApplicationUndeployed (String applicationId, int tenant } else { Application application = topology.getApplication(applicationId); // remove clusters - for (Map.Entry> serviceNameToClusterIdEntry: - application.getServiceNameToClusterIdsMap().entrySet()) { - Service service = topology.getService(serviceNameToClusterIdEntry.getKey()); - for (String clusterId : serviceNameToClusterIdEntry.getValue()) { - service.removeCluster(clusterId); + for (Map.Entry clusterDataHolderEntry : application.getClusterDataMap().entrySet()) { + Service service = topology.getService(clusterDataHolderEntry.getValue().getServiceType()); + if (service != null) { + service.removeCluster(clusterDataHolderEntry.getValue().getClusterId()); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index 55e37e65ee..cc7c5883ed 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -40,8 +40,8 @@ public class Application implements ParentBehavior { private DependencyOrder dependencyOrder; // Group Map, key = Group.alias private Map aliasToGroupMap; - // Cluster Id map, key = service name - private Map> serviceNameToClusterIdsMap; + // Cluster Id map, key = subscription alias for the cartridge type + private Map aliasToClusterDataMap; // Application status private Status status; @@ -50,7 +50,7 @@ public Application (String id) { this.key = RandomStringUtils.randomAlphanumeric(16); this.status = Status.Created; aliasToGroupMap = new HashMap(); - serviceNameToClusterIdsMap = new HashMap>(); + aliasToClusterDataMap = new HashMap(); } @Override @@ -74,8 +74,8 @@ public Map getAliasToGroupMap() { } @Override - public Map> getClusterMap() { - return this.serviceNameToClusterIdsMap; + public Map getClusterDataMap() { + return this.aliasToClusterDataMap; } @Override @@ -116,6 +116,16 @@ public DependencyOrder getDependencyOrder() { return dependencyOrder; } + @Override + public void setClusterData(Map aliasToClusterData) { + this.aliasToClusterDataMap.putAll(aliasToClusterData); + } + + @Override + public ClusterDataHolder getClusterData(String alias) { + return aliasToClusterDataMap.get(alias); + } + // @Override // public void addClusterId(String serviceName, String clusterId) { // @@ -132,20 +142,6 @@ public DependencyOrder getDependencyOrder() { // } // } - @Override - public void setClusterIds(Map> serviceNameToClusterIds) { - serviceNameToClusterIdsMap.putAll(serviceNameToClusterIds); - } - - @Override - public Set getClusterIds(String serviceName) { - return serviceNameToClusterIdsMap.get(serviceName); - } - - public Map> getServiceNameToClusterIdsMap() { - return serviceNameToClusterIdsMap; - } - public String getId() { return id; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java new file mode 100644 index 0000000000..cceb4fc5cb --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.domain.topology; + +import java.io.Serializable; + +public class ClusterDataHolder implements Serializable { + + private String serviceType; + + private String clusterId; + + public ClusterDataHolder (String serviceType, String clusterId) { + + this.serviceType = serviceType; + this.clusterId = clusterId; + } + + + public String getServiceType() { + return serviceType; + } + + public String getClusterId() { + return clusterId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 548aabdc60..c47667f397 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -36,8 +36,8 @@ public class Group implements ParentBehavior { private DependencyOrder dependencyOrder; // Sub Group Map, key = Group.alias private Map aliasToGroupMap; - // Cluster id map, key = service name - private Map> serviceNameToClusterIdsMap; + // Cluster Id map, key = subscription alias for the cartridge type + private Map aliasToClusterDataMap; // Group status private Status status; @@ -46,7 +46,7 @@ public Group (String name, String alias) { this.alias = alias; this.status = Status.Created; aliasToGroupMap = new HashMap(); - serviceNameToClusterIdsMap = new HashMap>(); + aliasToClusterDataMap = new HashMap(); } @Override @@ -70,8 +70,8 @@ public Map getAliasToGroupMap() { } @Override - public Map> getClusterMap() { - return this.serviceNameToClusterIdsMap; + public Map getClusterDataMap() { + return this.aliasToClusterDataMap; } @Override @@ -129,17 +129,13 @@ public DependencyOrder getDependencyOrder() { // } @Override - public void setClusterIds(Map> serviceNameToClusterIds) { - serviceNameToClusterIdsMap.putAll(serviceNameToClusterIds); + public void setClusterData(Map aliasToClusterData) { + this.aliasToClusterDataMap.putAll(aliasToClusterData); } @Override - public Set getClusterIds(String serviceName) { - return serviceNameToClusterIdsMap.get(serviceName); - } - - public Map> getServiceNameToClusterIdsMap() { - return serviceNameToClusterIdsMap; + public ClusterDataHolder getClusterData(String alias) { + return aliasToClusterDataMap.get(alias); } public String getName() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index bfad2aeade..d6c7035299 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -34,7 +34,7 @@ public interface ParentBehavior extends Serializable { public Map getAliasToGroupMap(); - public Map> getClusterMap(); + public Map getClusterDataMap(); public Group getGroupRecursively (String groupAlias); @@ -44,11 +44,7 @@ public interface ParentBehavior extends Serializable { public DependencyOrder getDependencyOrder (); -// public void addClusterId (String serviceName, String clusterId); + public void setClusterData (Map aliasToClusterData); - public void setClusterIds (Map> serviceNameToClusterIds); - - public Set getClusterIds(String serviceName); - - public Map> getServiceNameToClusterIdsMap(); + public ClusterDataHolder getClusterData (String alias); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index 3674eb3cee..79236676e8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -35,6 +35,6 @@ public Application getApplication() { public String toString() { return "ApplicationCreatedEvent [app id= " + application.getId() + ", groups= " + application.getGroups() + ", clusters= " + - application.getClusterMap().values() + "]"; + application.getClusterDataMap().values() + "]"; } } From aab7f1895e98987943ce23d859a4e7667942f56e Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 24 Sep 2014 13:21:32 +0530 Subject: [PATCH 093/436] fixing monitors start up time issue and NPE --- .../grouping/DependencyBuilder.java | 10 ++--- .../AutoscalerTopologyEventReceiver.java | 26 ++++++----- .../stratos/autoscaler/monitor/Monitor.java | 43 ++++++++++--------- 3 files changed, 43 insertions(+), 36 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index a021ce3685..54b4cf82d8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -59,16 +59,16 @@ public static Queue getStartupOrder(ParentBehavior component) { } } //TODO adding all the missed groups or clusters as the top child to the list - for(Group group: component.getAliasToGroupMap().values()) { - if(!startup.contains(group.getAlias())) { - startup.add(group.getAlias()); + for(String grpAlias: component.getAliasToGroupMap().keySet()) { + if(!startup.contains("group." + grpAlias)) { + startup.add("group." + grpAlias); } } for(Set clusterIds: component.getServiceNameToClusterIdsMap().values()) { for (String clusterId : clusterIds) { - if(!startup.contains(clusterId)) { - startup.add(clusterId); + if(!startup.contains("cartridge." + clusterId)) { + startup.add("cartridge." + clusterId); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 238d64eb7f..f056de200a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -52,6 +52,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { private TopologyEventReceiver topologyEventReceiver; private boolean terminated; + private boolean topologyInitialized; public AutoscalerTopologyEventReceiver() { this.topologyEventReceiver = new TopologyEventReceiver(); @@ -89,10 +90,14 @@ private void addEventListeners() { @Override protected void onEvent(Event event) { try { - TopologyManager.acquireReadLock(); - // for (Application application : TopologyManager.getTopology().getApplications()) { - // startApplicationMonitor(application); - // } + if(!topologyInitialized) { + topologyInitialized = true; + TopologyManager.acquireReadLock(); + for (Application application : TopologyManager.getTopology().getApplications()) { + startApplicationMonitor(application); + } + } + } catch (Exception e) { log.error("Error processing event", e); } finally { @@ -495,12 +500,7 @@ public void run() { ApplicationMonitor applicationMonitor = null; int retries = 5; boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - + while (!success && retries != 0) { try { applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); success = true; @@ -510,9 +510,13 @@ public void run() { application.getId(); log.debug(msg, e); retries--; + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } } - } while (!success && retries != 0); + } if (applicationMonitor == null) { String msg = "Application monitor creation failed, even after retrying for 5 times, " diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 6b299ef3e0..dfaf720b5c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -53,6 +53,8 @@ public abstract class Monitor extends Observable implements Observer { protected ParentBehavior component; public Monitor(ParentBehavior component) { + groupMonitors = new HashMap(); + abstractClusterMonitors = new HashMap(); this.component = component; startDependency(); } @@ -120,21 +122,19 @@ public void startDependency() { if(!preOrderTraverse.isEmpty()) { String dependency = preOrderTraverse.poll(); if (dependency.contains("group")) { - startGroupMonitor(this, dependency, component); + startGroupMonitor(this, dependency.substring(6), component); } else if (dependency.contains("cartridge")) { - - Set clusterIds = component.getClusterIds(dependency); - for (String clusterId : clusterIds) { + /*String clusterId = component.findClusterId(dependency.substring(10)); Cluster cluster = null; TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(dependency).getCluster(clusterId); TopologyManager.releaseReadLock(); if (cluster != null) { startClusterMonitor(cluster); } else { //TODO throw exception since Topology is inconsistent - } - } + }*/ } } else { //all the groups/clusters have been started and waiting for activation @@ -200,12 +200,7 @@ public void run() { ClusterMonitor monitor = null; int retries = 5; boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - + while (!success && retries != 0) { try { monitor = AutoscalerUtil.getClusterMonitor(cluster); success = true; @@ -214,13 +209,22 @@ public void run() { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); log.debug(msg, e); retries--; + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } } catch (PartitionValidationException e) { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); log.debug(msg, e); retries--; + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } } - } while (!success && retries != 0); + + } if (monitor == null) { String msg = "Cluster monitor creation failed, even after retrying for 5 times, " @@ -256,12 +260,7 @@ public void run() { GroupMonitor monitor = null; int retries = 5; boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - + while (!success && retries != 0) { try { monitor = AutoscalerUtil.getGroupMonitor(group.getGroup(dependency)); monitor.addObserver(parent); @@ -271,9 +270,13 @@ public void run() { String msg = "Group monitor creation failed for group: " + dependency; log.debug(msg, e); retries--; + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } } - } while (!success && retries != 0); + } if (monitor == null) { String msg = "Group monitor creation failed, even after retrying for 5 times, " From 305b287b78ddaa0e13424eea4dd5eb8b400090a4 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 13:26:11 +0530 Subject: [PATCH 094/436] overriding hashcode and equals --- .../application/ApplicationUtils.java | 2 +- .../pojo/ApplicationClusterContext.java | 21 +++++++++++++++++++ .../pojo/payload/MetaDataHolder.java | 3 ++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 8559e008a3..87838392a2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -78,7 +78,7 @@ public static MetaDataHolder getClusterLevelPayloadData (String appId, String gr if (groupName != null) { metaDataHolder = new MetaDataHolder(appId, groupName, clusterId); } else { - metaDataHolder = new MetaDataHolder(appId); + metaDataHolder = new MetaDataHolder(appId, clusterId); } Properties clusterLevelPayloadProperties = new Properties(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java index fb37d99b0e..8fa9feef95 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -113,4 +113,25 @@ public String getTenantRange() { public void setTenantRange(String tenantRange) { this.tenantRange = tenantRange; } + + public boolean equals(Object other) { + + if(other == null || !(other instanceof ApplicationClusterContext)) { + return false; + } + + if(this == other) { + return true; + } + + ApplicationClusterContext that = (ApplicationClusterContext)other; + + return this.cartridgeType.equals(that.cartridgeType) && + this.clusterId.equals(that.clusterId); + } + + public int hashCode () { + return this.cartridgeType.hashCode() + this.clusterId.hashCode(); + } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java index 59bf380085..3db9f71b50 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java @@ -35,9 +35,10 @@ public class MetaDataHolder { private Properties properties; - public MetaDataHolder (String appId) { + public MetaDataHolder (String appId, String clusterId) { this.appId = appId; + this.clusterId = clusterId; } public MetaDataHolder(String appId, String groupName, String clusterId) { From 8e7a00b1e69ad815057474f6e6b4f1851f29a56f Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 24 Sep 2014 15:14:09 +0530 Subject: [PATCH 095/436] improving generic metadata client --- .../pom.xml | 5 ++ .../client/DefaultMetaDataServiceClient.java | 29 ++++++-- .../client/MetaDataServiceClient.java | 4 +- .../metadata/client/beans/PropertyBean.java | 64 +++++++++++++++++ .../client/rest/DefaultRestClient.java | 71 +++++++++++++++++-- .../sample/MetaDataServiceClientSample.java | 5 +- .../registry/CarbonRegistry.java | 2 +- .../services/MetaDataAdmin.java | 41 +++++------ 8 files changed, 183 insertions(+), 38 deletions(-) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml index 4139219f63..fcafdaa816 100644 --- a/components/org.apache.stratos.metadata.client/pom.xml +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -27,6 +27,11 @@ 1.9 provided + + com.google.code.gson + gson + 2.2.4 + diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java index 6f8e9cbd79..d60dfb2240 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java @@ -21,7 +21,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; +import org.apache.stratos.metadata.client.beans.PropertyBean; import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.exception.RestClientException; import org.apache.stratos.metadata.client.rest.DefaultRestClient; import org.apache.stratos.metadata.client.rest.RestClient; @@ -36,7 +39,7 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient { private RestClient restClient; private String baseUrl; - public DefaultMetaDataServiceClient (String baseUrl) { + public DefaultMetaDataServiceClient (String baseUrl) throws RestClientException { this.baseUrl = baseUrl; restClient = new DefaultRestClient(); } @@ -45,12 +48,30 @@ public void initialize() { // initialization, if any } - public void addProperty(String appId, String clusterId, String propertyKey, String propertyValue) + public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption { - //To change body of implemented methods use File | Settings | File Templates. + String applicationPath = baseUrl.concat("application/").concat(appId).concat("/cluster/").concat(clusterId).concat("/property"); + PropertyBean property = new PropertyBean(propertyKey, propertyValue); + try { + restClient.doPost(applicationPath, property); + } catch (RestClientException e) { + log.error(String.format("Error occurred while adding property %s", propertyKey)); + } } -// public void addProperty(String appId, String propertyKey, String propertyValue) + public void addPropertyToApplication(String appId, String propertyKey, String propertyValue) + throws MetaDataServiceClientExeption { + String applicationPath = baseUrl.concat("application/").concat(appId).concat("/property"); + PropertyBean property = new PropertyBean(propertyKey, propertyValue); + HttpResponse x; + try { + x = restClient.doPost(applicationPath, property); + } catch (RestClientException e) { + log.error(String.format("Error occurred while adding property %s", propertyKey)); + } + } + +// public void addPropertyToCluster(String appId, String propertyKey, String propertyValue) // throws MetaDataServiceClientExeption { // //To change body of implemented methods use File | Settings | File Templates. // } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java index ff262643d3..fa89f965c4 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java @@ -41,7 +41,7 @@ public interface MetaDataServiceClient { * @param propertyValue Value of the Property * @throws MetaDataServiceClientExeption */ - public void addProperty (String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; + public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; // /** // * Adds a property key value pair for the specified app @@ -51,7 +51,7 @@ public interface MetaDataServiceClient { // * @param propertyValue Value of the Property // * @throws MetaDataServiceClientExeption // */ -// public void addProperty (String appId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; +// public void addPropertyToCluster (String appId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; // // /** // * Retrieves the property key value pairs for the relevant cluster of the specified app diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java new file mode 100644 index 0000000000..dd2d777789 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.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.metadata.client.beans; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@XmlRootElement(name="properties") +public class PropertyBean { + private String key; + private List values = new ArrayList(); + + public PropertyBean(){} + public PropertyBean(String key, String value){ + this.key=key; + this.values.add(value); + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String[] getValues(){ + String[] values = new String[this.values.size()]; + values = this.values.toArray(values); + return values; + } + + public void setValues(String[] values) { + this.values.addAll(Arrays.asList(values)); + } + + + public void setValues(String value) { + this.values.add(value); + } + + public void addValue(String value){ + this.values.add(value); + } +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index 8c767e2f23..c8ccad5fae 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -19,6 +19,9 @@ package org.apache.stratos.metadata.client.rest; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.apache.commons.codec.binary.Base64; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -26,25 +29,49 @@ import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; -import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLContextBuilder; +import org.apache.http.conn.ssl.TrustSelfSignedStrategy; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.HttpClients; import org.apache.stratos.metadata.client.exception.RestClientException; import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; public class DefaultRestClient implements RestClient { + private static final String APPLICATION_JSON = "application/json"; private static Log log = LogFactory.getLog(DefaultRestClient.class); private HttpClient httpClient; - public DefaultRestClient() { - this.httpClient = new DefaultHttpClient(); + public DefaultRestClient() throws RestClientException{ + SSLContextBuilder builder = new SSLContextBuilder(); + + SSLConnectionSocketFactory sslsf = null; + try { + builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); + sslsf = new SSLConnectionSocketFactory( + builder.build()); + } catch (NoSuchAlgorithmException e) { + throw new RestClientException(e); + } catch (KeyManagementException e) { + throw new RestClientException(e); + } catch (KeyStoreException e) { + throw new RestClientException(e); + } + this.httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException { HttpPost post = new HttpPost(resourcePath); - //TODO set params + addPayloadJsonString(payload, post); + setAuthHeader(post); try { return httpClient.execute(post); @@ -55,6 +82,30 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien } } + private void setAuthHeader(HttpPost post) { + String username = getUsername(); + String password = getPassword(); + String identity = username+":"+password; + String encoding = new String(Base64.encodeBase64(identity.getBytes())); + post.setHeader("Authorization", "Basic " + encoding); + } + + private String getUsername() { + return null; + } + + private String getPassword() { + return null; + } + + private void addPayloadJsonString(Object payload, HttpPost post) { + GsonBuilder gsonBuilder = new GsonBuilder(); + Gson gson = gsonBuilder.create(); + + String payloadText = gson.toJson(payload, payload.getClass()); + addStringPayload(post, payloadText); + } + public HttpResponse doGet(String resourcePath) throws RestClientException { HttpGet get = new HttpGet(resourcePath); @@ -82,4 +133,16 @@ public HttpResponse doDelete(String resourcePath) throws RestClientException { throw new RestClientException(errorMsg, e); } } + + + private void addStringPayload(HttpPost post, String payloadText) { + StringEntity stringEntity = null; + try { + stringEntity = new StringEntity(payloadText); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + stringEntity.setContentType(APPLICATION_JSON); + post.setEntity(stringEntity); + } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java index ad7eb2fae0..fd50cb7b81 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java @@ -26,6 +26,7 @@ import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; +import org.apache.stratos.metadata.client.exception.RestClientException; import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory; import org.apache.stratos.metadata.client.pojo.DataContext; @@ -42,11 +43,11 @@ public class MetaDataServiceClientSample { private MetaDataClientConfig metaDataClientConfig; - public MetaDataServiceClientSample() { + public MetaDataServiceClientSample() throws RestClientException { initialize(); } - private void initialize() { + private void initialize() throws RestClientException { metaDataClientConfig = MetaDataClientConfig.getInstance(); metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig. 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 8078f91b1b..520c846bed 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 @@ -216,7 +216,7 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp Resource regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); - tempRegistry.put(regResource.getPath(), regResource); + tempRegistry.put(resourcePath, regResource); } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index 11d927f757..ccc2b208ee 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -1,31 +1,22 @@ package org.apache.stratos.metadataservice.services; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; -import org.apache.stratos.metadataservice.definition.ApplicationBean; import org.apache.stratos.metadataservice.definition.CartridgeMetaData; -import org.apache.stratos.metadataservice.definition.ClusterBean; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.RegistryException; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; import java.net.URI; -import java.util.ArrayList; import java.util.List; @Path("/") @@ -118,7 +109,7 @@ public Response getClusterProperties(@PathParam("application_id") String applica propertiesArr = properties.toArray(propertiesArr); } } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while getting properties ", e); } Response.ResponseBuilder rb=null; @@ -156,7 +147,7 @@ public Response getClusterProperty(@PathParam("application_id") String applicati } } } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while getting property ", e); } Response.ResponseBuilder rb=null; @@ -194,7 +185,7 @@ public Response getClusterDependencies(@PathParam("application_id") String appli } } } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while getting properties ", e); } Response.ResponseBuilder rb=null; if(property == null){ @@ -226,7 +217,7 @@ public Response getApplicationProperties(@PathParam("application_id") String app propertiesArr = properties.toArray(propertiesArr); } } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while getting properties ", e); } Response.ResponseBuilder rb=null; @@ -263,8 +254,8 @@ public Response getApplicationProperty(@PathParam("application_id") String appli break; } } - } catch (Exception e) { - e.printStackTrace(); + } catch (RegistryException e) { + log.error("Error occurred while getting property", e); } Response.ResponseBuilder rb=null; @@ -294,7 +285,7 @@ public Response addClusterDependencies(@PathParam("application_id") String appli try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); } catch (RegistryException e) { - e.printStackTrace(); + log.error("Error occurred while adding dependencies ", e); } return Response.created(url).build(); } @@ -314,7 +305,7 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); } catch (RegistryException e) { - e.printStackTrace(); + log.error("Error occurred while adding property", e); } return Response.created(url).build(); @@ -338,7 +329,7 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties); } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while adding properties ", e); } @@ -362,7 +353,7 @@ public Response addPropertiesToApplication(@PathParam("application_id") String a try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties); } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while adding properties ", e); } @@ -386,7 +377,7 @@ public Response addPropertyToApplication(@PathParam("application_id") String app try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property); } catch (Exception e) { - e.printStackTrace(); + log.error("Error occurred while adding property ", e); } From 95db1675dc4f75abb79845abd6b572ff82582f7c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 16:24:41 +0530 Subject: [PATCH 096/436] reading username and password from configuration file for meta data service --- .../client/config/MetaDataClientConfig.java | 30 +++++++++++++++++-- .../client/rest/DefaultRestClient.java | 5 ++-- .../client/util/MetaDataClientConstants.java | 11 +++++-- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java index 8bb3cbea28..2596ca9847 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -37,6 +37,10 @@ public class MetaDataClientConfig { private String dataExtractorClass; + private String username; + + private String password; + private XMLConfiguration config; private static volatile MetaDataClientConfig metaDataClientConfig; @@ -61,9 +65,21 @@ private void readConfig () throws RuntimeException{ MetaDataClientConstants.METADATA_SERVICE_BASE_URL + " ] in the config file"); } + username = config.getString(MetaDataClientConstants.METADATA_SERVICE_USERNAME); + if (username == null) { + throw new RuntimeException("Meta data service username not defined in the configuration"); + } + + password = config.getString(MetaDataClientConstants.METADATA_SERVICE_PASSWORD); + if (password == null) { + throw new RuntimeException("Meta data service password not defined in the configuration"); + } + dataExtractorClass = config.getString(MetaDataClientConstants.METADATA_CLIENT_DATA_EXTRACTOR_CLASS); if (dataExtractorClass == null) { - log.info("No custom Data Extractor class detected in the configuration"); + if(log.isDebugEnabled()) { + log.debug("No custom Data Extractor class detected in the configuration"); + } } } @@ -108,13 +124,23 @@ public String getDataExtractorClass() { return dataExtractorClass; } + public String getUsername() { + return username; + } + + public String getPassword() { + return password; + } + /* Sample Configuration file: - xx.xx.xx.xx + localhost + admin + admin org.foo.MyDataExtractor diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index c8ccad5fae..cb12b8d66b 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -34,6 +34,7 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.HttpClients; +import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.exception.RestClientException; import java.io.IOException; @@ -91,11 +92,11 @@ private void setAuthHeader(HttpPost post) { } private String getUsername() { - return null; + return MetaDataClientConfig.getInstance().getUsername(); } private String getPassword() { - return null; + return MetaDataClientConfig.getInstance().getPassword(); } private void addPayloadJsonString(Object payload, HttpPost post) { diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java index 1b2baf28f9..c027bed00f 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java @@ -21,9 +21,14 @@ public class MetaDataClientConstants { - public static String METADATA_CLIENT_CONFIG_FILE = "METADATA_CLIENT_CONFIG_FILE"; + public static final String METADATA_CLIENT_CONFIG_FILE = "METADATA_CLIENT_CONFIG_FILE"; - public static String METADATA_SERVICE_BASE_URL = "metadataService.baseUrl"; + public static final String METADATA_SERVICE_BASE_URL = "metadataService.baseUrl"; + + public static final String METADATA_SERVICE_USERNAME = "metadataService.username"; + + public static final String METADATA_SERVICE_PASSWORD = "metadataService.password"; + + public static final String METADATA_CLIENT_DATA_EXTRACTOR_CLASS = "metadataClient.dataExtractorClass"; - public static String METADATA_CLIENT_DATA_EXTRACTOR_CLASS = "metadataClient.dataExtractorClass"; } From 2e512ebf2c6b23276c3add269d637a02459b520c Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 24 Sep 2014 17:51:56 +0530 Subject: [PATCH 097/436] creating metadata feature --- .../pom.xml | 102 ++++++++++++++++++ features/common/pom.xml | 37 +++++++ .../stratos/modules/p2-profile-gen/pom.xml | 29 ++++- 3 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 features/common/org.apache.stratos.metadata.client.feature/pom.xml create mode 100644 features/common/pom.xml diff --git a/features/common/org.apache.stratos.metadata.client.feature/pom.xml b/features/common/org.apache.stratos.metadata.client.feature/pom.xml new file mode 100644 index 0000000000..6a8402f515 --- /dev/null +++ b/features/common/org.apache.stratos.metadata.client.feature/pom.xml @@ -0,0 +1,102 @@ + + + + + + + org.apache.stratos + common.features + 4.1.0-SNAPSHOT + + + 4.0.0 + org.apache.stratos.metadata.client.feature + pom + Apache Stratos - Metadata client Feature + http://apache.org + + + + + com.google.code.gson + gson + ${gson2.version} + + + org.apache.httpcomponents + httpasyncclient + 4.0-beta3 + + + org.apache.httpcomponents + httpclient-osgi + 4.3.5 + + + org.apache.httpcomponents + httpcore-osgi + 4.3.2 + + + org.apache.httpcomponents + httpcore-nio + 4.2.4 + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + 4-p2-feature-generation + package + + p2-feature-gen + + + org.apache.stratos.metadata.client + ../../../etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.apache.stratos:org.apache.stratos.metadata.client:${project.version} + com.google.code.gson:gson:${gson2.version} + org.apache.commons:commons-lang3:3.1 + + + + + + + + + diff --git a/features/common/pom.xml b/features/common/pom.xml new file mode 100644 index 0000000000..b2a448137b --- /dev/null +++ b/features/common/pom.xml @@ -0,0 +1,37 @@ + + + + + org.apache.stratos + stratos-features-parent + 4.1.0-SNAPSHOT + + + 4.0.0 + common.features + pom + Apache Stratos - Metadata Client Module + http://apache.org + + + org.apache.stratos.metadata.client.feature + + + diff --git a/products/stratos/modules/p2-profile-gen/pom.xml b/products/stratos/modules/p2-profile-gen/pom.xml index 48161dcba2..91e9ed2380 100644 --- a/products/stratos/modules/p2-profile-gen/pom.xml +++ b/products/stratos/modules/p2-profile-gen/pom.xml @@ -247,6 +247,8 @@ org.wso2.carbon:org.wso2.carbon.cassandra.mgt.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.cassandra.dataaccess.feature:${carbon.platform.version} org.wso2.carbon:org.wso2.carbon.cassandra.common.feature:${carbon.platform.version} + + org.apache.stratos:org.apache.stratos.metadata.client.feature:${project.version} @@ -313,6 +315,8 @@ + + p2 profile generation for sm package @@ -449,6 +453,8 @@ + + p2 profile generation for as package @@ -500,14 +506,16 @@ org.apache.stratos.metadataservice.feature.group ${project.version} - - org.apache.stratos.metadataservice.feature.group - ${project.version} - + + org.apache.stratos.metadata.client.feature.group + ${project.version} + + + p2 profile generation for CC package @@ -590,9 +598,16 @@ org.apache.stratos.metadataservice.feature.group ${project.version} + + org.apache.stratos.metadata.client.feature.group + ${project.version} + + + + 3-p2-profile-generation package @@ -833,6 +848,12 @@ org.apache.stratos.metadataservice.feature.group ${project.version} + + + org.apache.stratos.metadata.client.feature.group + ${project.version} + + From 37bbe696c396b35a60a87857ba3677e9f6926130 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 24 Sep 2014 21:29:41 +0530 Subject: [PATCH 098/436] add common feature to root pom --- features/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/features/pom.xml b/features/pom.xml index baf64e7b95..efbcd53a3e 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -43,6 +43,7 @@ manager messaging + common From 8b6bc51425a8369ce08ee467cc0a09b2be1bc11f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 21:57:44 +0530 Subject: [PATCH 099/436] temp fix for METADATA_CLIENT_CONFIG_FILE system property not found issue --- .../cloud/controller/application/ApplicationUtils.java | 4 ++-- .../metadata/client/sample/MetaDataServiceClientSample.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 87838392a2..7117170b5a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -159,11 +159,11 @@ public static StringBuilder getTextPayload (String appId, String groupName, Stri payloadBuilder.append(","); payloadBuilder.append("CLUSTER_ID=" + clusterId); // meta data endpoint - if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { + // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { // TODO //payloadBuilder.append(","); //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); - } + // } payloadBuilder.append(","); return payloadBuilder; diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java index fd50cb7b81..6c0215d8ac 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java @@ -44,7 +44,7 @@ public class MetaDataServiceClientSample { public MetaDataServiceClientSample() throws RestClientException { - initialize(); + //initialize(); } private void initialize() throws RestClientException { From bfcaf0f5469c7c6f1ecdd4002177c9336d93e74f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 24 Sep 2014 22:10:57 +0530 Subject: [PATCH 100/436] fixing a bug in adding Groups to aliasToGroupMap --- .../controller/application/parser/DefaultApplicationParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 2dcf955096..282b4d9035 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -363,7 +363,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, subscribableInfoCtxts, definedGroupCtxts); - nestedGroups.put(nestedGroup.getName(), nestedGroup); + nestedGroups.put(nestedGroup.getAlias(), nestedGroup); } group.setGroups(nestedGroups); From d7ee8405eda6e0877bbecc5a90fa71dafc75ddc1 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 24 Sep 2014 22:15:10 +0530 Subject: [PATCH 101/436] add logs --- .../metadataservice/registry/CarbonRegistry.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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 520c846bed..d721c8bbec 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 @@ -217,6 +217,7 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp regResource.setProperty(property.getKey(), Arrays.asList(property.getValues())); tempRegistry.put(resourcePath, regResource); + log.info(String.format("Property %s is added to cluster %s of application %s", property.getKey(), clusterId, applicationId)); } @@ -232,9 +233,7 @@ public void addPropertiesToCluster(String applicationName, String clusterId, New } tempRegistry.put(resourcePath, regResource); - if(log.isDebugEnabled()){ - log.debug("A resource added to: " + resourcePath); - } + log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName)); } public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { @@ -247,6 +246,7 @@ public void addPropertiesToApplication(String applicationId, NewProperty[] prope } tempRegistry.put(resourcePath, regResource); + log.info(String.format("Properties are added to application %s", applicationId)); } public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { @@ -255,6 +255,7 @@ public void addPropertyToApplication(String applicationId, NewProperty property) Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); tempRegistry.put(resourcePath, regResource); + log.info(String.format("Property %s is added to application %s ", property.getKey(), applicationId)); } public List getPropertiesOfApplication(String applicationId) throws RegistryException { @@ -295,6 +296,9 @@ private Resource createOrGetResourceforApplication(Registry tempRegistry, String regResource = tempRegistry.get(resourcePath); }else{ regResource = tempRegistry.newCollection(); + if(log.isDebugEnabled()){ + log.debug("Registry resource is create at path " + regResource.getPath() + " for application"); + } } return regResource; } @@ -309,6 +313,9 @@ private Resource createOrGetResourceforCluster(Registry tempRegistry, String res regResource = tempRegistry.get(resourcePath); }else{ regResource = tempRegistry.newResource(); + if(log.isDebugEnabled()){ + log.debug("Registry resource is create at path for cluster" + regResource.getPath() + " for cluster"); + } } return regResource; } From 99410302978bb743cfb18005cd212e733109c92b Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 24 Sep 2014 22:16:47 +0530 Subject: [PATCH 102/436] remove unused apis --- .../services/MetaDataAdmin.java | 41 +------------------ 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index ccc2b208ee..fdf9375e19 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -4,7 +4,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; @@ -39,45 +38,7 @@ public void initialize() throws RestAPIException { conf = ConfUtil.getInstance(null).getConfiguration(); } - @POST - @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public String addCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, - @PathParam("cartridgetype") String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception { - - conf = ConfUtil.getInstance(null).getConfiguration(); - - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - return DataRegistryFactory.getDataRegistryFactory(registryType) - .addCartridgeMetaDataDetails(applicationName, cartridgeType, - cartridgeMetaData); - - } - - @GET - @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public String getCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, - @PathParam("cartridgetype") String cartridgeType) - - throws Exception { - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - return DataRegistryFactory.getDataRegistryFactory(registryType) - .getCartridgeMetaDataDetails(applicationName, cartridgeType); - - } - - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception { conf = ConfUtil.getInstance(null).getConfiguration(); String registryType = From f1ccd9b049989501d6c1a8c0cb6ff4d5a2bd69ab Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 24 Sep 2014 22:57:04 +0530 Subject: [PATCH 103/436] fixing issues while starting group monitors --- .../grouping/DependencyBuilder.java | 30 +++++-- .../AutoscalerTopologyEventReceiver.java | 18 +++-- .../stratos/autoscaler/monitor/Monitor.java | 78 ++++++------------- .../application/ApplicationMonitor.java | 35 +++++++++ .../monitor/group/GroupMonitor.java | 50 ++++++++++++ 5 files changed, 143 insertions(+), 68 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index 6b43c37393..afec81800a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -60,22 +60,36 @@ public static Queue getStartupOrder(ParentBehavior component) { } } //TODO adding all the missed groups or clusters as the top child to the list - for(String grpAlias: component.getAliasToGroupMap().keySet()) { - if(!startup.contains("group." + grpAlias)) { - startup.add("group." + grpAlias); + //TODO handle by application and group itself groupName and serviceName + + if(component instanceof Application) { + for(Group group: component.getAliasToGroupMap().values()) { + if(!startup.contains("group." + group.getAlias())) { + startup.add("group." + group.getAlias()); + } } - } - Set cartridgeAliases = component.getClusterDataMap().keySet(); + Set cartridgeAliases = component.getClusterDataMap().keySet(); - for(String carAlias : cartridgeAliases) { + for(String carAlias : cartridgeAliases) { if(!startup.contains("cartridge." + carAlias)) { startup.add("cartridge." + carAlias); + } } - } - + } else if(component instanceof Group) { + for(Group group: component.getAliasToGroupMap().values()) { + if(!startup.contains("group." + group.getName())) { + startup.add("group." + group.getName()); + } + } + for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + if(!startup.contains("cartridge." + dataHolder.getServiceType())) { + startup.add("cartridge." + dataHolder.getServiceType()); + } + } + } return startup; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index f056de200a..575e1a5fa6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -90,9 +90,9 @@ private void addEventListeners() { @Override protected void onEvent(Event event) { try { + TopologyManager.acquireReadLock(); if(!topologyInitialized) { topologyInitialized = true; - TopologyManager.acquireReadLock(); for (Application application : TopologyManager.getTopology().getApplications()) { startApplicationMonitor(application); } @@ -500,9 +500,16 @@ public void run() { ApplicationMonitor applicationMonitor = null; int retries = 5; boolean success = false; - while (!success && retries != 0) { + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } try { + long start = System.currentTimeMillis(); applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); + long end = System.currentTimeMillis(); + log.info("***********************time taken to start app mon: " + (end - start)/1000); success = true; //TODO exception handling } catch (Exception e) { @@ -510,13 +517,10 @@ public void run() { application.getId(); log.debug(msg, e); retries--; - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + } - } + } while (!success && retries != 0); if (applicationMonitor == null) { String msg = "Application monitor creation failed, even after retrying for 5 times, " diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 9a476004e8..a584584981 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -60,6 +60,8 @@ public Monitor(ParentBehavior component) { startDependency(); } + protected abstract void startDependency(); + public Map getGroupMonitors() { return groupMonitors; @@ -112,38 +114,7 @@ public void setId(String id) { this.id = id; } - public void startDependency() { - //Need to get the order every time as group/cluster might already been started - //TODO breadth first search in a tree and find the parallel one - //TODO build up the tree with ordered manner - - preOrderTraverse = DependencyBuilder.getStartupOrder(component); - - //start the first dependency - if(!preOrderTraverse.isEmpty()) { - String dependency = preOrderTraverse.poll(); - if (dependency.contains("group")) { - startGroupMonitor(this, dependency.substring(6), component); - } else if (dependency.contains("cartridge")) { - ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); - Cluster cluster = null; - TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); - TopologyManager.releaseReadLock(); - if (cluster != null) { - startClusterMonitor(cluster); - } else { - //TODO throw exception since Topology is inconsistent - } - - } - } else { - //all the groups/clusters have been started and waiting for activation - log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); - } - } + protected synchronized void startClusterMonitor(Cluster cluster) { Thread th = null; if (cluster.isLbCluster() @@ -156,10 +127,10 @@ protected synchronized void startClusterMonitor(Cluster cluster) { } if (th != null) { th.start(); - try { + /*try { th.join(); } catch (InterruptedException ignore) { - } + }*/ if (log.isDebugEnabled()) { log.debug(String @@ -178,10 +149,10 @@ protected synchronized void startGroupMonitor(Monitor parent, String dependency, if (th != null) { th.start(); - try { + /*try { th.join(); } catch (InterruptedException ignore) { - } + }*/ if (log.isDebugEnabled()) { log.debug(String @@ -203,7 +174,11 @@ public void run() { ClusterMonitor monitor = null; int retries = 5; boolean success = false; - while (!success && retries != 0) { + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } try { monitor = AutoscalerUtil.getClusterMonitor(cluster); success = true; @@ -212,24 +187,19 @@ public void run() { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); log.debug(msg, e); retries--; - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + } catch (PartitionValidationException e) { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); log.debug(msg, e); retries--; - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + } - } + } while (!success && retries != 0); - if (monitor == null) { + + if (monitor == null) { String msg = "Cluster monitor creation failed, even after retrying for 5 times, " + "for cluster: " + cluster.getClusterId(); log.error(msg); @@ -263,7 +233,12 @@ public void run() { GroupMonitor monitor = null; int retries = 5; boolean success = false; - while (!success && retries != 0) { + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { monitor = AutoscalerUtil.getGroupMonitor(group.getGroup(dependency)); monitor.addObserver(parent); @@ -273,13 +248,10 @@ public void run() { String msg = "Group monitor creation failed for group: " + dependency; log.debug(msg, e); retries--; - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + } - } + } while (!success && retries != 0); if (monitor == null) { String msg = "Group monitor creation failed, even after retrying for 5 times, " diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index d3c4113dd4..b5dcbdbef7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -56,6 +56,41 @@ protected void onEvent(Event event) { } + @Override + protected void startDependency() { + //Need to get the order every time as group/cluster might already been started + //TODO breadth first search in a tree and find the parallel one + //TODO build up the tree with ordered manner + + preOrderTraverse = DependencyBuilder.getStartupOrder(component); + + //start the first dependency + if(!preOrderTraverse.isEmpty()) { + String dependency = preOrderTraverse.poll(); + if (dependency.contains("group")) { + startGroupMonitor(this, dependency.substring(6), component); + } else if (dependency.contains("cartridge")) { + ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); + String clusterId = clusterDataHolder.getClusterId(); + String serviceName = clusterDataHolder.getServiceType(); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if (cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } + + } + } else { + //all the groups/clusters have been started and waiting for activation + log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); + } + + + } /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 28662c6a58..2f297bbc4c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -18,9 +18,15 @@ */ package org.apache.stratos.autoscaler.monitor.group; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.List; import java.util.Map; @@ -30,6 +36,8 @@ * groups and clusters */ public class GroupMonitor extends Monitor { + private static final Log log = LogFactory.getLog(GroupMonitor.class); + @@ -39,6 +47,48 @@ public GroupMonitor(Group group) { } + @Override + public void startDependency() { + //Need to get the order every time as group/cluster might already been started + //TODO breadth first search in a tree and find the parallel one + //TODO build up the tree with ordered manner + + preOrderTraverse = DependencyBuilder.getStartupOrder(component); + + //start the first dependency + if(!preOrderTraverse.isEmpty()) { + String dependency = preOrderTraverse.poll(); + if (dependency.contains("group")) { + for(Group group: component.getAliasToGroupMap().values()) { + if(group.getName().equals(dependency.substring(6))) { + startGroupMonitor(this, group.getAlias(), component); + } + } + } else if (dependency.contains("cartridge")) { + for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + if(dataHolder.getServiceType().equals(dependency.substring(10))) { + String clusterId = dataHolder.getClusterId(); + String serviceName = dataHolder.getServiceType(); + Cluster cluster = null; + TopologyManager.acquireReadLock(); + cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); + TopologyManager.releaseReadLock(); + if (cluster != null) { + startClusterMonitor(cluster); + } else { + //TODO throw exception since Topology is inconsistent + } + } + } + + + } + } else { + //all the groups/clusters have been started and waiting for activation + log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); + } + } + //monitor the status of the cluster and the groups public void monitor() { From a34b61537d9417fa808519f5d56dbdb08e03b98c Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 11:11:42 +0530 Subject: [PATCH 104/436] fixing cluster monitor status issue and reomving LB ref from cluster monitor --- .../apache/stratos/autoscaler/monitor/Monitor.java | 11 ++++++++--- .../autoscaler/monitor/cluster/ClusterMonitor.java | 4 ++-- .../stratos/autoscaler/util/AutoscalerUtil.java | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index a584584981..19f8298b46 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -115,7 +115,7 @@ public void setId(String id) { } - protected synchronized void startClusterMonitor(Cluster cluster) { + protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { Thread th = null; if (cluster.isLbCluster() && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { @@ -123,7 +123,7 @@ protected synchronized void startClusterMonitor(Cluster cluster) { cluster)); } else if (!cluster.isLbCluster() && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { th = new Thread( - new ClusterMonitorAdder(cluster)); + new ClusterMonitorAdder(parent, cluster)); } if (th != null) { th.start(); @@ -165,8 +165,10 @@ protected synchronized void startGroupMonitor(Monitor parent, String dependency, private class ClusterMonitorAdder implements Runnable { private Cluster cluster; + private Monitor parent; - public ClusterMonitorAdder(Cluster cluster) { + public ClusterMonitorAdder(Monitor parent, Cluster cluster) { + this.parent = parent; this.cluster = cluster; } @@ -181,6 +183,7 @@ public void run() { } try { monitor = AutoscalerUtil.getClusterMonitor(cluster); + monitor.addObserver(parent); success = true; //TODO start the status checker } catch (PolicyValidationException e) { @@ -203,6 +206,7 @@ public void run() { String msg = "Cluster monitor creation failed, even after retrying for 5 times, " + "for cluster: " + cluster.getClusterId(); log.error(msg); + //TODO parent.notify(); throw new RuntimeException(msg); } @@ -257,6 +261,7 @@ public void run() { String msg = "Group monitor creation failed, even after retrying for 5 times, " + "for group: " + dependency; log.error(msg); + //TODO parent.notify(); throw new RuntimeException(msg); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index eb94ffddf2..30a4275217 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -76,8 +76,8 @@ public void run() { Thread.sleep(60000); } catch (InterruptedException ignore) { }*/ - this.status = Status.Running; - while (!isDestroyed() && status.getCode() >= ClusterStatus.Running.getCode()) { + //this.status = Status.Running; + while (!isDestroyed() && status.getCode() >= Status.Running.getCode()) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 690b44e313..df01a84f47 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -168,7 +168,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal // find lb reference type - java.util.Properties props = cluster.getProperties(); + /*java.util.Properties props = cluster.getProperties(); if(props.containsKey(Constants.LOAD_BALANCER_REF)) { String value = props.getProperty(Constants.LOAD_BALANCER_REF); @@ -176,14 +176,16 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal if(log.isDebugEnabled()) { log.debug("Set the lb reference type: "+value); } - } + }*/ //register a status Checker // set hasPrimary property // hasPrimary is true if there are primary members available in that cluster - clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(Constants.IS_PRIMARY))); + if(cluster.getProperties() != null) { + clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(Constants.IS_PRIMARY))); + } log.info("Cluster monitor created: "+clusterMonitor.toString()); return clusterMonitor; From f8ca4b27876f62623cdb7ea2ff1d711c90c36049 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 11:46:41 +0530 Subject: [PATCH 105/436] adding status topic receiver in CC and fixing issues in cluster monitor --- .../monitor/application/ApplicationMonitor.java | 2 +- .../autoscaler/monitor/cluster/ClusterMonitor.java | 2 +- .../autoscaler/monitor/group/GroupMonitor.java | 2 +- .../internal/CloudControllerDSComponent.java | 12 +++++++++++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index b5dcbdbef7..963b24a91b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -78,7 +78,7 @@ protected void startDependency() { cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); TopologyManager.releaseReadLock(); if (cluster != null) { - startClusterMonitor(cluster); + startClusterMonitor(this,cluster); } else { //TODO throw exception since Topology is inconsistent } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 30a4275217..8c1e5080ea 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -77,7 +77,7 @@ public void run() { } catch (InterruptedException ignore) { }*/ //this.status = Status.Running; - while (!isDestroyed() && status.getCode() >= Status.Running.getCode()) { + while (!isDestroyed()) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 2f297bbc4c..4b5d62bcf0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -74,7 +74,7 @@ public void startDependency() { cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); TopologyManager.releaseReadLock(); if (cluster != null) { - startClusterMonitor(cluster); + startClusterMonitor(this, cluster); } else { //TODO throw exception since Topology is inconsistent } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 572e619490..5831948c06 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.application.status.receiver.ApplicationStatusTopicReceiver; import org.apache.stratos.cloud.controller.exception.CloudControllerException; import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; @@ -33,6 +34,7 @@ import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber; +import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; import org.apache.stratos.messaging.util.Constants; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; @@ -63,7 +65,7 @@ public class CloudControllerDSComponent { private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class); - + private ApplicationStatusTopicReceiver applicationStatusTopicReceiver; protected void activate(ComponentContext context) { try { @@ -77,6 +79,14 @@ protected void activate(ComponentContext context) { InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator(); Thread tdelegator = new Thread(delegator); tdelegator.start(); + + applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver(); + Thread appThread = new Thread(applicationStatusTopicReceiver); + appThread.start(); + if (log.isDebugEnabled()) { + log.debug("Application status Receiver thread started"); + } + // Register cloud controller service BundleContext bundleContext = context.getBundleContext(); From 787b554ee993045b079d9c59aedd0522f1c23a13 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 25 Sep 2014 11:50:22 +0530 Subject: [PATCH 106/436] adding a method to get all cluster info. in an App recursively --- .../impl/CloudControllerServiceImpl.java | 37 ++++++++++++++++++- .../controller/topology/TopologyBuilder.java | 12 ++++-- .../domain/topology/Application.java | 29 +++++++++++++++ 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 6f72e63676..5b04df2df4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -35,6 +35,7 @@ import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -48,6 +49,11 @@ import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient; +import org.apache.stratos.metadata.client.MetaDataServiceClient; +import org.apache.stratos.metadata.client.config.MetaDataClientConfig; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.exception.RestClientException; import org.jclouds.compute.ComputeService; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; @@ -1436,8 +1442,35 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); } - //TODO: publish data to meta data service - applicationParser.getPayloadData(); + //TODO: improve +// Set medaDataHolders = applicationParser.getPayloadData(); +// if (medaDataHolders != null) { +// +// MetaDataServiceClient metaDataServiceClient; +// try { +// +// metaDataServiceClient = new DefaultMetaDataServiceClient(MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); +// metaDataServiceClient.initialize(); +// +// } catch (RestClientException e) { +// log.error("Error creating instance of Metadata Service Client", e); +// throw new ApplicationDefinitionException(e); +// } +// +// for (MetaDataHolder metaDataHolder : medaDataHolders) { +// for (Map.Entry metaDataEntry : metaDataHolder.getProperties().entrySet()) { +// try { +// metaDataServiceClient.addPropertyToCluster(metaDataHolder.getAppId(), metaDataHolder.getClusterId(), +// (String)metaDataEntry.getKey(), (String)metaDataEntry.getValue()); +// +// } catch (MetaDataServiceClientExeption e) { +// log.error("Error publishing data to Metadata Service", e); +// throw new ApplicationDefinitionException(e); +// } +// } +// } +// } + TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), applicationParser.getPayloadData()); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 25dc0273db..28de73e060 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -672,10 +672,16 @@ public static void handleApplicationUndeployed (String applicationId, int tenant } else { Application application = topology.getApplication(applicationId); // remove clusters - for (Map.Entry clusterDataHolderEntry : application.getClusterDataMap().entrySet()) { - Service service = topology.getService(clusterDataHolderEntry.getValue().getServiceType()); + for (ClusterDataHolder clusterDataHolder : application.getClusterDataRecursively()) { + Service service = topology.getService(clusterDataHolder.getServiceType()); if (service != null) { - service.removeCluster(clusterDataHolderEntry.getValue().getClusterId()); + service.removeCluster(clusterDataHolder.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); + } + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index cc7c5883ed..ec9c1fdaf8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -78,6 +78,35 @@ public Map getClusterDataMap() { return this.aliasToClusterDataMap; } + public Set getClusterDataRecursively () { + + Set appClusterData = new HashSet(); + + // get top level Cluster Data + if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) { + appClusterData.addAll(this.aliasToClusterDataMap.values()); + } + + // find other nested Cluster Data (in the Groups) + if (getGroups() != null) { + getClusterData(appClusterData, getGroups()); + } + + return appClusterData; + } + + private void getClusterData (Set clusterData, Collection groups) { + + for (Group group : groups) { + if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) { + clusterData.addAll(group.getClusterDataMap().values()); + if (group.getGroups() != null) { + getClusterData(clusterData, group.getGroups()); + } + } + } + } + @Override public Group getGroupRecursively(String groupAlias) { From 2937b6962f066ae1ec85e874be491375f27278b3 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 12:51:42 +0530 Subject: [PATCH 107/436] adding application activated event support in AS and CC --- .../grouping/topic/StatusEventPublisher.java | 16 +++- .../status/checker/StatusChecker.java | 85 ++++++++++-------- .../ApplicationStatusTopicReceiver.java | 9 ++ .../controller/topology/TopologyBuilder.java | 29 ++++++ .../topology/TopologyEventPublisher.java | 8 ++ .../status/ApplicationActivatedEvent.java | 38 ++++++++ .../status/ClusterActivatedEvent.java | 2 +- .../status/ClusterMaintenanceModeEvent.java | 5 +- .../status/ClusterReadyToShutdownEvent.java | 7 +- .../status/GroupActivatedEvent.java | 8 +- .../status/GroupMaintenanceModeEvent.java | 7 +- .../status/GroupReadyToShutdownEvent.java | 7 +- ...GroupStatusEvent.java => StatusEvent.java} | 2 +- .../topology/ApplicationActivatedEvent.java | 34 +++++++ .../event/topology/GroupActivatedEvent.java | 9 +- .../ApplicationActivatedEventListener.java} | 14 ++- .../ApplicationActivatedEventListener.java | 27 ++++++ ...ionStatusAppActivatedMessageProcessor.java | 67 ++++++++++++++ ...nStatusGroupActivatedMessageProcessor.java | 12 ++- ...pplicationStatusMessageProcessorChain.java | 6 ++ .../ApplicationActivatedMessageProcessor.java | 89 +++++++++++++++++++ .../TopologyMessageProcessorChain.java | 14 ++- 22 files changed, 401 insertions(+), 94 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupStatusEvent.java => StatusEvent.java} (93%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/{event/application/status/ClusterStatusEvent.java => listener/application/status/ApplicationActivatedEventListener.java} (66%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index da8dff8513..13860fe05a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -5,10 +5,7 @@ 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.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupMaintenanceModeEvent; +import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.util.Constants; /** @@ -54,6 +51,17 @@ public static void sendGroupActivatedEvent (String appId, String groupId) { publishEvent(groupActivatedEvent); } + public static void sendApplicationActivatedEvent (String appId) { + + if(log.isInfoEnabled()) { + log.info("Publishing Application activated event for [application]: " + appId); + } + + ApplicationActivatedEvent applicationActivatedEvent = new ApplicationActivatedEvent(appId); + + publishEvent(applicationActivatedEvent); + } + public static void sendGroupInMaintenanceEvent (String appId, String groupId) { if(log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 0f7d023816..cecd09afe0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -30,7 +30,6 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.Map; -import java.util.Set; /** * This will be used to evaluate the status of a group @@ -44,15 +43,15 @@ private StatusChecker() { } - private static class Holder { - private static final StatusChecker INSTANCE = new StatusChecker(); - } - public static StatusChecker getInstance() { //TODO synchronized return Holder.INSTANCE; } + /** + * + * @param clusterId1 + */ public void onMemberStatusChange(String clusterId1) { final String clusterId = clusterId1; Runnable exCluster = new Runnable() { @@ -62,7 +61,7 @@ public void run() { for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { //minimum check per partition for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - if(partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { + if (partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { clusterActive = true; } else if (partitionContext.getActiveMemberCount() > partitionContext.getMinimumMemberCount()) { log.info("cluster already activated..."); @@ -72,7 +71,7 @@ public void run() { } } // if active then notify upper layer - if(clusterActive) { + if (clusterActive) { //send event to cluster status topic StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), monitor.getServiceId(), monitor.getClusterId()); @@ -81,11 +80,11 @@ public void run() { } }; + Thread clusterThread = new Thread(exCluster); + clusterThread.start(); } - /** - * * @param groupId * @param appId */ @@ -94,7 +93,6 @@ public void onGroupStatusChange(final String groupId, final String appId) { } /** - * * @param clusterId * @param appId */ @@ -103,31 +101,32 @@ public void onClusterStatusChange(final String clusterId, final String appId) { } private void updateChild(final String clusterId, final String appId) { - Runnable exGroup = new Runnable() { + Runnable group = new Runnable() { public void run() { Application application = TopologyManager.getTopology().getApplication(appId); Map clusterIds = application.getClusterDataMap(); Map groups = application.getAliasToGroupMap(); - updateChildStatus(clusterId, groups, clusterIds, application); + updateChildStatus(appId, clusterId, groups, clusterIds, application); } }; + Thread groupThread = new Thread(group); + groupThread.start(); } /** - * * @param clusterId * @param appId * @param partitionContext is to decide in which partition has less members while others have active members */ public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { - Runnable exCluster = new Runnable() { + Runnable memberFault = new Runnable() { public void run() { ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); boolean clusterActive = false; boolean clusterInMaintenance = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { - if(partitionContext.getPartitionId().equals(partition.getPartitionId()) && + if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { clusterInMaintenance = true; } else { @@ -137,7 +136,7 @@ public void run() { , partition.getPartitionId(), partition.getNetworkPartitionId(), partition.getMinimumMemberCount(), partition.getActiveMemberCount(), clusterId)); } - if(partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) { + if (partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) { clusterActive = true; } clusterActive = false; @@ -145,48 +144,52 @@ public void run() { } // if in maintenance then notify upper layer - if(clusterActive && clusterInMaintenance) { + if (clusterActive && clusterInMaintenance) { //send clusterInmaintenance event to cluster status topic } } }; + Thread faultHandlingThread = new Thread(memberFault); + faultHandlingThread.start(); } - - private boolean updateChildStatus(String id, Map groups, Map clusterData, ParentBehavior parent) { + private boolean updateChildStatus(String appId, String id, Map groups, + Map clusterData, ParentBehavior parent) { boolean groupActive = false; boolean clustersActive = false; boolean groupsActive = false; boolean childFound = false; - if(clusterData.containsValue(id) || groups.containsKey(id)) { + if (clusterData.containsValue(id) || groups.containsKey(id)) { childFound = true; - if(!clusterData.isEmpty() && !groups.isEmpty()) { + if (!clusterData.isEmpty() && !groups.isEmpty()) { clustersActive = getClusterStatus(clusterData); groupsActive = getGroupStatus(groups); groupActive = clustersActive && groupsActive; - } else if (!groups.isEmpty()){ + } else if (!groups.isEmpty()) { groupsActive = getGroupStatus(groups); groupActive = groupsActive; - } else if (!clusterData.isEmpty()){ + } else if (!clusterData.isEmpty()) { clustersActive = getClusterStatus(clusterData); groupActive = clustersActive; } else { //TODO warn log } //send the activation event - if(parent instanceof Application && groupActive) { - //TODO send application activated event - } else if(parent instanceof Group && groupActive) { - //TODO send Group activated event + if (parent instanceof Application && groupActive) { + //send application activated event + StatusEventPublisher.sendApplicationActivatedEvent(appId); + } else if (parent instanceof Group && groupActive) { + //send activation to the parent + StatusEventPublisher.sendGroupActivatedEvent(appId, ((Group) parent).getAlias()); } return childFound; } else { - if(!groups.isEmpty()) { - for(Group group: groups.values()) { - return updateChildStatus(id, group.getAliasToGroupMap(), group.getClusterDataMap(), group); + if (!groups.isEmpty()) { + for (Group group : groups.values()) { + return updateChildStatus(appId, id, group.getAliasToGroupMap(), group.getClusterDataMap(), group); } } @@ -196,8 +199,8 @@ private boolean updateChildStatus(String id, Map groups, Map groups) { boolean groupActiveStatus = false; - for(Group group: groups.values()) { - if(group.getStatus().equals(GroupStatus.Active)) { + for (Group group : groups.values()) { + if (group.getStatus().equals(GroupStatus.Active)) { groupActiveStatus = true; } else { groupActiveStatus = false; @@ -209,16 +212,20 @@ private boolean getGroupStatus(Map groups) { private boolean getClusterStatus(Map clusterData) { boolean clusterActiveStatus = false; - for(Map.Entry clusterDataHolderEntry: clusterData.entrySet()) { + for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); - if(service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). - getStatus().equals(ClusterStatus.Active)) { - clusterActiveStatus = true; - } else { - clusterActiveStatus = false; - } + if (service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). + getStatus().equals(ClusterStatus.Active)) { + clusterActiveStatus = true; + } else { + clusterActiveStatus = false; + } } return clusterActiveStatus; } + private static class Holder { + private static final StatusChecker INSTANCE = new StatusChecker(); + } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 9abdbbbeb9..f5efb21d33 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -24,6 +24,7 @@ import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.listener.application.status.ApplicationActivatedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; @@ -82,6 +83,14 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() { + + @Override + protected void onEvent(Event event) { + + } + }); + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 25dc0273db..ecb0f67bc5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -33,6 +33,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; +import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; @@ -786,6 +787,34 @@ public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedE TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1); } + public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(applicationActivatedEvent.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + applicationActivatedEvent.getAppId())); + return; + } + + + + org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent applicationActivatedEvent1 = + new org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent( + applicationActivatedEvent.getAppId()); + try { + TopologyManager.acquireWriteLock(); + application.setStatus(Status.Activated); + log.info("Application activated adding status started for Topology"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); + } + /*public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 0cbec9b1df..1679115c17 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -256,6 +256,14 @@ public static void sendConfigApplicationRemovedEventEvent(String alias) { publishEvent(compositeApplicationCreatedEvent); } + public static void sendApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application activated event: [appId] %s", + applicationActivatedEvent.getAppId())); + } + publishEvent(applicationActivatedEvent); + } + public static void publishEvent(Event event) { EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); eventPublisher.publish(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java new file mode 100644 index 0000000000..1f64c7a226 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationActivatedEvent.java @@ -0,0 +1,38 @@ +/* + * 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.messaging.event.application.status; + +import java.io.Serializable; + +/** + * This event will be fired upon the application activated is detected. + */ +public class ApplicationActivatedEvent extends StatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String appId; + + public ApplicationActivatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java index 334ea15440..c1434ddad8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java @@ -25,7 +25,7 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class ClusterActivatedEvent extends ClusterStatusEvent implements Serializable { +public class ClusterActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java index 12ab74fc15..b9f6158624 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java @@ -20,7 +20,10 @@ import java.io.Serializable; -public class ClusterMaintenanceModeEvent extends ClusterStatusEvent implements Serializable { +/** + * This will be fired upon the cluster instability detection by either cep/autoscaler. + */ +public class ClusterMaintenanceModeEvent extends StatusEvent implements Serializable { private final String serviceName; private final String clusterId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java index 33326186fd..b76bb7efbc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java @@ -18,13 +18,10 @@ */ package org.apache.stratos.messaging.event.application.status; -import java.io.Serializable; - /** - * This event is fired by cartridge agent when it has cleaned up the data and - * ready to shutdown. + * This event is fired by autoscaler before actually terminate a cluster. */ -public class ClusterReadyToShutdownEvent extends ClusterStatusEvent implements Serializable { +public class ClusterReadyToShutdownEvent extends StatusEvent { private final String serviceName; private final String clusterId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java index 05d646d622..2357881a71 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java @@ -19,13 +19,11 @@ package org.apache.stratos.messaging.event.application.status; -import java.io.Serializable; - /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupActivatedEvent extends GroupStatusEvent implements Serializable { +public class GroupActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; @@ -37,8 +35,8 @@ public GroupActivatedEvent(String appId, String groupId) { } public String getGroupId() { - return this.groupId; - } + return this.groupId; + } public String getAppId() { return appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java index 7b9a09b150..5e6534d0e1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java @@ -18,9 +18,10 @@ */ package org.apache.stratos.messaging.event.application.status; -import java.io.Serializable; - -public class GroupMaintenanceModeEvent extends GroupStatusEvent implements Serializable { +/** + * This event will be fired upon the instability of group detection by autoscaler. + */ +public class GroupMaintenanceModeEvent extends StatusEvent { private String groupId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java index 4e1d7764ce..d1ed012c43 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java @@ -18,13 +18,10 @@ */ package org.apache.stratos.messaging.event.application.status; -import java.io.Serializable; - /** - * This event is fired by cartridge agent when it has cleaned up the data and - * ready to shutdown. + * This event is fired by autoscaler before actually terminate a group. */ -public class GroupReadyToShutdownEvent extends GroupStatusEvent implements Serializable { +public class GroupReadyToShutdownEvent extends StatusEvent { private String groupId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java similarity index 93% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java index 08b9116d18..7ffc449a8c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupStatusEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java @@ -26,6 +26,6 @@ /** * Represents all instance status events. */ -public abstract class GroupStatusEvent extends Event implements Serializable { +public abstract class StatusEvent extends Event implements Serializable { private static final long serialVersionUID = -4790128084271867615L; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java new file mode 100644 index 0000000000..64417c7ecc --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java @@ -0,0 +1,34 @@ +/* + * 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.messaging.event.topology; + +/** + * This event will be sent to Topology upon activation of application + */ +public class ApplicationActivatedEvent extends TopologyEvent { + private String appId; + + public ApplicationActivatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java index b5c8148b98..3328d22b22 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupActivatedEvent.java @@ -21,7 +21,7 @@ import org.apache.stratos.messaging.event.Event; /** - * Group Activated Event which will be sent by Autoscaler + * Group Activated Event which will be sent to Topology upon group activation */ public class GroupActivatedEvent extends Event { private String appId; @@ -36,15 +36,8 @@ public String getAppId() { return appId; } - public void setAppId(String appId) { - this.appId = appId; - } - public String getGroupId() { return groupId; } - public void setGroupId(String groupId) { - this.groupId = groupId; - } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java similarity index 66% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java index 73eecb535e..22f2ac1a44 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterStatusEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java @@ -7,7 +7,7 @@ * "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 + * 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 @@ -16,16 +16,12 @@ * specific language governing permissions and limitations * under the License. */ +package org.apache.stratos.messaging.listener.application.status; -package org.apache.stratos.messaging.event.application.status; - -import org.apache.stratos.messaging.event.Event; - -import java.io.Serializable; +import org.apache.stratos.messaging.listener.EventListener; /** - * Represents all instance status events. + * This listener will get triggered upon the application activated event. */ -public abstract class ClusterStatusEvent extends Event implements Serializable { - private static final long serialVersionUID = -4790128084271867615L; +public abstract class ApplicationActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java new file mode 100644 index 0000000000..f54ab9e442 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will be triggered upon the application activated event received. + */ +public abstract class ApplicationActivatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java new file mode 100644 index 0000000000..1a46cdf6df --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by reka on 9/25/14. + */ +public class ApplicationStatusAppActivatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusAppActivatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + + } + + @Override + public boolean process(String type, String message, Object object) { + if (ApplicationActivatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ApplicationActivatedEvent event = + (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java index 52415f0410..3d6b069798 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java @@ -27,7 +27,8 @@ import org.apache.stratos.messaging.util.Util; public class ApplicationStatusGroupActivatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ApplicationStatusGroupActivatedMessageProcessor.class); + private static final Log log = + LogFactory.getLog(ApplicationStatusGroupActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -39,9 +40,10 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { if (ClusterActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupActivatedEvent event = (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); + GroupActivatedEvent event = + (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Received GroupActivatedEvent: " + event.toString()); } // Notify event listeners @@ -51,7 +53,9 @@ public boolean process(String type, String message, Object object) { if (nextProcessor != null) { return nextProcessor.process(type, message, object); } else { - throw new RuntimeException(String.format("Failed to process group activated message using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index 96fbc69e28..809789bf3a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationActivatedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; @@ -34,6 +35,7 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; + private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; public void initialize() { // Add instance notifier event processors @@ -41,6 +43,8 @@ public void initialize() { add(clusterActivatedMessageProcessor); groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); + appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor(); + add(appActivatedMessageProcessor); if (log.isDebugEnabled()) { log.debug("Instance notifier message processor chain initialized"); @@ -52,6 +56,8 @@ public void addEventListener(EventListener eventListener) { clusterActivatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationActivatedEventListener) { + appActivatedMessageProcessor.addEventListener(eventListener); } else { throw new RuntimeException("Unknown event listener"); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java new file mode 100644 index 0000000000..8c1e66b695 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor responsible to process the application activation even and update the Topology. + */ +public class ApplicationActivatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationActivatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (ApplicationActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. + jsonToObject(message, ApplicationActivatedEvent.class); + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + application.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Application updated as activated : %s", + application.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 652ebe40d3..e3ddfa3cf0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -50,6 +50,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; + private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; public void initialize() { // Add topology event processors @@ -104,8 +105,8 @@ public void initialize() { applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor(); add(applicationRemovedMessageProcessor); - compositeApplicationRemovedMessageProcessor = new CompositeApplicationRemovedMessageProcessor(); - add(applicationRemovedMessageProcessor); + applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); + add(applicationActivatedMessageProcessor); if (log.isDebugEnabled()) { log.debug("Grouping: added applicationCreatedMessageProcessor, applicationRemovedMessageProcessor: " + @@ -155,13 +156,8 @@ public void addEventListener(EventListener eventListener) { if (log.isDebugEnabled()) { log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); } - - } else if (eventListener instanceof CompositeApplicationRemovedEventListener) { - compositeApplicationRemovedMessageProcessor.addEventListener(eventListener); - if (log.isDebugEnabled()) { - log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); - } - + } else if (eventListener instanceof ApplicationActivatedEventListener) { + applicationActivatedMessageProcessor.addEventListener(eventListener); } else { throw new RuntimeException("Unknown event listener"); } From b040c6fe4e90662a1d79e7455f654ee7ad8e8383 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 12:58:00 +0530 Subject: [PATCH 108/436] update cc to publish app activation to Topology --- .../status/receiver/ApplicationStatusTopicReceiver.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index f5efb21d33..7cce18f676 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.listener.application.status.ApplicationActivatedEventListener; @@ -87,6 +88,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { + TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event); } }); @@ -94,4 +96,7 @@ protected void onEvent(Event event) { } + public void setTerminated(boolean terminated) { + this.terminated = terminated; + } } From 217bc5476e5b1d574b0160ae257af55262f82459 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 13:04:04 +0530 Subject: [PATCH 109/436] changing the correct topic and code formatting --- .../grouping/DependencyBuilder.java | 23 +- .../grouping/topic/StatusEventPublisher.java | 38 +-- .../controller/topology/TopologyBuilder.java | 250 ++---------------- 3 files changed, 50 insertions(+), 261 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index afec81800a..3887fa8e06 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -20,7 +20,6 @@ import org.apache.stratos.messaging.domain.topology.*; -import java.util.Collection; import java.util.LinkedList; import java.util.Queue; import java.util.Set; @@ -35,7 +34,7 @@ public static Queue getStartupOrder(ParentBehavior component) { Queue startup = new LinkedList(); DependencyOrder dependencyOrder = component.getDependencyOrder(); - if(dependencyOrder != null) { + if (dependencyOrder != null) { Set startupOrderSet = dependencyOrder.getStartupOrders(); for (StartupOrder startupOrder : startupOrderSet) { @@ -62,29 +61,29 @@ public static Queue getStartupOrder(ParentBehavior component) { //TODO adding all the missed groups or clusters as the top child to the list //TODO handle by application and group itself groupName and serviceName - if(component instanceof Application) { - for(Group group: component.getAliasToGroupMap().values()) { - if(!startup.contains("group." + group.getAlias())) { + if (component instanceof Application) { + for (Group group : component.getAliasToGroupMap().values()) { + if (!startup.contains("group." + group.getAlias())) { startup.add("group." + group.getAlias()); } } Set cartridgeAliases = component.getClusterDataMap().keySet(); - for(String carAlias : cartridgeAliases) { - if(!startup.contains("cartridge." + carAlias)) { + for (String carAlias : cartridgeAliases) { + if (!startup.contains("cartridge." + carAlias)) { startup.add("cartridge." + carAlias); } } - } else if(component instanceof Group) { - for(Group group: component.getAliasToGroupMap().values()) { - if(!startup.contains("group." + group.getName())) { + } else if (component instanceof Group) { + for (Group group : component.getAliasToGroupMap().values()) { + if (!startup.contains("group." + group.getName())) { startup.add("group." + group.getName()); } } - for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { - if(!startup.contains("cartridge." + dataHolder.getServiceType())) { + for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + if (!startup.contains("cartridge." + dataHolder.getServiceType())) { startup.add("cartridge." + dataHolder.getServiceType()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 13860fe05a..efd5eea7ad 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -9,41 +9,41 @@ import org.apache.stratos.messaging.util.Constants; /** - * Created by reka on 9/21/14. + * This will publish application related events to application status topic. */ public class StatusEventPublisher { private static final Log log = LogFactory.getLog(StatusEventPublisher.class); - public static void sendClusterActivatedEvent (String appId, String serviceName, String clusterId) { + public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { - if(log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Publishing Cluster activated event for [application]: " + appId + - " [cluster]: " + clusterId ); + " [cluster]: " + clusterId); } - ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId,serviceName, clusterId); + ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent); } - public static void sendClusterInMaintenanceEvent (String appId, String serviceName, String clusterId) { + public static void sendClusterInMaintenanceEvent(String appId, String serviceName, String clusterId) { - if(log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Publishing Cluster in_maintenance event for [application]: " + appId + - " [cluster]: " + clusterId ); + " [cluster]: " + clusterId); } ClusterMaintenanceModeEvent clusterInMaintenanceEvent = - new ClusterMaintenanceModeEvent(appId,serviceName, clusterId); + new ClusterMaintenanceModeEvent(appId, serviceName, clusterId); publishEvent(clusterInMaintenanceEvent); } - public static void sendGroupActivatedEvent (String appId, String groupId) { + public static void sendGroupActivatedEvent(String appId, String groupId) { - if(log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Publishing Group activated event for [application]: " + appId + - " [group]: " + groupId ); + " [group]: " + groupId); } GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId); @@ -51,9 +51,9 @@ public static void sendGroupActivatedEvent (String appId, String groupId) { publishEvent(groupActivatedEvent); } - public static void sendApplicationActivatedEvent (String appId) { + public static void sendApplicationActivatedEvent(String appId) { - if(log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Publishing Application activated event for [application]: " + appId); } @@ -62,11 +62,11 @@ public static void sendApplicationActivatedEvent (String appId) { publishEvent(applicationActivatedEvent); } - public static void sendGroupInMaintenanceEvent (String appId, String groupId) { + public static void sendGroupInMaintenanceEvent(String appId, String groupId) { - if(log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info("Publishing Group in_maintenance event for [application]: " + appId + - " [group]: " + groupId ); + " [group]: " + groupId); } GroupMaintenanceModeEvent groupMaintenanceModeEvent = @@ -76,8 +76,8 @@ public static void sendGroupInMaintenanceEvent (String appId, String groupId) { } public static void publishEvent(Event event) { - //TODO change the topics for cluster and group accordingly - EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.INSTANCE_STATUS_TOPIC); + //publishing events to application status topic + EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATION_STATUS_TOPIC); eventPublisher.publish(event); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 5eb3f97ee4..a0779e3ccf 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -22,11 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.ClusterContext; -import org.apache.stratos.cloud.controller.pojo.PortMapping; -import org.apache.stratos.cloud.controller.pojo.Registrant; import org.apache.stratos.cloud.controller.pojo.*; +import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -135,10 +132,10 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { // update the cluster cluster = service.getCluster(clusterId); cluster.addHostName(registrant.getHostName()); - if(service.getServiceType() == ServiceType.MultiTenant) { + if (service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); } - if(service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { + if (service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { props.setProperty(Constants.IS_PRIMARY, service.getProperties().getProperty(Constants.IS_PRIMARY)); } cluster.setProperties(props); @@ -147,10 +144,10 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { cluster = new Cluster(cartridgeType, clusterId, registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName()); cluster.addHostName(registrant.getHostName()); - if(service.getServiceType() == ServiceType.MultiTenant) { + if (service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); } - if(service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { + if (service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { props.setProperty(Constants.IS_PRIMARY, service.getProperties().getProperty(Constants.IS_PRIMARY)); } cluster.setProperties(props); @@ -297,10 +294,10 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent log.debug("TopologyBuilder found composite app for " + appAlias); } String clusterId = instanceStartedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); instanceStartedEvent.setGroupId(groupAlias); if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); } } @@ -351,15 +348,14 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate log.debug("TopologyBuilder found composite app for member activated " + appAlias); } String clusterId = instanceActivatedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); instanceActivatedEvent.setGroupId(groupAlias); if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); } } - Member member = cluster.getMember(instanceActivatedEvent.getMemberId()); if (member == null) { @@ -441,10 +437,10 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst log.debug("TopologyBuilder found composite app for " + appAlias); } String clusterId = instanceReadyToShutdownEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); instanceReadyToShutdownEvent.setGroupId(groupAlias); if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); } } @@ -522,10 +518,10 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance } String clusterId = instanceMaintenanceModeEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); + String groupAlias = app.extractClusterGroupFromClusterId(clusterId); instanceMaintenanceModeEvent.setGroupId(groupAlias); if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); } } @@ -583,14 +579,14 @@ public static void handleMemberTerminated(String serviceName, String clusterId, String appAlias = "compositeApplicationAlias"; CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - String groupAlias = null; + String groupAlias = null; if (app != null) { if (log.isDebugEnabled()) { log.debug("TopologyBuilder found composite app for " + appAlias); } - groupAlias = app.extractClusterGroupFromClusterId(clusterId); + groupAlias = app.extractClusterGroupFromClusterId(clusterId); if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); + log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); } } @@ -619,7 +615,6 @@ public static void handleApplicationDeployed(Application application, Set metaDataHolders) { - Topology topology = TopologyManager.getTopology(); try { TopologyManager.acquireWriteLock(); @@ -659,10 +654,10 @@ public static void handleApplicationDeployed(Application application, } } - public static void handleApplicationUndeployed (String applicationId, int tenantId, String tenantDomain) { + public static void handleApplicationUndeployed(String applicationId, int tenantId, String tenantDomain) { Topology topology = TopologyManager.getTopology(); - + try { TopologyManager.acquireWriteLock(); @@ -708,10 +703,9 @@ public static void handleCompositeApplicationCreated(ConfigCompositeApplication TopologyManager.acquireWriteLock(); String key = "compositeApplicationAlias"; //app.getAlias() - topology.addConfigCompositeApplication(key ,messConfigApp); + topology.addConfigCompositeApplication(key, messConfigApp); TopologyManager.updateTopology(topology); - } - finally { + } finally { TopologyManager.releaseWriteLock(); } TopologyEventPublisher.sendConfigApplicationCreatedEventEvent(messConfigApp); @@ -803,8 +797,6 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app return; } - - org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent applicationActivatedEvent1 = new org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent( applicationActivatedEvent.getAppId()); @@ -821,206 +813,4 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); } - - - /*public static ConfigCompositeApplication convertCompositeApplication(CompositeApplicationDefinition compositeApplicationDefinition) { - ConfigCompositeApplication messApp = new ConfigCompositeApplication(); - String alias = compositeApplicationDefinition.getAlias(); - messApp.setAlias(alias); - String applicationId = compositeApplicationDefinition.getApplicationId(); - messApp.setApplicationId(applicationId); - org.apache.stratos.cloud.controller.pojo.ConfigCartridge[] arrayMessCartridges = compositeApplicationDefinition.getCartridges(); - org.apache.stratos.cloud.controller.pojo.ConfigGroup [] messConfigGroup = compositeApplicationDefinition.getComponents(); - - List cartridges = new ArrayList(); - List messGroups = new ArrayList(); - List messDependencies= new ArrayList(); - - for (org.apache.stratos.cloud.controller.pojo.ConfigCartridge cfg : arrayMessCartridges) { - ConfigCartridge cartridge = new ConfigCartridge(); - cartridge.setAlias(cfg.getAlias()); - - cartridges.add(cartridge); - } - messApp.setCartridges(cartridges); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: messConfigGroup size: " + messConfigGroup.length); - } - for (org.apache.stratos.cloud.controller.pojo.ConfigGroup gr : messConfigGroup) { - ConfigGroup group = new ConfigGroup(); - - // alias - group.setAlias(gr.getAlias()); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: messConfigGroup group alias " + gr.getAlias()); - } - // subscribables - String [] arraySub = gr.getSubscribables(); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: messConfigGroup group nr of subscribables " + arraySub.length); - } - List subscribables = new ArrayList(); - if (arraySub != null) { - int i = 0; - for (String sub : arraySub) { - subscribables.add(arraySub[i]); - i++; - } - } else { - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: messConfigGroup group nr no subscribables is null"); - } - } - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: adding subscribables to group: " + group.getAlias() + - " and nr of subscribables " + subscribables.size()); - } - group.setSubscribables(subscribables); - // dependencies - org.apache.stratos.cloud.controller.pojo.ConfigDependencies dep = gr.getDependencies(); - ConfigDependencies messDep = new ConfigDependencies(); - org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair [] pairs = dep.getStartup_order(); - List startup_order; - if (pairs != null) { - log.debug("TopolgyBuilder: number of startup pairs " + pairs.length); - startup_order = new ArrayList(pairs.length); - //for (org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair pair : pairs) { - for (int i = 0; i < pairs.length; i++) { - org.apache.stratos.cloud.controller.pojo.ConfigDependencyPair pair = pairs[i]; - if (pair != null) { - ConfigDependencies.Pair messPair = new ConfigDependencies.Pair(pair.getKey(), pair.getValue()); - startup_order.add(messPair); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: adding dep pairs to group: " + pair.getKey() + " / " + - pair.getValue() + " at " + i); - } - } else { - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: Error while adding pair, pair is null"); - } - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: no dependencies added"); - } - startup_order = new ArrayList(0); - } - - messDep.setStartup_order(startup_order); - messDep.setKill_behavior(dep.getKill_behavior()); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: added kill behavior " + dep.getKill_behavior()); - } - group.setDependencies(messDep); - - messGroups.add(group); - if (log.isDebugEnabled()) { - log.debug("TopolgyBuilder: number of groups " + messGroups.size()); - } - } - messApp.setComponents(messGroups); - if (log.isDebugEnabled()) { - if (messApp.getComponents() != null) { - log.debug("TopolgyBuilder: added total nr of groups to application " + messApp.getComponents().size()); - } - else { - log.debug("TopolgyBuilder: added total nr of groups to application is null"); - } - } - - - /* test - ConfigGroup grX = new ConfigGroup(); - grX.setAlias("hug"); - List subX = new ArrayList(); - subX.add("cone"); - grX.setSubscribables(subX); - ConfigDependencies cgX = new ConfigDependencies(); - cgX.setKill_behavior("kill-all"); - log.debug("verifying cgX object serialization : " + Util.ObjectToJson(cgX)); - ConfigDependencies.Pair startup_orderX = new ConfigDependencies.Pair("eins", "zwei"); - List depspairsX = new ArrayList(); - depspairsX.add(startup_orderX); - log.debug("verifying depspairsX object serialization : " + Util.ObjectToJson(depspairsX)); - cgX.setStartup_order(depspairsX); - grX.setDependencies(cgX); - log.debug("verifying grX object serialization : " + Util.ObjectToJson(grX)); - messGroups.add(grX); - messApp.setComponents(messGroups); - log.debug("verifying messApp object serialization : " + Util.ObjectToJson(messApp)); - // - test end */ - /* - return messApp; - }*/ - - /* - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (log.isDebugEnabled()) { - log.debug("processing application event of type " + type + - " / topology:" + topology + " msg: " + message); - } - - if (CompositeApplicationCreatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) { - - if (log.isDebugEnabled()) { - log.debug("topology is not initialized .... need to add check ... Grouping"); - } - - //return false; - } - - // Parse complete message and build event - CompositeApplicationCreatedEvent event = - (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("processing application created event with application id: " + event.getApplicationAlias()); - } - - // Validate event against the existing topology - if (topology.compositeApplicationExists(event.getApplicationAlias())) { - if (log.isWarnEnabled()) { - log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias())); - } - } else { - - ConfigCompositeApplication configApp = event.getCompositeApplication(); - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(configApp); - CompositeApplication app = new CompositeApplication(); - app.setAlias(configApp.getAlias()); - app.setTop_level(builder.buildApplication()); - String key = "compositeApplicationAlias"; //app.getAlias() - topology.addCompositeApplication(key ,app); - - if (log.isInfoEnabled()) { - log.info("CompositeApplication created with alias" +app.getAlias() + " and saved with key " + "compositeApplicationAlias" ); - log.info(String.format("CompositeApplication created: [app] %s", app.getTop_level())); - if (log.isDebugEnabled()) { - log.debug("verifying CompositeApplication object serialization : " + Util.ObjectToJson(app)); - } - } - } - - // Notify event listeners - notifyEventListeners(event); - return true; - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - */ - - } From bc967e308b7c21813f2bbd0cda0e6d223cd0a8d1 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 25 Sep 2014 13:40:14 +0530 Subject: [PATCH 110/436] adding puppet related info to the text payload --- .../application/ApplicationUtils.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 7117170b5a..695af5d4a8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -127,7 +127,7 @@ public static MetaDataHolder getClusterLevelPayloadData (String appId, String gr // cartridge key clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key); // get global payload params - clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); + //clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); metaDataHolder.setProperties(clusterLevelPayloadProperties); return metaDataHolder; @@ -158,6 +158,23 @@ public static StringBuilder getTextPayload (String appId, String groupName, Stri } payloadBuilder.append(","); payloadBuilder.append("CLUSTER_ID=" + clusterId); + // puppet related + if (System.getProperty("puppet.ip") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip")); + } + if (System.getProperty("puppet.hostname") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); + } + if (System.getProperty("puppet.env") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.env")); + } + if (System.getProperty("puppet.dns.available") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.dns.available")); + } // meta data endpoint // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { // TODO From 24fc938eaed677f65931d8483f50ca8930d05c69 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 25 Sep 2014 16:19:50 +0530 Subject: [PATCH 111/436] reverting to text based payloads temporarily --- .../application/ApplicationUtils.java | 104 ++++++- .../parser/DefaultApplicationParser.java | 26 +- .../ApplicationCartridgePayloadData.java | 27 ++ .../application/payload/BasicPayloadData.java | 253 ++++++++++++++++++ .../payload/DataCartridgePayloadData.java | 27 ++ .../FrameworkCartridgePayloadData.java | 27 ++ .../LoadBalancerCartridgePayloadData.java | 27 ++ .../application/payload/PayloadData.java | 69 +++++ .../application/payload/PayloadFactory.java | 59 ++++ 9 files changed, 604 insertions(+), 15 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java create mode 100755 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 695af5d4a8..697f33a8fb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -19,12 +19,15 @@ package org.apache.stratos.cloud.controller.application; +import org.apache.stratos.cloud.controller.application.payload.BasicPayloadData; +import org.apache.stratos.cloud.controller.application.payload.PayloadData; +import org.apache.stratos.cloud.controller.application.payload.PayloadFactory; +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.PortMapping; import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import java.util.*; import java.util.regex.Pattern; @@ -115,9 +118,9 @@ public static MetaDataHolder getClusterLevelPayloadData (String appId, String gr clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl()); } // ports - if (createPortMappingPayloadString(cartridge) != null) { - clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge)); - } +// if (createPortMappingPayloadString(cartridge) != null) { +// clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge)); +// } // provider if (cartridge.getProvider() != null) { clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider()); @@ -144,8 +147,9 @@ private static String createPortMappingPayloadString (Cartridge cartridge) { } // remove last "|" character + String portMappingString = portMapBuilder.toString().replaceAll("\\|$", ""); - return portMapBuilder.toString().replaceAll("\\|$", ""); + return portMappingString; } public static StringBuilder getTextPayload (String appId, String groupName, String clusterId) { @@ -185,4 +189,94 @@ public static StringBuilder getTextPayload (String appId, String groupName, Stri return payloadBuilder; } + + public static PayloadData createPayload (String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String clusterId, + String hostName, String repoUrl, String alias, Map customPayloadEntries) + throws ApplicationDefinitionException { + + //Create the payload + BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridge, subscriptionKey, + clusterId, hostName, repoUrl, alias, tenantId); + //Populate the basic payload details + basicPayloadData.populatePayload(); + + PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridge.getProvider(), + cartridge.getType(), basicPayloadData); + + boolean isDeploymentParam = false; + // get the payload parameters defined in the cartridge definition file for this cartridge type + if (cartridge.getProperties() != null && !cartridge.getProperties().isEmpty()) { + + for (Map.Entry propertyEntry : cartridge.getProperties().entrySet()) { + // 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 (propertyEntry.getKey() + .startsWith("payload_parameter.")) { + String payloadParamName = propertyEntry.getKey(); + String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1); + if("DEPLOYMENT".equals(payloadParamSubstring)) { + isDeploymentParam = true; + } + payloadData.add(payloadParamSubstring, propertyEntry.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> entrySet = customPayloadEntries.entrySet(); + for (Map.Entry entry : entrySet) { + payloadData.add(entry.getKey(), entry.getValue()); + } + } + + return payloadData; + } + + private static BasicPayloadData createBasicPayload (String appId, String groupName, Cartridge cartridge, + String subscriptionKey, String clusterId, + String hostName, String repoUrl, String alias, + int tenantId) { + + BasicPayloadData basicPayloadData = new BasicPayloadData(); + basicPayloadData.setAppId(appId); + basicPayloadData.setGroupName(groupName); + basicPayloadData.setApplicationPath(cartridge.getBaseDir()); + basicPayloadData.setSubscriptionKey(subscriptionKey); + //basicPayloadData.setDeployment("default");//currently hard coded to default + basicPayloadData.setMultitenant(String.valueOf(cartridge.isMultiTenant())); + basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridge)); + basicPayloadData.setServiceName(cartridge.getType()); + basicPayloadData.setProvider(cartridge.getProvider()); + + if(repoUrl != null) { + basicPayloadData.setGitRepositoryUrl(repoUrl); + } + + if (clusterId != null) { + basicPayloadData.setClusterId(clusterId); + } + + if (hostName != null) { + basicPayloadData.setHostName(hostName); + } + + if (alias != null) { + basicPayloadData.setSubscriptionAlias(alias); + } + + basicPayloadData.setTenantId(tenantId); + + basicPayloadData.setTenantRange("*"); + + return basicPayloadData; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 282b4d9035..62db219272 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -500,13 +500,15 @@ private Map parseLeafLevelSubscriptions (String appId // create and collect this cluster's information assert subscribableInfoCtxt != null; - ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(subscribableCtxt.getType(), - appId, groupName, clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false); + ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, + key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), + clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false); this.applicationClusterContexts.add(appClusterCtxt); + // TODO: I will bring you back when meta data service is completed B-) // create cluster level meta data - this.metaDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, - hostname, appClusterCtxt.getTenantRange(), clusterId, subscribableCtxt, subscribableInfoCtxt, cartridge)); + //this.metaDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, + // hostname, appClusterCtxt.getTenantRange(), clusterId, subscribableCtxt, subscribableInfoCtxt, cartridge)); // add relevant information to the map clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId)); @@ -531,15 +533,19 @@ private Map parseLeafLevelSubscriptions (String appId //clusterDataHolder.setPayloadDataHolders(payloadDataHolders); } - private ApplicationClusterContext createApplicationClusterContext (String serviceType, String appId, - String groupName, String clusterId, - String hostname, String deploymentPolicy, - boolean isLB) { + private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge, + String subscriptionKey, int tenantId, String repoUrl, + String alias, String clusterId, String hostname, + String deploymentPolicy, boolean isLB) + throws ApplicationDefinitionException { // Create text payload - String textPayload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); + //String textPayload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); + + String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId, + hostname, repoUrl, alias, null).toString(); - return new ApplicationClusterContext(serviceType, clusterId, hostname, textPayload, deploymentPolicy, isLB); + return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); } // public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java new file mode 100644 index 0000000000..870c22c38a --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +public class ApplicationCartridgePayloadData extends PayloadData { + + public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java new file mode 100644 index 0000000000..c15e49225d --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java @@ -0,0 +1,253 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; + +/** + * Contains basic payload data fields + */ +public class BasicPayloadData implements Serializable { + + private static Log log = LogFactory.getLog(BasicPayloadData.class); + + private String appId; + private String groupName; + 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("APP_ID=" + getAppId()); + payloadBuilder.append(","); + payloadBuilder.append("GROUP_NAME=" + getGroupName()); + payloadBuilder.append(","); + 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("puppet.ip")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available")); + + } + + 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; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java new file mode 100644 index 0000000000..1848b6d042 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +public class DataCartridgePayloadData extends PayloadData { + + public DataCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java new file mode 100644 index 0000000000..a22d40bfc8 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +public class FrameworkCartridgePayloadData extends PayloadData { + + public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java new file mode 100644 index 0000000000..6ceeba91d2 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +public class LoadBalancerCartridgePayloadData extends PayloadData { + + public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java new file mode 100644 index 0000000000..35b1fe6030 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.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 completePayloadMap; + public PayloadData(BasicPayloadData basicPayloadData) { + + this.setBasicPayloadData(basicPayloadData); + completePayloadMap = new HashMap(); + } + + 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(); + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java new file mode 100755 index 0000000000..2b3ea8be59 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java @@ -0,0 +1,59 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + + * http://www.apache.org/licenses/LICENSE-2.0 + + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application.payload; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; + + +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 + */ + public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType, + BasicPayloadData basicPayloadData) + throws ApplicationDefinitionException { + + PayloadData payloadData = null; + + //TODO: fix after adding the property Category to Cartridge Definition + if (cartridgeProvider.equals("data")) { + payloadData = new DataCartridgePayloadData(basicPayloadData); + } else { + payloadData = new FrameworkCartridgePayloadData(basicPayloadData); + } + + if(payloadData == null) { + throw new ApplicationDefinitionException("Unable to find matching payload for cartridge type " + cartridgeType + + ", provider " + cartridgeProvider); + } + + return payloadData; + } +} From ec185f200e1303302edb6e3a70154ca7619f9422 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 25 Sep 2014 16:24:10 +0530 Subject: [PATCH 112/436] adding getSubscriptionsOfApplication to rest api --- .../rest/endpoint/services/ServiceUtils.java | 19 ++++++++++++++----- .../rest/endpoint/services/StratosAdmin.java | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 4f102e3354..d5744a4bdb 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -24,17 +24,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; -import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; +import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; -import org.apache.stratos.manager.composite.application.CompositeApplicationManager; import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; +import org.apache.stratos.manager.composite.application.CompositeApplicationManager; +import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager; import org.apache.stratos.manager.dto.Cartridge; @@ -44,6 +44,7 @@ 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.subscription.SubscriptionData; @@ -70,7 +71,6 @@ 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; @@ -299,6 +299,15 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit throw new RestAPIException(e); } } + + 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); + } + } static void unDeployApplication(String appId, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index a3cfa31901..d8e5a40e42 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -31,8 +31,8 @@ import org.apache.stratos.manager.exception.DomainMappingExistsException; import org.apache.stratos.manager.exception.ServiceDoesNotExistException; 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.subscription.SubscriptionDomain; import org.apache.stratos.rest.endpoint.ServiceHolder; import org.apache.stratos.rest.endpoint.Utils; import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; @@ -46,7 +46,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.CartridgeDefinitionBean; import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; -import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Repository; import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.topology.Cluster; import org.apache.stratos.rest.endpoint.exception.RestAPIException; @@ -71,7 +70,6 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; - import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -437,6 +435,20 @@ public Response getAvailableMultiTenantCartridges() throws RestAPIException { return rb.build(); } + + @GET + @Path("/subsscriptions/{application_id}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getSubscriptionsOfApplication(@PathParam("application_id") String applicationId) throws RestAPIException { + ApplicationSubscription subscriptions = ServiceUtils.getApplicationSubscriptions(applicationId, getConfigContext()); + if(subscriptions == null){ + return Response.status(Response.Status.NOT_FOUND).build(); + } + return Response.ok().entity(subscriptions).build(); + } + @GET @Path("/cartridge/list") @Produces("application/json") From 48aa865fdaa9e7c1a4e4ff65f86b2b0338823048 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 16:24:48 +0530 Subject: [PATCH 113/436] adding monitor message passing using notification --- .../AutoscalerTopologyEventReceiver.java | 42 +++++++++++++- .../monitor/AbstractClusterMonitor.java | 18 +++++- .../stratos/autoscaler/monitor/Monitor.java | 21 +++---- .../application/ApplicationMonitor.java | 55 +++++++++++++++---- .../monitor/cluster/ClusterMonitor.java | 10 +--- .../monitor/cluster/LbClusterMonitor.java | 9 --- .../events/ApplicationActivatedEvent.java | 42 ++++++++++++++ .../monitor/events/ClusterActivatedEvent.java | 49 ++++++++++++++++- .../events/ClusterInMaintenanceEvent.java | 20 ++++++- .../monitor/events/GroupActivatedEvent.java | 43 ++++++++++++++- .../events/GroupInMaintenanceEvent.java | 20 ++++++- .../monitor/events/MonitorEvent.java | 22 +++++++- .../monitor/events/MonitorStatusEvent.java | 42 ++++++++++++++ .../monitor/group/GroupMonitor.java | 28 ++++++++++ 14 files changed, 372 insertions(+), 49 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 575e1a5fa6..d5ebec82db 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -146,12 +146,50 @@ protected void onEvent(Event event) { ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); Monitor monitor = appMonitor.findParentMonitorOfCluster(clusterId); - monitor.notify(); + AbstractClusterMonitor clusterMonitor = AutoscalerContext.getInstance().getMonitor(clusterId); + + //TODO monitor.notify(); //starting the status checker to decide on the status of it's parent StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); + topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupActivatedEvent] Received: " + event.getClass()); + + GroupActivatedEvent groupActivatedEvent = (GroupActivatedEvent) event; + String appId = groupActivatedEvent.getAppId(); + String groupId = groupActivatedEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + Monitor monitor = appMonitor.findParentMonitorOfGroup(groupId); + + //TODO monitor.notify(); + //starting the status checker to decide on the status of it's parent + StatusChecker.getInstance().onGroupStatusChange(groupId, appId); + } + }); + + topologyEventReceiver.addEventListener(new ApplicationActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationActivatedEvent] Received: " + event.getClass()); + + ApplicationActivatedEvent applicationActivatedEvent = (ApplicationActivatedEvent) event; + String appId = applicationActivatedEvent.getAppId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + //TODO update appmonitor + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override @@ -408,6 +446,8 @@ protected void onEvent(Event event) { } // partitionContext.incrementCurrentActiveMemberCount(1); partitionContext.movePendingMemberToActiveMembers(memberId); + //triggering the status checker + StatusChecker.getInstance().onMemberStatusChange(e.getClusterId()); } catch (Exception e) { log.error("Error processing event", e); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index cb93886c30..ae47f63d89 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import java.util.Map; @@ -35,6 +36,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; @@ -66,6 +68,8 @@ abstract public class AbstractClusterMonitor extends Observable implements Obser protected String serviceId; protected String appId; + protected Status status; + protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; // time intereval between two runs of the Monitor. Default is 90000ms. @@ -230,10 +234,22 @@ public void setTerminateDependencyFactHandle( @Override public void update(Observable observable, Object o) { - + //get the update from parent monitor } public int getMonitorInterval() { return monitorInterval; } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + log.info(String.format("[Monitor] %s is notifying the parent" + + "on its state change from %s to %s", clusterId, this.status, status)); + this.status = status; + setChanged(); + notifyObservers(new MonitorStatusEvent(status, clusterId)); + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 19f8298b46..420fc38f0b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -26,13 +26,13 @@ import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.ParentBehavior; +import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; @@ -53,10 +53,13 @@ public abstract class Monitor extends Observable implements Observer { protected ParentBehavior component; + protected Status status; + public Monitor(ParentBehavior component) { groupMonitors = new HashMap(); abstractClusterMonitors = new HashMap(); this.component = component; + preOrderTraverse = DependencyBuilder.getStartupOrder(component); startDependency(); } @@ -89,17 +92,6 @@ public void setAbstractClusterMonitors(Map abstr public abstract void monitor(); - @Override - public void update(Observable observable, Object arg) { - if(arg instanceof Event) { - Event event = (Event) arg; - if(log.isDebugEnabled()) { - log.debug(String.format("Event received: %s", event.getClass().getName())); - } - onEvent(event); - } - } - /** * Triggered when an event is received. * @param event @@ -162,6 +154,9 @@ protected synchronized void startGroupMonitor(Monitor parent, String dependency, } } + public Status getStatus() { + return status; + } private class ClusterMonitorAdder implements Runnable { private Cluster cluster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 963b24a91b..c517868b36 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -23,6 +23,7 @@ import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.*; @@ -44,11 +45,18 @@ public ApplicationMonitor(ParentBehavior application) { } @Override - public void update(Observable observable, Object arg) { - if(arg instanceof Event) { - + public void update(Observable observable, Object event) { + if(event instanceof MonitorStatusEvent) { + MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; + Status childStatus = statusEvent.getStatus(); + String notifier = statusEvent.getNotifierId(); + log.info(String.format("[Monitor] %s got notified from the [child] %s" + + "on its state change from %s to %s", id, notifier, this.status, status)); + if(childStatus == Status.Activated) { + //start the next dependency + startDependency(); + } } - } @Override @@ -62,9 +70,7 @@ protected void startDependency() { //TODO breadth first search in a tree and find the parallel one //TODO build up the tree with ordered manner - preOrderTraverse = DependencyBuilder.getStartupOrder(component); - - //start the first dependency + // start the first dependency if(!preOrderTraverse.isEmpty()) { String dependency = preOrderTraverse.poll(); if (dependency.contains("group")) { @@ -95,11 +101,40 @@ protected void startDependency() { /** * Find the group monitor by traversing recursively in the hierarchical monitors. - * @param id the unique alias of the Group + * @param groupId the unique alias of the Group * @return the found GroupMonitor */ - public Monitor findGroupMonitorWithId(String id) { - return findGroupMonitor(id, groupMonitors.values()); + public Monitor findGroupMonitorWithId(String groupId) { + return findGroupMonitor(groupId, groupMonitors.values()); + + } + + /** + * Find the cluster monitor by traversing recursively in the hierarchical monitors. + * @param clusterId + * @return + */ + public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { + return findClusterMonitor(clusterId, abstractClusterMonitors.values(), groupMonitors.values()); + + } + + private AbstractClusterMonitor findClusterMonitor(String clusterId, + Collection clusterMonitors, + Collection groupMonitors) { + for (AbstractClusterMonitor monitor : clusterMonitors) { + // check if alias is equal, if so, return + if (monitor.equals(clusterId)) { + return monitor; + } + } + + for(GroupMonitor groupMonitor : groupMonitors) { + return findClusterMonitor(clusterId, + groupMonitor.getAbstractClusterMonitors().values(), + groupMonitor.getGroupMonitors().values()); + } + return null; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 8c1e5080ea..1189f8f656 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -46,7 +46,7 @@ public class ClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(ClusterMonitor.class); private String lbReferenceType; private boolean hasPrimary; - private Status status; + public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { @@ -241,12 +241,4 @@ public boolean isHasPrimary() { public void setHasPrimary(boolean hasPrimary) { this.hasPrimary = hasPrimary; } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index 0335db9170..e627503a1a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -117,14 +117,5 @@ public String toString() { } - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java new file mode 100644 index 0000000000..719c94faf9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java @@ -0,0 +1,42 @@ +/* + * 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.autoscaler.monitor.events; + +import org.apache.stratos.messaging.domain.topology.Status; + +/** + * This will use to notify observers upon a application activation events received in Topology. + */ +public class ApplicationActivatedEvent extends MonitorEvent { + private Status status; + private String appId; + + public ApplicationActivatedEvent(Status status, String appId) { + this.status = status; + this.appId = appId; + } + + public Status getStatus() { + return status; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java index e35fe744d4..54e64071bb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java @@ -1,7 +1,54 @@ +/* + * 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.autoscaler.monitor.events; +import org.apache.stratos.messaging.domain.topology.Status; + /** - * Created by reka on 9/21/14. + * This will use to notify observers upon a cluster activation events received in Topology. */ public class ClusterActivatedEvent extends MonitorEvent { + private Status status; + private String appId; + private String clusterId; + private String serviceName; + + public ClusterActivatedEvent(Status status, String appId, String clusterId, String serviceName) { + this.status = status; + this.appId = appId; + this.clusterId = clusterId; + this.serviceName = serviceName; + } + + public Status getStatus() { + return status; + } + + public String getAppId() { + return appId; + } + + public String getClusterId() { + return clusterId; + } + + public String getServiceName() { + return serviceName; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java index f227195de9..14d322c13b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java @@ -1,7 +1,25 @@ +/* + * 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.autoscaler.monitor.events; /** - * Created by reka on 9/21/14. + * This will use to notify observers upon a cluster maintenance events received in Topology. */ public class ClusterInMaintenanceEvent extends MonitorEvent { } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java index 448df651bc..cd7d37dde9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java @@ -1,7 +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.autoscaler.monitor.events; +import org.apache.stratos.messaging.domain.topology.Status; + /** - * Created by reka on 9/21/14. + * This will use to notify observers upon a group activation events received in Topology. */ public class GroupActivatedEvent extends MonitorEvent { + private Status status; + private String appId; + private String groupId; + + public GroupActivatedEvent(Status status, String appId, String groupId) { + this.status = status; + this.appId = appId; + this.groupId = groupId; + } + + public Status getStatus() { + return status; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java index e7b0605f6f..163e0d6c13 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java @@ -1,7 +1,25 @@ +/* + * 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.autoscaler.monitor.events; /** - * Created by reka on 9/21/14. + * This will use to notify observers upon a group maintenance events received in Topology. */ public class GroupInMaintenanceEvent extends MonitorEvent { } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java index 8fcf78296e..96e2ae4bc2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java @@ -1,9 +1,27 @@ +/* + * 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.autoscaler.monitor.events; import java.io.Serializable; /** - * Created by reka on 9/21/14. + * This event will be used to notify observers based on the status events received from Topology. */ -public abstract class MonitorEvent implements Serializable{ +public abstract class MonitorEvent implements Serializable { } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java new file mode 100644 index 0000000000..61fcf95fae --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java @@ -0,0 +1,42 @@ +/* + * 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.autoscaler.monitor.events; + +import org.apache.stratos.messaging.domain.topology.Status; + +/** + * Created by reka on 9/25/14. + */ +public class MonitorStatusEvent extends MonitorEvent { + private Status status; + private String notifierId; + + public MonitorStatusEvent(Status status, String notifierId) { + this.status = status; + this.notifierId = notifierId; + } + + public Status getStatus() { + return status; + } + + public String getNotifierId() { + return notifierId; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 4b5d62bcf0..8fa20f1a55 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -22,14 +22,17 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.List; import java.util.Map; +import java.util.Observable; /** * This is GroupMonitor to monitor the group which consists of @@ -47,6 +50,31 @@ public GroupMonitor(Group group) { } + @Override + public void update(Observable observable, Object event) { + if(event instanceof MonitorStatusEvent) { + MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; + Status childStatus = statusEvent.getStatus(); + String notifier = statusEvent.getNotifierId(); + log.info(String.format("[Monitor] %s got notified from the [child] %s" + + "on its state change from %s to %s", id, notifier, this.status, status)); + if(childStatus == Status.Activated) { + //start the next dependency + startDependency(); + } + + } + + } + + public void setStatus(Status status) { + log.info(String.format("[Monitor] %s is notifying the parent" + + "on its state change from %s to %s", id, this.status, status)); + this.status = status; + setChanged(); + notifyObservers(new MonitorStatusEvent(status, id)); + } + @Override public void startDependency() { //Need to get the order every time as group/cluster might already been started From 8eb6ea5a190c61016e1c597b30e5717da3d17b17 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 25 Sep 2014 17:32:17 +0530 Subject: [PATCH 114/436] setting autoscaling policy correctly --- .../controller/application/parser/DefaultApplicationParser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 62db219272..36dc7f8ab5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -503,6 +503,7 @@ private Map parseLeafLevelSubscriptions (String appId ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false); + appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); // TODO: I will bring you back when meta data service is completed B-) From 478ed8df4197501ae9665a1008193665f1c031a0 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 25 Sep 2014 18:05:47 +0530 Subject: [PATCH 115/436] checking for duplicate app id before converting in rest EP --- .../rest/endpoint/services/ServiceUtils.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index d5744a4bdb..7ccd082a62 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -264,27 +264,24 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit // } // check if an application with same id already exists - + // check if application with same appId / tenant already exists + CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager(); + int tenantId = ApplicationManagementUtil.getTenantId(ctxt); + String appId = compositeAppDefinition.getApplicationId(); + + try { + if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) { + String msg = "Duplicate application appId: " + appId + " for tenant " + tenantId; + throw new RestAPIException(msg); + } + } catch (ApplicationSubscriptionException e1) { + throw new RestAPIException(e1); + } ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(compositeAppDefinition); applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); - - // check if application with same appId / tenant already exists - CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager(); - int tenantId = ApplicationManagementUtil.getTenantId(ctxt); - String appId = applicationContext.getApplicationId(); - - - try { - if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) { - String msg = "Duplicate application appId: " + appId + " for tenant " + tenantId; - throw new RestAPIException(msg); - } - } catch (ApplicationSubscriptionException e1) { - throw new RestAPIException(e1); - } try { CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); From 4f33da653e2323ce974a6a83da489d2a1ff778e6 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 18:07:29 +0530 Subject: [PATCH 116/436] adding empty check to queue --- .../autoscaler/monitor/application/ApplicationMonitor.java | 4 +++- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 4 +++- .../stratos/autoscaler/status/checker/StatusChecker.java | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index c517868b36..09921de501 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -54,7 +54,9 @@ public void update(Observable observable, Object event) { "on its state change from %s to %s", id, notifier, this.status, status)); if(childStatus == Status.Activated) { //start the next dependency - startDependency(); + if(!preOrderTraverse.isEmpty()) { + startDependency(); + } } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 8fa20f1a55..aa17b1e0fb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -60,7 +60,9 @@ public void update(Observable observable, Object event) { "on its state change from %s to %s", id, notifier, this.status, status)); if(childStatus == Status.Activated) { //start the next dependency - startDependency(); + if(!preOrderTraverse.isEmpty()) { + startDependency(); + } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index cecd09afe0..06d24aea10 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -158,8 +158,8 @@ public void run() { private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentBehavior parent) { boolean groupActive = false; - boolean clustersActive = false; - boolean groupsActive = false; + boolean clustersActive; + boolean groupsActive; boolean childFound = false; if (clusterData.containsValue(id) || groups.containsKey(id)) { @@ -175,7 +175,7 @@ private boolean updateChildStatus(String appId, String id, Map gr clustersActive = getClusterStatus(clusterData); groupActive = clustersActive; } else { - //TODO warn log + log.warn("Clusters/groups not found in this [component] "+ appId); } //send the activation event if (parent instanceof Application && groupActive) { From 6e7b8f91de7c673c2dbbe1a9c48210cf397034a3 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 25 Sep 2014 18:09:33 +0530 Subject: [PATCH 117/436] remove unnecessary log messages --- .../receiver/topology/AutoscalerTopologyEventReceiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index d5ebec82db..218fdb0731 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -549,7 +549,7 @@ public void run() { long start = System.currentTimeMillis(); applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); long end = System.currentTimeMillis(); - log.info("***********************time taken to start app mon: " + (end - start)/1000); + log.info("Time taken to start app monitor: " + (end - start)/1000); success = true; //TODO exception handling } catch (Exception e) { From 3d446201a38a41d29ac5120a1a0f9f5fe028f211 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 25 Sep 2014 18:10:30 +0530 Subject: [PATCH 118/436] make some logs meaning full --- .../manager/manager/CartridgeSubscriptionManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 index c3b27c7bab..cfc1504127 100644 --- 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 @@ -102,7 +102,7 @@ public ApplicationSubscription createApplicationSubscription (String appId, int appSubscription = dataInsertionAndRetrievalMgr.getApplicationSubscription(tenantId, appId); } catch (PersistenceManagerException e) { - log.error("failed to Application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); + log.error("failed to retrieve application Subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); throw new ApplicationSubscriptionException(e); } @@ -122,9 +122,8 @@ public ApplicationSubscription createApplicationSubscription (String appId, int this.persistApplicationSubscription(appSubscription); } catch (ADCException e) { // TODO Auto-generated catch block - log.error("app Id already exists, failed to createCompositeAppSubscription for appId: " + appId + + log.error("Failed to persist applicaiton subscription for appId: " + appId + " and tenantId: " + tenantId + " e:" + e); - e.printStackTrace(); } } From 59a8b66141ee41db263b8fc220eef0572108e9b5 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 18:43:41 +0530 Subject: [PATCH 119/436] fixing topology locking issue --- .../autoscaler/monitor/application/ApplicationMonitor.java | 4 ++-- .../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 09921de501..6c320a018c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -82,9 +82,9 @@ protected void startDependency() { String clusterId = clusterDataHolder.getClusterId(); String serviceName = clusterDataHolder.getServiceType(); Cluster cluster = null; - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); if (cluster != null) { startClusterMonitor(this,cluster); } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index aa17b1e0fb..0ce9dbb995 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -100,9 +100,9 @@ public void startDependency() { String clusterId = dataHolder.getClusterId(); String serviceName = dataHolder.getServiceType(); Cluster cluster = null; - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); if (cluster != null) { startClusterMonitor(this, cluster); } else { From b859d66a23740f1765c8dbe79dae5976f1b7617c Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 25 Sep 2014 20:45:05 +0530 Subject: [PATCH 120/436] change debug logs to warn --- .../apache/stratos/autoscaler/monitor/Monitor.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 420fc38f0b..776a0d58ad 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -26,7 +26,6 @@ import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -125,7 +124,7 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) }*/ if (log.isDebugEnabled()) { - log.debug(String + log.error(String .format("Cluster monitor thread has been started successfully: [cluster] %s ", cluster.getClusterId())); } @@ -183,13 +182,13 @@ public void run() { //TODO start the status checker } catch (PolicyValidationException e) { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); + log.warn(msg, e); retries--; } catch (PartitionValidationException e) { String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); + log.warn(msg, e); retries--; } @@ -245,7 +244,7 @@ public void run() { } catch (Exception e) { String msg = "Group monitor creation failed for group: " + dependency; - log.debug(msg, e); + log.warn(msg, e); retries--; @@ -292,12 +291,12 @@ public void run() { } catch (PolicyValidationException e) { String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); + log.warn(msg, e); retries--; } catch (PartitionValidationException e) { String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.debug(msg, e); + log.warn(msg, e); retries--; } } while (!success && retries <= 0); From a9b26c4581ae4a37bce6d2d3785ab9a1d998da82 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 25 Sep 2014 22:54:06 +0530 Subject: [PATCH 121/436] adding status checking to the receiver and adding debug logs --- .../grouping/DependencyBuilder.java | 11 ++++++ .../AutoscalerTopologyEventReceiver.java | 38 ++++++++++--------- .../stratos/autoscaler/monitor/Monitor.java | 26 +++++++++++-- .../application/ApplicationMonitor.java | 32 ++++++++++++++-- .../monitor/group/GroupMonitor.java | 19 +++++----- 5 files changed, 92 insertions(+), 34 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java index 3887fa8e06..c1214d9dff 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java @@ -18,6 +18,8 @@ */ package org.apache.stratos.autoscaler.grouping; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; import java.util.LinkedList; @@ -29,6 +31,7 @@ * across all the groups and clusters */ public class DependencyBuilder { + private static final Log log = LogFactory.getLog(DependencyBuilder.class); public static Queue getStartupOrder(ParentBehavior component) { @@ -62,6 +65,10 @@ public static Queue getStartupOrder(ParentBehavior component) { //TODO handle by application and group itself groupName and serviceName if (component instanceof Application) { + if(log.isDebugEnabled()) { + log.debug("Building dependency for the Application/Group " + + ((Application) component).getId()); + } for (Group group : component.getAliasToGroupMap().values()) { if (!startup.contains("group." + group.getAlias())) { startup.add("group." + group.getAlias()); @@ -77,6 +84,10 @@ public static Queue getStartupOrder(ParentBehavior component) { } } } else if (component instanceof Group) { + if(log.isDebugEnabled()) { + log.debug("Building dependency for the Application/Group " + + ((Group) component).getAlias()); + } for (Group group : component.getAliasToGroupMap().values()) { if (!startup.contains("group." + group.getName())) { startup.add("group." + group.getName()); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 218fdb0731..2cb28b1c0d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; @@ -35,6 +36,7 @@ import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.listener.topology.*; @@ -97,7 +99,6 @@ protected void onEvent(Event event) { startApplicationMonitor(application); } } - } catch (Exception e) { log.error("Error processing event", e); } finally { @@ -119,17 +120,11 @@ protected void onEvent(Event event) { //acquire read lock TopologyManager.acquireReadLock(); - - try { - //TODO build dependency and organize the application - - //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication()); - - } finally { - //release read lock - TopologyManager.releaseReadLock(); - } + //start the application monitor + //TODO catch exception by ApplicationMonitor + startApplicationMonitor(applicationCreatedEvent.getApplication()); + //release read lock + TopologyManager.releaseReadLock(); } }); @@ -143,12 +138,12 @@ protected void onEvent(Event event) { ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; String appId = clusterActivatedEvent.getAppId(); String clusterId = clusterActivatedEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getMonitor(clusterId); - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - Monitor monitor = appMonitor.findParentMonitorOfCluster(clusterId); - AbstractClusterMonitor clusterMonitor = AutoscalerContext.getInstance().getMonitor(clusterId); + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(Status.Activated); - //TODO monitor.notify(); //starting the status checker to decide on the status of it's parent StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } @@ -165,9 +160,11 @@ protected void onEvent(Event event) { String groupId = groupActivatedEvent.getGroupId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - Monitor monitor = appMonitor.findParentMonitorOfGroup(groupId); + GroupMonitor monitor = appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(Status.Activated); - //TODO monitor.notify(); //starting the status checker to decide on the status of it's parent StatusChecker.getInstance().onGroupStatusChange(groupId, appId); } @@ -183,6 +180,7 @@ protected void onEvent(Event event) { String appId = applicationActivatedEvent.getAppId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + appMonitor.setStatus(Status.Activated); //TODO update appmonitor //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); @@ -547,6 +545,10 @@ public void run() { } try { long start = System.currentTimeMillis(); + if(log.isDebugEnabled()) { + log.debug("application monitor is going to be started for [application] " + + application.getId()); + } applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); long end = System.currentTimeMillis(); log.info("Time taken to start app monitor: " + (end - start)/1000); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 776a0d58ad..8be7d0390e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.ParentBehavior; import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.event.Event; @@ -59,7 +60,8 @@ public Monitor(ParentBehavior component) { abstractClusterMonitors = new HashMap(); this.component = component; preOrderTraverse = DependencyBuilder.getStartupOrder(component); - startDependency(); + + //startDependency(); } protected abstract void startDependency(); @@ -115,6 +117,11 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } else if (!cluster.isLbCluster() && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { th = new Thread( new ClusterMonitorAdder(parent, cluster)); + if (log.isDebugEnabled()) { + log.debug(String + .format("Cluster monitor Adder has been added: [cluster] %s ", + cluster.getClusterId())); + } } if (th != null) { th.start(); @@ -134,6 +141,11 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentBehavior component) { Thread th = null; if (!this.groupMonitors.containsKey(dependency)) { + if (log.isDebugEnabled()) { + log.debug(String + .format("Group monitor Adder has been added: [group] %s ", + dependency)); + } th = new Thread( new GroupMonitorAdder(parent, dependency, component)); } @@ -176,6 +188,10 @@ public void run() { } catch (InterruptedException e1) { } try { + if(log.isDebugEnabled()) { + log.debug("CLuster monitor is going to be started for [cluster] " + + cluster.getClusterId()); + } monitor = AutoscalerUtil.getClusterMonitor(cluster); monitor.addObserver(parent); success = true; @@ -217,12 +233,12 @@ public void run() { } private class GroupMonitorAdder implements Runnable { - private ParentBehavior group; + private Group group; private String dependency; private Monitor parent; public GroupMonitorAdder(Monitor parent, String dependency, ParentBehavior group) { - this.group = group; + this.group = (Group)group; this.dependency = dependency; this.parent = parent; } @@ -238,6 +254,10 @@ public void run() { } try { + if(log.isDebugEnabled()) { + log.debug("Group monitor is going to be started for [group] " + + group.getAlias()); + } monitor = AutoscalerUtil.getGroupMonitor(group.getGroup(dependency)); monitor.addObserver(parent); success = true; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 6c320a018c..0961b2190f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -39,8 +39,14 @@ public class ApplicationMonitor extends Monitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); - public ApplicationMonitor(ParentBehavior application) { + public ApplicationMonitor(Application application) { super(application); + this.id = application.getId(); + if(preOrderTraverse.isEmpty()) { + log.warn("the child group/cluster cannot be found for the Application " + id); + } else { + startDependency(); + } //keep } @@ -73,10 +79,19 @@ protected void startDependency() { //TODO build up the tree with ordered manner // start the first dependency + + if(!preOrderTraverse.isEmpty()) { String dependency = preOrderTraverse.poll(); + if(log.isDebugEnabled()) { + log.debug("Dependency check for the [group] " + dependency + " started"); + } if (dependency.contains("group")) { - startGroupMonitor(this, dependency.substring(6), component); + String groupId = dependency.substring(6); + if(log.isDebugEnabled()) { + log.debug("Dependency check starting the [group]" + groupId); + } + startGroupMonitor(this, groupId, component); } else if (dependency.contains("cartridge")) { ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); String clusterId = clusterDataHolder.getClusterId(); @@ -86,6 +101,9 @@ protected void startDependency() { cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); //TopologyManager.releaseReadLock(); if (cluster != null) { + if(log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); + } startClusterMonitor(this,cluster); } else { //TODO throw exception since Topology is inconsistent @@ -106,7 +124,7 @@ protected void startDependency() { * @param groupId the unique alias of the Group * @return the found GroupMonitor */ - public Monitor findGroupMonitorWithId(String groupId) { + public GroupMonitor findGroupMonitorWithId(String groupId) { return findGroupMonitor(groupId, groupMonitors.values()); } @@ -140,7 +158,7 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, } - private Monitor findGroupMonitor(String id, Collection monitors) { + private GroupMonitor findGroupMonitor(String id, Collection monitors) { for (GroupMonitor monitor : monitors) { // check if alias is equal, if so, return if (monitor.equals(id)) { @@ -205,6 +223,12 @@ public void monitor() { //evaluate dependency } + public void setStatus(Status status) { + log.info(String.format("[ApplicationMonitor] %s " + + "state changes from %s to %s", id, this.status, status)); + this.status = status; + } + public Queue getPreOrderTraverse() { return preOrderTraverse; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 0ce9dbb995..c2f6ca4fa0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -23,10 +23,7 @@ import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -41,13 +38,14 @@ public class GroupMonitor extends Monitor { private static final Log log = LogFactory.getLog(GroupMonitor.class); - - - public GroupMonitor(Group group) { super(group); - //TODO build dependencies and keep them here - + this.id = group.getAlias(); + if(preOrderTraverse.isEmpty()) { + log.warn("the child group/cluster cannot be found for the Group " + id); + } else { + startDependency(); + } } @Override @@ -88,6 +86,9 @@ public void startDependency() { //start the first dependency if(!preOrderTraverse.isEmpty()) { String dependency = preOrderTraverse.poll(); + if(log.isDebugEnabled()) { + log.debug("Dependency check for the Group " + dependency + " started"); + } if (dependency.contains("group")) { for(Group group: component.getAliasToGroupMap().values()) { if(group.getName().equals(dependency.substring(6))) { From 4432a31c4ac292c0bf1f125d5ad7cc71360d7985 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 26 Sep 2014 13:02:43 +0530 Subject: [PATCH 122/436] fixing class cast exception --- .../topology/AutoscalerTopologyEventReceiver.java | 15 ++++++++++----- .../stratos/autoscaler/monitor/Monitor.java | 8 ++++---- .../monitor/application/ApplicationMonitor.java | 12 ++++++++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 2cb28b1c0d..fd84833f0a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -193,17 +193,22 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ApplicationCreatedEventListener] Received: " + event.getClass()); + log.info("[ApplicationRemovedEvent] Received: " + event.getClass()); - ApplicationRemovedEvent applicationCreatedEvent = (ApplicationRemovedEvent) event; + ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event; //acquire read lock TopologyManager.acquireReadLock(); try { - //TODO build dependency and organize the application - - //remove monitors by checking the termination + //TODO remove monitors as well as any starting or pending threads + ApplicationMonitor monitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationRemovedEvent.getApplicationId()); + List clusters = monitor.findClustersOfApplication(applicationRemovedEvent.getApplicationId()); + for(String clusterId: clusters) { + AutoscalerContext.getInstance().getMonitor(clusterId).setDestroyed(true); + AutoscalerContext.getInstance().removeMonitor(clusterId); + } } finally { //release read lock diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 8c2ccb6346..215c2222d1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -229,14 +229,14 @@ public void run() { } private class GroupMonitorAdder implements Runnable { - private Group group; private String dependency; private Monitor parent; + private ParentBehavior component; public GroupMonitorAdder(Monitor parent, String dependency, ParentBehavior group) { - this.group = (Group)group; this.dependency = dependency; this.parent = parent; + this.component = group; } public void run() { @@ -252,9 +252,9 @@ public void run() { try { if(log.isDebugEnabled()) { log.debug("Group monitor is going to be started for [group] " - + group.getAlias()); + + dependency); } - monitor = AutoscalerUtil.getGroupMonitor(group.getGroup(dependency)); + monitor = AutoscalerUtil.getGroupMonitor(component.getGroup(dependency)); monitor.addObserver(parent); success = true; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 0961b2190f..839bef76fb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -129,6 +129,18 @@ public GroupMonitor findGroupMonitorWithId(String groupId) { } + public List findClustersOfApplication(String appId) { + List clusters = new ArrayList(); + //considering only one level + for(AbstractClusterMonitor monitor : this.abstractClusterMonitors.values()) { + clusters.add(monitor.getClusterId()); + } + //TODO rest + return clusters; + + } + + /** * Find the cluster monitor by traversing recursively in the hierarchical monitors. * @param clusterId From c67af55c412c3200fdd76b31a4e1ab72789d503a Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 26 Sep 2014 14:47:25 +0530 Subject: [PATCH 123/436] adding clusters to Topology as part of ApplicationCreatedEvent --- .../AutoscalerTopologyEventReceiver.java | 19 ++++-- .../application/ApplicationMonitor.java | 63 ++++++++++--------- .../controller/topology/TopologyBuilder.java | 9 ++- .../topology/TopologyEventPublisher.java | 4 +- .../topology/ApplicationCreatedEvent.java | 16 ++++- .../ApplicationCreatedMessageProcessor.java | 6 +- 6 files changed, 74 insertions(+), 43 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index fd84833f0a..eefb907fba 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -204,12 +204,23 @@ protected void onEvent(Event event) { //TODO remove monitors as well as any starting or pending threads ApplicationMonitor monitor = AutoscalerContext.getInstance(). getAppMonitor(applicationRemovedEvent.getApplicationId()); - List clusters = monitor.findClustersOfApplication(applicationRemovedEvent.getApplicationId()); - for(String clusterId: clusters) { - AutoscalerContext.getInstance().getMonitor(clusterId).setDestroyed(true); - AutoscalerContext.getInstance().removeMonitor(clusterId); + if(monitor != null) { + List clusters = monitor. + findClustersOfApplication(applicationRemovedEvent.getApplicationId()); + for(String clusterId: clusters) { + //stopping the cluster monitor and remove it from the AS + AutoscalerContext.getInstance().getMonitor(clusterId).setDestroyed(true); + AutoscalerContext.getInstance().removeMonitor(clusterId); + } + //removing the application monitor + AutoscalerContext.getInstance(). + removeAppMonitor(applicationRemovedEvent.getApplicationId()); + } else { + log.warn("Application Monitor cannot be found for the removed [application] " + + applicationRemovedEvent.getApplicationId()); } + } finally { //release read lock TopologyManager.releaseReadLock(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 839bef76fb..ac2b556711 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -20,14 +20,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.grouping.DependencyBuilder; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.util.GroupStatus; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -42,7 +39,7 @@ public class ApplicationMonitor extends Monitor { public ApplicationMonitor(Application application) { super(application); this.id = application.getId(); - if(preOrderTraverse.isEmpty()) { + if (preOrderTraverse.isEmpty()) { log.warn("the child group/cluster cannot be found for the Application " + id); } else { startDependency(); @@ -52,15 +49,15 @@ public ApplicationMonitor(Application application) { @Override public void update(Observable observable, Object event) { - if(event instanceof MonitorStatusEvent) { + if (event instanceof MonitorStatusEvent) { MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; Status childStatus = statusEvent.getStatus(); String notifier = statusEvent.getNotifierId(); log.info(String.format("[Monitor] %s got notified from the [child] %s" + "on its state change from %s to %s", id, notifier, this.status, status)); - if(childStatus == Status.Activated) { + if (childStatus == Status.Activated) { //start the next dependency - if(!preOrderTraverse.isEmpty()) { + if (!preOrderTraverse.isEmpty()) { startDependency(); } } @@ -79,16 +76,14 @@ protected void startDependency() { //TODO build up the tree with ordered manner // start the first dependency - - - if(!preOrderTraverse.isEmpty()) { + if (!preOrderTraverse.isEmpty()) { String dependency = preOrderTraverse.poll(); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Dependency check for the [group] " + dependency + " started"); } if (dependency.contains("group")) { String groupId = dependency.substring(6); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Dependency check starting the [group]" + groupId); } startGroupMonitor(this, groupId, component); @@ -98,21 +93,27 @@ protected void startDependency() { String serviceName = clusterDataHolder.getServiceType(); Cluster cluster = null; //TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); - //TopologyManager.releaseReadLock(); - if (cluster != null) { - if(log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); + Topology topology = TopologyManager.getTopology(); + if (topology.serviceExists(serviceName)) { + Service service = topology.getService(serviceName); + if (service.clusterExists(clusterId)) { + cluster = service.getCluster(clusterId); + if (log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); + } + startClusterMonitor(this, cluster); + } else { + log.warn("[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName); } - startClusterMonitor(this,cluster); } else { - //TODO throw exception since Topology is inconsistent + log.warn("[Service] " + serviceName + " cannot be found in the Topology"); } - + //TopologyManager.releaseReadLock(); } } else { //all the groups/clusters have been started and waiting for activation - log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); + log.info("All the groups/clusters of the [Application]: " + this.id + " have been started."); } @@ -121,6 +122,7 @@ protected void startDependency() { /** * Find the group monitor by traversing recursively in the hierarchical monitors. + * * @param groupId the unique alias of the Group * @return the found GroupMonitor */ @@ -132,7 +134,7 @@ public GroupMonitor findGroupMonitorWithId(String groupId) { public List findClustersOfApplication(String appId) { List clusters = new ArrayList(); //considering only one level - for(AbstractClusterMonitor monitor : this.abstractClusterMonitors.values()) { + for (AbstractClusterMonitor monitor : this.abstractClusterMonitors.values()) { clusters.add(monitor.getClusterId()); } //TODO rest @@ -143,6 +145,7 @@ public List findClustersOfApplication(String appId) { /** * Find the cluster monitor by traversing recursively in the hierarchical monitors. + * * @param clusterId * @return */ @@ -161,7 +164,7 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, } } - for(GroupMonitor groupMonitor : groupMonitors) { + for (GroupMonitor groupMonitor : groupMonitors) { return findClusterMonitor(clusterId, groupMonitor.getAbstractClusterMonitors().values(), groupMonitor.getGroupMonitors().values()); @@ -187,17 +190,17 @@ private GroupMonitor findGroupMonitor(String id, Collection monito public Monitor findParentMonitorOfGroup(String groupId) { - return findParentMonitorForGroup(groupId, this); + return findParentMonitorForGroup(groupId, this); } private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { //if this monitor has the group, return it as the parent - if(monitor.getGroupMonitors().containsKey(groupId)) { + if (monitor.getGroupMonitors().containsKey(groupId)) { return monitor; } else { - if(monitor.getGroupMonitors() != null) { + if (monitor.getGroupMonitors() != null) { //check whether the children has the group and find its parent - for(GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + for (GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { return findParentMonitorForGroup(groupId, groupMonitor); } @@ -213,12 +216,12 @@ public Monitor findParentMonitorOfCluster(String clusterId) { private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { //if this monitor has the group, return it as the parent - if(monitor.getAbstractClusterMonitors().containsKey(clusterId)) { + if (monitor.getAbstractClusterMonitors().containsKey(clusterId)) { return monitor; } else { - if(monitor.getGroupMonitors() != null) { + if (monitor.getGroupMonitors() != null) { //check whether the children has the group and find its parent - for(GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + for (GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { return findParentMonitorForCluster(clusterId, groupMonitor); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index a0779e3ccf..b766007981 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -42,10 +42,8 @@ import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.util.Constants; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.Properties; -import java.util.Set; /** * this is to manipulate the received events by cloud controller @@ -623,7 +621,7 @@ public static void handleApplicationDeployed(Application application, log.warn("Application with id [ " + application.getId() + " ] already exists in Topology"); return; } - + List clusters = new ArrayList(); for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), @@ -631,6 +629,7 @@ public static void handleApplicationDeployed(Application application, cluster.setStatus(Status.Created); cluster.addHostName(applicationClusterContext.getHostName()); cluster.setTenantRange(applicationClusterContext.getTenantRange()); + clusters.add(cluster); Service service = topology.getService(applicationClusterContext.getCartridgeType()); if (service != null) { @@ -647,7 +646,7 @@ public static void handleApplicationDeployed(Application application, TopologyManager.updateTopology(topology); log.info("Application with id [ " + application.getId() + " ] added to Topology successfully"); - TopologyEventPublisher.sendApplicationCreatedEvent(application); + TopologyEventPublisher.sendApplicationCreatedEvent(application ,clusters); } finally { TopologyManager.releaseWriteLock(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 1679115c17..53efeaa209 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -90,13 +90,13 @@ public static void sendClusterCreatedEvent(String serviceName, String clusterId, } - public static void sendApplicationCreatedEvent (Application application) { + public static void sendApplicationCreatedEvent (Application application, List clusters) { if(log.isInfoEnabled()) { log.info("Publishing Application created event: " + application.toString()); } - publishEvent(new ApplicationCreatedEvent(application)); + publishEvent(new ApplicationCreatedEvent(application, clusters)); } public static void sendApplicationRemovedEvent(String applicationId, int tenantId, String tenantDomain) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index 79236676e8..a36e65f8e4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -20,13 +20,19 @@ package org.apache.stratos.messaging.event.topology; import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Cluster; + +import java.util.List; public class ApplicationCreatedEvent extends TopologyEvent { private Application application; - public ApplicationCreatedEvent (Application application) { + private List clusterList; + + public ApplicationCreatedEvent (Application application, List clusters) { this.application = application; + this.setClusterList(clusters); } public Application getApplication() { @@ -37,4 +43,12 @@ public String toString() { return "ApplicationCreatedEvent [app id= " + application.getId() + ", groups= " + application.getGroups() + ", clusters= " + application.getClusterDataMap().values() + "]"; } + + public List getClusterList() { + return clusterList; + } + + public void setClusterList(List clusterList) { + this.clusterList = clusterList; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 5525e7ad62..f02e4be940 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -21,6 +21,7 @@ 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.Topology; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -70,7 +71,10 @@ public boolean process(String type, String message, Object object) { log.warn("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); } else { - // add to Topology + // add application and the clusters to Topology + for(Cluster cluster: appCreatedEvent.getClusterList()) { + topology.getService(cluster.getServiceName()).addCluster(cluster); + } topology.addApplication(appCreatedEvent.getApplication()); } From bd9197ded0006ac6ddae9645d42eb85d99027eba Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 26 Sep 2014 17:11:11 +0530 Subject: [PATCH 124/436] fixing NPE in member activation --- .../AutoscalerTopologyEventReceiver.java | 20 +++++++++++++++++-- .../status/checker/StatusChecker.java | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index eefb907fba..522039092c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -94,7 +94,7 @@ protected void onEvent(Event event) { try { TopologyManager.acquireReadLock(); if(!topologyInitialized) { - topologyInitialized = true; + topologyInitialized = true; for (Application application : TopologyManager.getTopology().getApplications()) { startApplicationMonitor(application); } @@ -446,9 +446,25 @@ protected void onEvent(Event event) { TopologyManager.acquireReadLock(); MemberActivatedEvent e = (MemberActivatedEvent) event; + String networkPartitionId = e.getNetworkPartitionId(); + String clusterId = e.getClusterId(); + String partitionId = e.getPartitionId(); String memberId = e.getMemberId(); - PartitionContext partitionContext = null; + AbstractClusterMonitor monitor; + + if (AutoscalerContext.getInstance().monitorExist(clusterId)) { + monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + } else { + //This is LB member + monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); + } + + NetworkPartitionContext networkPartitionContext = monitor. + getNetworkPartitionCtxt(networkPartitionId); + + PartitionContext partitionContext = networkPartitionContext. + getPartitionCtxt(partitionId); partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); // TODO starting the pending clusters which are waiting for this member activation in a cluster diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 06d24aea10..4db5017eb3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -66,8 +66,9 @@ public void run() { } else if (partitionContext.getActiveMemberCount() > partitionContext.getMinimumMemberCount()) { log.info("cluster already activated..."); clusterActive = true; + } else { + clusterActive = false; } - clusterActive = false; } } // if active then notify upper layer From 13ef15c86080a22d65ac9830ba0ca147245a7bde Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 26 Sep 2014 18:03:38 +0530 Subject: [PATCH 125/436] fixing the ClusterActivatedEvent issue and updating the cluster with appId --- .../monitor/group/GroupMonitor.java | 33 +++++++++++-------- .../autoscaler/util/AutoscalerUtil.java | 1 + .../controller/topology/TopologyBuilder.java | 4 +-- .../messaging/domain/topology/Cluster.java | 10 +++++- ...pplicationStatusEventMessageDelegator.java | 17 ++++------ 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index c2f6ca4fa0..cfab9dee2d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -96,23 +96,28 @@ public void startDependency() { } } } else if (dependency.contains("cartridge")) { - for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { - if(dataHolder.getServiceType().equals(dependency.substring(10))) { - String clusterId = dataHolder.getClusterId(); - String serviceName = dataHolder.getServiceType(); - Cluster cluster = null; - //TopologyManager.acquireReadLock(); - cluster = TopologyManager.getTopology().getService(serviceName).getCluster(clusterId); - //TopologyManager.releaseReadLock(); - if (cluster != null) { - startClusterMonitor(this, cluster); - } else { - //TODO throw exception since Topology is inconsistent + ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); + String clusterId = clusterDataHolder.getClusterId(); + String serviceName = clusterDataHolder.getServiceType(); + Cluster cluster = null; + //TopologyManager.acquireReadLock(); + Topology topology = TopologyManager.getTopology(); + if (topology.serviceExists(serviceName)) { + Service service = topology.getService(serviceName); + if (service.clusterExists(clusterId)) { + cluster = service.getCluster(clusterId); + if (log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); } + startClusterMonitor(this, cluster); + } else { + log.warn("[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName); } + } else { + log.warn("[Service] " + serviceName + " cannot be found in the Topology"); } - - + //TopologyManager.releaseReadLock(); } } else { //all the groups/clusters have been started and waiting for activation diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index df01a84f47..6a05371d00 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -111,6 +111,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(), deploymentPolicy, policy); + clusterMonitor.setAppId(cluster.getAppId()); clusterMonitor.setStatus(Status.Created); for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){ diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index b766007981..9541ac082c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -140,7 +140,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { cluster.setLbCluster(isLb); } else { cluster = new Cluster(cartridgeType, clusterId, - registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName()); + registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName(), null); cluster.addHostName(registrant.getHostName()); if (service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); @@ -625,7 +625,7 @@ public static void handleApplicationDeployed(Application application, for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName()); + applicationClusterContext.getAutoscalePolicyName(), application.getId()); cluster.setStatus(Status.Created); cluster.addHostName(applicationClusterContext.getHostName()); cluster.setTenantRange(applicationClusterContext.getTenantRange()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 957fce4827..578089ab73 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -51,17 +51,21 @@ public class Cluster implements Serializable { private Status status; + private String appId; + private String loadBalanceAlgorithmName; @XmlJavaTypeAdapter(MapAdapter.class) private Properties properties; - public Cluster(String serviceName, String clusterId, String deploymentPolicyName, String autoscalePolicyName) { + public Cluster(String serviceName, String clusterId, String deploymentPolicyName, + String autoscalePolicyName, String appId) { this.serviceName = serviceName; this.clusterId = clusterId; this.deploymentPolicyName = deploymentPolicyName; this.autoscalePolicyName = autoscalePolicyName; this.hostNames = new ArrayList(); this.memberMap = new HashMap(); + this.appId = appId; } public String getServiceName() { @@ -227,5 +231,9 @@ public boolean equals(Object other) { public int hashCode () { return clusterId.hashCode(); } + + public String getAppId() { + return appId; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java index ccf9dd3ae8..2b1ad5bdbc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java @@ -23,6 +23,7 @@ import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; import org.apache.stratos.messaging.message.processor.application.status.ApplicationStatusMessageProcessorChain; +import org.apache.stratos.messaging.util.Constants; import javax.jms.TextMessage; @@ -53,17 +54,11 @@ public void run() { try { TextMessage message = messageQueue.take(); - String messageText = message.getText(); - if (log.isDebugEnabled()) { - log.debug("Application status event message received: [message] " + messageText); - } - EventMessage eventMessage = jsonToEventMessage(messageText); - if(eventMessage == null){ - log.error("Error occurred while extracting message"); - continue; - } - String type = eventMessage.getEventName(); - String json = eventMessage.getMessage(); + // Retrieve the header + String type = message.getStringProperty(Constants.EVENT_CLASS_NAME); + + // Retrieve the actual message + String json = message.getText(); if (log.isDebugEnabled()) { log.debug(String.format("Application status event message received from queue: %s", type)); From 5649e6ed4f4f21ea54f56f53d0f8937c04cee5b0 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 26 Sep 2014 18:41:08 +0530 Subject: [PATCH 126/436] updating the cluster activation --- .../autoscaler/status/checker/StatusChecker.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 4db5017eb3..7f179553e0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -162,8 +162,14 @@ private boolean updateChildStatus(String appId, String id, Map gr boolean clustersActive; boolean groupsActive; boolean childFound = false; + boolean clusterFound = false; - if (clusterData.containsValue(id) || groups.containsKey(id)) { + for(ClusterDataHolder clusterDataHolder : clusterData.values()) { + if(clusterDataHolder.getClusterId().equals(id)) { + clusterFound = true; + } + } + if (clusterFound || groups.containsKey(id)) { childFound = true; if (!clusterData.isEmpty() && !groups.isEmpty()) { clustersActive = getClusterStatus(clusterData); @@ -216,7 +222,7 @@ private boolean getClusterStatus(Map clusterData) { for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); if (service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). - getStatus().equals(ClusterStatus.Active)) { + getStatus() == Status.Activated) { clusterActiveStatus = true; } else { clusterActiveStatus = false; From 5fa84a08fd7051be17652b8377b155aed53e9cc5 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 26 Sep 2014 18:48:46 +0530 Subject: [PATCH 127/436] fixing a compilation failure and a NPE --- .../load/balancer/conf/LoadBalancerConfiguration.java | 2 +- .../metadataservice/registry/CarbonRegistry.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java index 3c6c5d1308..c269419f77 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java @@ -441,7 +441,7 @@ private LoadBalancerConfiguration transform(Node loadBalancerNode) { for (Node clusterNode : clustersNode.getChildNodes()) { String clusterId = clusterNode.getName(); - Cluster cluster = new Cluster(service.getServiceName(), clusterId, null, null); + Cluster cluster = new Cluster(service.getServiceName(), clusterId, null, null, null); String tenantRange = clusterNode.getProperty(Constants.CONF_PROPERTY_TENANT_RANGE); if (StringUtils.isNotBlank(tenantRange)) { 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 d721c8bbec..98377c42f3 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 @@ -176,8 +176,15 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car throws Exception { Registry registry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + cartridgeType; - registry.delete(resourcePath); - return false; + if (registry != null) { + registry.delete(resourcePath); + return true; + } else { + if (log.isDebugEnabled()) { + log.debug("Unable to delete the meta data since the Registry is NULL"); + } + return false; + } } From 5aac10ea462943c4d0eb68ab6564046528d81b18 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sat, 27 Sep 2014 03:27:58 +0530 Subject: [PATCH 128/436] fixing a NPE in a debug log :D --- .../parser/DefaultApplicationParser.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 36dc7f8ab5..16c66a5bfb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -78,12 +78,16 @@ public Application parse(Object obj) throws ApplicationDefinitionException { // get the defined groups Map definedGroups = getDefinedGroups(applicationCtxt); if (log.isDebugEnabled()) { - Set> groupEntries = definedGroups.entrySet(); - log.debug("Defined Groups: [ "); - for (Map.Entry groupEntry : groupEntries) { - log.debug("Group alias: " + groupEntry.getKey()); + if (definedGroups != null) { + Set> groupEntries = definedGroups.entrySet(); + log.debug("Defined Groups: [ "); + for (Map.Entry groupEntry : groupEntries) { + log.debug("Group alias: " + groupEntry.getKey()); + } + log.debug(" ]"); + } else { + log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId()); } - log.debug(" ]"); } // get the Subscribables Information From c4740c0638865654fbb1e9217e3f781d69b2b897 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 30 Sep 2014 18:14:11 +0530 Subject: [PATCH 129/436] fix for STRATOS-851 --- .../manager/CartridgeSubscriptionManager.java | 5 ++ .../rest/endpoint/services/ServiceUtils.java | 74 +++++++++++++++++-- 2 files changed, 72 insertions(+), 7 deletions(-) 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 index cfc1504127..0dd09a5217 100644 --- 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 @@ -870,4 +870,9 @@ public Collection isCartridgeSubscribed(int tenantId, Str DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); return dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType); } + + public Collection getCartridgeSubscriptionsForType (String cartridgeType) { + + return new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(cartridgeType); + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 7ccd082a62..515a21af47 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -345,17 +345,77 @@ static void undeployCartridge(String cartridgeType) throws RestAPIException { CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); if (cloudControllerServiceClient != null) { + + CartridgeInfo cartridgeInfo = null; try { - cloudControllerServiceClient.unDeployCartridgeDefinition(cartridgeType); + cartridgeInfo = cloudControllerServiceClient.getCartridgeInfo(cartridgeType); + } catch (RemoteException e) { - log.error(e.getMessage(), e); - throw new RestAPIException(e.getMessage(), e); - } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) { - String msg = e.getFaultMessage().getInvalidCartridgeTypeException().getMessage(); - log.error(msg, e); - throw new RestAPIException(msg, e); + log.error("Error in getting Cartridge details for type " + cartridgeType); + throw new RestAPIException(e); + + } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { + log.error("Error in getting Cartridge details for type " + cartridgeType); + throw new RestAPIException(e); + } + + if (cartridgeInfo == null) { + String errorMsg = "Cartridge information not found for type " + cartridgeType; + log.error(errorMsg); + throw new RestAPIException(errorMsg); } + // 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 = "Multi tenant Service already exists for " + cartridgeType + ", cannot undeploy"; + log.error(errorMsg); + throw new RestAPIException(errorMsg); + } else { + // can undeploy + undeployCartridgeDefinition(cloudControllerServiceClient, cartridgeType); + } + + } catch (ADCException e) { + log.error("Error in getting MT Service details for type " + cartridgeType); + throw new RestAPIException(e); + } + + } else { + // if not multi tenant, check if there are any existing Subscriptions + Collection cartridgeSubscriptions = + cartridgeSubsciptionManager.getCartridgeSubscriptionsForType(cartridgeType); + if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) { + // not allowed to undeploy! + String errorMsg = "Subscription exists for " + cartridgeType + ", cannot undeploy"; + log.error(errorMsg); + throw new RestAPIException(errorMsg); + } else { + // can undeploy + undeployCartridgeDefinition(cloudControllerServiceClient, cartridgeType); + } + } + } + } + + private static void undeployCartridgeDefinition (CloudControllerServiceClient cloudControllerServiceClient, + String cartridgeType) throws RestAPIException { + + try { + cloudControllerServiceClient.unDeployCartridgeDefinition(cartridgeType); + + } catch (RemoteException e) { + log.error(e.getMessage(), e); + throw new RestAPIException(e.getMessage(), e); + + } catch (CloudControllerServiceInvalidCartridgeTypeExceptionException e) { + String msg = e.getFaultMessage().getInvalidCartridgeTypeException().getMessage(); + log.error(msg, e); + throw new RestAPIException(msg, e); } } From ec68c2d232c1035c71351aeaa0cb78bc8ac766ed Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 1 Oct 2014 14:59:35 +0530 Subject: [PATCH 130/436] change info log to debug --- .../org/apache/stratos/metadataservice/util/ConfUtil.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java index bbe20786c0..1abbf0777e 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -19,8 +19,6 @@ package org.apache.stratos.metadataservice.util; -import java.io.File; - import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; @@ -28,6 +26,8 @@ import org.apache.stratos.metadataservice.Constants; import org.wso2.carbon.utils.CarbonUtils; +import java.io.File; + /** * This class contains utility methods for read metadata configuration file. */ @@ -40,7 +40,8 @@ public class ConfUtil { private static ConfUtil instance = null; private ConfUtil(String configFilePath) { - log.info("Loading configuration....."); + log.debug("Loading configuration....."); + try { File confFile; From a0e36dbe82893c502ea6f8867309d096ae74a6de Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 1 Oct 2014 15:01:55 +0530 Subject: [PATCH 131/436] release the http method once executed --- .../apache/stratos/metadata/client/rest/DefaultRestClient.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index cb12b8d66b..55e03604fc 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -80,6 +80,8 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien String errorMsg = "Error while executing POST statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); + }finally { + post.releaseConnection(); } } From d488711472a062c2c4434558b441fc472d60a7b5 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 1 Oct 2014 17:02:16 +0530 Subject: [PATCH 132/436] http client release --- .../stratos/metadata/client/rest/DefaultRestClient.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index 55e03604fc..64e25679f9 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -120,6 +120,8 @@ public HttpResponse doGet(String resourcePath) throws RestClientException { String errorMsg = "Error while executing GET statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); + }finally { + get.releaseConnection(); } } @@ -134,6 +136,8 @@ public HttpResponse doDelete(String resourcePath) throws RestClientException { String errorMsg = "Error while executing DELETE statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); + }finally { + delete.releaseConnection(); } } From 07eeac30a33c234db66f6df976a84874f9b242fc Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 1 Oct 2014 17:45:36 +0530 Subject: [PATCH 133/436] change default registry type to carbon --- .../stratos/metadataservice/registry/DataRegistryFactory.java | 4 ++-- .../stratos/metadataservice/services/MetaDataAdmin.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java index 25f0053f5a..2f6a1132fc 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataRegistryFactory.java @@ -24,9 +24,9 @@ public class DataRegistryFactory { public static DataStore getDataRegistryFactory(String registryName) { - if (registryName.equals("GREG")) { + if (registryName.equals("greg")) { return new GRegRegistry(); - } else if (registryName.equals("OWN")) { + } else if (registryName.equals("carbon")) { return new CarbonRegistry(); } else { return null; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index fdf9375e19..439cc0be70 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -27,7 +27,7 @@ public class MetaDataAdmin { @Context HttpServletRequest httpServletRequest; - private final String defaultRegType = "GREG"; + private final String defaultRegType = "carbon"; private XMLConfiguration conf; From 45caaf71f4a901333568e657ce1cba956dcec7a7 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 2 Oct 2014 10:02:33 +0530 Subject: [PATCH 134/436] moving registry type retrive to constructer. So no need to retrive it everytime --- .../services/MetaDataAdmin.java | 53 ++++--------------- 1 file changed, 9 insertions(+), 44 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index 439cc0be70..b20f7b32d4 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -30,12 +30,17 @@ public class MetaDataAdmin { private final String defaultRegType = "carbon"; private XMLConfiguration conf; + private String registryType; + public MetaDataAdmin(){ + conf = ConfUtil.getInstance(null).getConfiguration(); + registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + } @POST @Path("/init") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public void initialize() throws RestAPIException { - conf = ConfUtil.getInstance(null).getConfiguration(); + } public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) @@ -55,11 +60,7 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getClusterProperties(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); List properties; NewProperty[] propertiesArr = null; try { @@ -88,10 +89,6 @@ public Response getClusterProperties(@PathParam("application_id") String applica @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName){ - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); List properties = null; NewProperty property = null; @@ -126,11 +123,7 @@ public Response getClusterProperty(@PathParam("application_id") String applicati @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - List properties = null; + List properties; NewProperty property = null; try { @@ -163,12 +156,7 @@ public Response getClusterDependencies(@PathParam("application_id") String appli @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getApplicationProperties(@PathParam("application_id") String applicationId){ - conf = ConfUtil.getInstance(null).getConfiguration(); - - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - List properties = null; + List properties; NewProperty[] propertiesArr = null; try { properties = DataRegistryFactory.getDataRegistryFactory(registryType) @@ -196,11 +184,7 @@ public Response getApplicationProperties(@PathParam("application_id") String app @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getApplicationProperty(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName){ - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - List properties = null; + List properties; NewProperty property = null; try { @@ -240,9 +224,7 @@ public Response addClusterDependencies(@PathParam("application_id") String appli throw new RestAPIException("Property name should be dependencies"); } URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); } catch (RegistryException e) { @@ -260,9 +242,7 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); } catch (RegistryException e) { @@ -282,11 +262,6 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); - conf = ConfUtil.getInstance(null).getConfiguration(); - - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties); } catch (Exception e) { @@ -306,11 +281,6 @@ public Response addPropertiesToApplication(@PathParam("application_id") String a throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); - conf = ConfUtil.getInstance(null).getConfiguration(); - - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties); } catch (Exception e) { @@ -330,11 +300,6 @@ public Response addPropertyToApplication(@PathParam("application_id") String app throws RestAPIException { URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); - conf = ConfUtil.getInstance(null).getConfiguration(); - - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); try { DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property); } catch (Exception e) { From fc233a0546ce407425e0a8cdb3c70a8bea12b254 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 2 Oct 2014 17:09:51 +0530 Subject: [PATCH 135/436] refactor metadata rest api --- .../registry/CarbonRegistry.java | 178 +----------------- .../metadataservice/registry/DataStore.java | 14 +- .../registry/GRegRegistry.java | 144 +------------- .../services/MetaDataAdmin.java | 173 ++--------------- 4 files changed, 27 insertions(+), 482 deletions(-) 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 98377c42f3..3ae47ce726 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 @@ -31,7 +31,6 @@ import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.core.service.RegistryService; public class CarbonRegistry extends AbstractAdmin implements DataStore { @@ -48,7 +47,7 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore { private static final String defaultUsername = "admin@org.com"; private static final String defaultPassword = "admin123"; private static final String serverURL = "https://localhost:9445/services/"; - private static final String mainResource = "/startos/"; + private static final String mainResource = "/stratos/"; private static final int defaultRank = 3; private RegistryService registryService; @@ -56,121 +55,13 @@ public CarbonRegistry() { } - /* - * Add the meta data to governance registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, - * org.apache.stratos.metadataservice.definition.CartridgeMetaData) - */ - @Override - public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception { - log.debug("Adding meta data details"); - - Registry tempRegistry = getGovernanceUserRegistry(); - try { - - Resource resource = tempRegistry.newResource(); - - String type = cartridgeMetaData.type; - - resource.setContent("Application description :: " + type); - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - - resource.addProperty("Application Name", cartridgeMetaData.applicationName); - resource.addProperty("Display Name", cartridgeMetaData.displayName); - resource.addProperty("Description", cartridgeMetaData.description); - resource.addProperty("Cartidge Type", cartridgeMetaData.type); - resource.addProperty("provider", cartridgeMetaData.provider); - resource.addProperty("Version", cartridgeMetaData.version); - resource.addProperty("host", cartridgeMetaData.host); - - for (PropertyBean prop : cartridgeMetaData.properties) { - resource.addProperty("hostname", prop.hostname); - resource.addProperty("username", prop.username); - resource.addProperty("password", prop.password); - } - - tempRegistry.put(resourcePath, resource); - - if(log.isDebugEnabled()){ - log.debug("A resource added to: " + resourcePath); - } - - Comment comment = new Comment(); - comment.setText("Added the " + applicationName + " " + type + " cartridge"); - // registry.addComment(resourcePath, comment); - - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("addCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - - } - - return "success"; - } - - /* - * Get the meta data from the registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) - */ - @Override - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = getGovernanceUserRegistry(); - CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); - try { - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - if (registry.resourceExists(resourcePath)) { - - Resource getResource = registry.get(resourcePath); - - cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); - cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); - cartridgeMetaData.description = getResource.getProperty("Description"); - cartridgeMetaData.displayName = getResource.getProperty("Display Name"); - cartridgeMetaData.host = getResource.getProperty("host"); - cartridgeMetaData.provider = getResource.getProperty("provider"); - cartridgeMetaData.version = getResource.getProperty("Version"); - - List lst = new ArrayList(); - PropertyBean prop = new PropertyBean(); - prop.hostname = getResource.getProperty("hostname"); - prop.username = getResource.getProperty("username"); - prop.password = getResource.getProperty("password"); - lst.add(prop); - - cartridgeMetaData.properties = lst; - - } - - } catch (Exception e) { - - if (log.isErrorEnabled()) { - log.error("getCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - - } - return cartridgeMetaData.toString(); - } - - /* - * - * Remove the meta data from the registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) - */ + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ @Override public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception { @@ -243,59 +134,6 @@ public void addPropertiesToCluster(String applicationName, String clusterId, New log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName)); } - public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationId; - Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); - - for(NewProperty property : properties){ - regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); - - } - tempRegistry.put(resourcePath, regResource); - log.info(String.format("Properties are added to application %s", applicationId)); - } - - public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationId; - Resource regResource = createOrGetResourceforApplication(tempRegistry, resourcePath); - regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); - tempRegistry.put(resourcePath, regResource); - log.info(String.format("Property %s is added to application %s ", property.getKey(), applicationId)); - } - - public List getPropertiesOfApplication(String applicationId) throws RegistryException { - Registry tempRegistry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationId; - if(!tempRegistry.resourceExists(resourcePath)){ - return null; - //throw new RegistryException("Cluster does not exist at " + resourcePath); - } - Resource regResource = tempRegistry.get(resourcePath); - - ArrayList newProperties = new ArrayList(); - - Properties props = regResource.getProperties(); - Enumeration x = props.propertyNames(); - while(x.hasMoreElements()) - { - String key = (String) x.nextElement(); - List values = regResource.getPropertyValues(key); - NewProperty property = new NewProperty(); - property.setKey(key); - String[] valueArr = new String[values.size()]; - property.setValues(values.toArray(valueArr)); - - newProperties.add(property); - - } - if(newProperties.size() == 0){ - return null; - } - return newProperties; - } - private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException { Resource regResource; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index f7cac250cf..e1b1218fb2 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,8 +18,6 @@ */ package org.apache.stratos.metadataservice.registry; -import org.apache.stratos.metadataservice.definition.ApplicationBean; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.wso2.carbon.registry.api.RegistryException; @@ -29,13 +27,8 @@ * Interface of the Data Store */ public interface DataStore { - public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception; - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception; - - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception; public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) @@ -45,9 +38,4 @@ public List getPropertiesOfCluster(String applicationName, String c public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; - void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException; - - void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException; - - List getPropertiesOfApplication(String applicationId) throws RegistryException; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index c454631a2f..1726d10418 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -19,7 +19,6 @@ package org.apache.stratos.metadataservice.registry; import java.io.File; -import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -30,15 +29,10 @@ import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.ApplicationBean; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; -import org.apache.stratos.metadataservice.definition.PropertyBean; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; /** @@ -94,125 +88,13 @@ private static WSRegistryServiceClient setRegistry() throws Exception { return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); } - /* - * Add the meta data to governance registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * addCartridgeMetaDataDetails(java.lang.String, java.lang.String, - * org.apache.stratos.metadataservice.definition.CartridgeMetaData) - */ - @Override - public String addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception { - - Registry registry = setRegistry(); - try { - - Resource resource = registry.newResource(); - - String type = cartridgeMetaData.type; - - resource.setContent("Application description :: " + type); - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - - resource.addProperty("Application Name", cartridgeMetaData.applicationName); - resource.addProperty("Display Name", cartridgeMetaData.displayName); - resource.addProperty("Description", cartridgeMetaData.description); - resource.addProperty("Cartidge Type", cartridgeMetaData.type); - resource.addProperty("provider", cartridgeMetaData.provider); - resource.addProperty("Version", cartridgeMetaData.version); - resource.addProperty("host", cartridgeMetaData.host); - - for (PropertyBean prop : cartridgeMetaData.properties) { - resource.addProperty("hostname", prop.hostname); - resource.addProperty("username", prop.username); - resource.addProperty("password", prop.password); - } - - registry.put(resourcePath, resource); - - - registry.rateResource(resourcePath, defaultRank); - - Comment comment = new Comment(); - comment.setText("Added the " + applicationName + " " + type + " cartridge"); - registry.addComment(resourcePath, comment); - - } catch (Exception e) { - - if (log.isErrorEnabled()) { - log.error("addCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - ((WSRegistryServiceClient) registry).logut(); - } - - return "success"; - } - - /* - * Get the meta data from the registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * getCartridgeMetaDataDetails(java.lang.String, java.lang.String) - */ - @Override - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = setRegistry(); - CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); - try { - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - if (registry.resourceExists(resourcePath)) { - - Resource getResource = registry.get(resourcePath); - if(log.isDebugEnabled()){ - log.debug("Resource retrived"); - log.debug("Printing retrieved resource content: " + - new String((byte[]) getResource.getContent())); - } - - cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); - cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); - cartridgeMetaData.description = getResource.getProperty("Description"); - cartridgeMetaData.displayName = getResource.getProperty("Display Name"); - cartridgeMetaData.host = getResource.getProperty("host"); - cartridgeMetaData.provider = getResource.getProperty("provider"); - cartridgeMetaData.version = getResource.getProperty("Version"); - - List lst = new ArrayList(); - PropertyBean prop = new PropertyBean(); - prop.hostname = getResource.getProperty("hostname"); - prop.username = getResource.getProperty("username"); - prop.password = getResource.getProperty("password"); - lst.add(prop); - - cartridgeMetaData.properties = lst; - - } - - } catch (Exception e) { - - if (log.isErrorEnabled()) { - log.error("getCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - ((WSRegistryServiceClient) registry).logut(); - } - return cartridgeMetaData.toString(); - } - - /* - * - * Remove the meta data from the registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) - */ + /* + * + * Remove the meta data from the registry + * + * @see org.apache.stratos.metadataservice.registry.DataStore# + * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + */ @Override public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception { @@ -234,16 +116,4 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp } - public void addPropertiesToApplication(String applicationId, NewProperty[] properties) throws RegistryException { - - } - - public void addPropertyToApplication(String applicationId, NewProperty property) throws RegistryException { - - } - - public List getPropertiesOfApplication(String applicationId) throws RegistryException { - return null; - } - } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index b20f7b32d4..cc341ec967 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -7,6 +7,7 @@ import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; +import org.apache.stratos.metadataservice.registry.DataStore; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.RegistryException; @@ -27,14 +28,15 @@ public class MetaDataAdmin { @Context HttpServletRequest httpServletRequest; - private final String defaultRegType = "carbon"; + private final String DEFAULT_REG_TYPE = "carbon"; private XMLConfiguration conf; - private String registryType; + DataStore registry; public MetaDataAdmin(){ conf = ConfUtil.getInstance(null).getConfiguration(); - registryType = conf.getString("metadataservice.govenanceregistrytype", defaultRegType); + String registryType = conf.getString("metadataservice.govenanceregistrytype", DEFAULT_REG_TYPE); + registry = DataRegistryFactory.getDataRegistryFactory(registryType); } @POST @Path("/init") @@ -48,9 +50,8 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car conf = ConfUtil.getInstance(null).getConfiguration(); String registryType = conf.getString("metadataservice.govenanceregistrytype", - defaultRegType); - return DataRegistryFactory.getDataRegistryFactory(registryType) - .removeCartridgeMetaDataDetails(applicationName, cartridgeType); + DEFAULT_REG_TYPE); + return registry.removeCartridgeMetaDataDetails(applicationName, cartridgeType); } @@ -64,7 +65,7 @@ public Response getClusterProperties(@PathParam("application_id") String applica List properties; NewProperty[] propertiesArr = null; try { - properties = DataRegistryFactory.getDataRegistryFactory(registryType) + properties = registry .getPropertiesOfCluster(applicationId, clusterId); if(properties != null) { propertiesArr = new NewProperty[properties.size()]; @@ -93,7 +94,7 @@ public Response getClusterProperty(@PathParam("application_id") String applicati NewProperty property = null; try { - properties = DataRegistryFactory.getDataRegistryFactory(registryType) + properties = registry .getPropertiesOfCluster(applicationId, clusterId); if(properties == null){ return Response.status(Response.Status.NOT_FOUND).build(); @@ -117,122 +118,6 @@ public Response getClusterProperty(@PathParam("application_id") String applicati return rb.build(); } - @GET - @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId){ - List properties; - NewProperty property = null; - - try { - properties = DataRegistryFactory.getDataRegistryFactory(registryType) - .getPropertiesOfCluster(applicationId, clusterId); - if(properties == null){ - return Response.status(Response.Status.NOT_FOUND).build(); - } - for(NewProperty p : properties){ - if("dependencies".equals(p.getKey())){ - property = p; - break; - } - } - } catch (Exception e) { - log.error("Error occurred while getting properties ", e); - } - Response.ResponseBuilder rb=null; - if(property == null){ - rb = Response.status(Response.Status.NOT_FOUND); - }else{ - rb = Response.ok().entity(property); - } - return rb.build(); - } - - @GET - @Path("/application/{application_id}/properties") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getApplicationProperties(@PathParam("application_id") String applicationId){ - List properties; - NewProperty[] propertiesArr = null; - try { - properties = DataRegistryFactory.getDataRegistryFactory(registryType) - .getPropertiesOfApplication(applicationId); - if(properties != null) { - propertiesArr = new NewProperty[properties.size()]; - propertiesArr = properties.toArray(propertiesArr); - } - } catch (Exception e) { - log.error("Error occurred while getting properties ", e); - } - - Response.ResponseBuilder rb=null; - if(propertiesArr == null){ - rb = Response.status(Response.Status.NOT_FOUND); - }else{ - rb = Response.ok().entity(propertiesArr); - } - return rb.build(); - } - - @GET - @Path("/application/{application_id}/property/{property_name}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getApplicationProperty(@PathParam("application_id") String applicationId, @PathParam("property_name") String propertyName){ - List properties; - NewProperty property = null; - - try { - properties = DataRegistryFactory.getDataRegistryFactory(registryType) - .getPropertiesOfApplication(applicationId); - if(properties == null){ - return Response.status(Response.Status.NOT_FOUND).build(); - } - for(NewProperty p : properties){ - if(propertyName.equals(p.getKey())){ - property = p; - break; - } - } - } catch (RegistryException e) { - log.error("Error occurred while getting property", e); - } - - Response.ResponseBuilder rb=null; - if(property == null){ - rb = Response.status(Response.Status.NOT_FOUND); - }else{ - rb = Response.ok().entity(property); - } - return rb.build(); - } - - - @POST - @Path("/application/{application_id}/cluster/{cluster_id}/dependencies") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addClusterDependencies(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty property) throws RestAPIException { - - if(!property.getKey().equals("dependencies")){ - throw new RestAPIException("Property name should be dependencies"); - } - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); - - try { - DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); - } catch (RegistryException e) { - log.error("Error occurred while adding dependencies ", e); - } - return Response.created(url).build(); - } - @POST @Path("application/{application_id}/cluster/{cluster_id}/property") @Produces("application/json") @@ -244,7 +129,7 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId + "/" + property.getKey()).build(); try { - DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToCluster(applicationId, clusterId, property); + registry.addPropertyToCluster(applicationId, clusterId, property); } catch (RegistryException e) { log.error("Error occurred while adding property", e); } @@ -263,7 +148,7 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); try { - DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToCluster(applicationId, clusterId, properties); + registry.addPropertiesToCluster(applicationId, clusterId, properties); } catch (Exception e) { log.error("Error occurred while adding properties ", e); } @@ -272,41 +157,5 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl return Response.created(url).build(); } - @POST - @Path("application/{application_id}/properties") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addPropertiesToApplication(@PathParam("application_id") String applicationId,NewProperty[] properties) - throws RestAPIException { - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); - - try { - DataRegistryFactory.getDataRegistryFactory(registryType).addPropertiesToApplication(applicationId, properties); - } catch (Exception e) { - log.error("Error occurred while adding properties ", e); - } - - - return Response.created(url).build(); - } - - @POST - @Path("application/{application_id}/property") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addPropertyToApplication(@PathParam("application_id") String applicationId, NewProperty property) - throws RestAPIException { - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId).build(); - try { - DataRegistryFactory.getDataRegistryFactory(registryType).addPropertyToApplication(applicationId, property); - } catch (Exception e) { - log.error("Error occurred while adding property ", e); - } - - - return Response.created(url).build(); - } } From b3ac27364fdb8e31baa00e5c32830dda17afaf04 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 2 Oct 2014 17:46:01 +0530 Subject: [PATCH 136/436] changing the Startup Order to be based on aliases in Groups --- .../parser/DefaultApplicationParser.java | 31 ++----- .../application/parser/ParserUtils.java | 82 ++++++++++++++++++- .../domain/topology/Application.java | 4 +- 3 files changed, 89 insertions(+), 28 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 16c66a5bfb..27c412668b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -250,17 +250,6 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); return application; - - //ApplicationDataHolder applicationDataHolder = new ApplicationDataHolder(); - //assert clusterDataHolder != null; - //applicationDataHolder.setClusters(clusterDataHolder.getApplicationClusterContexts()); - //applicationDataHolder.setPayloadDataHolders(clusterDataHolder.getPayloadDataHolders()); - //applicationDataHolder.setApplication(application); - - // persist the information in FasterLookUpDataHolder - //persist(dataHolder); - - //return applicationDataHolder; } private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, @@ -333,7 +322,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); DependencyOrder dependencyOrder = new DependencyOrder(); // create the Dependency Ordering - Set startupOrders = getStartupOrderForGroup(groupCtxt.getName()); + Set startupOrders = getStartupOrderForGroup(groupCtxt); if (startupOrders != null) { dependencyOrder.setStartupOrders(startupOrders); } @@ -347,14 +336,6 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); group.setClusterData(clusterDataMap); - //clusters.addAll(clusterDataHolderOfGroup.getApplicationClusterContexts()); -// if (clusterDataHolder == null) { -// clusterDataHolder = clusterDataHolderOfGroup; -// } else { -// clusterDataHolder.getApplicationClusterContexts().addAll(clusterDataHolderOfGroup.getApplicationClusterContexts()); -// clusterDataHolder.getClusterIdMap().putAll(clusterDataHolderOfGroup.getClusterIdMap()); -// //clusterDataHolder.getPayloadDataHolders().addAll(clusterDataHolderOfGroup.getPayloadDataHolders()); -// } } // get nested groups @@ -376,18 +357,20 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g return group; } - private Set getStartupOrderForGroup(String serviceGroupName) throws ApplicationDefinitionException { + private Set getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { - ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); + ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(groupContext.getName()); if (serviceGroup == null) { - handleError("Service Group Definition not found for name " + serviceGroupName); + handleError("Service Group Definition not found for name " + groupContext.getName()); } assert serviceGroup != null; if (serviceGroup.getDependencies() != null) { if (serviceGroup.getDependencies().getStartupOrder() != null) { - return ParserUtils.convert(serviceGroup.getDependencies().getStartupOrder()); + + // convert to Startup Order with aliases + return ParserUtils.convert(serviceGroup.getDependencies().getStartupOrder(), groupContext); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index 7ae90107a2..f47970c7f1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.application.parser; +import org.apache.stratos.cloud.controller.pojo.application.GroupContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; import org.apache.stratos.messaging.domain.topology.StartupOrder; import java.util.HashSet; @@ -26,7 +28,7 @@ public class ParserUtils { - public static Set convert (org.apache.stratos.cloud.controller.pojo.StartupOrder [] startupOrderArr) { + public static Set convert (org.apache.stratos.cloud.controller.pojo.StartupOrder [] startupOrderArr, GroupContext groupContext) { Set startupOrders = new HashSet(); @@ -34,10 +36,86 @@ public static Set convert (org.apache.stratos.cloud.controller.poj return startupOrders; } + for (int i = 0; i < startupOrderArr.length ; i++) { - startupOrders.add(new StartupOrder(startupOrderArr[i].getStart(), startupOrderArr[i].getAfter())); + // convert all Startup Orders to aliases-based + // start + String startAlias; + if (startupOrderArr[i].getStart().startsWith("cartridge.")) { + String cartridgeType = startupOrderArr[i].getStart().substring(10); + startAlias = getAliasForServiceType(cartridgeType, groupContext); + if (startAlias == null) { + throw new RuntimeException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Service type " + cartridgeType); + } + + startAlias = "cartridge.".concat(startAlias); + + } else if (startupOrderArr[i].getStart().startsWith("group.")) { + String groupName = startupOrderArr[i].getStart().substring(6); + startAlias = getAliasForGroupName(groupName, groupContext); + if (startAlias == null) { + throw new RuntimeException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Group name " + groupName); + } + + startAlias = "group.".concat(startAlias); + + } else { + throw new RuntimeException("Incorrect Startup Order specified"); + } + + // after + String afterAlias; + if (startupOrderArr[i].getAfter().startsWith("cartridge.")) { + String cartridgeType = startupOrderArr[i].getAfter().substring(10); + afterAlias = getAliasForServiceType(cartridgeType, groupContext); + if (afterAlias == null) { + throw new RuntimeException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Service type " + cartridgeType); + } + + afterAlias = "cartridge.".concat(afterAlias); + + } else if (startupOrderArr[i].getAfter().startsWith("group.")) { + String groupName = startupOrderArr[i].getAfter().substring(6); + afterAlias = getAliasForGroupName(groupName, groupContext); + if (afterAlias == null) { + throw new RuntimeException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Group name " + groupName); + } + + afterAlias = "group.".concat(afterAlias); + + } else { + throw new RuntimeException("Incorrect Startup Order specified"); + } + + startupOrders.add(new StartupOrder(startAlias, afterAlias)); } return startupOrders; } + + private static String getAliasForGroupName (String groupName, GroupContext groupContext) { + + for (GroupContext groupCtxt : groupContext.getGroupContexts()) { + if (groupName.equals(groupCtxt.getName())) { + return groupCtxt.getAlias(); + } + } + + return null; + } + + private static String getAliasForServiceType (String serviceType, GroupContext groupContext) { + + for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) { + if (serviceType.equals(subCtxt.getType())) { + return subCtxt.getAlias(); + } + } + + return null; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index ec9c1fdaf8..a2e5732097 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -59,8 +59,8 @@ public void addGroup(Group group) { } @Override - public void setGroups(Map groupNameToGroup) { - aliasToGroupMap.putAll(groupNameToGroup); + public void setGroups(Map aliasToGroup) { + aliasToGroupMap.putAll(aliasToGroup); } @Override From bdd9443edbbff480f49c1be4b983e2a74dba05f2 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 2 Oct 2014 18:48:59 +0530 Subject: [PATCH 137/436] adding dependency tree buildig support from Comsite application to autoscaler --- .../apache/stratos/autoscaler/Constants.java | 5 + .../grouping/DependencyBuilder.java | 107 ---------- .../dependency/DependencyBuilder.java | 189 +++++++++++++++++ .../grouping/dependency/DependencyTree.java | 190 ++++++++++++++++++ .../context/ApplicationContext.java | 74 +++++++ .../context/ApplicationContextFactory.java | 61 ++++++ .../dependency/context/ClusterContext.java | 28 +++ .../dependency/context/GroupContext.java | 28 +++ .../monitor/ApplicationMonitorFactory.java | 30 +++ .../stratos/autoscaler/monitor/Monitor.java | 161 ++++++++++----- .../application/ApplicationMonitor.java | 107 ++-------- .../monitor/group/GroupMonitor.java | 75 +------ .../domain/topology/StartupOrder.java | 11 + .../messaging/domain/topology/Status.java | 7 +- 14 files changed, 758 insertions(+), 315 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java index 8b2f78723a..a44840600e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java @@ -71,4 +71,9 @@ public class Constants { //member expiry interval public static final String MEMBER_EXPIRY_INTERVAL = "member.expiry.interval"; + + //Grouping + public static final String KILL_NONE = "kill-none"; + public static final String KILL_ALL = "kill-all"; + public static final String KILL_DEPENDENTS = "kill-dependents"; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java deleted file mode 100644 index c1214d9dff..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/DependencyBuilder.java +++ /dev/null @@ -1,107 +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.autoscaler.grouping; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.*; - -import java.util.LinkedList; -import java.util.Queue; -import java.util.Set; - -/** - * This is to build the startup/termination dependencies - * across all the groups and clusters - */ -public class DependencyBuilder { - private static final Log log = LogFactory.getLog(DependencyBuilder.class); - - public static Queue getStartupOrder(ParentBehavior component) { - - Queue startup = new LinkedList(); - DependencyOrder dependencyOrder = component.getDependencyOrder(); - if (dependencyOrder != null) { - Set startupOrderSet = dependencyOrder.getStartupOrders(); - for (StartupOrder startupOrder : startupOrderSet) { - - String start = startupOrder.getStart(); - String after = startupOrder.getAfter(); - - if (!startup.contains(start)) { - startup.add(start); - if (!startup.contains(after)) { - startup.add(after); - - } else { - //TODO throw exception since after is there before start - } - } else { - if (!startup.contains(after)) { - startup.add(after); - } else { - //TODO throw exception since start and after already there - } - } - } - } - //TODO adding all the missed groups or clusters as the top child to the list - //TODO handle by application and group itself groupName and serviceName - - if (component instanceof Application) { - if(log.isDebugEnabled()) { - log.debug("Building dependency for the Application/Group " + - ((Application) component).getId()); - } - for (Group group : component.getAliasToGroupMap().values()) { - if (!startup.contains("group." + group.getAlias())) { - startup.add("group." + group.getAlias()); - } - } - - Set cartridgeAliases = component.getClusterDataMap().keySet(); - - for (String carAlias : cartridgeAliases) { - if (!startup.contains("cartridge." + carAlias)) { - startup.add("cartridge." + carAlias); - - } - } - } else if (component instanceof Group) { - if(log.isDebugEnabled()) { - log.debug("Building dependency for the Application/Group " + - ((Group) component).getAlias()); - } - for (Group group : component.getAliasToGroupMap().values()) { - if (!startup.contains("group." + group.getName())) { - startup.add("group." + group.getName()); - } - } - for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { - if (!startup.contains("cartridge." + dataHolder.getServiceType())) { - startup.add("cartridge." + dataHolder.getServiceType()); - - } - } - } - return startup; - - } - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java new file mode 100644 index 0000000000..7d8ff2d25e --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -0,0 +1,189 @@ +/* + * 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.autoscaler.grouping.dependency; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.*; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory; +import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; +import org.apache.stratos.messaging.domain.topology.*; + +import java.util.Set; + +/** + * This is to build the startup/termination dependencies + * across all the groups and clusters + */ +public class DependencyBuilder { + private static final Log log = LogFactory.getLog(DependencyBuilder.class); + + private DependencyBuilder() { + + } + + private static class Holder { + private static final DependencyBuilder INSTANCE = new DependencyBuilder(); + } + + public static DependencyBuilder getInstance() { + return Holder.INSTANCE; + } + + /** + * This will build the dependency tree based on the given dependency order + * @param component it will give the necessary information to build the tree + * @return the dependency tree out of the dependency orders + */ + public DependencyTree buildDependency(ParentBehavior component) { + Group group = (Group) component; + DependencyTree dependencyTree = new DependencyTree(group.getAlias()); + DependencyOrder dependencyOrder = component.getDependencyOrder(); + + if (dependencyOrder != null) { + if (log.isDebugEnabled()) { + log.debug("Building dependency for the Application/Group " + + group.getAlias()); + } + + //Parsing the kill behaviour + String killBehavior = dependencyOrder.getKillbehavior(); + + if (Constants.KILL_NONE.equals(killBehavior)) { + dependencyTree.setKillNone(true); + } else if (Constants.KILL_ALL.equals(killBehavior)) { + dependencyTree.setKillAll(true); + } else if (Constants.KILL_DEPENDENTS.equals(killBehavior)) { + dependencyTree.setKillDependent(true); + } + if (log.isDebugEnabled()) { + log.debug("Setting the [killBehavior] " + killBehavior + " to the " + + "[dependency-tree] " + dependencyTree.getId()); + } + + //Parsing the start up order + Set startupOrderSet = dependencyOrder.getStartupOrders(); + ApplicationContext foundContext = null; + for (StartupOrder startupOrder : startupOrderSet) { + foundContext = null; + for (String start : startupOrder.getStartList()) { + ApplicationContext applicationContext = ApplicationContextFactory. + getApplicationContext(start, component, dependencyTree); + String id = applicationContext.getId(); //TODO change the id + + ApplicationContext existingApplicationContext = + dependencyTree.findApplicationContextWithId(id); + if (existingApplicationContext == null) { + if (foundContext != null) { + //appending the start up order to existing group/cluster + foundContext.addApplicationContext(applicationContext); + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + foundContext.getId() + + " and adding the [dependency] " + id + " as the child"); + } + } else { + //adding list of startup order to the dependency tree + dependencyTree.addApplicationContext(applicationContext); + } + } else { + if (foundContext == null) { + //assigning the found context to the later use. + foundContext = existingApplicationContext; + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + id + " and setting it " + + "for the next dependency to follow"); + } + } else { + //TODO Throw exception, since another same start order already found + log.warn("Startup order is not consistent. It contains the group/cluster " + + "which has been used more than one in another startup order"); + } + + } + + } + + } + + //TODO need to parser the scalable dependencies + } + + + //adding the rest of the children who are independent to the top level + // as they can start in parallel. + for (Group group1 : component.getAliasToGroupMap().values()) { + if (dependencyTree.findApplicationContextWithId(group1.getAlias()) == null) { + dependencyTree.addApplicationContext(new GroupContext(group1.getAlias(), + dependencyTree.isKillDependent())); + } + } + for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + if (dependencyTree.findApplicationContextWithId(dataHolder.getClusterId()) == null) { + dependencyTree.addApplicationContext(new ClusterContext(dataHolder.getClusterId(), + dependencyTree.isKillDependent())); + + } + } + return null; + } + + /*public static Queue getStartupOrder(ParentBehavior component) { + + + Queue startup = new LinkedList(); + DependencyOrder dependencyOrder = component.getDependencyOrder(); + if (dependencyOrder != null) { + Set startupOrderSet = dependencyOrder.getStartupOrders(); + for (StartupOrder startupOrder : startupOrderSet) { + + String start = startupOrder.getStart(); + String after = startupOrder.getAfter(); + + if (!startup.contains(start)) { + startup.add(start); + if (!startup.contains(after)) { + startup.add(after); + + } else { + //TODO throw exception since after is there before start + } + } else { + if (!startup.contains(after)) { + startup.add(after); + } else { + //TODO throw exception since start and after already there + } + } + } + } + //TODO adding all the missed groups or clusters as the top child to the list + //TODO handle by application and group itself groupName and serviceName + + if (component instanceof Application) { + + } else if (component instanceof Group) { + + } + return startup; + + }*/ + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java new file mode 100644 index 0000000000..1c6b28f039 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -0,0 +1,190 @@ +/* + * 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.autoscaler.grouping.dependency; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.messaging.domain.topology.Status; + +import java.util.ArrayList; +import java.util.List; + +/** + * This is to contain the dependency tree of an application/group + */ +public class DependencyTree { + private static final Log log = LogFactory.getLog(DependencyTree.class); + + private List applicationContextList; + + private Status status; + + private boolean started; + + private boolean terminated; + + private boolean killAll; + + private boolean killNone; + + private boolean killDependent; + + private String id; + + public DependencyTree(String id) { + applicationContextList = new ArrayList(); + this.setId(id); + } + + public List getApplicationContextList() { + return applicationContextList; + } + + public void setApplicationContextList(List applicationContextList) { + this.applicationContextList = applicationContextList; + } + + public void addApplicationContext(ApplicationContext applicationContext) { + applicationContextList.add(applicationContext); + + } + + /** + * Find an ApplicationContext from dependency tree with the given id + * @param id the alias/id of group/cluster + * @return ApplicationContext of the given id + */ + public ApplicationContext findApplicationContextWithId(String id) { + return findApplicationContextWithId(id, applicationContextList); + } + + /** + * Find the ApplicationContext using Breadth first search. + * @param id the alias/id of group/cluster + * @param contexts the list of contexts in the same level of the tree + * @return ApplicationContext of the given id + */ + private ApplicationContext findApplicationContextWithId(String id, List contexts) { + for(ApplicationContext context: contexts) { + if(context.getId().equals(id)) { + return context; + } + } + //if not found in the top level search recursively + for(ApplicationContext context: contexts) { + return findApplicationContextWithId(id, context.getApplicationContextList()); + } + return null; + } + + /** + * Getting the next start able dependencies upon the activate event + * received for a group/cluster which is part of this tree. + * @param id the alias/id of group/cluster which received the activated event. + * @return list of dependencies + */ + public List getStarAbleDependencies(String id) { + //finding the application context which received the activated event and + // returning it's immediate children as the dependencies. + ApplicationContext context = findApplicationContextWithId(id); + return context.getApplicationContextList(); + } + + /** + * Getting the next start able dependencies upon the monitor initialization. + * @return list of dependencies + */ + public List getStarAbleDependencies() { + //returning the top level as the monitor is in initializing state + return this.applicationContextList; + } + + /** + * When one group/cluster terminates/in_maintenance, need to consider about other + * dependencies + * @param id the alias/id of group/cluster in which terminated event received + * @return + */ + public List getKillDependencies(String id) { + ApplicationContext applicationContext = findApplicationContextWithId(id); + if(killDependent) { + return applicationContext.getApplicationContextList(); + } + return null; + } + + + + public boolean isKillAll() { + return killAll; + } + + public void setKillAll(boolean killAll) { + this.killAll = killAll; + } + + public boolean isKillNone() { + return killNone; + } + + public void setKillNone(boolean killNone) { + this.killNone = killNone; + } + + public boolean isStarted() { + return started; + } + + public void setStarted(boolean started) { + this.started = started; + } + + public boolean isTerminated() { + return terminated; + } + + public void setTerminated(boolean terminated) { + this.terminated = terminated; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public boolean isKillDependent() { + return killDependent; + } + + public void setKillDependent(boolean killDependent) { + this.killDependent = killDependent; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java new file mode 100644 index 0000000000..d9b6df8d66 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -0,0 +1,74 @@ +/* + * 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.autoscaler.grouping.dependency.context; + +import org.apache.stratos.messaging.domain.topology.Status; + +import java.util.ArrayList; +import java.util.List; + +/** + * This is to keep track of the + */ +public abstract class ApplicationContext { + private List applicationContextList; + + private String id; + protected boolean started; + protected boolean terminated; + + private Status status; + + protected boolean killDependent; + + public ApplicationContext(String id, boolean killDependent) { + applicationContextList = new ArrayList(); + this.killDependent = killDependent; + this.id = id; + } + + public List getApplicationContextList() { + return applicationContextList; + } + + public void setApplicationContextList(List applicationContextList) { + this.applicationContextList = applicationContextList; + } + + public void addApplicationContext(ApplicationContext applicationContext) { + applicationContextList.add(applicationContext); + + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java new file mode 100644 index 0000000000..737a27d1b3 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -0,0 +1,61 @@ +/* + * 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.autoscaler.grouping.dependency.context; + +import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; +import org.apache.stratos.messaging.domain.topology.ParentBehavior; + +/** + * Factory to create new GroupContext or ClusterContext + */ +public class ApplicationContextFactory { + + public static ApplicationContext getApplicationContext(String startOrder, + ParentBehavior component, + DependencyTree dependencyTree) { + String id; + ApplicationContext applicationContext = null; + if (startOrder.contains("group")) { + id = getGroupFromStartupOrder(startOrder); + //TODO getting the alias of the group using groupName + applicationContext = new GroupContext(component.getGroup(id).getAlias(), + dependencyTree.isKillDependent()); + } else if (startOrder.contains("cartridge")) { + id = getClusterFromStartupOrder(startOrder); + //TODO getting the cluster id of the using cartridge name + applicationContext = new ClusterContext(component.getClusterData(id).getClusterId(), + dependencyTree.isKillDependent()); + } else { + //TODO throw exception + } + return applicationContext; + + } + + public static String getGroupFromStartupOrder(String startupOrder) { + return startupOrder.substring(6); + } + + public static String getClusterFromStartupOrder(String startupOrder) { + return startupOrder.substring(10); + } + + + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java new file mode 100644 index 0000000000..23ea039757 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java @@ -0,0 +1,28 @@ +/* + * 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.autoscaler.grouping.dependency.context; + +/** + * Created by reka on 10/1/14. + */ +public class ClusterContext extends ApplicationContext { + public ClusterContext(String id, boolean killDependent) { + super(id ,killDependent); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java new file mode 100644 index 0000000000..0e65d2b107 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java @@ -0,0 +1,28 @@ +/* + * 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.autoscaler.grouping.dependency.context; + +/** + * Created by reka on 10/1/14. + */ +public class GroupContext extends ApplicationContext { + public GroupContext(String id, boolean killDependent) { + super(id ,killDependent); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java new file mode 100644 index 0000000000..d75780ee12 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -0,0 +1,30 @@ +/* + * 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.autoscaler.monitor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Created by reka on 10/2/14. + */ +public class ApplicationMonitorFactory { + private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class); + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 215c2222d1..122c815967 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -23,98 +23,128 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.grouping.DependencyBuilder; +import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; +import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.ParentBehavior; -import org.apache.stratos.messaging.domain.topology.Status; -import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; +import java.util.concurrent.ScheduledExecutorService; /** * Monitor is to monitor it's child monitors and * control them according to the dependencies respectively. */ public abstract class Monitor extends Observable implements Observer { - private static final Log log = LogFactory.getLog(Monitor.class); protected String id; - protected Map groupMonitors; - protected Map abstractClusterMonitors; + protected Map aliasToGroupMonitorsMap; + + protected Map clusterIdToClusterMonitorsMap; + + protected Map clusterIdToExecutorServiceMap; - protected Queue preOrderTraverse = new LinkedList(); + private Map adderIdToExecutorServiceMap; + + //protected Queue preOrderTraverse; + + protected DependencyTree dependencyTree; protected ParentBehavior component; protected Status status; public Monitor(ParentBehavior component) { - groupMonitors = new HashMap(); - abstractClusterMonitors = new HashMap(); + aliasToGroupMonitorsMap = new HashMap(); + clusterIdToClusterMonitorsMap = new HashMap(); + clusterIdToExecutorServiceMap = new HashMap(); + adderIdToExecutorServiceMap = new HashMap(); + //preOrderTraverse = new LinkedList(); this.component = component; - preOrderTraverse = DependencyBuilder.getStartupOrder(component); - - //startDependency(); + dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } - protected abstract void startDependency(); - + public abstract void monitor(); - public Map getGroupMonitors() { - return groupMonitors; + public Map getAliasToGroupMonitorsMap() { + return aliasToGroupMonitorsMap; } - public void setGroupMonitors(Map groupMonitors) { - this.groupMonitors = groupMonitors; + public String getId() { + return this.id; } - public Map getAbstractClusterMonitors() { - return abstractClusterMonitors; + public void setId(String id) { + this.id = id; } - public void addAbstractMonitor(AbstractClusterMonitor monitor) { - this.abstractClusterMonitors.put(monitor.getClusterId(), monitor); - } + public void startDependency() { + //start the first dependency + List applicationContexts = dependencyTree.getStarAbleDependencies(); + startDependency(applicationContexts); - public AbstractClusterMonitor getAbstractMonitor(String clusterId) { - return this.abstractClusterMonitors.get(clusterId); } - public void setAbstractClusterMonitors(Map abstractClusterMonitors) { - this.abstractClusterMonitors = abstractClusterMonitors; + public void startDependency(String id) { + List applicationContexts = dependencyTree.getStarAbleDependencies(id); + startDependency(applicationContexts); } - public abstract void monitor(); - - /** - * Triggered when an event is received. - * @param event - */ - protected abstract void onEvent(Event event); - - public String getId() { - return this.id; - } + private void startDependency(List applicationContexts) { + if(applicationContexts == null) { + //all the groups/clusters have been started and waiting for activation + log.warn("There is no child found for the [group]: " + this.id ); + } + for (ApplicationContext context : applicationContexts) { + if (log.isDebugEnabled()) { + log.debug("Dependency check for the Group " + context.getId() + " started"); + } + if (context instanceof GroupContext) { + startGroupMonitor(this, context.getId(), component); + } else if (context instanceof ClusterContext) { + ClusterDataHolder clusterDataHolder = component.getClusterData(context.getId()); + String clusterId = clusterDataHolder.getClusterId(); + String serviceName = clusterDataHolder.getServiceType(); + Cluster cluster; + //TopologyManager.acquireReadLock(); + Topology topology = TopologyManager.getTopology(); + if (topology.serviceExists(serviceName)) { + Service service = topology.getService(serviceName); + if (service.clusterExists(clusterId)) { + cluster = service.getCluster(clusterId); + if (log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); + } + startClusterMonitor(this, cluster); + } else { + log.warn("[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName); + } + } else { + log.warn("[Service] " + serviceName + " cannot be found in the Topology"); + } + //TopologyManager.releaseReadLock(); + } + } - public void setId(String id) { - this.id = id; } - protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { Thread th = null; if (cluster.isLbCluster() - && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { + && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { th = new Thread(new LBClusterMonitorAdder( cluster)); - } else if (!cluster.isLbCluster() && !this.abstractClusterMonitors.containsKey(cluster.getClusterId())) { + } else if (!cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { th = new Thread( new ClusterMonitorAdder(parent, cluster)); if (log.isDebugEnabled()) { @@ -129,8 +159,7 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) th.join(); } catch (InterruptedException ignore) { }*/ - - log.info(String + log.info(String .format("Cluster monitor thread has been started successfully: [cluster] %s ", cluster.getClusterId())); } @@ -138,7 +167,7 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentBehavior component) { Thread th = null; - if (!this.groupMonitors.containsKey(dependency)) { + if (!this.aliasToGroupMonitorsMap.containsKey(dependency)) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor Adder has been added: [group] %s ", @@ -165,6 +194,14 @@ public Status getStatus() { return status; } + public Map getAdderIdToExecutorServiceMap() { + return adderIdToExecutorServiceMap; + } + + public void setAdderIdToExecutorServiceMap(Map adderIdToExecutorServiceMap) { + this.adderIdToExecutorServiceMap = adderIdToExecutorServiceMap; + } + private class ClusterMonitorAdder implements Runnable { private Cluster cluster; private Monitor parent; @@ -220,7 +257,7 @@ public void run() { th.start(); AutoscalerContext.getInstance().addMonitor(monitor); - abstractClusterMonitors.put(cluster.getClusterId(), monitor); + clusterIdToClusterMonitorsMap.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); @@ -275,7 +312,7 @@ public void run() { throw new RuntimeException(msg); } - groupMonitors.put(dependency, monitor); + aliasToGroupMonitorsMap.put(dependency, monitor); parent.addObserver(monitor); if (log.isInfoEnabled()) { @@ -327,7 +364,7 @@ public void run() { Thread th = new Thread(monitor); th.start(); AutoscalerContext.getInstance().addLbMonitor(monitor); - abstractClusterMonitors.put(cluster.getClusterId(), monitor); + clusterIdToClusterMonitorsMap.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); @@ -335,5 +372,25 @@ public void run() { } } + public void setAliasToGroupMonitorsMap(Map aliasToGroupMonitorsMap) { + this.aliasToGroupMonitorsMap = aliasToGroupMonitorsMap; + } + + public Map getClusterIdToClusterMonitorsMap() { + return clusterIdToClusterMonitorsMap; + } + + public void addAbstractMonitor(AbstractClusterMonitor monitor) { + this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); + } + + public AbstractClusterMonitor getAbstractMonitor(String clusterId) { + return this.clusterIdToClusterMonitorsMap.get(clusterId); + } + + public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { + this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index ac2b556711..eeef1d4c0a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -24,9 +24,8 @@ import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Status; import java.util.*; @@ -39,12 +38,7 @@ public class ApplicationMonitor extends Monitor { public ApplicationMonitor(Application application) { super(application); this.id = application.getId(); - if (preOrderTraverse.isEmpty()) { - log.warn("the child group/cluster cannot be found for the Application " + id); - } else { - startDependency(); - } - //keep + startDependency(); } @Override @@ -56,67 +50,12 @@ public void update(Observable observable, Object event) { log.info(String.format("[Monitor] %s got notified from the [child] %s" + "on its state change from %s to %s", id, notifier, this.status, status)); if (childStatus == Status.Activated) { - //start the next dependency - if (!preOrderTraverse.isEmpty()) { - startDependency(); - } - } - } - } - - @Override - protected void onEvent(Event event) { - - } + //update the notifier as active in the dependency tree - @Override - protected void startDependency() { - //Need to get the order every time as group/cluster might already been started - //TODO breadth first search in a tree and find the parallel one - //TODO build up the tree with ordered manner - - // start the first dependency - if (!preOrderTraverse.isEmpty()) { - String dependency = preOrderTraverse.poll(); - if (log.isDebugEnabled()) { - log.debug("Dependency check for the [group] " + dependency + " started"); - } - if (dependency.contains("group")) { - String groupId = dependency.substring(6); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [group]" + groupId); - } - startGroupMonitor(this, groupId, component); - } else if (dependency.contains("cartridge")) { - ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); - Cluster cluster = null; - //TopologyManager.acquireReadLock(); - Topology topology = TopologyManager.getTopology(); - if (topology.serviceExists(serviceName)) { - Service service = topology.getService(serviceName); - if (service.clusterExists(clusterId)) { - cluster = service.getCluster(clusterId); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); - } - startClusterMonitor(this, cluster); - } else { - log.warn("[Cluster] " + clusterId + " cannot be found in the " + - "Topology for [service] " + serviceName); - } - } else { - log.warn("[Service] " + serviceName + " cannot be found in the Topology"); - } - //TopologyManager.releaseReadLock(); + //start the next dependency + startDependency(notifier); } - } else { - //all the groups/clusters have been started and waiting for activation - log.info("All the groups/clusters of the [Application]: " + this.id + " have been started."); } - - } @@ -127,14 +66,14 @@ protected void startDependency() { * @return the found GroupMonitor */ public GroupMonitor findGroupMonitorWithId(String groupId) { - return findGroupMonitor(groupId, groupMonitors.values()); + return findGroupMonitor(groupId, aliasToGroupMonitorsMap.values()); } public List findClustersOfApplication(String appId) { List clusters = new ArrayList(); //considering only one level - for (AbstractClusterMonitor monitor : this.abstractClusterMonitors.values()) { + for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) { clusters.add(monitor.getClusterId()); } //TODO rest @@ -150,7 +89,7 @@ public List findClustersOfApplication(String appId) { * @return */ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { - return findClusterMonitor(clusterId, abstractClusterMonitors.values(), groupMonitors.values()); + return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), aliasToGroupMonitorsMap.values()); } @@ -166,8 +105,8 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, for (GroupMonitor groupMonitor : groupMonitors) { return findClusterMonitor(clusterId, - groupMonitor.getAbstractClusterMonitors().values(), - groupMonitor.getGroupMonitors().values()); + groupMonitor.getClusterIdToClusterMonitorsMap().values(), + groupMonitor.getAliasToGroupMonitorsMap().values()); } return null; @@ -180,8 +119,8 @@ private GroupMonitor findGroupMonitor(String id, Collection monito return monitor; } else { // check if this Group has nested sub Groups. If so, traverse them as well - if (monitor.getGroupMonitors() != null) { - return findGroupMonitor(id, monitor.getGroupMonitors().values()); + if (monitor.getAliasToGroupMonitorsMap() != null) { + return findGroupMonitor(id, monitor.getAliasToGroupMonitorsMap().values()); } } } @@ -195,12 +134,12 @@ public Monitor findParentMonitorOfGroup(String groupId) { private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { //if this monitor has the group, return it as the parent - if (monitor.getGroupMonitors().containsKey(groupId)) { + if (monitor.getAliasToGroupMonitorsMap().containsKey(groupId)) { return monitor; } else { - if (monitor.getGroupMonitors() != null) { + if (monitor.getAliasToGroupMonitorsMap() != null) { //check whether the children has the group and find its parent - for (GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + for (GroupMonitor groupMonitor : monitor.getAliasToGroupMonitorsMap().values()) { return findParentMonitorForGroup(groupId, groupMonitor); } @@ -216,12 +155,12 @@ public Monitor findParentMonitorOfCluster(String clusterId) { private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { //if this monitor has the group, return it as the parent - if (monitor.getAbstractClusterMonitors().containsKey(clusterId)) { + if (monitor.getClusterIdToClusterMonitorsMap().containsKey(clusterId)) { return monitor; } else { - if (monitor.getGroupMonitors() != null) { + if (monitor.getAliasToGroupMonitorsMap() != null) { //check whether the children has the group and find its parent - for (GroupMonitor groupMonitor : monitor.getGroupMonitors().values()) { + for (GroupMonitor groupMonitor : monitor.getAliasToGroupMonitorsMap().values()) { return findParentMonitorForCluster(clusterId, groupMonitor); } @@ -243,12 +182,4 @@ public void setStatus(Status status) { "state changes from %s to %s", id, this.status, status)); this.status = status; } - - public Queue getPreOrderTraverse() { - return preOrderTraverse; - } - - public void setPreOrderTraverse(Queue preOrderTraverse) { - this.preOrderTraverse = preOrderTraverse; - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index cfab9dee2d..376d5d482b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -20,15 +20,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.grouping.DependencyBuilder; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.List; -import java.util.Map; import java.util.Observable; /** @@ -41,26 +41,23 @@ public class GroupMonitor extends Monitor { public GroupMonitor(Group group) { super(group); this.id = group.getAlias(); - if(preOrderTraverse.isEmpty()) { - log.warn("the child group/cluster cannot be found for the Group " + id); - } else { - startDependency(); - } + startDependency(); + } @Override public void update(Observable observable, Object event) { - if(event instanceof MonitorStatusEvent) { + if (event instanceof MonitorStatusEvent) { MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; Status childStatus = statusEvent.getStatus(); String notifier = statusEvent.getNotifierId(); log.info(String.format("[Monitor] %s got notified from the [child] %s" + "on its state change from %s to %s", id, notifier, this.status, status)); - if(childStatus == Status.Activated) { + if (childStatus == Status.Activated) { //start the next dependency - if(!preOrderTraverse.isEmpty()) { - startDependency(); - } + startDependency(notifier); + } else if(childStatus == Status.In_Maintenance) { + } } @@ -76,63 +73,11 @@ public void setStatus(Status status) { } @Override - public void startDependency() { - //Need to get the order every time as group/cluster might already been started - //TODO breadth first search in a tree and find the parallel one - //TODO build up the tree with ordered manner - preOrderTraverse = DependencyBuilder.getStartupOrder(component); - - //start the first dependency - if(!preOrderTraverse.isEmpty()) { - String dependency = preOrderTraverse.poll(); - if(log.isDebugEnabled()) { - log.debug("Dependency check for the Group " + dependency + " started"); - } - if (dependency.contains("group")) { - for(Group group: component.getAliasToGroupMap().values()) { - if(group.getName().equals(dependency.substring(6))) { - startGroupMonitor(this, group.getAlias(), component); - } - } - } else if (dependency.contains("cartridge")) { - ClusterDataHolder clusterDataHolder = component.getClusterData(dependency.substring(10)); - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); - Cluster cluster = null; - //TopologyManager.acquireReadLock(); - Topology topology = TopologyManager.getTopology(); - if (topology.serviceExists(serviceName)) { - Service service = topology.getService(serviceName); - if (service.clusterExists(clusterId)) { - cluster = service.getCluster(clusterId); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); - } - startClusterMonitor(this, cluster); - } else { - log.warn("[Cluster] " + clusterId + " cannot be found in the " + - "Topology for [service] " + serviceName); - } - } else { - log.warn("[Service] " + serviceName + " cannot be found in the Topology"); - } - //TopologyManager.releaseReadLock(); - } - } else { - //all the groups/clusters have been started and waiting for activation - log.info("All the groups/clusters of the [group]: " + this.id + " have been started."); - } - } //monitor the status of the cluster and the groups public void monitor() { - } - - @Override - protected void onEvent(Event event) { - } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java index ba2cc2e5e9..220380e862 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.domain.topology; import java.io.Serializable; +import java.util.List; public class StartupOrder implements Serializable { @@ -27,6 +28,8 @@ public class StartupOrder implements Serializable { private String after; + private List startList; + public StartupOrder (String start, String after) { this.start = start; this.after = after; @@ -39,4 +42,12 @@ public String getStart() { public String getAfter() { return after; } + + public List getStartList() { + return startList; + } + + public void setStartList(List startList) { + this.startList = startList; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java index fafb4e87f1..7ba27fc4d4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -22,9 +22,10 @@ public enum Status { Created(1), - In_Maintenance(2), - Running(3), - Activated(4); + Running(2), + Activated(3), + In_Maintenance(4), + Removed(5); private int code; From b52735ee788d4d2370c892db6aecc8d9ec6387a7 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Thu, 2 Oct 2014 13:36:52 -0700 Subject: [PATCH 138/436] fixing issue when undeploying servicegroup - Cannot Undeploy Group which is Already Deployed --- .../controller/impl/CloudControllerServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 5b04df2df4..0901944b17 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -333,15 +333,19 @@ public void undeployServiceGroup(String name) throws InvalidServiceGroupExceptio } ServiceGroup serviceGroup = null; - if((serviceGroup = dataHolder.getServiceGroup(name)) != null) { - if (dataHolder.getServiceGroups().remove(name)) { + + serviceGroup = dataHolder.getServiceGroup(name); + + if (serviceGroup != null) { + if (dataHolder.getServiceGroups().remove(serviceGroup)) { persist(); if(log.isInfoEnabled()) { log.info("Successfully undeployed the Service Group definition: " + serviceGroup); } return; } - } + } + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; log.error(msg); throw new InvalidServiceGroupException(msg); From b3c5aaa581110f3353afa3d3a3297520bcf4a72e Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 3 Oct 2014 17:16:43 +0530 Subject: [PATCH 139/436] add metaInfoAlias to application definition --- .../composite/application/beans/SubscribableInfo.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 index 3e0ba547c6..72385dc5ae 100644 --- 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 @@ -38,6 +38,8 @@ public class SubscribableInfo { private String repoPassword; + private String metaInfoAlias; + public String getAlias() { return alias; } @@ -93,4 +95,12 @@ public String getRepoPassword() { public void setRepoPassword(String repoPassword) { this.repoPassword = repoPassword; } + + public String getMetaInfoAlias() { + return metaInfoAlias; + } + + public void setMetaInfoAlias(String metaInfoAlias) { + this.metaInfoAlias = metaInfoAlias; + } } From 08dcefb58b263efa6cc243ae06b971f6499dff07 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Sun, 5 Oct 2014 21:49:45 +0530 Subject: [PATCH 140/436] add dependencyAliases to application --- .../application/SubscribableInfoContext.java | 10 + .../application/beans/SubscribableInfo.java | 10 +- .../resources/CloudControllerService.wsdl | 549 +++++++++--------- 3 files changed, 290 insertions(+), 279 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java index 6812962c43..5f75a7c155 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java @@ -35,6 +35,8 @@ public class SubscribableInfoContext { private String repoPassword; + private String[] dependencyAliases; + public String getAlias() { return alias; } @@ -90,4 +92,12 @@ public String getRepoPassword() { public void setRepoPassword(String repoPassword) { this.repoPassword = repoPassword; } + + public String[] getDependencyAliases() { + return dependencyAliases; + } + + public void setDependencyAliases(String[] dependencyAliases) { + this.dependencyAliases = dependencyAliases; + } } 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 index 72385dc5ae..27353fa5c4 100644 --- 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 @@ -38,7 +38,7 @@ public class SubscribableInfo { private String repoPassword; - private String metaInfoAlias; + private String[] dependencyAliases; public String getAlias() { return alias; @@ -96,11 +96,11 @@ public void setRepoPassword(String repoPassword) { this.repoPassword = repoPassword; } - public String getMetaInfoAlias() { - return metaInfoAlias; + public String[] getDependencyAliases() { + return dependencyAliases; } - public void setMetaInfoAlias(String metaInfoAlias) { - this.metaInfoAlias = metaInfoAlias; + public void setDependencyAliases(String[] dependencyAliases) { + this.dependencyAliases = dependencyAliases; } } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 876fcd8bb2..a46988032e 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,8 +6,8 @@ - - + + @@ -15,15 +15,15 @@ - - - + + + - + @@ -37,9 +37,9 @@ - + - + @@ -52,6 +52,7 @@ + @@ -61,305 +62,298 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + + + - + - + - - - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -375,128 +369,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -505,16 +446,40 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -529,11 +494,24 @@ - + - - - + + + + + + + + + + + + + + + + @@ -545,15 +523,55 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -564,14 +582,14 @@ - + - + @@ -580,9 +598,8 @@ - + - @@ -590,71 +607,55 @@ - + + - - - + + + - - - - - - - + - - + + + + + - - - - - - - + + + + + - + - - + - + - - - - - - - - - - - - - + + + - + + + + - - - - - - - - - + + + + + @@ -734,15 +735,15 @@ - - - + + + @@ -842,15 +843,15 @@ - - - - + + + + @@ -1018,6 +1019,15 @@ + + + + + + + + + @@ -1030,15 +1040,6 @@ - - - - - - - - - @@ -1264,6 +1265,15 @@ + + + + + + + + + @@ -1276,15 +1286,6 @@ - - - - - - - - - @@ -1471,6 +1472,12 @@ + + + + + + @@ -1480,12 +1487,6 @@ - - - - - - @@ -1558,22 +1559,22 @@ - + - + - + - + - + - + \ No newline at end of file From 67b00b93dfe830958d1021b3e707a77298ed6686 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 6 Oct 2014 11:25:47 +0530 Subject: [PATCH 141/436] adding some comments --- .../impl/CloudControllerServiceImpl.java | 31 +------- .../domain/topology/Application.java | 28 ++----- .../domain/topology/ClusterDataHolder.java | 7 ++ .../messaging/domain/topology/Group.java | 12 ++- .../domain/topology/ParentBehavior.java | 76 +++++++++++++++++-- 5 files changed, 95 insertions(+), 59 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 0901944b17..e99a722d2e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1440,42 +1440,13 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) ApplicationParser applicationParser = new DefaultApplicationParser(); Application application = applicationParser.parse(applicationContext); + // Create a Cluster Context obj. for each of the Clusters in the Application for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); } - //TODO: improve -// Set medaDataHolders = applicationParser.getPayloadData(); -// if (medaDataHolders != null) { -// -// MetaDataServiceClient metaDataServiceClient; -// try { -// -// metaDataServiceClient = new DefaultMetaDataServiceClient(MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); -// metaDataServiceClient.initialize(); -// -// } catch (RestClientException e) { -// log.error("Error creating instance of Metadata Service Client", e); -// throw new ApplicationDefinitionException(e); -// } -// -// for (MetaDataHolder metaDataHolder : medaDataHolders) { -// for (Map.Entry metaDataEntry : metaDataHolder.getProperties().entrySet()) { -// try { -// metaDataServiceClient.addPropertyToCluster(metaDataHolder.getAppId(), metaDataHolder.getClusterId(), -// (String)metaDataEntry.getKey(), (String)metaDataEntry.getValue()); -// -// } catch (MetaDataServiceClientExeption e) { -// log.error("Error publishing data to Metadata Service", e); -// throw new ApplicationDefinitionException(e); -// } -// } -// } -// } - - TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), applicationParser.getPayloadData()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index a2e5732097..dd7d6ea6fe 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -23,6 +23,10 @@ import java.util.*; +/** + * Represents an Application in the Topology + */ + public class Application implements ParentBehavior { private static final long serialVersionUID = -5092959597171649688L; @@ -59,13 +63,13 @@ public void addGroup(Group group) { } @Override - public void setGroups(Map aliasToGroup) { - aliasToGroupMap.putAll(aliasToGroup); + public void setGroups(Map groupAliasToGroup) { + aliasToGroupMap.putAll(groupAliasToGroup); } @Override - public Group getGroup(String groupName) { - return aliasToGroupMap.get(groupName); + public Group getGroup(String groupAlias) { + return aliasToGroupMap.get(groupAlias); } @Override @@ -155,22 +159,6 @@ public ClusterDataHolder getClusterData(String alias) { return aliasToClusterDataMap.get(alias); } -// @Override -// public void addClusterId(String serviceName, String clusterId) { -// -// synchronized (serviceNameToClusterIdsMap) { -// if (serviceNameToClusterIdsMap.get(serviceName) == null) { -// // not found, create -// Set clusterIds = new HashSet(); -// clusterIds.add(clusterId); -// serviceNameToClusterIdsMap.put(serviceName, clusterIds); -// } else { -// // the cluster id set already exists, update -// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); -// } -// } -// } - public String getId() { return id; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java index cceb4fc5cb..70eab4c335 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java @@ -21,10 +21,17 @@ import java.io.Serializable; +/** + * Data Holder for a Cluster. + * Will hold the Service Type and Cluster Id. + */ + public class ClusterDataHolder implements Serializable { + // Service/Cartridge type private String serviceType; + // Cluster id private String clusterId; public ClusterDataHolder (String serviceType, String clusterId) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index c47667f397..cd849b69c3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -21,6 +21,10 @@ import java.util.*; +/** + * Represents a Group/nested Group in an Application/Group + */ + public class Group implements ParentBehavior { private static final long serialVersionUID = 8347096598203655846L; @@ -55,13 +59,13 @@ public void addGroup(Group group) { } @Override - public void setGroups(Map groupNameToGroup) { - aliasToGroupMap.putAll(groupNameToGroup); + public void setGroups(Map groupAliasToGroup) { + aliasToGroupMap.putAll(groupAliasToGroup); } @Override - public Group getGroup(String groupName) { - return aliasToGroupMap.get(groupName); + public Group getGroup(String groupAlias) { + return aliasToGroupMap.get(groupAlias); } @Override diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java index d6c7035299..5fbdf0c0fa 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java @@ -22,29 +22,95 @@ import java.io.Serializable; import java.util.Collection; import java.util.Map; -import java.util.Set; + +/** + * Abstraction for a an entity that can have child entities + * in an Application withing the Topology + */ public interface ParentBehavior extends Serializable { + /** + * Adds a group + * + * @param group Group instance to be added + */ public void addGroup (Group group); - public void setGroups (Map groupNameToGroup); + /** + * Setter for Group alias to Group map + * + * @param groupAliasToGroup Map, key = alias given to the Group, value = Group + */ + public void setGroups (Map groupAliasToGroup); + + /** + * Get the Group for the given alias in the context of the parent entity. + * Will not search recursively in the nested levels. + * + * @param groupAlias alias of the Group + * @return Group, if exists for the given alias, else null + */ + public Group getGroup (String groupAlias); - public Group getGroup (String groupName); + /** + * Get the Group for the given alias in the context of the parent entity. + * Will search recursively in the nested levels. + * + * @param groupAlias alias of the Group + * @return Group, if exists for the given alias, else null + */ + public Group getGroupRecursively (String groupAlias); + /** + * Getter for alias to Group map + * Will not search recursively in the nested levels. + * + * @return Map, key = alias given to the Group, value = Group + */ public Map getAliasToGroupMap(); + /** + * Getter for cluster alias to ClusterData map for this level + * + * @return Map, key = alias given to the cluster, value = ClusterData object + */ public Map getClusterDataMap(); - public Group getGroupRecursively (String groupAlias); - + /** + * Collection of Groups in this level + * + * @return Group Collection object, empty if no Groups are found + */ public Collection getGroups (); + /** + * Setter for Dependency Order + * + * @param dependencyOrder Dependency Order object + */ public void setDependencyOrder (DependencyOrder dependencyOrder); + /** + * Getter for Dependency Order for this level + * + * @return Dependency Order object + */ public DependencyOrder getDependencyOrder (); + /** + * Setter for alias to Cluster Data map + * + * @param aliasToClusterData Map, key = alias given to the cluster, value = ClusterData object + */ public void setClusterData (Map aliasToClusterData); + /** + * Getter for Cluster Data instance for the given alias + * Will not search recursively in the nested levels. + * + * @param alias + * @return + */ public ClusterDataHolder getClusterData (String alias); } From 4e64f18bdb861939a2eb49845e2ac480f137139f Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 6 Oct 2014 11:47:25 +0530 Subject: [PATCH 142/436] adding kill behavior to the dependency tree --- .../dependency/DependencyBuilder.java | 2 +- .../grouping/dependency/DependencyTree.java | 38 ++++++++- .../stratos/autoscaler/monitor/Monitor.java | 84 ++++++++++--------- .../application/ApplicationMonitor.java | 7 -- .../monitor/group/GroupMonitor.java | 9 -- 5 files changed, 80 insertions(+), 60 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 7d8ff2d25e..6d1eee3e1f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -142,7 +142,7 @@ public DependencyTree buildDependency(ParentBehavior component) { } } - return null; + return dependencyTree; } /*public static Queue getStartupOrder(ParentBehavior component) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 1c6b28f039..c17aef0c91 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; @@ -51,6 +52,9 @@ public class DependencyTree { public DependencyTree(String id) { applicationContextList = new ArrayList(); this.setId(id); + if(log.isDebugEnabled()) { + log.debug("Starting a dependency tree for the [group/application] " + id); + } } public List getApplicationContextList() { @@ -120,16 +124,42 @@ public List getStarAbleDependencies() { * When one group/cluster terminates/in_maintenance, need to consider about other * dependencies * @param id the alias/id of group/cluster in which terminated event received - * @return + * @return all the kill able children dependencies */ public List getKillDependencies(String id) { - ApplicationContext applicationContext = findApplicationContextWithId(id); + List allChildrenOfAppContext = new ArrayList(); + if(killDependent) { - return applicationContext.getApplicationContextList(); + //finding the ApplicationContext of the given id + ApplicationContext applicationContext = findApplicationContextWithId(id); + //finding all the children of the found application context + findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), + allChildrenOfAppContext); + return allChildrenOfAppContext; + } else if(killAll) { + //killall will be killed by the monitor from it's list. + findAllChildrenOfAppContext(this.applicationContextList, + allChildrenOfAppContext); + } - return null; + //return empty for the kill-none case + return allChildrenOfAppContext; } + /** + * + * @param applicationContexts + * @param childContexts + * @return + */ + public List findAllChildrenOfAppContext(List applicationContexts, + List childContexts) { + for(ApplicationContext context : applicationContexts) { + childContexts.add(context); + findAllChildrenOfAppContext(context.getApplicationContextList(), childContexts); + } + return childContexts; + } public boolean isKillAll() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 122c815967..a75df54a6e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -36,7 +36,9 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; +import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; /** * Monitor is to monitor it's child monitors and @@ -55,8 +57,6 @@ public abstract class Monitor extends Observable implements Observer { private Map adderIdToExecutorServiceMap; - //protected Queue preOrderTraverse; - protected DependencyTree dependencyTree; protected ParentBehavior component; @@ -73,29 +73,25 @@ public Monitor(ParentBehavior component) { dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } - public abstract void monitor(); - - public Map getAliasToGroupMonitorsMap() { - return aliasToGroupMonitorsMap; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } + /** + * This will start the parallel dependencies at once from the top level. + * it will get invoked when the monitor starts up only. + * //TODO restarting the whole group + */ public void startDependency() { //start the first dependency - List applicationContexts = dependencyTree.getStarAbleDependencies(); + List applicationContexts = this.dependencyTree.getStarAbleDependencies(); startDependency(applicationContexts); } + /** + * This will get invoked based on the activation event of its one of the child + * @param id alias/clusterId of which receive the activated event + */ public void startDependency(String id) { - List applicationContexts = dependencyTree.getStarAbleDependencies(id); + List applicationContexts = this.dependencyTree.getStarAbleDependencies(id); startDependency(applicationContexts); } @@ -139,26 +135,22 @@ private void startDependency(List applicationContexts) { } protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { - Thread th = null; + ScheduledExecutorService adder = Executors.newSingleThreadScheduledExecutor(); if (cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - th = new Thread(new LBClusterMonitorAdder( - cluster)); + adder.scheduleAtFixedRate(new LBClusterMonitorAdder( + cluster), 5, 5, TimeUnit.SECONDS); } else if (!cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - th = new Thread( - new ClusterMonitorAdder(parent, cluster)); + adder.scheduleAtFixedRate(new ClusterMonitorAdder(parent, cluster), 5, 5, TimeUnit.SECONDS); + if (log.isDebugEnabled()) { log.debug(String .format("Cluster monitor Adder has been added: [cluster] %s ", cluster.getClusterId())); } } - if (th != null) { - th.start(); - /*try { - th.join(); - } catch (InterruptedException ignore) { - }*/ + if (adder != null) { + adderIdToExecutorServiceMap.put(cluster.getClusterId(), adder); log.info(String .format("Cluster monitor thread has been started successfully: [cluster] %s ", cluster.getClusterId())); @@ -166,25 +158,26 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentBehavior component) { - Thread th = null; + ScheduledExecutorService adder = Executors.newSingleThreadScheduledExecutor(); + if (!this.aliasToGroupMonitorsMap.containsKey(dependency)) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor Adder has been added: [group] %s ", dependency)); } - th = new Thread( - new GroupMonitorAdder(parent, dependency, component)); + adder.scheduleAtFixedRate(new GroupMonitorAdder(parent, dependency, component), 5, 5, TimeUnit.SECONDS); + } - if (th != null) { - th.start(); + if (adder != null) { /*try { - th.join(); - } catch (InterruptedException ignore) { + adder.awaitTermination(30, TimeUnit.SECONDS); + } catch (InterruptedException e) { + e.printStackTrace(); }*/ - - log.info(String + adderIdToExecutorServiceMap.put(((Group)component).getAlias(), adder); + log.info(String .format("Group monitor thread has been started successfully: [group] %s ", dependency)); } @@ -216,10 +209,10 @@ public void run() { int retries = 5; boolean success = false; do { - try { + /*try { Thread.sleep(5000); } catch (InterruptedException e1) { - } + }*/ try { if(log.isDebugEnabled()) { log.debug("CLuster monitor is going to be started for [cluster] " @@ -372,6 +365,19 @@ public void run() { } } + + public Map getAliasToGroupMonitorsMap() { + return aliasToGroupMonitorsMap; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + public void setAliasToGroupMonitorsMap(Map aliasToGroupMonitorsMap) { this.aliasToGroupMonitorsMap = aliasToGroupMonitorsMap; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index eeef1d4c0a..d3b9faa28f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -170,13 +170,6 @@ private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { } - @Override - public void monitor() { - startDependency(); - - //evaluate dependency - } - public void setStatus(Status status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 376d5d482b..eae7ed602c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -71,13 +71,4 @@ public void setStatus(Status status) { setChanged(); notifyObservers(new MonitorStatusEvent(status, id)); } - - @Override - - - //monitor the status of the cluster and the groups - public void monitor() { - - - } } From d7eb101f0493b4336dcbc66918d243ee030aab3c Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 6 Oct 2014 14:21:44 +0530 Subject: [PATCH 143/436] code aligning --- .../grouping/dependency/DependencyTree.java | 33 +++++++++++-------- .../application/ApplicationMonitor.java | 5 ++- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index c17aef0c91..a5b9ce23d5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; @@ -52,7 +51,7 @@ public class DependencyTree { public DependencyTree(String id) { applicationContextList = new ArrayList(); this.setId(id); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Starting a dependency tree for the [group/application] " + id); } } @@ -72,6 +71,7 @@ public void addApplicationContext(ApplicationContext applicationContext) { /** * Find an ApplicationContext from dependency tree with the given id + * * @param id the alias/id of group/cluster * @return ApplicationContext of the given id */ @@ -81,19 +81,20 @@ public ApplicationContext findApplicationContextWithId(String id) { /** * Find the ApplicationContext using Breadth first search. - * @param id the alias/id of group/cluster + * + * @param id the alias/id of group/cluster * @param contexts the list of contexts in the same level of the tree * @return ApplicationContext of the given id */ private ApplicationContext findApplicationContextWithId(String id, List contexts) { - for(ApplicationContext context: contexts) { - if(context.getId().equals(id)) { + for (ApplicationContext context : contexts) { + if (context.getId().equals(id)) { return context; } } //if not found in the top level search recursively - for(ApplicationContext context: contexts) { - return findApplicationContextWithId(id, context.getApplicationContextList()); + for (ApplicationContext context : contexts) { + return findApplicationContextWithId(id, context.getApplicationContextList()); } return null; } @@ -101,6 +102,7 @@ private ApplicationContext findApplicationContextWithId(String id, List getStarAbleDependencies(String id) { /** * Getting the next start able dependencies upon the monitor initialization. + * * @return list of dependencies */ public List getStarAbleDependencies() { @@ -123,20 +126,21 @@ public List getStarAbleDependencies() { /** * When one group/cluster terminates/in_maintenance, need to consider about other * dependencies + * * @param id the alias/id of group/cluster in which terminated event received * @return all the kill able children dependencies */ public List getKillDependencies(String id) { List allChildrenOfAppContext = new ArrayList(); - if(killDependent) { + if (killDependent) { //finding the ApplicationContext of the given id ApplicationContext applicationContext = findApplicationContextWithId(id); //finding all the children of the found application context findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), - allChildrenOfAppContext); + allChildrenOfAppContext); return allChildrenOfAppContext; - } else if(killAll) { + } else if (killAll) { //killall will be killed by the monitor from it's list. findAllChildrenOfAppContext(this.applicationContextList, allChildrenOfAppContext); @@ -147,14 +151,15 @@ public List getKillDependencies(String id) { } /** + * This will help to find out all the children of a particular node * - * @param applicationContexts - * @param childContexts - * @return + * @param applicationContexts app contexts of the particular node + * @param childContexts contains the children of the node + * @return all the children of the given node */ public List findAllChildrenOfAppContext(List applicationContexts, List childContexts) { - for(ApplicationContext context : applicationContexts) { + for (ApplicationContext context : applicationContexts) { childContexts.add(context); findAllChildrenOfAppContext(context.getApplicationContextList(), childContexts); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index d3b9faa28f..30b872786e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -27,7 +27,10 @@ import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Status; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Observable; /** * ApplicationMonitor is to control the child monitors From 0aeed04723650d63cc4d7166f38fea066aa73789 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 6 Oct 2014 17:12:01 +0530 Subject: [PATCH 144/436] doing code review changes --- .../parser/DefaultApplicationParser.java | 320 ++++++++---------- .../impl/CloudControllerServiceImpl.java | 4 +- .../interfaces/ApplicationParser.java | 17 + .../controller/topology/TopologyBuilder.java | 9 +- 4 files changed, 162 insertions(+), 188 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 27c412668b..156ab778f1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -19,6 +19,7 @@ package org.apache.stratos.cloud.controller.application.parser; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.application.ApplicationUtils; @@ -56,11 +57,7 @@ public DefaultApplicationParser () { @Override public Application parse(Object obj) throws ApplicationDefinitionException { - ApplicationContext applicationCtxt = null; - - if (obj instanceof ApplicationContext) { - applicationCtxt = (ApplicationContext) obj; - } + ApplicationContext applicationCtxt = (ApplicationContext) obj; if (applicationCtxt == null) { handleError("Invalid Composite Application Definition"); @@ -118,6 +115,14 @@ public Set getPayloadData() throws ApplicationDefinitionExceptio return metaDataHolders; } + /** + * Extract Group information from Application Definition + * + * @param appCtxt ApplicationContext object with Application information + * @return Map [group alias -> Group] + * + * @throws ApplicationDefinitionException if the Group information is invalid + */ private Map getDefinedGroups (ApplicationContext appCtxt) throws ApplicationDefinitionException { @@ -131,7 +136,7 @@ private Map getDefinedGroups (ApplicationContext appCtxt) for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) { // check validity of group name - if (groupContext.getName() == null || groupContext.getName().isEmpty()) { + if (StringUtils.isEmpty(groupContext.getName())) { handleError("Invalid Group name specified"); } @@ -141,7 +146,8 @@ private Map getDefinedGroups (ApplicationContext appCtxt) } // check validity of group alias - if (groupContext.getAlias() == null || groupContext.getAlias().isEmpty() || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { + + if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); } @@ -162,6 +168,14 @@ private Map getDefinedGroups (ApplicationContext appCtxt) return definedGroups; } + /** + * Extract Subscription Information from the Application Definition + * + * @param appCtxt ApplicationContext object with Application information + * @return Map [cartridge alias -> Group] + * + * @throws ApplicationDefinitionException if the Subscription information is invalid + */ private Map getSubscribableInformation (ApplicationContext appCtxt) throws ApplicationDefinitionException { @@ -173,7 +187,7 @@ private Map getSubscribableInformation (Applica for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) { - if (subscribableInfoCtxt.getAlias() == null || subscribableInfoCtxt.getAlias().isEmpty() || + if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) || !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) { handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); } @@ -194,11 +208,29 @@ private Map getSubscribableInformation (Applica return subscribableInformation; } + /** + * Check if a Group Definition is deployed + * + * @param serviceGroupName Group name + * @return true if the Group is deployed, else false + * + * @throws ApplicationDefinitionException + */ private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException { return FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName) != null; } + /** + * Builds the Application structure + * + * @param appCtxt ApplicationContext object with Application information + * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @return Application Application object denoting the Application structure + * + * @throws ApplicationDefinitionException If an error occurs in building the Application structure + */ private Application buildCompositeAppStructure (ApplicationContext appCtxt, Map definedGroupCtxts, Map subscribableInfoCtxts) @@ -252,6 +284,19 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, return application; } + /** + * Parse Group information + * + * @param appId Application id + * @param tenantId tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupCtxts Group information + * @param subscribableInformation Subscribable Information + * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information + * @return Map [alias -> Group] + * + * @throws ApplicationDefinitionException if an error occurs in parsing Group Information + */ private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, Map subscribableInformation, Map definedGroupCtxts) @@ -272,6 +317,12 @@ private Map parseGroups (String appId, int tenantId, String key, return groupAliasToGroup; } + /** + * Extracts nested Group information recursively + * + * @param nestedGroups Nested Groups set to be populated recursively + * @param groups Collection of Groups + */ private void getNestedGroupContexts (Set nestedGroups, Collection groups) { if (groups != null) { @@ -284,6 +335,12 @@ private void getNestedGroupContexts (Set nestedGroups, Collection } } + /** + * Filters duplicated Groups from top level + * + * @param topLevelGroups Top level Groups + * @param nestedGroups nested Groups + */ private void filterDuplicatedGroupContexts (Collection topLevelGroups, Set nestedGroups) { for (Group nestedGroup : nestedGroups) { @@ -304,6 +361,19 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr } } + /** + * Parses an individual Group + * + * @param appId Application id + * @param tenantId tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupCtxt Group definition information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information + * @return Group object + * + * @throws ApplicationDefinitionException if unable to parse + */ private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, Map subscribableInfoCtxts, Map definedGroupCtxts) @@ -357,6 +427,14 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g return group; } + /** + * Find the startup order + * + * @param groupContext GroupContext with Group defintion information + * @return Set of Startup Orders which are defined in the Group + * + * @throws ApplicationDefinitionException + */ private Set getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(groupContext.getName()); @@ -377,6 +455,14 @@ private Set getStartupOrderForGroup(GroupContext groupContext) thr return null; } + /** + * Find the startup order for an Application + * + * @param startupOrderCtxts Startup Order information related to the Application + * @return Set of Startup Orders + * + * @throws ApplicationDefinitionException if an error occurs + */ private Set getStartupOrderForApplicationComponents (Set startupOrderCtxts) throws ApplicationDefinitionException { @@ -393,6 +479,14 @@ private Set getStartupOrderForApplicationComponents (Set getSubsribableContexts (List subscribableCtxts, -// Map subscribableInfoCtxts) -// throws ApplicationDefinitionException { -// -// Set subscribableContexts = new HashSet(); -// -// for (SubscribableContext subscribableCtxt : subscribableCtxts) { -// // check is there is a related Subscribable Information -// SubscribableInfo subscribableInfo = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); -// if (subscribableInfo == null) { -// throw new CompositeApplicationDefinitionException("Related Subscribable Information not found for Subscribable with alias: " -// + subscribableCtxt.getAlias()); -// } -// -// // check if Cartridge Type is valid -// if (subscribableCtxt.getType() == null || subscribableCtxt.getType().isEmpty()) { -// throw new CompositeApplicationDefinitionException ("Invalid Cartridge Type specified : [ " -// + subscribableCtxt.getType() + " ]"); -// } -// -// // check if a cartridge with relevant type is already deployed. else, can't continue -// if (!isCartrigdeDeployed(subscribableCtxt.getType())) { -// throw new CompositeApplicationDefinitionException("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + -// " ] for Composite Application"); -// } -// -// subscribableContexts.add(ParserUtils.convert(subscribableCtxt, subscribableInfo)); -// } -// -// return subscribableContexts; -// } - + /** + * Parse Subscription Information + * + * @param appId Application id + * @param tenantId Tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupName Group name (if relevant) + * @param subscribableCtxts Subscribable Information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @return Map [subscription alias -> ClusterDataHolder] + * + * @throws ApplicationDefinitionException + */ private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, List subscribableCtxts, Map subscribableInfoCtxts) throws ApplicationDefinitionException { Map clusterDataMap = new HashMap(); -// Set clusters = new HashSet(); - //Set payloadDataHolders = new HashSet(); for (SubscribableContext subscribableCtxt : subscribableCtxts) { @@ -461,7 +534,7 @@ private Map parseLeafLevelSubscriptions (String appId } // check if Cartridge Type is valid - if (subscribableCtxt.getType() == null || subscribableCtxt.getType().isEmpty()) { + if (StringUtils.isEmpty(subscribableCtxt.getType())) { handleError("Invalid Cartridge Type specified : [ " + subscribableCtxt.getType() + " ]"); } @@ -493,34 +566,31 @@ private Map parseLeafLevelSubscriptions (String appId appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); - // TODO: I will bring you back when meta data service is completed B-) - // create cluster level meta data - //this.metaDataHolders.add(ApplicationUtils.getClusterLevelPayloadData(appId, groupName, tenantId, key, - // hostname, appClusterCtxt.getTenantRange(), clusterId, subscribableCtxt, subscribableInfoCtxt, cartridge)); - // add relevant information to the map clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId)); - - //////////// - //Cluster cluster = getCluster(subscribableCtxt, subscribableInfoCtxt, cartridge); - //addClusterId(clusterDataMap, subscribableCtxt.getType(), clusterId); - //clusterDataMap.put(subscribableCtxt.getType(), cluster.getClusterId()); - //clusters.add(cluster); -// if (clusterDataMap.put(subscribableCtxt.getType(), cluster.getClusterId()) != null) { -// // Application Definition has same cartridge multiple times at the top-level -// handleError("Cartridge [ " + subscribableCtxt.getType() + " ] appears twice in the Application Definition's top level"); -// } - /////////////// - -// createClusterContext(appId, groupName, subscribableCtxt.getType(), cluster.getClusterId(), -// cluster.getHostNames().get(0)); } return clusterDataMap; - //return new ClusterDataHolder(clusterDataMap, clusters); - //clusterDataHolder.setPayloadDataHolders(payloadDataHolders); } + /** + * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application + * + * @param appId Application id + * @param groupName Group name + * @param cartridge Cartridge information + * @param subscriptionKey Generated key for the Application + * @param tenantId Tenant Id of the tenant which deployed the Application + * @param repoUrl Repository URL + * @param alias alias specified for this Subscribable in the Application Definition + * @param clusterId Cluster id + * @param hostname Hostname + * @param deploymentPolicy Deployment policy used + * @param isLB if this cluster is an LB + * @return ApplicationClusterContext object with relevant information + * + * @throws ApplicationDefinitionException If any error occurs + */ private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String repoUrl, String alias, String clusterId, String hostname, @@ -528,134 +598,12 @@ private ApplicationClusterContext createApplicationClusterContext (String appId, throws ApplicationDefinitionException { // Create text payload - //String textPayload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); - String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId, hostname, repoUrl, alias, null).toString(); return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); } -// public void addClusterId (Map> serviceNameToClusterIdsMap, String serviceName, String clusterId) { -// -// if (serviceNameToClusterIdsMap.get(serviceName) == null) { -// // not found, create -// Set clusterIds = new HashSet(); -// clusterIds.add(clusterId); -// serviceNameToClusterIdsMap.put(serviceName, clusterIds); -// } else { -// // the cluster id set already exists, update -// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); -// } -// } - -// private void createClusterContext (String appId, String groupName, String serviceType, String clusterId, -// String hostName) throws ApplicationDefinitionException { -// -// Cartridge cartridge; -// if ((cartridge = dataHolder.getCartridge(serviceType)) == null) { -// -// String msg = "Unregistered Cartridge type: " + serviceType; -// log.error(msg); -// throw new ApplicationDefinitionException(msg); -// } -// -// //Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); -// //String property = props.getProperty(Constants.IS_LOAD_BALANCER); -// //boolean isLb = property != null ? Boolean.parseBoolean(property) : false; -// String payload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); -// -// ClusterContext ctxt = buildClusterContext(cartridge, clusterId, -// payload, hostName, null, false, null); -// -// dataHolder.addClusterContext(ctxt); -// } -// -// private void persist(FasterLookUpDataHolder dataHolder) { -// try { -// RegistryManager.getInstance().persist( -// dataHolder); -// } catch (RegistryException e) { -// -// String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; -// log.fatal(msg); -// throw new CloudControllerException(msg, e); -// } -// } -// -// private ClusterContext buildClusterContext(Cartridge cartridge, -// String clusterId, String payload, String hostName, -// Properties props, boolean isLb, Persistence persistence) { -// -// -// // initialize ClusterContext -// ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, -// hostName, isLb); -// -// String property = null; -// if (props != null) { -// property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); -// } -// -// long timeout = property != null ? Long.parseLong(property) : 30000; -// -// boolean persistanceRequired = false; -// if(persistence != null){ -// persistanceRequired = persistence.isPersistanceRequired(); -// } -// -// if(persistanceRequired){ -// ctxt.setVolumes(persistence.getVolumes()); -// ctxt.setVolumeRequired(true); -// }else{ -// ctxt.setVolumeRequired(false); -// } -// ctxt.setTimeoutInMillis(timeout); -// return ctxt; -// } -// -// private Cluster getCluster (SubscribableContext subscribableCtxt, SubscribableInfoContext subscribableInfoCtxt, Cartridge cartridge) -// -// throws ApplicationDefinitionException { -// -// // get hostname and cluster id -// ClusterInformation clusterInfo; -// if (cartridge.isMultiTenant()) { -// clusterInfo = new MTClusterInformation(); -// } else { -// clusterInfo = new STClusterInformation(); -// } -// -// String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); -// String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); -// -// Cluster cluster = new Cluster(subscribableCtxt.getType(), clusterId, subscribableInfoCtxt.getDeploymentPolicy(), -// subscribableInfoCtxt.getAutoscalingPolicy()); -// Clo -// cluster.addHostName(hostname); -// cluster.setLbCluster(false); -// cluster.setStatus(Status.Created); -// -// return cluster; -// } - -// private GroupDataHolder getGroupInformation (List groupCtxts, -// Map subscribableInformation, -// Map definedGroupCtxts) -// throws ApplicationDefinitionException { -// -// Set groupContexts = new HashSet(); -// -// for (GroupContext groupCtxt : groupCtxts) { -// groupContexts.add(parseGroup(groupCtxt, subscribableInformation, definedGroupCtxts)); -// } -// -// //Set topLevelGroupContexts = getTopLevelGroupContexts(groupContexts); -// Set nestedGroupContexts = new HashSet(); -// getNestedGroupContexts(nestedGroupContexts, groupContexts); -// filterDuplicatedGroupContexts(groupContexts, nestedGroupContexts); -// } - private Cartridge getCartridge (String cartridgeType) { return FasterLookUpDataHolder.getInstance().getCartridge(cartridgeType); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index e99a722d2e..a6f74df718 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1456,7 +1456,9 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) @Override public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - TopologyBuilder.handleApplicationUndeployed(applicationId, tenantId, tenantDomain); + TopologyBuilder.handleApplicationUndeployed(dataHolder, applicationId, tenantId, tenantDomain); + + persist(); } private List restoreConfigCompositeApplication () { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java index 77cbe332ea..7bd471df6a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java @@ -28,9 +28,26 @@ public interface ApplicationParser { + /** + * Parses the Application Definition + * + * @param obj Object with the Application Definition. An Object is used here since there can be + * significant changes between the way composite Applications are defined in different + * conventions + * @return Application structure denoting the parsed Application + * @throws ApplicationDefinitionException If the Application Definition is invalid + */ public Application parse (Object obj) throws ApplicationDefinitionException; + /** + * Returns a set of ApplicationClusterContext which will comprise of cluster related information + * extracted from the Application definition + * + * @return Set of ApplicationClusterContext objects + * @throws ApplicationDefinitionException if any error occurs + */ public Set getApplicationClusterContexts() throws ApplicationDefinitionException; + // TODO: remove public Set getPayloadData () throws ApplicationDefinitionException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 9541ac082c..6d50f6c123 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -653,7 +653,7 @@ public static void handleApplicationDeployed(Application application, } } - public static void handleApplicationUndeployed(String applicationId, int tenantId, String tenantDomain) { + public static void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder, String applicationId, int tenantId, String tenantDomain) { Topology topology = TopologyManager.getTopology(); @@ -670,6 +670,7 @@ public static void handleApplicationUndeployed(String applicationId, int tenantI for (ClusterDataHolder clusterDataHolder : application.getClusterDataRecursively()) { Service service = topology.getService(clusterDataHolder.getServiceType()); if (service != null) { + // remove Cluster service.removeCluster(clusterDataHolder.getClusterId()); if (log.isDebugEnabled()) { log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); @@ -678,6 +679,12 @@ public static void handleApplicationUndeployed(String applicationId, int tenantI log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); } + + // remove runtime data + dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); + if(log.isDebugEnabled()) { + log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); + } } // remove application From a07a7532ef9bbfa456b83548db6aff8fd97c3e08 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 7 Oct 2014 16:56:33 +0530 Subject: [PATCH 145/436] adding dependecyAliases --- .../application/ApplicationUtils.java | 23 +- .../parser/DefaultApplicationParser.java | 13 +- .../application/payload/BasicPayloadData.java | 58 + .../cloud/controller/pojo/Cartridge.java | 16 +- .../controller/pojo/CartridgeConfig.java | 12 +- .../controller/util/CloudControllerUtil.java | 4 + .../definition/CartridgeDefinitionBean.java | 13 +- .../bean/util/converter/PojoConverter.java | 7 + .../resources/CloudControllerService.wsdl | 1095 +++++++++-------- tools/test.json | 0 10 files changed, 675 insertions(+), 566 deletions(-) create mode 100644 tools/test.json diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java index 697f33a8fb..35600c4e82 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.application; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.application.payload.BasicPayloadData; import org.apache.stratos.cloud.controller.application.payload.PayloadData; import org.apache.stratos.cloud.controller.application.payload.PayloadFactory; @@ -33,6 +35,7 @@ import java.util.regex.Pattern; public class ApplicationUtils { + private static final Log log = LogFactory.getLog(ApplicationUtils.class); public static boolean isAliasValid (String alias) { @@ -190,13 +193,13 @@ public static StringBuilder getTextPayload (String appId, String groupName, Stri return payloadBuilder; } - public static PayloadData createPayload (String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String clusterId, - String hostName, String repoUrl, String alias, Map customPayloadEntries) + public static PayloadData createPayload(String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String clusterId, + String hostName, String repoUrl, String alias, Map customPayloadEntries, String[] dependencyAliases) throws ApplicationDefinitionException { //Create the payload BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridge, subscriptionKey, - clusterId, hostName, repoUrl, alias, tenantId); + clusterId, hostName, repoUrl, alias, tenantId, dependencyAliases); //Populate the basic payload details basicPayloadData.populatePayload(); @@ -241,10 +244,10 @@ public static PayloadData createPayload (String appId, String groupName, Cartrid return payloadData; } - private static BasicPayloadData createBasicPayload (String appId, String groupName, Cartridge cartridge, - String subscriptionKey, String clusterId, - String hostName, String repoUrl, String alias, - int tenantId) { + private static BasicPayloadData createBasicPayload(String appId, String groupName, Cartridge cartridge, + String subscriptionKey, String clusterId, + String hostName, String repoUrl, String alias, + int tenantId, String[] dependencyAliases) { BasicPayloadData basicPayloadData = new BasicPayloadData(); basicPayloadData.setAppId(appId); @@ -276,6 +279,12 @@ private static BasicPayloadData createBasicPayload (String appId, String groupNa basicPayloadData.setTenantId(tenantId); basicPayloadData.setTenantRange("*"); + basicPayloadData.setDependencyAliases(dependencyAliases); + if(cartridge.getExportingProperties() != null){ + basicPayloadData.setExportingProperties(cartridge.getExportingProperties()); + log.info("testing1 getExportingProperties " + cartridge.getExportingProperties()); + + } return basicPayloadData; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 27c412668b..2a7b25f4f7 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -489,7 +489,8 @@ private Map parseLeafLevelSubscriptions (String appId assert subscribableInfoCtxt != null; ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), - clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false); + clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases()); + appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); @@ -521,17 +522,17 @@ private Map parseLeafLevelSubscriptions (String appId //clusterDataHolder.setPayloadDataHolders(payloadDataHolders); } - private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge, - String subscriptionKey, int tenantId, String repoUrl, - String alias, String clusterId, String hostname, - String deploymentPolicy, boolean isLB) + private ApplicationClusterContext createApplicationClusterContext(String appId, String groupName, Cartridge cartridge, + String subscriptionKey, int tenantId, String repoUrl, + String alias, String clusterId, String hostname, + String deploymentPolicy, boolean isLB, String[] dependencyAliases) throws ApplicationDefinitionException { // Create text payload //String textPayload = ApplicationUtils.getTextPayload(appId, groupName, clusterId).toString(); String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId, - hostname, repoUrl, alias, null).toString(); + hostname, repoUrl, alias, null, dependencyAliases).toString(); return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java index c15e49225d..2c3c187ebe 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java @@ -49,6 +49,8 @@ public class BasicPayloadData implements Serializable { private String portMappings; private String multitenant; private String provider; + private String[] dependencyAliases; + private String[] exportingProperties; protected StringBuilder payloadBuilder; @@ -100,6 +102,14 @@ public void populatePayload () { payloadBuilder.append(","); payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available")); + if(getDependencyAliasesPayloadString() != null){ + payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString()); + } + + if(getExportingPropertiesPayloadString() != null){ + payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString()); + } + } public String getServiceName() { @@ -250,4 +260,52 @@ public String getGroupName() { public void setGroupName(String groupName) { this.groupName = groupName; } + + public String[] getDependencyAliases() { + return dependencyAliases; + } + + public void setDependencyAliases(String[] dependencyAliases) { + this.dependencyAliases = dependencyAliases; + } + + private String getDependencyAliasesPayloadString(){ + if(dependencyAliases == null){ + return null; + } + + StringBuilder dependencyAliasesPayload = new StringBuilder(); + for(int i=0; i< dependencyAliases.length; i++){ + dependencyAliasesPayload.append(dependencyAliases[i]); + if(i != dependencyAliases.length -1){ + dependencyAliasesPayload.append("|"); + } + } + log.info("testing1 getDependencyAliasesPayloadString " + dependencyAliasesPayload); + return dependencyAliasesPayload.toString(); + } + + private String getExportingPropertiesPayloadString(){ + if(exportingProperties == null){ + return null; + } + + StringBuilder exportingPropertiesPayload = new StringBuilder(); + for(int i=0; i< exportingProperties.length; i++){ + exportingPropertiesPayload.append(exportingProperties[i]); + if(i != exportingProperties.length -1){ + exportingPropertiesPayload.append("|"); + } + } + log.info("testing1 getExportingPropertiesPayloadString " + exportingPropertiesPayload); + return exportingPropertiesPayload.toString(); + } + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java index dafaa2c66e..805aaa5ed2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Cartridge.java @@ -77,7 +77,9 @@ public class Cartridge implements Serializable{ private List deploymentDirs; private IaasProvider lastlyUsedIaas; - + + private String[] exportingProperties; + /** * Key - partition id * Value - Corresponding IaasProvider. @@ -369,6 +371,14 @@ public String getServiceGroup() { public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } - - + + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java index 0862ad1b3b..00fe884518 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java @@ -62,6 +62,7 @@ public class CartridgeConfig implements Serializable { private LoadbalancerConfig lbConfig; private String serviceGroup; + private String[] exportingProperties; public String getType() { @@ -269,6 +270,13 @@ public String getServiceGroup() { public void setServiceGroup(String serviceGroup) { this.serviceGroup = serviceGroup; } - - + + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java index e9a57bed6d..0ad848852f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java @@ -160,6 +160,10 @@ public static Cartridge toCartridge(CartridgeConfig config) { } } + if(config.getExportingProperties() != null){ + cartridge.setExportingProperties(config.getExportingProperties()); + } + return cartridge; } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java index 87c6aac088..2a99610bbe 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/cartridge/definition/CartridgeDefinitionBean.java @@ -58,12 +58,15 @@ public class CartridgeDefinitionBean { public String serviceGroup; + private String[] exportingProperties; + public String toString () { return "Type: " + type + ", Provider: " + provider + ", Host: " + host + ", Display Name: " + displayName + ", Description: " + description + ", Version: " + version + ", Multitenant " + multiTenant + "\n" + getDeploymentDetails() + "\n PortMapping: " + getPortMappings() + "\n IaaS: " + getIaasProviders() + - "\n LoadBalancer: " + getLoadBalancerInfo() + "\n Properties: " + getProperties() +"\n VolumeBean mappings "+ persistence.toString(); + "\n LoadBalancer: " + getLoadBalancerInfo() + "\n Properties: " + getProperties() +"\n VolumeBean mappings "+ persistence.toString() + + "\n Exports " + exportingProperties.toString(); } private String getDeploymentDetails () { @@ -114,4 +117,12 @@ private String getProperties () { } return propertyBuilder.toString(); } + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 0067d37193..a100a93553 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -96,6 +96,11 @@ public static CartridgeConfig populateCartridgeConfigPojo (CartridgeDefinitionBe cartridgeConfig.setProperties(getProperties(cartridgeDefinitionBean.property)); } + if(cartridgeDefinitionBean.getExportingProperties() != null) + { + cartridgeConfig.setExportingProperties(cartridgeDefinitionBean.getExportingProperties()); + } + return cartridgeConfig; } @@ -717,7 +722,9 @@ private static SubscribableInfoContext[] getSubscribableInfoContextArrFromSubscr subscribableInfoContext.setPrivateRepo(subscribableInfo.isPrivateRepo()); subscribableInfoContext.setRepoUsername(subscribableInfo.getRepoUsername()); subscribableInfoContext.setRepoPassword(subscribableInfo.getRepoPassword()); + subscribableInfoContext.setDependencyAliases(subscribableInfo.getDependencyAliases()); subscribableInfoContexts[i++] = subscribableInfoContext; + } return subscribableInfoContexts; diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index a46988032e..f57808e235 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -4,1577 +4,1578 @@ - - - - - - - + + + + + + + - - - + + + - - + + - - + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - + + - - - - - - - - + + + + + + + + - - + + - - + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - + + - - - + + + - - - - + + + + - + - - - + + + - - + + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + - + - - - + + + - + - - - - - + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file diff --git a/tools/test.json b/tools/test.json new file mode 100644 index 0000000000..e69de29bb2 From 3c8deacccbd6a76ba25fec51b218150bb83e7868 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 7 Oct 2014 17:46:21 +0530 Subject: [PATCH 146/436] add comma to separate payload --- .../controller/application/payload/BasicPayloadData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java index 2c3c187ebe..c655b1b883 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java @@ -101,11 +101,11 @@ public void populatePayload () { payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env")); payloadBuilder.append(","); payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available")); - + payloadBuilder.append(","); if(getDependencyAliasesPayloadString() != null){ payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString()); } - + payloadBuilder.append(","); if(getExportingPropertiesPayloadString() != null){ payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString()); } From 4bd661edeafb06830d303b625c601051a286b794 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 7 Oct 2014 17:46:45 +0530 Subject: [PATCH 147/436] fixing NPE in debug logs --- .../topology/AutoscalerTopologyEventReceiver.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 522039092c..627b648f8a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -26,7 +26,6 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; @@ -587,12 +586,9 @@ public void run() { success = true; //TODO exception handling } catch (Exception e) { - String msg = "Application monitor creation failed for Application: " + - application.getId(); - log.debug(msg, e); + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); retries--; - - } } while (!success && retries != 0); From 2536b30b3933dff9fc9f67420cae45f494e5eaf2 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 7 Oct 2014 18:26:12 +0530 Subject: [PATCH 148/436] adding eventing support for monitors --- .../dependency/DependencyBuilder.java | 11 +- .../context/ApplicationContext.java | 15 ++ .../AutoscalerTopologyEventReceiver.java | 4 +- .../monitor/AbstractClusterMonitor.java | 51 ++++--- ...aintenanceEvent.java => EventHandler.java} | 14 +- .../stratos/autoscaler/monitor/Monitor.java | 137 +++++++++--------- .../monitor/MonitorStatusEventBuilder.java | 55 +++++++ .../application/ApplicationMonitor.java | 104 ++++++++++--- .../monitor/cluster/ClusterMonitor.java | 51 ++++--- ...Event.java => ApplicationStatusEvent.java} | 14 +- .../monitor/events/ClusterActivatedEvent.java | 54 ------- ...anceEvent.java => ClusterStatusEvent.java} | 15 +- .../monitor/events/GroupActivatedEvent.java | 48 ------ ...onitorEvent.java => GroupStatusEvent.java} | 10 +- .../monitor/events/MonitorStatusEvent.java | 27 ++-- .../monitor/group/GroupMonitor.java | 74 +++++++--- 16 files changed, 397 insertions(+), 287 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{events/ClusterInMaintenanceEvent.java => EventHandler.java} (68%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/{ApplicationActivatedEvent.java => ApplicationStatusEvent.java} (76%) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/{GroupInMaintenanceEvent.java => ClusterStatusEvent.java} (69%) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/{MonitorEvent.java => GroupStatusEvent.java} (74%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 6d1eee3e1f..59b9bf8af3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -54,14 +54,19 @@ public static DependencyBuilder getInstance() { * @return the dependency tree out of the dependency orders */ public DependencyTree buildDependency(ParentBehavior component) { - Group group = (Group) component; - DependencyTree dependencyTree = new DependencyTree(group.getAlias()); + String alias = null; + if(component instanceof Application) { + alias = ((Application)component).getId(); + } else if(component instanceof Group) { + alias = ((Group) component).getAlias(); + } + DependencyTree dependencyTree = new DependencyTree(alias); DependencyOrder dependencyOrder = component.getDependencyOrder(); if (dependencyOrder != null) { if (log.isDebugEnabled()) { log.debug("Building dependency for the Application/Group " + - group.getAlias()); + alias); } //Parsing the kill behaviour diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java index d9b6df8d66..f923bb0833 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -35,10 +35,13 @@ public abstract class ApplicationContext { private Status status; + private List statusLifeCycle; + protected boolean killDependent; public ApplicationContext(String id, boolean killDependent) { applicationContextList = new ArrayList(); + statusLifeCycle = new ArrayList(); this.killDependent = killDependent; this.id = id; } @@ -56,6 +59,10 @@ public void addApplicationContext(ApplicationContext applicationContext) { } + public void addStatusToLIfeCycle(Status status) { + this.statusLifeCycle.add(status); + } + public String getId() { return id; } @@ -71,4 +78,12 @@ public Status getStatus() { public void setStatus(Status status) { this.status = status; } + + public List getStatusLifeCycle() { + return statusLifeCycle; + } + + public void setStatusLifeCycle(List statusLifeCycle) { + this.statusLifeCycle = statusLifeCycle; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 627b648f8a..3e1bfe2c58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -582,7 +582,7 @@ public void run() { } applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); long end = System.currentTimeMillis(); - log.info("Time taken to start app monitor: " + (end - start)/1000); + log.info("Time taken to start Napp monitor: " + (end - start)/1000); success = true; //TODO exception handling } catch (Exception e) { @@ -594,7 +594,7 @@ public void run() { if (applicationMonitor == null) { String msg = "Application monitor creation failed, even after retrying for 5 times, " - + "for Application: " + applicationMonitor.getId(); + + "for Application: " + application.getId(); log.error(msg); throw new RuntimeException(msg); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index ae47f63d89..d48fdb4794 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -18,18 +18,14 @@ */ package org.apache.stratos.autoscaler.monitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; - -import java.util.Map; -import java.util.Observable; -import java.util.Observer; - import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; @@ -41,12 +37,14 @@ import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; +import java.util.Map; + /** * Is responsible for monitoring a service cluster. This runs periodically * and perform minimum instance check and scaling check using the underlying * rules engine. */ -abstract public class AbstractClusterMonitor extends Observable implements Observer, Runnable { +abstract public class AbstractClusterMonitor implements EventHandler, Runnable { private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); // Map @@ -70,6 +68,8 @@ abstract public class AbstractClusterMonitor extends Observable implements Obser protected Status status; + protected Monitor parent; + protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; // time intereval between two runs of the Monitor. Default is 90000ms. @@ -79,7 +79,7 @@ public AbstractClusterMonitor() { readConfigurations(); } - private void readConfigurations () { + private void readConfigurations() { XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); monitorInterval = conf.getInt(AutoScalerConstants.AUTOSCALER_MONITOR_INTERVAL, 90000); @@ -97,7 +97,7 @@ public void run() { public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); String networkPartitionId = member.getNetworkPartitionId(); - if(networkPartitionCtxts.containsKey(networkPartitionId)) { + if (networkPartitionCtxts.containsKey(networkPartitionId)) { log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); return networkPartitionCtxts.get(networkPartitionId); } @@ -105,10 +105,10 @@ public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { return null; } - public String getPartitionOfMember(String memberId){ - for(Service service: TopologyManager.getTopology().getServices()){ - for(Cluster cluster: service.getClusters()){ - if(cluster.memberExists(memberId)){ + public String getPartitionOfMember(String memberId) { + for (Service service : TopologyManager.getTopology().getServices()) { + for (Cluster cluster : service.getClusters()) { + if (cluster.memberExists(memberId)) { return cluster.getMember(memberId).getPartitionId(); } } @@ -232,11 +232,6 @@ public void setTerminateDependencyFactHandle( this.terminateDependencyFactHandle = terminateDependencyFactHandle; } - @Override - public void update(Observable observable, Object o) { - //get the update from parent monitor - } - public int getMonitorInterval() { return monitorInterval; } @@ -249,7 +244,21 @@ public void setStatus(Status status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", clusterId, this.status, status)); this.status = status; - setChanged(); - notifyObservers(new MonitorStatusEvent(status, clusterId)); + //notifying the parent monitor about the state change + MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + + } + + public Monitor getParent() { + return parent; + } + + public void setParent(Monitor parent) { + this.parent = parent; + } + + @Override + public void onEvent(MonitorStatusEvent statusEvent) { + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java similarity index 68% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java index 14d322c13b..b1ba90f227 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterInMaintenanceEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java @@ -16,10 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor.events; +package org.apache.stratos.autoscaler.monitor; + +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; /** - * This will use to notify observers upon a cluster maintenance events received in Topology. + * Event Handler to notify the observer/to receive notification */ -public class ClusterInMaintenanceEvent extends MonitorEvent { +public interface EventHandler { + /** + * Triggered when an event is received. + * + * @param statusEvent + */ + public abstract void onEvent(MonitorStatusEvent statusEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index a75df54a6e..05544067ba 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -30,9 +30,11 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.application.status.StatusEvent; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; @@ -44,35 +46,35 @@ * Monitor is to monitor it's child monitors and * control them according to the dependencies respectively. */ -public abstract class Monitor extends Observable implements Observer { +public abstract class Monitor implements EventHandler { private static final Log log = LogFactory.getLog(Monitor.class); + //id of the monitor, it can be alias or the id protected String id; - + //GroupMonitor map, key=GroupAlias and value=GroupMonitor protected Map aliasToGroupMonitorsMap; - + //AbstractMonitor map, key=clusterId and value=AbstractMonitors protected Map clusterIdToClusterMonitorsMap; - - protected Map clusterIdToExecutorServiceMap; - - private Map adderIdToExecutorServiceMap; - + //The monitors dependency tree with all the startable/killable dependencies protected DependencyTree dependencyTree; - + //application/group reference from the Topology protected ParentBehavior component; - + //status of the monitor whether it is running/in_maintainable/terminated protected Status status; public Monitor(ParentBehavior component) { aliasToGroupMonitorsMap = new HashMap(); clusterIdToClusterMonitorsMap = new HashMap(); - clusterIdToExecutorServiceMap = new HashMap(); - adderIdToExecutorServiceMap = new HashMap(); //preOrderTraverse = new LinkedList(); this.component = component; dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } + /** + * + */ + protected abstract void monitor(MonitorStatusEvent statusEvent); + /** * This will start the parallel dependencies at once from the top level. @@ -88,6 +90,7 @@ public void startDependency() { /** * This will get invoked based on the activation event of its one of the child + * * @param id alias/clusterId of which receive the activated event */ public void startDependency(String id) { @@ -95,10 +98,15 @@ public void startDependency(String id) { startDependency(applicationContexts); } + /** + * To start the dependency of the given application contexts + * + * @param applicationContexts the found applicationContexts to be started + */ private void startDependency(List applicationContexts) { - if(applicationContexts == null) { + if (applicationContexts == null) { //all the groups/clusters have been started and waiting for activation - log.warn("There is no child found for the [group]: " + this.id ); + log.warn("There is no child found for the [group]: " + this.id); } for (ApplicationContext context : applicationContexts) { if (log.isDebugEnabled()) { @@ -150,10 +158,10 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } } if (adder != null) { - adderIdToExecutorServiceMap.put(cluster.getClusterId(), adder); + //adderIdToExecutorServiceMap.put(cluster.getClusterId(), adder); log.info(String - .format("Cluster monitor thread has been started successfully: [cluster] %s ", - cluster.getClusterId())); + .format("Cluster monitor thread has been started successfully: [cluster] %s ", + cluster.getClusterId())); } } @@ -176,10 +184,10 @@ protected synchronized void startGroupMonitor(Monitor parent, String dependency, } catch (InterruptedException e) { e.printStackTrace(); }*/ - adderIdToExecutorServiceMap.put(((Group)component).getAlias(), adder); + //adderIdToExecutorServiceMap.put(((Group)component).getAlias(), adder); log.info(String - .format("Group monitor thread has been started successfully: [group] %s ", - dependency)); + .format("Group monitor thread has been started successfully: [group] %s ", + dependency)); } } @@ -187,12 +195,36 @@ public Status getStatus() { return status; } - public Map getAdderIdToExecutorServiceMap() { - return adderIdToExecutorServiceMap; + public Map getAliasToGroupMonitorsMap() { + return aliasToGroupMonitorsMap; } - public void setAdderIdToExecutorServiceMap(Map adderIdToExecutorServiceMap) { - this.adderIdToExecutorServiceMap = adderIdToExecutorServiceMap; + public void setAliasToGroupMonitorsMap(Map aliasToGroupMonitorsMap) { + this.aliasToGroupMonitorsMap = aliasToGroupMonitorsMap; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public Map getClusterIdToClusterMonitorsMap() { + return clusterIdToClusterMonitorsMap; + } + + public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { + this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; + } + + public void addAbstractMonitor(AbstractClusterMonitor monitor) { + this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); + } + + public AbstractClusterMonitor getAbstractMonitor(String clusterId) { + return this.clusterIdToClusterMonitorsMap.get(clusterId); } private class ClusterMonitorAdder implements Runnable { @@ -214,12 +246,13 @@ public void run() { } catch (InterruptedException e1) { }*/ try { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("CLuster monitor is going to be started for [cluster] " + cluster.getClusterId()); } monitor = AutoscalerUtil.getClusterMonitor(cluster); - monitor.addObserver(parent); + monitor.setParent(parent); + //monitor.addObserver(parent); success = true; //TODO start the status checker } catch (PolicyValidationException e) { @@ -238,7 +271,7 @@ public void run() { } while (!success && retries != 0); - if (monitor == null) { + if (monitor == null) { String msg = "Cluster monitor creation failed, even after retrying for 5 times, " + "for cluster: " + cluster.getClusterId(); log.error(msg); @@ -273,19 +306,20 @@ public void run() { GroupMonitor monitor = null; int retries = 5; boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } try { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Group monitor is going to be started for [group] " + dependency); } monitor = AutoscalerUtil.getGroupMonitor(component.getGroup(dependency)); - monitor.addObserver(parent); + monitor.setParent(parent); + //monitor.addObserver(parent); success = true; } catch (Exception e) { @@ -306,7 +340,7 @@ public void run() { } aliasToGroupMonitorsMap.put(dependency, monitor); - parent.addObserver(monitor); + //parent.addObserver(monitor); if (log.isInfoEnabled()) { log.info(String.format("Group monitor has been added successfully: [group] %s", @@ -366,37 +400,4 @@ public void run() { } - public Map getAliasToGroupMonitorsMap() { - return aliasToGroupMonitorsMap; - } - - public String getId() { - return this.id; - } - - public void setId(String id) { - this.id = id; - } - - public void setAliasToGroupMonitorsMap(Map aliasToGroupMonitorsMap) { - this.aliasToGroupMonitorsMap = aliasToGroupMonitorsMap; - } - - public Map getClusterIdToClusterMonitorsMap() { - return clusterIdToClusterMonitorsMap; - } - - public void addAbstractMonitor(AbstractClusterMonitor monitor) { - this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); - } - - public AbstractClusterMonitor getAbstractMonitor(String clusterId) { - return this.clusterIdToClusterMonitorsMap.get(clusterId); - } - - public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { - this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; - } - - } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java new file mode 100644 index 0000000000..a3f9e8f716 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -0,0 +1,55 @@ +/* + * 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.autoscaler.monitor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.monitor.events.ApplicationStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.messaging.domain.topology.Status; + +/** + * This will build the necessary monitor status events to be sent to the parent/child monitor + */ +public class MonitorStatusEventBuilder { + private static final Log log = LogFactory.getLog(MonitorStatusEventBuilder.class); + + public static void handleClusterStatusEvent(Monitor parent, Status status, String clusterId) { + ClusterStatusEvent clusterStatusEvent = new ClusterStatusEvent(status, clusterId); + notifyParent(parent, clusterStatusEvent); + } + + public static void handleGroupStatusEvent(Monitor parent, Status status, String groupId) { + GroupStatusEvent groupStatusEvent = new GroupStatusEvent(status, groupId); + notifyParent(parent, groupStatusEvent); + } + + public static void handleApplicationStatusEvent(Monitor parent, Status status, String appId) { + ApplicationStatusEvent applicationStatusEvent = new ApplicationStatusEvent(status, appId); + notifyParent(parent, applicationStatusEvent); + } + + private static void notifyParent(Monitor parent, MonitorStatusEvent statusEvent) { + parent.onEvent(statusEvent); + } + + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 30b872786e..a0f0a399fd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; @@ -30,7 +31,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Observable; /** * ApplicationMonitor is to control the child monitors @@ -44,10 +44,10 @@ public ApplicationMonitor(Application application) { startDependency(); } - @Override + /*@Override public void update(Observable observable, Object event) { - if (event instanceof MonitorStatusEvent) { - MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; + if (event instanceof MonitorStatusEvent1111) { + MonitorStatusEvent1111 statusEvent = (MonitorStatusEvent1111) event; Status childStatus = statusEvent.getStatus(); String notifier = statusEvent.getNotifierId(); log.info(String.format("[Monitor] %s got notified from the [child] %s" + @@ -59,20 +59,15 @@ public void update(Observable observable, Object event) { startDependency(notifier); } } - } + }*/ /** - * Find the group monitor by traversing recursively in the hierarchical monitors. + * To find all the clusters of an application * - * @param groupId the unique alias of the Group - * @return the found GroupMonitor + * @param appId the application which contains the clusters + * @return all the clusters of the application */ - public GroupMonitor findGroupMonitorWithId(String groupId) { - return findGroupMonitor(groupId, aliasToGroupMonitorsMap.values()); - - } - public List findClustersOfApplication(String appId) { List clusters = new ArrayList(); //considering only one level @@ -84,18 +79,26 @@ public List findClustersOfApplication(String appId) { } - /** * Find the cluster monitor by traversing recursively in the hierarchical monitors. * - * @param clusterId - * @return + * @param clusterId cluster id of the monitor to be searched + * @return the found cluster monitor */ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { - return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), aliasToGroupMonitorsMap.values()); + return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), + aliasToGroupMonitorsMap.values()); } + /** + * utility method to recursively search for cluster monitors in the App monitor + * + * @param clusterId cluster id of the monitor to be searched + * @param clusterMonitors cluster monitors found in the app Monitor + * @param groupMonitors group monitors found in the app monitor + * @return the found cluster monitor + */ private AbstractClusterMonitor findClusterMonitor(String clusterId, Collection clusterMonitors, Collection groupMonitors) { @@ -115,6 +118,25 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, } + /** + * Find the group monitor by traversing recursively in the hierarchical monitors. + * + * @param groupId the unique alias of the Group + * @return the found GroupMonitor + */ + public GroupMonitor findGroupMonitorWithId(String groupId) { + return findGroupMonitor(groupId, aliasToGroupMonitorsMap.values()); + + } + + + /** + * Utility method to find the group monitor recursively within app monitor + * + * @param id the unique alias of the Group + * @param monitors the group monitors found in the app monitor + * @return the found GroupMonitor + */ private GroupMonitor findGroupMonitor(String id, Collection monitors) { for (GroupMonitor monitor : monitors) { // check if alias is equal, if so, return @@ -131,10 +153,23 @@ private GroupMonitor findGroupMonitor(String id, Collection monito } + /** + * To find the parent monitor of a group's associate monitor + * + * @param groupId the id of the group + * @return the found parent monitor of the group + */ public Monitor findParentMonitorOfGroup(String groupId) { return findParentMonitorForGroup(groupId, this); } + /** + * Find the parent monitor of the given group in the app monitor + * + * @param groupId the id of the group + * @param monitor the app monitor + * @return the found parent monitor of the group + */ private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { //if this monitor has the group, return it as the parent if (monitor.getAliasToGroupMonitorsMap().containsKey(groupId)) { @@ -152,10 +187,23 @@ private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { } + /** + * Find the parent monitor of the given cluster in the app monitor + * + * @param clusterId the id of the cluster + * @return the found parent monitor of the cluster + */ public Monitor findParentMonitorOfCluster(String clusterId) { return findParentMonitorForCluster(clusterId, this); } + /** + * Find the parent monitor of the given cluster in the app monitor + * + * @param clusterId the id of the cluster + * @param monitor the app monitor + * @return the found parent monitor of the cluster + */ private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { //if this monitor has the group, return it as the parent if (monitor.getClusterIdToClusterMonitorsMap().containsKey(clusterId)) { @@ -173,9 +221,31 @@ private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { } + /** + * To set the status of the application monitor + * + * @param status the status + */ public void setStatus(Status status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); this.status = status; } + + @Override + public void onEvent(MonitorStatusEvent statusEvent) { + this.monitor(statusEvent); + } + + @Override + protected void monitor(MonitorStatusEvent statusEvent) { + ApplicationContext context = this.dependencyTree. + findApplicationContextWithId(statusEvent.getId()); + if(context.getStatusLifeCycle().isEmpty()) { + startDependency(statusEvent.getId()); + } else { + //TODO act based on life cyle events + } + + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 1189f8f656..0c81334fd8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -24,13 +24,13 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; import java.util.List; @@ -77,32 +77,32 @@ public void run() { } catch (InterruptedException ignore) { }*/ //this.status = Status.Running; - while (!isDestroyed()) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } - try { - if(!ClusterStatus.In_Maintenance.equals(status)) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); - } + while (!isDestroyed()) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } + try { + if (!ClusterStatus.In_Maintenance.equals(status)) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is suspended as the cluster is in " + + ClusterStatus.In_Maintenance + " mode......"); } - } catch (Exception e) { - log.error("Cluster monitor: Monitor failed." + this.toString(), e); - } - try { - Thread.sleep(monitorInterval); - } catch (InterruptedException ignore) { } + } catch (Exception e) { + log.error("Cluster monitor: Monitor failed." + this.toString(), e); + } + try { + Thread.sleep(monitorInterval); + } catch (InterruptedException ignore) { } + } } - private boolean isPrimaryMember(MemberContext memberContext){ + private boolean isPrimaryMember(MemberContext memberContext) { Properties props = memberContext.getProperties(); if (log.isDebugEnabled()) { log.debug(" Properties [" + props + "] "); @@ -133,14 +133,14 @@ public void monitor() { List primaryMemberListInPartition = new ArrayList(); // get active primary members in this partition context for (MemberContext memberContext : partitionContext.getActiveMembers()) { - if (isPrimaryMember(memberContext)){ + if (isPrimaryMember(memberContext)) { primaryMemberListInPartition.add(memberContext.getMemberId()); } } // get pending primary members in this partition context for (MemberContext memberContext : partitionContext.getPendingMembers()) { - if (isPrimaryMember(memberContext)){ + if (isPrimaryMember(memberContext)) { primaryMemberListInPartition.add(memberContext.getMemberId()); } } @@ -185,7 +185,7 @@ public void monitor() { boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); if (log.isDebugEnabled()) { - log.debug("flag of rifReset: " + rifReset + " flag of memoryConsumptionReset" + memoryConsumptionReset + log.debug("flag of rifReset: " + rifReset + " flag of memoryConsumptionReset" + memoryConsumptionReset + " flag of loadAverageReset" + loadAverageReset); } if (rifReset || memoryConsumptionReset || loadAverageReset) { @@ -241,4 +241,9 @@ public boolean isHasPrimary() { public void setHasPrimary(boolean hasPrimary) { this.hasPrimary = hasPrimary; } + + @Override + public void onEvent(MonitorStatusEvent statusEvent) { + + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java similarity index 76% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java index 719c94faf9..783cc7a560 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationActivatedEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java @@ -23,20 +23,14 @@ /** * This will use to notify observers upon a application activation events received in Topology. */ -public class ApplicationActivatedEvent extends MonitorEvent { - private Status status; - private String appId; +public class ApplicationStatusEvent extends MonitorStatusEvent { - public ApplicationActivatedEvent(Status status, String appId) { - this.status = status; - this.appId = appId; + public ApplicationStatusEvent(Status status, String id) { + super(status, id); } public Status getStatus() { - return status; + return this.status; } - public String getAppId() { - return appId; - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.java deleted file mode 100644 index 54e64071bb..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterActivatedEvent.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.autoscaler.monitor.events; - -import org.apache.stratos.messaging.domain.topology.Status; - -/** - * This will use to notify observers upon a cluster activation events received in Topology. - */ -public class ClusterActivatedEvent extends MonitorEvent { - private Status status; - private String appId; - private String clusterId; - private String serviceName; - - public ClusterActivatedEvent(Status status, String appId, String clusterId, String serviceName) { - this.status = status; - this.appId = appId; - this.clusterId = clusterId; - this.serviceName = serviceName; - } - - public Status getStatus() { - return status; - } - - public String getAppId() { - return appId; - } - - public String getClusterId() { - return clusterId; - } - - public String getServiceName() { - return serviceName; - } -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java similarity index 69% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java index 163e0d6c13..d05208fb15 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupInMaintenanceEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java @@ -18,8 +18,19 @@ */ package org.apache.stratos.autoscaler.monitor.events; +import org.apache.stratos.messaging.domain.topology.Status; + /** - * This will use to notify observers upon a group maintenance events received in Topology. + * This will use to notify observers upon a cluster activation events received in Topology. */ -public class GroupInMaintenanceEvent extends MonitorEvent { +public class ClusterStatusEvent extends MonitorStatusEvent { + + public ClusterStatusEvent(Status status, String id) { + super(status, id); + } + + public Status getStatus() { + return super.getStatus(); + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.java deleted file mode 100644 index cd7d37dde9..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupActivatedEvent.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.autoscaler.monitor.events; - -import org.apache.stratos.messaging.domain.topology.Status; - -/** - * This will use to notify observers upon a group activation events received in Topology. - */ -public class GroupActivatedEvent extends MonitorEvent { - private Status status; - private String appId; - private String groupId; - - public GroupActivatedEvent(Status status, String appId, String groupId) { - this.status = status; - this.appId = appId; - this.groupId = groupId; - } - - public Status getStatus() { - return status; - } - - public String getAppId() { - return appId; - } - - public String getGroupId() { - return groupId; - } -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java similarity index 74% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java index 96e2ae4bc2..aa31d73388 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java @@ -18,10 +18,14 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import java.io.Serializable; +import org.apache.stratos.messaging.domain.topology.Status; /** - * This event will be used to notify observers based on the status events received from Topology. + * This will use to notify observers upon a group activation events received in Topology. */ -public abstract class MonitorEvent implements Serializable { +public class GroupStatusEvent extends MonitorStatusEvent { + + public GroupStatusEvent(Status status, String id) { + super(status, id); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java index 61fcf95fae..336bd7a2ef 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java @@ -21,22 +21,31 @@ import org.apache.stratos.messaging.domain.topology.Status; /** - * Created by reka on 9/25/14. + * Monitor Status Event */ -public class MonitorStatusEvent extends MonitorEvent { - private Status status; - private String notifierId; +public abstract class MonitorStatusEvent { + protected Status status; + protected String id; - public MonitorStatusEvent(Status status, String notifierId) { - this.status = status; - this.notifierId = notifierId; + public MonitorStatusEvent(Status status, String id) { + this.setStatus(status); + this.setId(id); + } + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; } public Status getStatus() { return status; } - public String getNotifierId() { - return notifierId; + public void setStatus(Status status) { + this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index eae7ed602c..735bcd682a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -21,23 +21,25 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; +import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; +import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; - -import java.util.List; -import java.util.Observable; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.event.application.status.StatusEvent; /** * This is GroupMonitor to monitor the group which consists of * groups and clusters */ -public class GroupMonitor extends Monitor { +public class GroupMonitor extends Monitor implements EventHandler { private static final Log log = LogFactory.getLog(GroupMonitor.class); + private Monitor parent; + public GroupMonitor(Group group) { super(group); this.id = group.getAlias(); @@ -45,30 +47,54 @@ public GroupMonitor(Group group) { } - @Override + /*@Override public void update(Observable observable, Object event) { - if (event instanceof MonitorStatusEvent) { - MonitorStatusEvent statusEvent = (MonitorStatusEvent) event; - Status childStatus = statusEvent.getStatus(); - String notifier = statusEvent.getNotifierId(); - log.info(String.format("[Monitor] %s got notified from the [child] %s" + - "on its state change from %s to %s", id, notifier, this.status, status)); - if (childStatus == Status.Activated) { - //start the next dependency - startDependency(notifier); - } else if(childStatus == Status.In_Maintenance) { - - } + MonitorStatusEvent1111 statusEvent = (MonitorStatusEvent1111) event; + Status childStatus = statusEvent.getStatus(); + String notifier = statusEvent.getNotifierId(); + log.info(String.format("[Monitor] %s got notified from the [child] %s" + + "on its state change from %s to %s", id, notifier, this.status, status)); + if (childStatus == Status.Activated) { + //start the next dependency + startDependency(notifier); + } else if(childStatus == Status.In_Maintenance) { } + }*/ - } public void setStatus(Status status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); this.status = status; - setChanged(); - notifyObservers(new MonitorStatusEvent(status, id)); + //notifying the parent + MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + //setChanged(); + //notifyObservers(new MonitorStatusEvent1111(status, id)); + } + + @Override + public void onEvent(MonitorStatusEvent statusEvent) { + this.monitor(statusEvent); + } + + public Monitor getParent() { + return parent; + } + + public void setParent(Monitor parent) { + this.parent = parent; + } + + @Override + protected void monitor(MonitorStatusEvent statusEvent) { + ApplicationContext context = this.dependencyTree. + findApplicationContextWithId(statusEvent.getId()); + if(context.getStatusLifeCycle().isEmpty()) { + startDependency(statusEvent.getId()); + } else { + //TODO act based on life cyle events + } + } } From 4ace39c85ab1f989e888dcc48afd2c1092ff245f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 7 Oct 2014 10:21:48 +0530 Subject: [PATCH 149/436] initial changes for hierarchical topology locking --- .../AutoscalerHealthStatEventReceiver.java | 18 +- .../AutoscalerTopologyEventReceiver.java | 151 ++++--- .../controller/topology/TopologyBuilder.java | 7 +- .../LoadBalancerTopologyEventReceiver.java | 77 +++- .../StratosManagerTopologyEventReceiver.java | 78 +++- .../messaging/domain/topology/Service.java | 9 +- .../messaging/domain/topology/Topology.java | 11 +- .../domain/topology/locking/TopologyLock.java | 49 ++ .../locking/TopologyLockHierarchy.java | 147 ++++++ .../ApplicationActivatedMessageProcessor.java | 54 ++- .../ApplicationCreatedMessageProcessor.java | 65 +-- .../ApplicationRemovedMessageProcessor.java | 73 +-- .../topology/ClusterActivatedProcessor.java | 108 +++-- .../ClusterCreatedMessageProcessor.java | 131 +++--- ...lusterMaintenanceModeMessageProcessor.java | 104 +++-- .../ClusterRemovedMessageProcessor.java | 107 +++-- .../CompleteTopologyMessageProcessor.java | 200 +++++---- .../topology/GroupActivatedProcessor.java | 70 +-- .../InstanceSpawnedMessageProcessor.java | 150 ++++--- .../MemberActivatedMessageProcessor.java | 183 ++++---- .../MemberMaintenanceModeProcessor.java | 159 ++++--- ...MemberReadyToShutdownMessageProcessor.java | 160 ++++--- .../MemberStartedMessageProcessor.java | 157 ++++--- .../MemberSuspendedMessageProcessor.java | 155 ++++--- .../MemberTerminatedMessageProcessor.java | 139 +++--- .../ServiceCreatedMessageProcessor.java | 74 +-- .../ServiceRemovedMessageProcessor.java | 71 +-- .../TopologyMessageProcessorChain.java | 10 +- .../TopologyEventMessageDelegator.java | 10 +- .../receiver/topology/TopologyManager.java | 425 +++++++++++++++++- 30 files changed, 2070 insertions(+), 1082 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index 26d3179af4..a1213f69bc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -593,8 +593,11 @@ private String findNetworkPartitionId(String memberId) { } private Member findMember(String memberId) { + + TopologyManager.acquireReadLockForServices(); + try { - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); for(Service service : TopologyManager.getTopology().getServices()) { for(Cluster cluster : service.getClusters()) { if(cluster.memberExists(memberId)) { @@ -605,7 +608,8 @@ private Member findMember(String memberId) { return null; } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForServices(); } } @@ -613,8 +617,13 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { try { AbstractClusterMonitor monitor = getMonitor(clusterId); NetworkPartitionContext nwPartitionCtxt; + + // TODO: the optimal way would be to add Service Name to member fault event and use to get a + // hierarchical lock using TopologyManager.acquireReadLockForCluster(serviceName, clusterid) + TopologyManager.acquireReadLockForServices(); + try{ - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); Member member = findMember(memberId); if(null == member){ @@ -634,7 +643,8 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { } }finally{ - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForServices(); } // start a new member in the same Partition String partitionId = monitor.getPartitionOfMember(memberId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 3e1bfe2c58..4064510c55 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -90,22 +90,23 @@ private void addEventListeners() { topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() { @Override protected void onEvent(Event event) { - try { + + if (!topologyInitialized) { TopologyManager.acquireReadLock(); - if(!topologyInitialized) { - topologyInitialized = true; + + try { for (Application application : TopologyManager.getTopology().getApplications()) { startApplicationMonitor(application); } + + topologyInitialized = true; + } catch (Exception e) { + log.error("Error processing event", e); + } finally { + TopologyManager.releaseReadLock(); } - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - TopologyManager.releaseReadLock(); } } - - }); @@ -118,12 +119,19 @@ protected void onEvent(Event event) { ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; //acquire read lock - TopologyManager.acquireReadLock(); - //start the application monitor - //TODO catch exception by ApplicationMonitor - startApplicationMonitor(applicationCreatedEvent.getApplication()); - //release read lock - TopologyManager.releaseReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForApplication(applicationCreatedEvent.getApplication().getId()); + + try { + //start the application monitor + //TODO catch exception by ApplicationMonitor + startApplicationMonitor(applicationCreatedEvent.getApplication()); + + } finally { + //release read lock + TopologyManager.releaseReadLockForApplication(applicationCreatedEvent.getApplication().getId()); + //TopologyManager.releaseReadLock(); + } } }); @@ -197,7 +205,8 @@ protected void onEvent(Event event) { ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event; //acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId()); try { //TODO remove monitors as well as any starting or pending threads @@ -222,7 +231,8 @@ protected void onEvent(Event event) { } finally { //release read lock - TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId()); + //TopologyManager.releaseReadLock(); } } @@ -283,26 +293,34 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterMaintenanceModeEventListener() { @Override protected void onEvent(Event event) { + + ClusterMaintenanceModeEvent clusterMaitenanceEvent = null; + try { log.info("Event received: " + event); - ClusterMaintenanceModeEvent e = (ClusterMaintenanceModeEvent) event; - TopologyManager.acquireReadLock(); - Service service = TopologyManager.getTopology().getService(e.getServiceName()); - Cluster cluster = service.getCluster(e.getClusterId()); + clusterMaitenanceEvent = (ClusterMaintenanceModeEvent) event; + //TopologyManager.acquireReadLock(); + TopologyManager.acquireWriteLockForCluster(clusterMaitenanceEvent.getServiceName(), + clusterMaitenanceEvent.getClusterId()); + + Service service = TopologyManager.getTopology().getService(clusterMaitenanceEvent.getServiceName()); + Cluster cluster = service.getCluster(clusterMaitenanceEvent.getClusterId()); if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getMonitor(e.getClusterId()). - setStatus(e.getStatus()); + AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()). + setStatus(clusterMaitenanceEvent.getStatus()); } else if (AutoscalerContext.getInstance(). lbMonitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getLBMonitor(e.getClusterId()). - setStatus(e.getStatus()); + AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). + setStatus(clusterMaitenanceEvent.getStatus()); } else { log.error("cluster monitor not exists for the cluster: " + cluster.toString()); } } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(clusterMaitenanceEvent.getServiceName(), + clusterMaitenanceEvent.getClusterId()); } } @@ -312,16 +330,20 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override protected void onEvent(Event event) { + + ClusterRemovedEvent clusterRemovedEvent = null; try { - ClusterRemovedEvent e = (ClusterRemovedEvent) event; - TopologyManager.acquireReadLock(); + clusterRemovedEvent = (ClusterRemovedEvent) event; + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); - String clusterId = e.getClusterId(); - String deploymentPolicy = e.getDeploymentPolicy(); + String clusterId = clusterRemovedEvent.getClusterId(); + String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); AbstractClusterMonitor monitor; - if (e.isLbCluster()) { + if (clusterRemovedEvent.isLbCluster()) { DeploymentPolicy depPolicy = PolicyManager.getInstance(). getDeploymentPolicy(deploymentPolicy); if (depPolicy != null) { @@ -362,7 +384,9 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); } } @@ -380,14 +404,19 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { + MemberTerminatedEvent memberTerminatedEvent = null; try { - TopologyManager.acquireReadLock(); - MemberTerminatedEvent e = (MemberTerminatedEvent) event; - String networkPartitionId = e.getNetworkPartitionId(); - String clusterId = e.getClusterId(); - String partitionId = e.getPartitionId(); + //TopologyManager.acquireReadLock(); + + memberTerminatedEvent = (MemberTerminatedEvent) event; + String networkPartitionId = memberTerminatedEvent.getNetworkPartitionId(); + String clusterId = memberTerminatedEvent.getClusterId(); + String partitionId = memberTerminatedEvent.getPartitionId(); AbstractClusterMonitor monitor; + TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); + if (AutoscalerContext.getInstance().monitorExist(clusterId)) { monitor = AutoscalerContext.getInstance().getMonitor(clusterId); } else { @@ -400,7 +429,7 @@ protected void onEvent(Event event) { PartitionContext partitionContext = networkPartitionContext. getPartitionCtxt(partitionId); - String memberId = e.getMemberId(); + String memberId = memberTerminatedEvent.getMemberId(); partitionContext.removeMemberStatsContext(memberId); if (partitionContext.removeTerminationPendingMember(memberId)) { @@ -431,7 +460,9 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } } @@ -441,14 +472,18 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberActivatedEvent e = (MemberActivatedEvent) event; - String networkPartitionId = e.getNetworkPartitionId(); - String clusterId = e.getClusterId(); - String partitionId = e.getPartitionId(); - String memberId = e.getMemberId(); + String networkPartitionId = memberActivatedEvent.getNetworkPartitionId(); + String clusterId = memberActivatedEvent.getClusterId(); + String partitionId = memberActivatedEvent.getPartitionId(); + String memberId = memberActivatedEvent.getMemberId(); AbstractClusterMonitor monitor; @@ -476,12 +511,14 @@ protected void onEvent(Event event) { // partitionContext.incrementCurrentActiveMemberCount(1); partitionContext.movePendingMemberToActiveMembers(memberId); //triggering the status checker - StatusChecker.getInstance().onMemberStatusChange(e.getClusterId()); + StatusChecker.getInstance().onMemberStatusChange(memberActivatedEvent.getClusterId()); } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); } } }); @@ -490,16 +527,20 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { + MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; + + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberMaintenanceModeEvent e = (MemberMaintenanceModeEvent) event; - String memberId = e.getMemberId(); - String partitionId = e.getPartitionId(); - String networkPartitionId = e.getNetworkPartitionId(); + String memberId = memberMaintenanceModeEvent.getMemberId(); + String partitionId = memberMaintenanceModeEvent.getPartitionId(); + String networkPartitionId = memberMaintenanceModeEvent.getNetworkPartitionId(); PartitionContext partitionContext; - String clusterId = e.getClusterId(); + String clusterId = memberMaintenanceModeEvent.getClusterId(); AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist(clusterId)) { @@ -521,7 +562,9 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); } } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 6d50f6c123..30b1b0054a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -608,7 +608,7 @@ public static void handleMemberSuspended() { } } - public static void handleApplicationDeployed(Application application, + public static synchronized void handleApplicationDeployed(Application application, Set applicationClusterContexts, Set metaDataHolders) { @@ -644,6 +644,7 @@ public static void handleApplicationDeployed(Application application, // add to Topology and update topology.addApplication(application); TopologyManager.updateTopology(topology); + log.info("Application with id [ " + application.getId() + " ] added to Topology successfully"); TopologyEventPublisher.sendApplicationCreatedEvent(application ,clusters); @@ -653,7 +654,8 @@ public static void handleApplicationDeployed(Application application, } } - public static void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder, String applicationId, int tenantId, String tenantDomain) { + public static synchronized void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder, + String applicationId, int tenantId, String tenantDomain) { Topology topology = TopologyManager.getTopology(); @@ -672,6 +674,7 @@ public static void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder if (service != null) { // remove Cluster service.removeCluster(clusterDataHolder.getClusterId()); + if (log.isDebugEnabled()) { log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); } diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java index a5b5e423ab..4222075bb2 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java @@ -118,10 +118,15 @@ private boolean clusterHasActiveMembers(Cluster cluster) { topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { @Override protected void onEvent(Event event) { + + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + + //TopologyManager.acquireReadLock(); + TopologyManager.acquireWriteLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; Service service = TopologyManager.getTopology().getService(memberActivatedEvent.getServiceName()); if (service == null) { if (log.isWarnEnabled()) { @@ -167,16 +172,24 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); } } }); topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { @Override protected void onEvent(Event event) { + + MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; + + TopologyManager.acquireWriteLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; + //TopologyManager.acquireReadLock(); + Member member = findMember(memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId(), memberMaintenanceModeEvent.getMemberId()); @@ -186,16 +199,22 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); } } }); topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { @Override protected void onEvent(Event event) { + + MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + TopologyManager.acquireWriteLockForCluster(memberSuspendedEvent.getServiceName(), + memberSuspendedEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; + //TopologyManager.acquireReadLock(); Member member = findMember(memberSuspendedEvent.getServiceName(), memberSuspendedEvent.getClusterId(), memberSuspendedEvent.getMemberId()); @@ -205,16 +224,23 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(memberSuspendedEvent.getServiceName(), + memberSuspendedEvent.getClusterId()); } } }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { @Override protected void onEvent(Event event) { + + //TopologyManager.acquireReadLock(); + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + + TopologyManager.acquireWriteLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); + try { - TopologyManager.acquireReadLock(); - MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; Member member = findMember(memberTerminatedEvent.getServiceName(), memberTerminatedEvent.getClusterId(), memberTerminatedEvent.getMemberId()); @@ -224,18 +250,23 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } } }); topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override protected void onEvent(Event event) { - try { - TopologyManager.acquireReadLock(); - // Remove cluster from context - ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event; + // Remove cluster from context + ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event; + TopologyManager.acquireWriteLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); + + try { + //TopologyManager.acquireReadLock(); Cluster cluster = LoadBalancerContext.getInstance().getClusterIdClusterMap().getCluster(clusterRemovedEvent.getClusterId()); if (cluster != null) { for (Member member : cluster.getMembers()) { @@ -251,18 +282,23 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); } } }); topologyEventReceiver.addEventListener(new ServiceRemovedEventListener() { @Override protected void onEvent(Event event) { + + ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event; + TopologyManager.acquireWriteLockForServices(); + try { - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); // Remove all clusters of given service from context - ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event; Service service = TopologyManager.getTopology().getService(serviceRemovedEvent.getServiceName()); if (service != null) { for (Cluster cluster : service.getClusters()) { @@ -280,7 +316,8 @@ protected void onEvent(Event event) { } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseWriteLockForServices(); } } }); 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 index c3a57190ea..d61f474670 100644 --- 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 @@ -23,8 +23,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.ApplicationSubscriptionException; -import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; -import org.apache.stratos.manager.exception.CompositeApplicationException; import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; @@ -95,7 +93,9 @@ protected void onEvent(Event event) { String serviceType = clustercreatedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getServiceName(), + clustercreatedEvent.getClusterId()); try { Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clustercreatedEvent.getClusterId()); @@ -103,7 +103,9 @@ protected void onEvent(Event event) { } finally { //release read lock - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getServiceName(), + clustercreatedEvent.getClusterId()); } } @@ -137,14 +139,18 @@ protected void onEvent(Event event) { String serviceType = instanceSpawnedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(instanceSpawnedEvent.getServiceName(), + instanceSpawnedEvent.getClusterId()); try { Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain); TopologyClusterInformationModel.getInstance().addCluster(cluster); } finally { //release read lock - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(instanceSpawnedEvent.getServiceName(), + instanceSpawnedEvent.getClusterId()); } } }); @@ -162,14 +168,18 @@ protected void onEvent(Event event) { String serviceType = memberStartedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //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.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberStartedEvent.getServiceName(), + memberStartedEvent.getClusterId()); } } @@ -188,14 +198,18 @@ protected void onEvent(Event event) { String serviceType = memberActivatedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //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.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); } } }); @@ -213,7 +227,9 @@ protected void onEvent(Event event) { String serviceType = memberSuspendedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberSuspendedEvent.getServiceName(), + memberSuspendedEvent.getClusterId()); try { Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain); @@ -221,7 +237,9 @@ protected void onEvent(Event event) { } finally { //release read lock - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(), + memberSuspendedEvent.getClusterId()); } } }); @@ -239,7 +257,9 @@ protected void onEvent(Event event) { String serviceType = memberTerminatedEvent.getServiceName(); //acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); try { Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterDomain); @@ -247,8 +267,12 @@ protected void onEvent(Event event) { // check and remove terminated member if (cluster.memberExists(memberTerminatedEvent.getMemberId())) { // release the read lock and acquire the write lock - TopologyManager.releaseReadLock(); - TopologyManager.acquireWriteLock(); +// 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 @@ -263,17 +287,23 @@ protected void onEvent(Event event) { // downgrade to read lock - 1. acquire read lock, 2. release write lock // acquire read lock - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } finally { // release the write lock - TopologyManager.releaseWriteLock(); + // TopologyManager.releaseWriteLock(); + TopologyManager.releaseWriteLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } } TopologyClusterInformationModel.getInstance().addCluster(cluster); } finally { //release read lock - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } } }); @@ -288,7 +318,8 @@ protected void onEvent(Event event) { log.info("[ApplicationCreatedEventListener] Received: " + event.getClass()); try { - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForApplication(appCreateEvent.getApplication().getId()); // create and persist Application subscritpion CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); @@ -318,7 +349,8 @@ protected void onEvent(Event event) { PrivilegedCarbonContext.endTenantFlow(); } } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getId()); } } }); @@ -333,7 +365,8 @@ protected void onEvent(Event event) { log.info("[ApplicationRemovedEventListener] Received: " + event.getClass()); try { - TopologyManager.acquireReadLock(); + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForApplication(appRemovedEvent.getApplicationId()); // create and persist Application subscritpion CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); @@ -360,7 +393,8 @@ protected void onEvent(Event event) { PrivilegedCarbonContext.endTenantFlow(); } } finally { - TopologyManager.releaseReadLock(); + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForApplication(appRemovedEvent.getApplicationId()); } } }); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java index 46d46d4afa..d03cfda470 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Service.java @@ -19,6 +19,9 @@ package org.apache.stratos.messaging.domain.topology; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; + import java.io.Serializable; import java.util.*; @@ -59,14 +62,18 @@ public Collection getClusters() { public void addCluster(Cluster cluster) { this.clusterIdClusterMap.put(cluster.getClusterId(), cluster); + TopologyLockHierarchy.getInstance().addClusterLock(cluster.getClusterId(), new TopologyLock()); } public void removeCluster(Cluster cluster) { this.clusterIdClusterMap.remove(cluster.getClusterId()); + TopologyLockHierarchy.getInstance().removeTopologyLockForCluster(cluster.getClusterId()); } public Cluster removeCluster(String clusterId) { - return this.clusterIdClusterMap.remove(clusterId); + Cluster removedCluster = this.clusterIdClusterMap.remove(clusterId); + TopologyLockHierarchy.getInstance().removeTopologyLockForCluster(clusterId); + return removedCluster; } public boolean clusterExists(String clusterId) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index f8b535f5dd..dabf611b47 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -26,8 +26,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; /** * Defines a topology of serviceMap in Stratos. @@ -54,6 +54,7 @@ public Topology() { public void addApplication (Application application) { this.applicationMap.put(application.getId(), application); + TopologyLockHierarchy.getInstance().addApplicationLock(application.getId(), new TopologyLock()); } public Application getApplication (String applicationId) { @@ -62,6 +63,7 @@ public Application getApplication (String applicationId) { public void removeApplication (String applicationId) { applicationMap.remove(applicationId); + TopologyLockHierarchy.getInstance().removeTopologyLockForApplication(applicationId); } public Collection getApplications () { @@ -78,9 +80,10 @@ public Collection getServices() { public void addService(Service service) { this.serviceMap.put(service.getServiceName(), service); + TopologyLockHierarchy.getInstance().addServiceLock(service.getServiceName(), new TopologyLock()); } - public void addServices(Collection services) { + public synchronized void addServices(Collection services) { for (Service service : services) { addService(service); } @@ -88,10 +91,12 @@ public void addServices(Collection services) { public void removeService(Service service) { this.serviceMap.remove(service.getServiceName()); + TopologyLockHierarchy.getInstance().removeTopologyLockForService(service.getServiceName()); } public void removeService(String serviceName) { this.serviceMap.remove(serviceName); + TopologyLockHierarchy.getInstance().removeTopologyLockForService(serviceName); } public Service getService(String serviceName) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java new file mode 100644 index 0000000000..e1b90ad51d --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.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.messaging.domain.topology.locking; + +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class TopologyLock { + + private final ReentrantReadWriteLock lock; + + public TopologyLock () { + lock = new ReentrantReadWriteLock(true); + } + + public void acquireWriteLock() { + lock.writeLock().lock(); + } + + public void releaseWritelock() { + if (lock.isWriteLockedByCurrentThread()) { + lock.writeLock().unlock(); + } + } + + public void acquireReadLock() { + lock.readLock().lock(); + } + + public void releaseReadLock() { + lock.readLock().unlock(); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java new file mode 100644 index 0000000000..aa0f7a1f64 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -0,0 +1,147 @@ +/* + * 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.messaging.domain.topology.locking; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +public class TopologyLockHierarchy { + + private static final Log log = LogFactory.getLog(TopologyLockHierarchy.class); + + // lock for Services + private TopologyLock serviceLock; + + // lock for Applications + private TopologyLock applicatioLock; + + // key = Service.name + private Map serviceNameToTopologyLockMap; + + // key = Application.id + private Map applicationIdToTopologyLockMap; + + // key = Cluster.id + private Map clusterIdToTopologyLockMap; + + private static volatile TopologyLockHierarchy topologyLockHierarchy; + + private TopologyLockHierarchy () { + + this.serviceLock = new TopologyLock(); + this.applicatioLock = new TopologyLock(); + this.serviceNameToTopologyLockMap = new ConcurrentHashMap(); + this.applicationIdToTopologyLockMap = new ConcurrentHashMap(); + this.clusterIdToTopologyLockMap = new ConcurrentHashMap(); + } + + public static TopologyLockHierarchy getInstance () { + + if (topologyLockHierarchy == null) { + synchronized (TopologyLockHierarchy.class) { + if (topologyLockHierarchy == null) { + topologyLockHierarchy = new TopologyLockHierarchy(); + } + } + } + + return topologyLockHierarchy; + } + + public void addApplicationLock (String appId, final TopologyLock topologyLock) { + + if (!applicationIdToTopologyLockMap.containsKey(appId)) { + synchronized (applicationIdToTopologyLockMap) { + if (!applicationIdToTopologyLockMap.containsKey(appId)) { + applicationIdToTopologyLockMap.put(appId, topologyLock); + log.info("Added lock for Application " + appId); + } + } + } else { + log.warn("Topology Lock for Application " + appId + " already exists"); + } + } + + public TopologyLock getTopologyLockForApplication (String appId) { + return applicationIdToTopologyLockMap.get(appId); + } + + public void addServiceLock (String serviceName, final TopologyLock topologyLock) { + + if (!serviceNameToTopologyLockMap.containsKey(serviceName)) { + synchronized (serviceNameToTopologyLockMap) { + if (!serviceNameToTopologyLockMap.containsKey(serviceName)) { + serviceNameToTopologyLockMap.put(serviceName, topologyLock); + log.info("Added lock for Service " + serviceName); + } + } + } else { + log.warn("Topology Lock for Service " + serviceName + " already exists"); + } + } + + public TopologyLock getTopologyLockForService (String serviceName) { + return serviceNameToTopologyLockMap.get(serviceName); + } + + public void addClusterLock (String clusterId, final TopologyLock topologyLock) { + + if (!clusterIdToTopologyLockMap.containsKey(clusterId)) { + synchronized (clusterIdToTopologyLockMap) { + if (!clusterIdToTopologyLockMap.containsKey(clusterId)) { + clusterIdToTopologyLockMap.put(clusterId, topologyLock); + log.info("Added lock for Cluster " + clusterId); + } + } + } else { + log.warn("Topology Lock for Cluster " + clusterId + " already exists"); + } + } + + public TopologyLock getTopologyLockForCluster (String clusterId) { + return clusterIdToTopologyLockMap.get(clusterId); + } + + public void removeTopologyLockForApplication (String appId) { + applicationIdToTopologyLockMap.remove(appId); + log.info("Removed lock for Application " + appId); + } + + public void removeTopologyLockForService (String serviceName) { + serviceNameToTopologyLockMap.remove(serviceName); + log.info("Removed lock for Service " + serviceName); + } + + public void removeTopologyLockForCluster (String clusterId) { + clusterIdToTopologyLockMap.remove(clusterId); + log.info("Removed lock for Cluster " + clusterId); + } + + public TopologyLock getServiceLock() { + return serviceLock; + } + + public TopologyLock getApplicatioLock() { + return applicatioLock; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index 8c1e66b695..803a8710cf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; /** @@ -56,26 +57,16 @@ public boolean process(String type, String message, Object object) { ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. jsonToObject(message, ApplicationActivatedEvent.class); - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } else { - // Apply changes to the topology - application.setStatus(Status.Activated); - if (log.isInfoEnabled()) { - log.info(String.format("Application updated as activated : %s", - application.toString())); - } - } + TopologyManager.acquireReadLockForApplications(); + TopologyManager.acquireWriteLockForApplication(event.getAppId()); - // Notify event listeners - notifyEventListeners(event); - return true; + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForApplication(event.getAppId()); + TopologyManager.releaseReadLockForApplications(); + } } else { if (nextProcessor != null) { @@ -86,4 +77,29 @@ public boolean process(String type, String message, Object object) { } } } + + private boolean doProcess (ApplicationActivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + application.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Application updated as activated : %s", + application.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index f02e4be940..4368bd7be8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ApplicationCreatedMessageProcessor extends MessageProcessor { @@ -47,40 +48,21 @@ public boolean process(String type, String message, Object object) { return false; } - ApplicationCreatedEvent appCreatedEvent = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); - if (appCreatedEvent == null) { + ApplicationCreatedEvent event = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + if (event == null) { log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); return false; } - // check if required properties are available - if (appCreatedEvent.getApplication() == null) { - String errorMsg = "Application object of application created event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - if (appCreatedEvent.getApplication().getId() == null || appCreatedEvent.getApplication().getId().isEmpty()) { - String errorMsg = "App id of application created event is invalid: [ " + appCreatedEvent.getApplication().getId() + " ]"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } + TopologyManager.acquireWriteLockForApplications(); - // check if an Application with same name exists in topology - if (topology.applicationExists(appCreatedEvent.getApplication().getId())) { - log.warn("Application with id [ " + appCreatedEvent.getApplication().getId() + " ] already exists in Topology"); + try { + return doProcess(event, topology); - } else { - // add application and the clusters to Topology - for(Cluster cluster: appCreatedEvent.getClusterList()) { - topology.getService(cluster.getServiceName()).addCluster(cluster); - } - topology.addApplication(appCreatedEvent.getApplication()); + } finally { + TopologyManager.releaseWriteLockForApplications(); } - notifyEventListeners(appCreatedEvent); - return true; - } else { if (nextProcessor != null) { // ask the next processor to take care of the message. @@ -90,4 +72,35 @@ public boolean process(String type, String message, Object object) { } } } + + private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { + + // check if required properties are available + if (event.getApplication() == null) { + String errorMsg = "Application object of application created event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (event.getApplication().getId() == null || event.getApplication().getId().isEmpty()) { + String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getId() + " ]"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + if (topology.applicationExists(event.getApplication().getId())) { + log.warn("Application with id [ " + event.getApplication().getId() + " ] already exists in Topology"); + + } else { + // add application and the clusters to Topology + for(Cluster cluster: event.getClusterList()) { + topology.getService(cluster.getServiceName()).addCluster(cluster); + } + topology.addApplication(event.getApplication()); + } + + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java index c9dbb07820..ed6c2d47d1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -22,9 +22,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ApplicationRemovedMessageProcessor extends MessageProcessor { @@ -55,38 +55,20 @@ public boolean process(String type, String message, Object object) { return false; } - ApplicationRemovedEvent appRemovedEvent = (ApplicationRemovedEvent) Util.jsonToObject(message, ApplicationRemovedEvent.class); - if (appRemovedEvent == null) { + ApplicationRemovedEvent event = (ApplicationRemovedEvent) Util.jsonToObject(message, ApplicationRemovedEvent.class); + if (event == null) { log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); return false; } - - // check if required properties are available - if (appRemovedEvent.getApplicationId() == null) { - String errorMsg = "Application Id of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - if (appRemovedEvent.getTenantDomain()== null) { - String errorMsg = "Application tenant domain of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - // check if an Application with same name exists in topology - String appId = appRemovedEvent.getApplicationId(); - if (topology.applicationExists(appId)) { - log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); - topology.removeApplication(appId); - } - - if (log.isDebugEnabled()) { - log.debug("ApplicationRemovedMessageProcessor notifying listener " + object); - } - - notifyEventListeners(appRemovedEvent); - return true; + + TopologyManager.acquireWriteLockForApplications(); + + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForApplications(); + } } else { if (nextProcessor != null) { @@ -96,6 +78,35 @@ public boolean process(String type, String message, Object object) { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } - + } + + private boolean doProcess (ApplicationRemovedEvent event, Topology topology) { + + // check if required properties are available + if (event.getApplicationId() == null) { + String errorMsg = "Application Id of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (event.getTenantDomain()== null) { + String errorMsg = "Application tenant domain of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + String appId = event.getApplicationId(); + if (topology.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); + topology.removeApplication(appId); + } + + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor notifying listener "); + } + + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 52de45b5e1..78f772bf19 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -25,10 +25,10 @@ import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; /** @@ -45,75 +45,91 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; if (ClusterActivatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized - if (!topology.isInitialized()) + if (!topology.isInitialized()) { return false; + } // Parse complete message and build event ClusterActivatedEvent event = (ClusterActivatedEvent) Util. jsonToObject(message, ClusterActivatedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireReadLockForServices(); + TopologyManager.acquireWriteLockForService(event.getServiceName()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseReadLockForServices(); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (ClusterActivatedEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); + } - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), - event.getClusterId())); - } - } else { - // Apply changes to the topology - cluster.setStatus(Status.Activated); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster updated as activated : %s", - cluster.toString())); + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } + return false; } + } - // Notify event listeners - notifyEventListeners(event); - return true; + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + // Apply changes to the topology + cluster.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster updated as activated : %s", + cluster.toString())); } } + + // Notify event listeners + notifyEventListeners(event); + return true; } + } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index c0073434fe..94b9650422 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -27,6 +27,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ClusterCreatedMessageProcessor extends MessageProcessor { @@ -41,83 +42,97 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Topology topology = (Topology) object; if (ClusterCreatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized - if (!topology.isInitialized()) + if (!topology.isInitialized()) { return false; + } // Parse complete message and build event ClusterCreatedEvent event = (ClusterCreatedEvent) Util.jsonToObject(message, ClusterCreatedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } - } + TopologyManager.acquireReadLockForServices(); + TopologyManager.acquireWriteLockForService(event.getServiceName()); + try { + return doProcess(event, topology); - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } finally { + TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseReadLockForServices(); } - // Validate event properties - Cluster cluster = event.getCluster(); - if(cluster == null) { - String msg = "Cluster object of cluster created event is null."; - log.error(msg); - throw new RuntimeException(msg); - } - if (cluster.getHostNames().isEmpty()) { - throw new RuntimeException("Host name/s not found in cluster created event"); + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + } + } + + private boolean doProcess (ClusterCreatedEvent event,Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - if (service.clusterExists(event.getClusterId())) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(), - event.getClusterId())); - } - } else { - - // Apply changes to the topology - service.addCluster(cluster); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster created: %s", - cluster.toString())); - } - } + } - // Notify event listeners - notifyEventListeners(event); - return true; + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + // Validate event properties + Cluster cluster = event.getCluster(); + if(cluster == null) { + String msg = "Cluster object of cluster created event is null."; + log.error(msg); + throw new RuntimeException(msg); + } + if (cluster.getHostNames().isEmpty()) { + throw new RuntimeException("Host name/s not found in cluster created event"); + } + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + if (service.clusterExists(event.getClusterId())) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + + // Apply changes to the topology + service.addCluster(cluster); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster created: %s", + cluster.toString())); } } + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index f125c54f9c..86293639f1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ClusterMaintenanceModeMessageProcessor extends MessageProcessor { @@ -49,64 +50,77 @@ public boolean process(String type, String message, Object object) { ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util. jsonToObject(message, ClusterMaintenanceModeEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireReadLockForServices(); + TopologyManager.acquireWriteLockForService(event.getServiceName()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseReadLockForServices(); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (ClusterMaintenanceModeEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); + } - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), - event.getClusterId())); + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } - } else { - // Apply changes to the topology - cluster.setStatus(Status.In_Maintenance); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster updated as maintenance mode: %s", - cluster.toString())); - } - } + return false; + } + } - // Notify event listeners - notifyEventListeners(event); - return true; + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + // Apply changes to the topology + cluster.setStatus(Status.In_Maintenance); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster updated as maintenance mode: %s", + cluster.toString())); } } + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java index 69ef5b0548..1dfb929ac0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java @@ -26,6 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ClusterRemovedMessageProcessor extends MessageProcessor { @@ -50,65 +51,79 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterRemovedEvent event = (ClusterRemovedEvent) Util.jsonToObject(message, ClusterRemovedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireReadLockForServices(); + TopologyManager.acquireWriteLockForService(event.getServiceName()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseReadLockForServices(); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (ClusterRemovedEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } + } - // Notify event listeners before removing the cluster object - notifyEventListeners(event); - - if (!service.clusterExists(event.getClusterId())) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), - event.getClusterId())); + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } - } else { - - // Apply changes to the topology - service.removeCluster(event.getClusterId()); - - if (log.isInfoEnabled()) { - log.info(String.format("Cluster removed from service: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); - } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); } + return false; + } + + // Notify event listeners before removing the cluster object + notifyEventListeners(event); - return true; + if (!service.clusterExists(event.getClusterId())) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), + event.getClusterId())); + } } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + + // Apply changes to the topology + service.removeCluster(event.getClusterId()); + + if (log.isInfoEnabled()) { + log.info(String.format("Cluster removed from service: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); } } + + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 135bdaedf2..6d5cb8f6aa 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -26,6 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; import java.util.ArrayList; @@ -49,102 +50,20 @@ public boolean process(String type, String message, Object object) { if (CompleteTopologyEvent.class.getName().equals(type)) { // Parse complete message and build event CompleteTopologyEvent event = (CompleteTopologyEvent) Util.jsonToObject(message, CompleteTopologyEvent.class); - - // if topology has not already initialized - if (!topology.isInitialized()) { - - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - // Add services included in service filter - for (Service service : event.getTopology().getServices()) { - if (TopologyServiceFilter.getInstance() - .serviceNameIncluded(service.getServiceName())) { - topology.addService(service); - } else { - if (log.isDebugEnabled()) { - log.debug(String.format( - "Service is excluded: [service] %s", - service.getServiceName())); - } - } - } - } else { - // Add all services - topology.addServices(event.getTopology().getServices()); - } - - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - for (Service service : topology.getServices()) { - List clustersToRemove = new ArrayList(); - for (Cluster cluster : service.getClusters()) { - if (TopologyClusterFilter.getInstance() - .clusterIdExcluded(cluster.getClusterId())) { - clustersToRemove.add(cluster); - } - } - for (Cluster cluster : clustersToRemove) { - service.removeCluster(cluster); - if (log.isDebugEnabled()) { - log.debug(String.format( - "Cluster is excluded: [cluster] %s", - cluster.getClusterId())); - } - } - } - } - - // Apply member filter - if (TopologyMemberFilter.getInstance().isActive()) { - for (Service service : topology.getServices()) { - for (Cluster cluster : service.getClusters()) { - List membersToRemove = new ArrayList(); - for (Member member : cluster.getMembers()) { - if (TopologyMemberFilter.getInstance() - .lbClusterIdExcluded( - member.getLbClusterId())) { - membersToRemove.add(member); - } - } - for (Member member : membersToRemove) { - cluster.removeMember(member); - if (log.isDebugEnabled()) { - log.debug(String - .format("Member is excluded: [member] %s [lb-cluster-id] %s", - member.getMemberId(), - member.getLbClusterId())); - } - } - } - } - } - - // add existing Applications to Topology - Collection applications = event.getTopology().getApplications(); - if (applications != null && !applications.isEmpty()) { - for (Application application : applications) { - topology.addApplication(application); - if (log.isDebugEnabled()) { - log.debug("Application with id [ " + application.getId() + " ] added to Topology"); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("No Application information found in Complete Topology event"); - } - } - if (log.isInfoEnabled()) { - log.info("Topology initialized"); - } + if (!topology.isInitialized()) { + TopologyManager.acquireWriteLock(); + + try { + return doProcess(event, topology); - // Set topology initialized - topology.setInitialized(true); - } + } finally { + TopologyManager.releaseWriteLock(); + } + } else { + return true; + } - // Notify event listeners - notifyEventListeners(event); - return true; } else { if (nextProcessor != null) { // ask the next processor to take care of the message. @@ -153,4 +72,99 @@ public boolean process(String type, String message, Object object) { return false; } } + + private boolean doProcess (CompleteTopologyEvent event, Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + // Add services included in service filter + for (Service service : event.getTopology().getServices()) { + if (TopologyServiceFilter.getInstance() + .serviceNameIncluded(service.getServiceName())) { + topology.addService(service); + } else { + if (log.isDebugEnabled()) { + log.debug(String.format( + "Service is excluded: [service] %s", + service.getServiceName())); + } + } + } + } else { + // Add all services + topology.addServices(event.getTopology().getServices()); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + for (Service service : topology.getServices()) { + List clustersToRemove = new ArrayList(); + for (Cluster cluster : service.getClusters()) { + if (TopologyClusterFilter.getInstance() + .clusterIdExcluded(cluster.getClusterId())) { + clustersToRemove.add(cluster); + } + } + for (Cluster cluster : clustersToRemove) { + service.removeCluster(cluster); + if (log.isDebugEnabled()) { + log.debug(String.format( + "Cluster is excluded: [cluster] %s", + cluster.getClusterId())); + } + } + } + } + + // Apply member filter + if (TopologyMemberFilter.getInstance().isActive()) { + for (Service service : topology.getServices()) { + for (Cluster cluster : service.getClusters()) { + List membersToRemove = new ArrayList(); + for (Member member : cluster.getMembers()) { + if (TopologyMemberFilter.getInstance() + .lbClusterIdExcluded( + member.getLbClusterId())) { + membersToRemove.add(member); + } + } + for (Member member : membersToRemove) { + cluster.removeMember(member); + if (log.isDebugEnabled()) { + log.debug(String + .format("Member is excluded: [member] %s [lb-cluster-id] %s", + member.getMemberId(), + member.getLbClusterId())); + } + } + } + } + } + + // add existing Applications to Topology + Collection applications = event.getTopology().getApplications(); + if (applications != null && !applications.isEmpty()) { + for (Application application : applications) { + topology.addApplication(application); + if (log.isDebugEnabled()) { + log.debug("Application with id [ " + application.getId() + " ] added to Topology"); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Application information found in Complete Topology event"); + } + } + + if (log.isInfoEnabled()) { + log.info("Topology initialized"); + } + + // Set topology initialized + topology.setInitialized(true); + + // Notify event listeners + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 627d9a99aa..7200431f3d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -21,11 +21,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; -import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; -import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; /** @@ -53,34 +51,16 @@ public boolean process(String type, String message, Object object) { GroupActivatedEvent event = (GroupActivatedEvent) Util. jsonToObject(message, GroupActivatedEvent.class); - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } - Group group = application.getGroup(event.getGroupId()); + TopologyManager.acquireReadLockForApplications(); + TopologyManager.acquireWriteLockForApplication(event.getAppId()); - if (group == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), - event.getGroupId())); - } - } else { - // Apply changes to the topology - group.setStatus(Status.Activated); - if (log.isInfoEnabled()) { - log.info(String.format("Group updated as activated : %s", - group.toString())); - } - } + try { + return doProcess(event, topology); - // Notify event listeners - notifyEventListeners(event); - return true; + } finally { + TopologyManager.releaseWriteLockForApplication(event.getAppId()); + TopologyManager.releaseReadLockForApplications(); + } } else { if (nextProcessor != null) { @@ -91,4 +71,36 @@ public boolean process(String type, String message, Object object) { } } } + + private boolean doProcess (GroupActivatedEvent event,Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroup(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + group.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Group updated as activated : %s", + group.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java index 8e4e1b1640..2d3f8b3f5a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java @@ -26,6 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class InstanceSpawnedMessageProcessor extends MessageProcessor { @@ -50,92 +51,103 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event InstanceSpawnedEvent event = (InstanceSpawnedEvent) Util.jsonToObject(message, InstanceSpawnedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (InstanceSpawnedEvent event,Topology topology){ - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(event.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", event.getLbClusterId())); - } - return false; + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } + return false; } + } - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(event.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", event.getLbClusterId())); } return false; } - if (cluster.memberExists(event.getMemberId())) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already exists: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - Member member = new Member(event.getServiceName(), event.getClusterId(), event.getNetworkPartitionId(), event.getPartitionId(), event.getMemberId()); - member.setStatus(MemberStatus.Created); - member.setMemberPublicIp(event.getMemberPublicIp()); - member.setMemberIp(event.getMemberIp()); - member.setLbClusterId(event.getLbClusterId()); - member.setProperties(event.getProperties()); - cluster.addMember(member); - - if (log.isInfoEnabled()) { - log.info(String.format("Member created: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + if (cluster.memberExists(event.getMemberId())) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already exists: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { + // Apply changes to the topology + Member member = new Member(event.getServiceName(), event.getClusterId(), event.getNetworkPartitionId(), event.getPartitionId(), event.getMemberId()); + member.setStatus(MemberStatus.Created); + member.setMemberPublicIp(event.getMemberPublicIp()); + member.setMemberIp(event.getMemberIp()); + member.setLbClusterId(event.getLbClusterId()); + member.setProperties(event.getProperties()); + cluster.addMember(member); - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member created: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java index a5d701d9c4..ec1b5ec49a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java @@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberActivatedMessageProcessor extends MessageProcessor { @@ -54,111 +55,123 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberActivatedEvent event = (MemberActivatedEvent) Util.jsonToObject(message, MemberActivatedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (MemberActivatedEvent event,Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } + return false; } + } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } + return false; } + } - // Validate event properties - if ((event.getMemberIp() == null) || event.getMemberIp().isEmpty()) { - throw new RuntimeException(String.format("No ip address found in member activated event: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); + // Validate event properties + if ((event.getMemberIp() == null) || event.getMemberIp().isEmpty()) { + throw new RuntimeException(String.format("No ip address found in member activated event: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + if ((event.getPorts() == null) || (event.getPorts().size() == 0)) { + throw new RuntimeException(String.format("No ports found in member activated event: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); } - if ((event.getPorts() == null) || (event.getPorts().size() == 0)) { - throw new RuntimeException(String.format("No ports found in member activated event: [service] %s [cluster] %s [member] %s", + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", event.getServiceName(), event.getClusterId(), event.getMemberId())); } + return false; + } - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); - } - return false; - } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); - } - return false; - } - Member member = cluster.getMember(event.getMemberId()); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } return false; } + } - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; - } + if (member.getStatus() == MemberStatus.Activated) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already activated: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { - if (member.getStatus() == MemberStatus.Activated) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already activated: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - member.addPorts(event.getPorts()); - member.setMemberIp(event.getMemberIp()); - member.setStatus(MemberStatus.Activated); - - if (log.isInfoEnabled()) { - log.info(String.format("Member activated: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } + // Apply changes to the topology + member.addPorts(event.getPorts()); + member.setMemberIp(event.getMemberIp()); + member.setStatus(MemberStatus.Activated); - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member activated: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java index b6dc4897d7..b252a6176a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java @@ -27,6 +27,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberMaintenanceModeProcessor extends MessageProcessor { @@ -51,98 +52,110 @@ public boolean process(String type, String message, Object object) { MemberMaintenanceModeEvent event = (MemberMaintenanceModeEvent) Util. jsonToObject(message, MemberMaintenanceModeEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Member member = cluster.getMember(event.getMemberId()); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - return false; + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + return false; + } - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } + return false; } + } - if (member.getStatus() == MemberStatus.In_Maintenance) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already updated as In_Maintenance: " + - "[service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - member.setStatus(MemberStatus.In_Maintenance); - - if (log.isInfoEnabled()) { - log.info(String.format("Member updated as In_Maintenance: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + if (member.getStatus() == MemberStatus.In_Maintenance) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already updated as In_Maintenance: " + + "[service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { + // Apply changes to the topology + member.setStatus(MemberStatus.In_Maintenance); - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member updated as In_Maintenance: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java index 92115aa0ef..f0c3580f41 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java @@ -26,6 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberReadyToShutdownMessageProcessor extends MessageProcessor{ @@ -50,98 +51,111 @@ public boolean process(String type, String message, Object object) { MemberReadyToShutdownEvent event = (MemberReadyToShutdownEvent) Util. jsonToObject(message, MemberReadyToShutdownEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Member member = cluster.getMember(event.getMemberId()); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - return false; + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + return false; + } - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } + return false; } + } - if (member.getStatus() == MemberStatus.ReadyToShutDown) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already updated as Ready to Shutdown: " + - "[service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - member.setStatus(MemberStatus.ReadyToShutDown); - - if (log.isInfoEnabled()) { - log.info(String.format("Member updated as Ready to shutdown: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + if (member.getStatus() == MemberStatus.ReadyToShutDown) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already updated as Ready to Shutdown: " + + "[service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { + // Apply changes to the topology + member.setStatus(MemberStatus.ReadyToShutDown); - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member updated as Ready to shutdown: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + + // Notify event listeners + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java index 4d93957965..508ec39938 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java @@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberStartedMessageProcessor extends MessageProcessor { @@ -54,97 +55,109 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberStartedEvent event = (MemberStartedEvent) Util.jsonToObject(message, MemberStartedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (MemberStartedEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Member member = cluster.getMember(event.getMemberId()); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - return false; + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + return false; + } - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } + return false; } + } - if (member.getStatus() == MemberStatus.Starting) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already started: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - member.setStatus(MemberStatus.Starting); - - if (log.isInfoEnabled()) { - log.info(String.format("Member started: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + if (member.getStatus() == MemberStatus.Starting) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already started: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { + // Apply changes to the topology + member.setStatus(MemberStatus.Starting); - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member started: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + + // Notify event listeners + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java index 67c9b67e1f..4473add066 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java @@ -30,6 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberSuspendedMessageProcessor extends MessageProcessor { @@ -54,96 +55,108 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberSuspendedEvent event = (MemberSuspendedEvent) Util.jsonToObject(message, MemberSuspendedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (MemberSuspendedEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Member member = cluster.getMember(event.getMemberId()); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - return false; + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member does not exist: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); + } + return false; + } - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } + return false; } + } - if (member.getStatus() == MemberStatus.Suspended) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already suspended: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - - // Apply changes to the topology - member.setStatus(MemberStatus.Suspended); - - if (log.isInfoEnabled()) { - log.info(String.format("Member suspended: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + if (member.getStatus() == MemberStatus.Suspended) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already suspended: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } + } else { + // Apply changes to the topology + member.setStatus(MemberStatus.Suspended); - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + if (log.isInfoEnabled()) { + log.info(String.format("Member suspended: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + + notifyEventListeners(event); + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java index 5b5cbc953a..3619b537cf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java @@ -29,6 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class MemberTerminatedMessageProcessor extends MessageProcessor { @@ -53,87 +54,99 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberTerminatedEvent event = (MemberTerminatedEvent) Util.jsonToObject(message, MemberTerminatedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } - // Apply cluster filter - if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { - // Cluster is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); - } - return false; - } + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } + } + } + + private boolean doProcess (MemberTerminatedEvent event,Topology topology) { - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); } return false; } - Cluster cluster = service.getCluster(event.getClusterId()); - if (cluster == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", - event.getServiceName(), event.getClusterId())); + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); } return false; } - Member member = cluster.getMember(event.getMemberId()); - if(member != null) { - // Apply member filter - if(TopologyMemberFilter.getInstance().isActive()) { - if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); - } - return false; + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster does not exist: [service] %s [cluster] %s", + event.getServiceName(), event.getClusterId())); + } + return false; + } + Member member = cluster.getMember(event.getMemberId()); + if(member != null) { + // Apply member filter + if(TopologyMemberFilter.getInstance().isActive()) { + if(TopologyMemberFilter.getInstance().lbClusterIdExcluded(member.getLbClusterId())) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is excluded: [lb-cluster-id] %s", member.getLbClusterId())); } + return false; } } + } - // Notify event listeners before removing member object - notifyEventListeners(event); + // Notify event listeners before removing member object + notifyEventListeners(event); - if (member == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Member already terminated: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } - } else { - // Remove member from the cluster - cluster.removeMember(member); - - if (log.isInfoEnabled()) { - log.info(String.format("Member terminated: [service] %s [cluster] %s [member] %s", - event.getServiceName(), - event.getClusterId(), - event.getMemberId())); - } + if (member == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Member already terminated: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } - - return true; } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + // Remove member from the cluster + cluster.removeMember(member); + + if (log.isInfoEnabled()) { + log.info(String.format("Member terminated: [service] %s [cluster] %s [member] %s", + event.getServiceName(), + event.getClusterId(), + event.getMemberId())); } } + + return true; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java index 2c216f0202..1c4be8f8f0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ServiceCreatedMessageProcessor extends MessageProcessor { @@ -43,44 +44,21 @@ public boolean process(String type, String message, Object object) { if (ServiceCreatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized - if (!topology.isInitialized()) + if (!topology.isInitialized()) { return false; + } // Parse complete message and build event ServiceCreatedEvent event = (ServiceCreatedEvent) Util.jsonToObject(message, ServiceCreatedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } - } + TopologyManager.acquireWriteLockForServices(); + try { + return doProcess(event, topology); - // Validate event against the existing topology - if (topology.serviceExists(event.getServiceName())) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service already created: [service] %s", event.getServiceName())); - } - } else { - - // Apply changes to the topology - Service service = new Service(event.getServiceName(), event.getServiceType()); - service.addPorts(event.getPorts()); - topology.addService(service); - - if (log.isInfoEnabled()) { - log.info(String.format("Service created: [service] %s", event.getServiceName())); - } + } finally { + TopologyManager.releaseWriteLockForServices(); } - - notifyEventListeners(event); - return true; - } else { if (nextProcessor != null) { // ask the next processor to take care of the message. @@ -90,4 +68,40 @@ public boolean process(String type, String message, Object object) { } } } + + private boolean doProcess (ServiceCreatedEvent event, Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Validate event against the existing topology + if (topology.serviceExists(event.getServiceName())) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service already created: [service] %s", event.getServiceName())); + } + } else { + + // Apply changes to the topology + Service service = new Service(event.getServiceName(), event.getServiceType()); + service.addPorts(event.getPorts()); + topology.addService(service); + + if (log.isInfoEnabled()) { + log.info(String.format("Service created: [service] %s", event.getServiceName())); + } + } + + + notifyEventListeners(event); + return true; + + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java index 2c0bc70070..a38cbdcd13 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.event.topology.ServiceRemovedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; public class ServiceRemovedMessageProcessor extends MessageProcessor { @@ -49,38 +50,14 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ServiceRemovedEvent event = (ServiceRemovedEvent) Util.jsonToObject(message, ServiceRemovedEvent.class); - // Apply service filter - if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { - // Service is excluded, do not update topology or fire event - if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); - } - return false; - } - } - - // Notify event listeners before removing service object - notifyEventListeners(event); + TopologyManager.acquireWriteLockForServices(); + try { + return doProcess(event, topology); - // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); - if (service == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); - } - } else { - - // Apply changes to the topology - topology.removeService(service); - - if (log.isInfoEnabled()) { - log.info(String.format("Service removed: [service] %s", event.getServiceName())); - } + } finally { + TopologyManager.releaseWriteLockForServices(); } - return true; } else { if (nextProcessor != null) { // ask the next processor to take care of the message. @@ -90,4 +67,40 @@ public boolean process(String type, String message, Object object) { } } } + + private boolean doProcess (ServiceRemovedEvent event, Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Notify event listeners before removing service object + notifyEventListeners(event); + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + } else { + + // Apply changes to the topology + topology.removeService(service); + + if (log.isInfoEnabled()) { + log.info(String.format("Service removed: [service] %s", event.getServiceName())); + } + } + + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index e3ddfa3cf0..db9e8b1831 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -47,7 +47,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; private GroupActivatedProcessor groupActivatedProcessor; - private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; + //private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; @@ -108,11 +108,6 @@ public void initialize() { applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); add(applicationActivatedMessageProcessor); - if (log.isDebugEnabled()) { - log.debug("Grouping: added applicationCreatedMessageProcessor, applicationRemovedMessageProcessor: " + - applicationCreatedMessageProcessor + " / " + applicationRemovedMessageProcessor); - } - if (log.isDebugEnabled()) { log.debug("Topology message processor chain initialized X1"); } @@ -153,9 +148,6 @@ public void addEventListener(EventListener eventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationRemovedEventListener) { applicationRemovedMessageProcessor.addEventListener(eventListener); - if (log.isDebugEnabled()) { - log.debug("Grouping: added eventlistener to applicationCreatedMessageProcessor: " + eventListener); - } } else if (eventListener instanceof ApplicationActivatedEventListener) { applicationActivatedMessageProcessor.addEventListener(eventListener); } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageDelegator.java index 9cc8f789d3..218c441e7d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageDelegator.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyEventMessageDelegator.java @@ -69,15 +69,15 @@ public void run() { log.debug(String.format("Topology event message [%s] received from queue: %s", type, messageQueue.getClass())); } - try { - TopologyManager.acquireWriteLock(); +// try { +// TopologyManager.acquireWriteLock(); if (log.isDebugEnabled()) { log.debug(String.format("Delegating topology event message: %s", type)); } processorChain.process(type, json, TopologyManager.getTopology()); - } finally { - TopologyManager.releaseWriteLock(); - } +// } finally { +// TopologyManager.releaseWriteLock(); +// } } catch (Exception e) { log.error("Failed to retrieve topology event message", e); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index 5df66bd2ad..2ffd7f6c55 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -21,7 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; + +import java.util.Set; import java.util.concurrent.locks.ReentrantReadWriteLock; /** @@ -30,43 +36,454 @@ * Usage: * Acquire a relevant lock and invoke the getTopology() method inside a try block. * Once processing is done release the lock using a finally block. + * + * Acquiring Locks: + * + * Stratos supports hierarchical locking. As per the practice, we need to lock the + * hierarchy from root level till the relevant sub tree. + * + * Acquire a write lock: + * + * From root level, acquire read lock, and acquire a write lock only for the + * relevant sub tree. + * + * Acquire a read lock: + * + * From root level, acquire read locks till the relevant sub tree + * + * Examples - + * + * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - + * acquiring: + * 1. acquire read lock for all Services + * 2. acquire read lock for the particular Service, to which the cluster belongs to + * 3. acquire write lock for the Cluster + * + * releasing: + * 1. release write lock for the Cluster + * 2. release read lock for the particular Service + * 3. release read lock for all Services + * + * Example 2: Acquiring write lock to add a new Cluster object - + * acquiring: + * 1. acquire read lock for all Services + * 2. acquire write lock for the particular Service, to which the cluster belongs to + * + * releasing: + * 1. release write lock for the particular Service + * 2. release read lock for all Services + * + * Example 3: Acquiring read lock to read Cluster information + * acquiring: + * 1. acquire read lock for all Services + * 2. acquire read lock for the particular Service, to which the cluster belongs to + * 3. acquire read lock for the relevant Cluster + * + * releasing: + * 1. release read lock for the relevant Cluster + * 2. release read lock for the particular Service + * 3. release read lock for all Services + * + * Example 4: Acquiring the write lock to add a deploy a Cartridge (add a new Service) + * acquire: + * 1. acquire write lock for all Services + * + * release: + * 1. release write lock for all Services */ public class TopologyManager { private static final Log log = LogFactory.getLog(TopologyManager.class); private static volatile Topology topology; + private static final TopologyLockHierarchy topologyLockHierarchy = + TopologyLockHierarchy.getInstance(); private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); + + // Top level locks - should be used to lock the entire Topology + public static void acquireReadLock() { if(log.isDebugEnabled()) { - log.debug("Read lock acquired"); + log.debug("Read lock acquired for Topology"); } readLock.lock(); } public static void releaseReadLock() { if(log.isDebugEnabled()) { - log.debug("Read lock released"); + log.debug("Read lock released for Topology"); } readLock.unlock(); } public static void acquireWriteLock() { if(log.isDebugEnabled()) { - log.debug("Write lock acquired"); + log.debug("Write lock acquired for Topology"); } writeLock.lock(); } public static void releaseWriteLock() { if(log.isDebugEnabled()) { - log.debug("Write lock released"); + log.debug("Write lock released for Topology"); } writeLock.unlock(); } + // Application, Service and Cluster read locks + + public static void acquireReadLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Applications"); + } + topologyLockHierarchy.getApplicatioLock().acquireReadLock(); + } + + public static void releaseReadLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Read lock released for Applications"); + } + topologyLockHierarchy.getApplicatioLock().releaseReadLock(); + } + + public static void acquireReadLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Services"); + } + topologyLockHierarchy.getServiceLock().acquireReadLock(); + } + + public static void releaseReadLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Read lock released for Services"); + } + topologyLockHierarchy.getServiceLock().releaseReadLock(); + } + + // Application, Service and Cluster write locks + + public static void acquireWriteLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Applications"); + } + topologyLockHierarchy.getApplicatioLock().acquireWriteLock(); + } + + public static void releaseWriteLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Applications"); + } + topologyLockHierarchy.getApplicatioLock().releaseWritelock(); + } + + public static void acquireWriteLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Services"); + } + topologyLockHierarchy.getServiceLock().acquireWriteLock(); + } + + public static void releaseWriteLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Services"); + } + topologyLockHierarchy.getServiceLock().releaseWritelock(); + } + + public static void acquireReadLockForService (String serviceName) { + + // acquire read lock for all Services + acquireReadLockForServices(); + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.acquireReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Service " + serviceName); + } + } + } + + public static void releaseReadLockForService (String serviceName) { + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.releaseReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock released for Service " + serviceName); + } + } + + // release read lock for all Services + releaseReadLockForServices(); + } + + public static void acquireWriteLockForService (String serviceName) { + + // acquire read lock for all Applications + acquireReadLockForServices(); + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Service " + serviceName); + } + } + } + + public static void releaseWriteLockForService (String serviceName) { + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Service " + serviceName); + } + } + + // release read lock for all Services + releaseReadLockForServices(); + } + + public static void acquireReadLockForCluster (String serviceName, String clusterId) { + + // acquire read lock for the relevant Services + acquireReadLockForService(serviceName); + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + // acquire read lock for the relevant Cluster + topologyClusterLock.acquireReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Cluster " + clusterId); + } + } + } + + public static void releaseReadLockForCluster (String serviceName, String clusterId) { + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + // release read lock for the relevant Cluster + topologyClusterLock.releaseReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock released for Cluster " + clusterId); + } + } + + // release read lock for relevant Service + releaseReadLockForService(serviceName); + } + + public static void acquireWriteLockForCluster (String serviceName, String clusterId) { + + // acquire read lock for the relevant Services + acquireReadLockForService(serviceName); + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + topologyClusterLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Cluster " + clusterId); + } + } + } + + public static void releaseWriteLockForCluster (String serviceName, String clusterId) { + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + topologyClusterLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Cluster " + clusterId); + } + } + + // release read lock for relevant Service + releaseReadLockForService(serviceName); + } + + public static void acquireReadLockForApplication (String appId) { + + // acquire read lock for all Applications + acquireReadLockForApplications(); + + // get the Application's cluster's and acquire read locks + Application application = topology.getApplication(appId); + if (application == null) { + log.warn("Application " + appId + " is not found in the Topology"); + + } else { + + Set clusterData = application.getClusterDataRecursively(); + if (clusterData != null && !clusterData.isEmpty()) { + for (ClusterDataHolder clusterDataHolder : clusterData) { + // acquire read locks for services and clusters + acquireReadLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); + } + + } else { + if (log.isDebugEnabled()) { + log.debug("No Cluster Data found in Application " + appId); + } + } + } + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // now, lock Application + topologyAppLock.acquireReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Application " + appId); + } + } + } + + public static void releaseReadLockForApplication (String appId) { + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // release App lock + topologyAppLock.releaseReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock released for Application " + appId); + } + } + + // release read lock for all Applications + releaseReadLockForApplications(); + + // get the Application's cluster information + Application application = topology.getApplication(appId); + if (application == null) { + log.warn("Application " + appId + " is not found in the Topology"); + + } else { + Set clusterData = application.getClusterDataRecursively(); + if (clusterData != null && !clusterData.isEmpty()) { + for (ClusterDataHolder clusterDataHolder : clusterData) { + // release read locks for clusters and services + releaseReadLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Cluster Data found in Application " + appId); + } + } + } + } + + public static synchronized void acquireWriteLockForApplication (String appId) { + + // acquire read lock for all Applications + acquireReadLockForApplications(); + + // get the Application's cluster's and acquire read locks + Application application = topology.getApplication(appId); + if (application == null) { + log.warn("Application " + appId + " is not found in the Topology"); + + } else { + Set clusterData = application.getClusterDataRecursively(); + if (clusterData != null && !clusterData.isEmpty()) { + for (ClusterDataHolder clusterDataHolder : clusterData) { + acquireWriteLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Cluster Data found in Application " + appId); + } + } + } + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // now, lock Application + topologyAppLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Application " + appId); + } + } + } + + public static synchronized void releaseWriteLockForApplication (String appId) { + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // release App lock + topologyAppLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Application " + appId); + } + } + + // release read lock for all Applications + releaseReadLockForApplications(); + + // get the Application's cluster's and acquire read + Application application = topology.getApplication(appId); + if (application == null) { + log.warn("Application " + appId + " is not found in the Topology"); + + } else { + Set clusterData = application.getClusterDataRecursively(); + if (clusterData != null && !clusterData.isEmpty()) { + for (ClusterDataHolder clusterDataHolder : clusterData) { + // release read locks for clusters and services + releaseWriteLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Cluster Data found in Application " + appId); + } + } + } + } + + private static void handleLockNotFound (String errorMsg) { + log.warn(errorMsg); + //throw new RuntimeException(errorMsg); + } + public static Topology getTopology() { if (topology == null) { synchronized (TopologyManager.class){ From 622ce9fb6aa9b6ab4613626b32c805ff74d868cd Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 7 Oct 2014 19:08:25 +0530 Subject: [PATCH 150/436] hierarchical locking contd. --- .../impl/CloudControllerServiceImpl.java | 6 - .../controller/topology/TopologyBuilder.java | 7 +- .../topology/TopologyEventPublisher.java | 6 +- .../topology/ApplicationRemovedEvent.java | 15 +- .../ApplicationActivatedMessageProcessor.java | 2 - .../ApplicationCreatedMessageProcessor.java | 9 + .../ApplicationRemovedMessageProcessor.java | 23 ++ .../topology/ClusterActivatedProcessor.java | 2 - .../ClusterCreatedMessageProcessor.java | 2 - ...lusterMaintenanceModeMessageProcessor.java | 2 - .../ClusterRemovedMessageProcessor.java | 2 - .../topology/GroupActivatedProcessor.java | 2 - .../receiver/topology/TopologyManager.java | 80 ------- .../topology/locking/TopologyLockingTest.java | 209 ++++++++++++++++++ 14 files changed, 263 insertions(+), 104 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index a6f74df718..df2c217bc8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -35,7 +35,6 @@ import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -49,11 +48,6 @@ import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; -import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient; -import org.apache.stratos.metadata.client.MetaDataServiceClient; -import org.apache.stratos.metadata.client.config.MetaDataClientConfig; -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; -import org.apache.stratos.metadata.client.exception.RestClientException; import org.jclouds.compute.ComputeService; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadataBuilder; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 30b1b0054a..4aa70233e1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -664,12 +664,13 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold if (!topology.applicationExists(applicationId)) { log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); + //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); } else { Application application = topology.getApplication(applicationId); + Set clusterData = application.getClusterDataRecursively(); // remove clusters - for (ClusterDataHolder clusterDataHolder : application.getClusterDataRecursively()) { + for (ClusterDataHolder clusterDataHolder : clusterData) { Service service = topology.getService(clusterDataHolder.getServiceType()); if (service != null) { // remove Cluster @@ -696,7 +697,7 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold log.info("Removed application [ " + applicationId + " ] from Topology"); - TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); + TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain); } } finally { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 53efeaa209..a6d83507dc 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -39,6 +39,7 @@ import java.util.List; import java.util.Properties; +import java.util.Set; /** * this is to send the relevant events from cloud controller to topology topic @@ -99,13 +100,14 @@ public static void sendApplicationCreatedEvent (Application application, List clusterData, + int tenantId, String tenantDomain) { if(log.isInfoEnabled() || log.isDebugEnabled()) { log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId); } - publishEvent(new ApplicationRemovedEvent(applicationId, tenantId, tenantDomain)); + publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain)); } public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java index 1e51321d31..8b0f2cb171 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java @@ -19,6 +19,11 @@ package org.apache.stratos.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; + +import java.util.Set; + public class ApplicationRemovedEvent extends TopologyEvent { /** @@ -26,11 +31,15 @@ public class ApplicationRemovedEvent extends TopologyEvent { */ private static final long serialVersionUID = -5499420725533165623L; private String applicationId; + private Set clusterData; + private String tenantDomain; private int tenantId; - public ApplicationRemovedEvent (String applicationId, int tenantId, String tenantDomain) { + public ApplicationRemovedEvent (String applicationId, Set clusterData, + int tenantId, String tenantDomain) { this.applicationId = applicationId; + this.clusterData = clusterData; this.tenantId = tenantId; this.tenantDomain = tenantDomain; } @@ -46,4 +55,8 @@ public int getTenantId() { public String getTenantDomain() { return tenantDomain; } + + public Set getClusterData() { + return clusterData; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index 803a8710cf..4211830e61 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -57,7 +57,6 @@ public boolean process(String type, String message, Object object) { ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. jsonToObject(message, ApplicationActivatedEvent.class); - TopologyManager.acquireReadLockForApplications(); TopologyManager.acquireWriteLockForApplication(event.getAppId()); try { @@ -65,7 +64,6 @@ public boolean process(String type, String message, Object object) { } finally { TopologyManager.releaseWriteLockForApplication(event.getAppId()); - TopologyManager.releaseReadLockForApplications(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 4368bd7be8..c47867eac1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -22,12 +22,15 @@ 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.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; +import java.util.Set; + public class ApplicationCreatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); @@ -55,11 +58,17 @@ public boolean process(String type, String message, Object object) { } TopologyManager.acquireWriteLockForApplications(); + for (ClusterDataHolder clusterData : event.getApplication().getClusterDataRecursively()) { + TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + } try { return doProcess(event, topology); } finally { + for (ClusterDataHolder clusterData : event.getApplication().getClusterDataRecursively()) { + TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + } TopologyManager.releaseWriteLockForApplications(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java index ed6c2d47d1..629f21b278 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -21,6 +21,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -62,12 +64,18 @@ public boolean process(String type, String message, Object object) { } TopologyManager.acquireWriteLockForApplications(); + for (ClusterDataHolder clusterData : event.getClusterData()) { + TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + } try { return doProcess(event, topology); } finally { TopologyManager.releaseWriteLockForApplications(); + for (ClusterDataHolder clusterData : event.getClusterData()) { + TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + } } } else { @@ -102,6 +110,21 @@ private boolean doProcess (ApplicationRemovedEvent event, Topology topology) { topology.removeApplication(appId); } + if (event.getClusterData() != null) { + // remove the Clusters from the Topology + for (ClusterDataHolder clusterData : event.getClusterData()) { + Service service = topology.getService(clusterData.getServiceType()); + if (service != null) { + service.removeCluster(clusterData.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); + } + } else { + log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); + } + } + } + if (log.isDebugEnabled()) { log.debug("ApplicationRemovedMessageProcessor notifying listener "); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 78f772bf19..601cfb20fb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -58,14 +58,12 @@ public boolean process(String type, String message, Object object) { ClusterActivatedEvent event = (ClusterActivatedEvent) Util. jsonToObject(message, ClusterActivatedEvent.class); - TopologyManager.acquireReadLockForServices(); TopologyManager.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { TopologyManager.releaseWriteLockForService(event.getServiceName()); - TopologyManager.releaseReadLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index 94b9650422..6eddfd3878 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -53,14 +53,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterCreatedEvent event = (ClusterCreatedEvent) Util.jsonToObject(message, ClusterCreatedEvent.class); - TopologyManager.acquireReadLockForServices(); TopologyManager.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { TopologyManager.releaseWriteLockForService(event.getServiceName()); - TopologyManager.releaseReadLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 86293639f1..0b10504e82 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -50,14 +50,12 @@ public boolean process(String type, String message, Object object) { ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util. jsonToObject(message, ClusterMaintenanceModeEvent.class); - TopologyManager.acquireReadLockForServices(); TopologyManager.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { TopologyManager.releaseWriteLockForService(event.getServiceName()); - TopologyManager.releaseReadLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java index 1dfb929ac0..fb45cd38ad 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java @@ -51,14 +51,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterRemovedEvent event = (ClusterRemovedEvent) Util.jsonToObject(message, ClusterRemovedEvent.class); - TopologyManager.acquireReadLockForServices(); TopologyManager.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { TopologyManager.releaseWriteLockForService(event.getServiceName()); - TopologyManager.releaseReadLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 7200431f3d..3bf5fad791 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -51,7 +51,6 @@ public boolean process(String type, String message, Object object) { GroupActivatedEvent event = (GroupActivatedEvent) Util. jsonToObject(message, GroupActivatedEvent.class); - TopologyManager.acquireReadLockForApplications(); TopologyManager.acquireWriteLockForApplication(event.getAppId()); try { @@ -59,7 +58,6 @@ public boolean process(String type, String message, Object object) { } finally { TopologyManager.releaseWriteLockForApplication(event.getAppId()); - TopologyManager.releaseReadLockForApplications(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index 2ffd7f6c55..ed3b16a89c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -21,13 +21,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; -import java.util.Set; import java.util.concurrent.locks.ReentrantReadWriteLock; /** @@ -335,27 +332,6 @@ public static void acquireReadLockForApplication (String appId) { // acquire read lock for all Applications acquireReadLockForApplications(); - // get the Application's cluster's and acquire read locks - Application application = topology.getApplication(appId); - if (application == null) { - log.warn("Application " + appId + " is not found in the Topology"); - - } else { - - Set clusterData = application.getClusterDataRecursively(); - if (clusterData != null && !clusterData.isEmpty()) { - for (ClusterDataHolder clusterDataHolder : clusterData) { - // acquire read locks for services and clusters - acquireReadLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); - } - - } else { - if (log.isDebugEnabled()) { - log.debug("No Cluster Data found in Application " + appId); - } - } - } - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); if (topologyAppLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); @@ -385,25 +361,6 @@ public static void releaseReadLockForApplication (String appId) { // release read lock for all Applications releaseReadLockForApplications(); - - // get the Application's cluster information - Application application = topology.getApplication(appId); - if (application == null) { - log.warn("Application " + appId + " is not found in the Topology"); - - } else { - Set clusterData = application.getClusterDataRecursively(); - if (clusterData != null && !clusterData.isEmpty()) { - for (ClusterDataHolder clusterDataHolder : clusterData) { - // release read locks for clusters and services - releaseReadLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); - } - } else { - if (log.isDebugEnabled()) { - log.debug("No Cluster Data found in Application " + appId); - } - } - } } public static synchronized void acquireWriteLockForApplication (String appId) { @@ -411,24 +368,6 @@ public static synchronized void acquireWriteLockForApplication (String appId) { // acquire read lock for all Applications acquireReadLockForApplications(); - // get the Application's cluster's and acquire read locks - Application application = topology.getApplication(appId); - if (application == null) { - log.warn("Application " + appId + " is not found in the Topology"); - - } else { - Set clusterData = application.getClusterDataRecursively(); - if (clusterData != null && !clusterData.isEmpty()) { - for (ClusterDataHolder clusterDataHolder : clusterData) { - acquireWriteLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); - } - } else { - if (log.isDebugEnabled()) { - log.debug("No Cluster Data found in Application " + appId); - } - } - } - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); if (topologyAppLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); @@ -458,25 +397,6 @@ public static synchronized void releaseWriteLockForApplication (String appId) { // release read lock for all Applications releaseReadLockForApplications(); - - // get the Application's cluster's and acquire read - Application application = topology.getApplication(appId); - if (application == null) { - log.warn("Application " + appId + " is not found in the Topology"); - - } else { - Set clusterData = application.getClusterDataRecursively(); - if (clusterData != null && !clusterData.isEmpty()) { - for (ClusterDataHolder clusterDataHolder : clusterData) { - // release read locks for clusters and services - releaseWriteLockForCluster(clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); - } - } else { - if (log.isDebugEnabled()) { - log.debug("No Cluster Data found in Application " + appId); - } - } - } } private static void handleLockNotFound (String errorMsg) { diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java new file mode 100644 index 0000000000..5d33904724 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -0,0 +1,209 @@ +/* + * 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.messaging.topology.locking; + +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.junit.*; + +import java.util.HashMap; +import java.util.Map; + +//@RunWith(ConcurrentRunner.class) +//@Concurrent(threads = 12) +public class TopologyLockingTest { + + private static Topology topology; + + @BeforeClass + public static void setUpBeforeClass() { + System.out.println("Setting up TopologyLockingTest"); + topology = TopologyManager.getTopology(); + + //add Services + topology.addService(new Service("service1", ServiceType.SingleTenant)); + topology.addService(new Service("service2", ServiceType.SingleTenant)); + topology.addService(new Service("service3", ServiceType.SingleTenant)); + topology.addService(new Service("service4", ServiceType.SingleTenant)); + + // add Clusters + topology.getService("service1").addCluster(new Cluster("service1", "service1.cluster1.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + topology.getService("service1").addCluster(new Cluster("service1", "service1.cluster2.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + + topology.getService("service2").addCluster(new Cluster("service2", "service2.cluster1.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + topology.getService("service2").addCluster(new Cluster("service2", "service2.cluster2.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + + topology.getService("service3").addCluster(new Cluster("service3", "service3.cluster1.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + topology.getService("service3").addCluster(new Cluster("service3", "service3.cluster2.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + + topology.getService("service4").addCluster(new Cluster("service4", "service4.cluster1.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + topology.getService("service4").addCluster(new Cluster("service4", "service4.cluster2.domain", + "dummyDeploymentPolicy", "dummyAutoscalePolicy", null)); + + // Create Application 1 + Application app1 = new Application("app1"); + Map clusterDataMap1 = new HashMap(); + clusterDataMap1.put("alias1", new ClusterDataHolder("service1", "service1.cluster1.domain")); + clusterDataMap1.put("alias2", new ClusterDataHolder("service1", "service1.cluster2.domain")); + clusterDataMap1.put("alias3", new ClusterDataHolder("service2", "service2.cluster1.domain")); + clusterDataMap1.put("alias4", new ClusterDataHolder("service2", "service2.cluster2.domain")); + + // add cluster data to Application + app1.setClusterData(clusterDataMap1); + + // add Applicaiton to Topology + topology.addApplication(app1); + + // Create Application 2 + Application app2 = new Application("app2"); + Map clusterDataMap2 = new HashMap(); + clusterDataMap2.put("alias5", new ClusterDataHolder("service3", "service3.cluster1.domain")); + clusterDataMap2.put("alias6", new ClusterDataHolder("service3", "service3.cluster2.domain")); + clusterDataMap2.put("alias7", new ClusterDataHolder("service4", "service4.cluster1.domain")); + clusterDataMap2.put("alias8", new ClusterDataHolder("service4", "service4.cluster2.domain")); + + // add cluster data to Application + app2.setClusterData(clusterDataMap2); + + // add Applicaiton to Topology + topology.addApplication(app2); + } + + @Test + public void testAqcuireAndReleaseReadLocksForServices1To2 () { + + TopologyManager.acquireReadLockForService("service1"); + TopologyManager.acquireReadLockForService("service2"); + + TopologyManager.releaseReadLockForService("service1"); + TopologyManager.releaseReadLockForService("service2"); + } + + @Test + public void testAqcuireAndReleaseReadLocksForServices3To4 () { + + TopologyManager.acquireReadLockForService("service3"); + TopologyManager.acquireReadLockForService("service4"); + + TopologyManager.releaseReadLockForService("service3"); + TopologyManager.releaseReadLockForService("service4"); + } + + @Test + public void testAqcuireAndReleaseWriteLocksForServices1To2 () { + + TopologyManager.acquireWriteLockForService("service1"); + TopologyManager.acquireWriteLockForService("service2"); + + TopologyManager.releaseWriteLockForService("service1"); + TopologyManager.releaseWriteLockForService("service2"); + } + + @Test + public void testAqcuireAndReleaseWriteLocksForServices3To4 () { + + TopologyManager.acquireWriteLockForService("service3"); + TopologyManager.acquireWriteLockForService("service4"); + + TopologyManager.releaseWriteLockForService("service3"); + TopologyManager.releaseWriteLockForService("service4"); + } + + @Test + public void testAqcuireAndReleaseReadLocksForClustersOfService1 () { + + TopologyManager.acquireReadLockForCluster("service1", "service1.cluster1.domain"); + TopologyManager.acquireReadLockForCluster("service1", "service1.cluster2.domain"); + + TopologyManager.releaseReadLockForCluster("service1", "service1.cluster1.domain"); + TopologyManager.releaseReadLockForCluster("service1", "service1.cluster2.domain"); + } + + @Test + public void testAqcuireAndReleaseReadLocksForClustersOfService2 () { + + TopologyManager.acquireReadLockForCluster("service2", "service2.cluster1.domain"); + TopologyManager.acquireReadLockForCluster("service2", "service2.cluster2.domain"); + + TopologyManager.releaseReadLockForCluster("service2", "service2.cluster1.domain"); + TopologyManager.releaseReadLockForCluster("service2", "service2.cluster2.domain"); + } + + @Test + public void testAqcuireAndReleaseWriteLocksForClustersOfService1 () { + + TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); + TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); + + TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); + TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); + } + + @Test + public void testAqcuireAndReleaseWriteLocksForClustersOfService2 () { + + TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); + TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); + + TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); + TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); + } + + @Test + public void testAcquireAndReleaseReadLockForApp1 () { + + TopologyManager.acquireReadLockForApplication("app1"); + TopologyManager.releaseReadLockForApplication("app1"); + } + + @Test + public void testAcquireAndReleaseWriteLockForApp1 () { + + TopologyManager.acquireWriteLockForApplication("app1"); + TopologyManager.releaseWriteLockForApplication("app1"); + } + + @Test + public void testAcquireAndReleaseReadLockForApp2 () { + + TopologyManager.acquireReadLockForApplication("app2"); + TopologyManager.releaseReadLockForApplication("app2"); + } + + @Test + public void testAcquireAndReleaseWriteLockForApp2 () { + + TopologyManager.acquireWriteLockForApplication("app2"); + TopologyManager.releaseWriteLockForApplication("app2"); + } + + @AfterClass + public static void tearDownAfterClass() { + System.out.println("Cleaning up TopologyLockingTest"); + topology = null; + } +} From bd8ecbd0e41d3d4310acd618509b460a90ecefaf Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 7 Oct 2014 20:58:18 +0530 Subject: [PATCH 151/436] adding comments for lock methods and handling a possible BPE --- .../ApplicationCreatedMessageProcessor.java | 13 +- .../ApplicationRemovedMessageProcessor.java | 17 ++- .../receiver/topology/TopologyManager.java | 114 +++++++++++++++++- 3 files changed, 131 insertions(+), 13 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index c47867eac1..587d6f3fe5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -58,16 +58,21 @@ public boolean process(String type, String message, Object object) { } TopologyManager.acquireWriteLockForApplications(); - for (ClusterDataHolder clusterData : event.getApplication().getClusterDataRecursively()) { - TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + } } try { return doProcess(event, topology); } finally { - for (ClusterDataHolder clusterData : event.getApplication().getClusterDataRecursively()) { - TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + } } TopologyManager.releaseWriteLockForApplications(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java index 629f21b278..062c7e1e6d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -29,6 +29,8 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Util; +import java.util.Set; + public class ApplicationRemovedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); @@ -64,18 +66,23 @@ public boolean process(String type, String message, Object object) { } TopologyManager.acquireWriteLockForApplications(); - for (ClusterDataHolder clusterData : event.getClusterData()) { - TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + Set clusterDataHolders = event.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + } } try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForApplications(); - for (ClusterDataHolder clusterData : event.getClusterData()) { - TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + } } + TopologyManager.releaseWriteLockForApplications(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index ed3b16a89c..e86d9dfc23 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -101,6 +101,9 @@ public class TopologyManager { // Top level locks - should be used to lock the entire Topology + /** + * Acquires read lock for the Complete Topology + */ public static void acquireReadLock() { if(log.isDebugEnabled()) { log.debug("Read lock acquired for Topology"); @@ -108,6 +111,9 @@ public static void acquireReadLock() { readLock.lock(); } + /** + * Releases read lock for the Complete Topology + */ public static void releaseReadLock() { if(log.isDebugEnabled()) { log.debug("Read lock released for Topology"); @@ -115,6 +121,9 @@ public static void releaseReadLock() { readLock.unlock(); } + /** + * Acquires write lock for the Complete Topology + */ public static void acquireWriteLock() { if(log.isDebugEnabled()) { log.debug("Write lock acquired for Topology"); @@ -122,6 +131,9 @@ public static void acquireWriteLock() { writeLock.lock(); } + /** + * Releases write lock for the Complete Topology + */ public static void releaseWriteLock() { if(log.isDebugEnabled()) { log.debug("Write lock released for Topology"); @@ -129,8 +141,10 @@ public static void releaseWriteLock() { writeLock.unlock(); } - // Application, Service and Cluster read locks - + // Application and Service read locks + /** + * Acquires read lock for the all Applications + */ public static void acquireReadLockForApplications() { if(log.isDebugEnabled()) { log.debug("Read lock acquired for Applications"); @@ -138,6 +152,9 @@ public static void acquireReadLockForApplications() { topologyLockHierarchy.getApplicatioLock().acquireReadLock(); } + /** + * Releases read lock for the all Applications + */ public static void releaseReadLockForApplications() { if(log.isDebugEnabled()) { log.debug("Read lock released for Applications"); @@ -145,6 +162,9 @@ public static void releaseReadLockForApplications() { topologyLockHierarchy.getApplicatioLock().releaseReadLock(); } + /** + * Acquires read lock for the all Services + */ public static void acquireReadLockForServices() { if(log.isDebugEnabled()) { log.debug("Read lock acquired for Services"); @@ -152,6 +172,9 @@ public static void acquireReadLockForServices() { topologyLockHierarchy.getServiceLock().acquireReadLock(); } + /** + * Releases read lock for the all Services + */ public static void releaseReadLockForServices() { if(log.isDebugEnabled()) { log.debug("Read lock released for Services"); @@ -159,8 +182,10 @@ public static void releaseReadLockForServices() { topologyLockHierarchy.getServiceLock().releaseReadLock(); } - // Application, Service and Cluster write locks - + // Application and Service write locks + /** + * Acquires write lock for the all Applications + */ public static void acquireWriteLockForApplications() { if(log.isDebugEnabled()) { log.debug("Write lock acquired for Applications"); @@ -168,6 +193,9 @@ public static void acquireWriteLockForApplications() { topologyLockHierarchy.getApplicatioLock().acquireWriteLock(); } + /** + * Releases write lock for the all Applications + */ public static void releaseWriteLockForApplications() { if(log.isDebugEnabled()) { log.debug("Write lock released for Applications"); @@ -175,6 +203,9 @@ public static void releaseWriteLockForApplications() { topologyLockHierarchy.getApplicatioLock().releaseWritelock(); } + /** + * Acquires write lock for the all Services + */ public static void acquireWriteLockForServices() { if(log.isDebugEnabled()) { log.debug("Write lock acquired for Services"); @@ -182,6 +213,9 @@ public static void acquireWriteLockForServices() { topologyLockHierarchy.getServiceLock().acquireWriteLock(); } + /** + * Releases write lock for the all Services + */ public static void releaseWriteLockForServices() { if(log.isDebugEnabled()) { log.debug("Write lock released for Services"); @@ -189,6 +223,11 @@ public static void releaseWriteLockForServices() { topologyLockHierarchy.getServiceLock().releaseWritelock(); } + /** + * Acquires read lock for a Service + * + * @param serviceName service name to acquire read lock + */ public static void acquireReadLockForService (String serviceName) { // acquire read lock for all Services @@ -206,6 +245,11 @@ public static void acquireReadLockForService (String serviceName) { } } + /** + * Releases read lock for a Service + * + * @param serviceName service name to release read lock + */ public static void releaseReadLockForService (String serviceName) { TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); @@ -223,6 +267,11 @@ public static void releaseReadLockForService (String serviceName) { releaseReadLockForServices(); } + /** + * Acquires write lock for a Service + * + * @param serviceName service name to acquire write lock + */ public static void acquireWriteLockForService (String serviceName) { // acquire read lock for all Applications @@ -240,6 +289,11 @@ public static void acquireWriteLockForService (String serviceName) { } } + /** + * Releases write lock for a Service + * + * @param serviceName service name to release write lock + */ public static void releaseWriteLockForService (String serviceName) { TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); @@ -257,6 +311,14 @@ public static void releaseWriteLockForService (String serviceName) { releaseReadLockForServices(); } + /** + * Acquires read lock for a Cluster. This will acquire the read lock in the following order + * 1. for the Service + * 2. for the Cluster + * + * @param serviceName service name to acquire read lock + * @param clusterId cluster id to acquire read lock + */ public static void acquireReadLockForCluster (String serviceName, String clusterId) { // acquire read lock for the relevant Services @@ -275,6 +337,14 @@ public static void acquireReadLockForCluster (String serviceName, String cluster } } + /** + * Releases read lock for a Cluster. This will release the read lock in the following order + * 1. for the Cluster + * 2. for the Service + * + * @param serviceName service name to release read lock + * @param clusterId cluster id to release read lock + */ public static void releaseReadLockForCluster (String serviceName, String clusterId) { TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); @@ -293,6 +363,14 @@ public static void releaseReadLockForCluster (String serviceName, String cluster releaseReadLockForService(serviceName); } + /** + * Acquires write lock for a Cluster. This will acquire the write lock in the following order + * 1. for the Service + * 2. for the Cluster + * + * @param serviceName service name to acquire write lock + * @param clusterId cluster id to acquire write lock + */ public static void acquireWriteLockForCluster (String serviceName, String clusterId) { // acquire read lock for the relevant Services @@ -310,6 +388,14 @@ public static void acquireWriteLockForCluster (String serviceName, String cluste } } + /** + * Releases write lock for a Cluster. This will release the write lock in the following order + * 1. for the Cluster + * 2. for the Service + * + * @param serviceName service name to release write lock + * @param clusterId cluster id to release write lock + */ public static void releaseWriteLockForCluster (String serviceName, String clusterId) { TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); @@ -327,6 +413,11 @@ public static void releaseWriteLockForCluster (String serviceName, String cluste releaseReadLockForService(serviceName); } + /** + * Acquires read lock for the Application + * + * @param appId Application id + */ public static void acquireReadLockForApplication (String appId) { // acquire read lock for all Applications @@ -345,6 +436,11 @@ public static void acquireReadLockForApplication (String appId) { } } + /** + * Releases read lock for the Application + * + * @param appId Application id + */ public static void releaseReadLockForApplication (String appId) { TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); @@ -363,6 +459,11 @@ public static void releaseReadLockForApplication (String appId) { releaseReadLockForApplications(); } + /** + * Acquires write lock for the Application + * + * @param appId Application id + */ public static synchronized void acquireWriteLockForApplication (String appId) { // acquire read lock for all Applications @@ -381,6 +482,11 @@ public static synchronized void acquireWriteLockForApplication (String appId) { } } + /** + * Releases write lock for the Application + * + * @param appId Application id + */ public static synchronized void releaseWriteLockForApplication (String appId) { TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); From 02bb3863a6998506391276bb519c1598f95057d2 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 7 Oct 2014 18:49:17 -0700 Subject: [PATCH 152/436] startupOrder format change I --- .../parser/DefaultApplicationParser.java | 45 +- .../impl/CloudControllerServiceImpl.java | 15 +- .../cloud/controller/pojo/Dependencies.java | 20 +- .../pojo/application/DependencyContext.java | 20 +- .../DefaultCompositeApplicationParser.java | 32 +- .../structure/CompositeAppContext.java | 12 +- .../application/structure/GroupContext.java | 17 +- .../definitions/DependencyDefinitions.java | 23 +- .../deployer/DefaultServiceGroupDeployer.java | 35 +- .../bean/util/converter/PojoConverter.java | 21 +- .../webapp/stratos/WEB-INF/schemas/schema.xsd | 11 +- .../resources/CloudControllerService.wsdl | 1298 ++++++++--------- 12 files changed, 772 insertions(+), 777 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 7865dde0c6..d01674d2d2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -268,8 +268,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, // get top level Dependency definitions if (appCtxt.getComponents().getDependencyContext() != null) { DependencyOrder appDependencyOrder = new DependencyOrder(); - Set startupOrders = getStartupOrderForApplicationComponents(new HashSet(Arrays.asList(appCtxt.getComponents(). - getDependencyContext().getStartupOrderContext()))); + Set startupOrders = getStartupOrderForApplicationComponents(appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts()); if (startupOrders != null) { appDependencyOrder.setStartupOrders(startupOrders); } @@ -442,13 +441,32 @@ private Set getStartupOrderForGroup(GroupContext groupContext) thr if (serviceGroup == null) { handleError("Service Group Definition not found for name " + groupContext.getName()); } + + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName()); + } assert serviceGroup != null; if (serviceGroup.getDependencies() != null) { - if (serviceGroup.getDependencies().getStartupOrder() != null) { + if (serviceGroup.getDependencies().getStartupOrders() != null) { + + Set startupOrders = new HashSet(); + String [] st = serviceGroup.getDependencies().getStartupOrders(); + + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup # of startupOrders: " + st.length); + } - // convert to Startup Order with aliases - return ParserUtils.convert(serviceGroup.getDependencies().getStartupOrder(), groupContext); + for (String startupOrderContext : st) { + + String [] order = startupOrderContext.split(","); + + startupOrders.add(new StartupOrder(order[0], order[1])); + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup startupOrders:start: " + order[0] + " after: " + order[1]); + } + } + return startupOrders; } } @@ -463,18 +481,31 @@ private Set getStartupOrderForGroup(GroupContext groupContext) thr * * @throws ApplicationDefinitionException if an error occurs */ - private Set getStartupOrderForApplicationComponents (Set startupOrderCtxts) + private Set getStartupOrderForApplicationComponents (String [] startupOrdersCtxts) throws ApplicationDefinitionException { - if (startupOrderCtxts == null) { + if (startupOrdersCtxts == null) { return null; } + + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForApplicationComponents: # of: " + startupOrdersCtxts.length); + } Set startupOrders = new HashSet(); + /* for (StartupOrderContext startupOrderContext : startupOrderCtxts) { startupOrders.add(new StartupOrder(startupOrderContext.getStart(), startupOrderContext.getAfter())); } + */ + for (String startupOrderContext : startupOrdersCtxts) { + String [] order = startupOrderContext.split(","); + startupOrders.add(new StartupOrder(order[0], order[1])); + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForApplicationComponents: start: " + order[0] + " /after: " + order[1]); + } + } return startupOrders; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index df2c217bc8..72874e52bb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -293,7 +293,12 @@ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceG if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups.length); + log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups); + if (subGroups != null) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length); + } else { + log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null"); + } } @@ -303,13 +308,13 @@ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceG log.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); } - StartupOrder [] startupOrder = dependencies.getStartupOrder(); + String [] startupOrders = dependencies.getStartupOrders(); if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder" + startupOrder); + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); - if (startupOrder != null) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrder.length); + if (startupOrders != null) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); } else { log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java index 0177341375..7fa779d148 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Dependencies.java @@ -25,19 +25,11 @@ public class Dependencies implements Serializable { private static final long serialVersionUID = 4187267350546153680L; - - private StartupOrder [] startupOrder; + + private String [] startupOrders; private String killBehaviour; - public StartupOrder [] getStartupOrder() { - return startupOrder; - } - - public void setStartupOrder(StartupOrder [] startupOrder) { - this.startupOrder = startupOrder; - } - public String getKillBehaviour() { return killBehaviour; } @@ -45,4 +37,12 @@ public String getKillBehaviour() { public void setKillBehaviour(String killBehaviour) { this.killBehaviour = killBehaviour; } + + public String[] getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(String[] startupOrders) { + this.startupOrders = startupOrders; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java index 2b31729242..0459f36b5e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java @@ -21,19 +21,11 @@ public class DependencyContext { - - private StartupOrderContext[] startupOrderContexts; + + private String [] startupOrdersContexts; private String killBehaviour; - public StartupOrderContext[] getStartupOrderContext() { - return startupOrderContexts; - } - - public void setStartupOrderContext(StartupOrderContext[] startupOrderContexts) { - this.startupOrderContexts = startupOrderContexts; - } - public String getKillBehaviour() { return killBehaviour; } @@ -41,4 +33,12 @@ public String getKillBehaviour() { public void setKillBehaviour(String killBehaviour) { this.killBehaviour = killBehaviour; } + + public String [] getStartupOrdersContexts() { + return startupOrdersContexts; + } + + public void setStartupOrdersContexts(String [] startupOrdersContexts) { + this.startupOrdersContexts = startupOrdersContexts; + } } diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 0f24708d0c..3b54bedd2f 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -210,9 +210,12 @@ private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition c } // get top level Dependency definitions + if (compositeAppDefinition.getComponents().getDependencies() != null) { - compositeAppContext.setStartupOrder(getStartupOrderForApplicationComponents(compositeAppDefinition.getComponents(). - getDependencies().getStartupOrder())); + List startupOrderList = compositeAppDefinition.getComponents().getDependencies().getStartupOrders(); + String [] startupOrders = new String [startupOrderList.size()]; + startupOrders = startupOrderList.toArray(startupOrders); + compositeAppContext.setStartupOrders(startupOrders); compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour()); } @@ -298,7 +301,7 @@ private GroupContext getGroupContext (GroupDefinition group, Map getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { + private String [] getStartupOrderForGroup(String serviceGroupName) throws CompositeApplicationDefinitionException { ServiceGroupDefinition groupDefinition; @@ -337,29 +340,16 @@ private Set getStartupOrderForGroup(String serviceGroupName) throw } if (groupDefinition.getDependencies() != null) { - if (groupDefinition.getDependencies().getStartupOrder() != null) { - return ParserUtils.convert(groupDefinition.getDependencies().getStartupOrder()); + if (groupDefinition.getDependencies().getStartupOrders() != null) { + List startupOrdersList = groupDefinition.getDependencies().getStartupOrders(); + String [] startupOrders = new String [startupOrdersList.size()]; + return startupOrdersList.toArray(startupOrders); } } return null; } - private Set getStartupOrderForApplicationComponents (List startupOrderDefinitions) - throws CompositeApplicationDefinitionException { - - if (startupOrderDefinitions == null) { - return null; - } - - Set startupOrders = new HashSet(); - - for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { - startupOrders.add(new StartupOrder(startupOrderDefinition.getStart(), startupOrderDefinition.getAfter())); - } - - return startupOrders; - } private String getKillbehaviour (String serviceGroupName) throws CompositeApplicationDefinitionException { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java index 4cb7073368..287d475cc3 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java @@ -30,6 +30,8 @@ public class CompositeAppContext { private Set subscribableContexts; private Set startupOrder; + + private String [] startupOrders; private String killBehaviour; @@ -77,7 +79,15 @@ public void setKillBehaviour(String killBehaviour) { this.killBehaviour = killBehaviour; } - public boolean equals(Object other) { + public String [] getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(String [] startupOrders) { + this.startupOrders = startupOrders; + } + + public boolean equals(Object other) { if(this == other) { return true; diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java index b235c1b859..4874de3f5a 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/GroupContext.java @@ -35,20 +35,19 @@ public class GroupContext { private Set subscribableContexts; - private Set startupOrder; + private String [] startupOrders; private String killBehaviour; + public String [] getStartupOrders() { + return startupOrders; + } - public Set getStartupOrder() { - return startupOrder; - } - - public void setStartupOrder(Set startupOrder) { - this.startupOrder = startupOrder; - } + public void setStartupOrders(String [] startupOrders) { + this.startupOrders = startupOrders; + } - public String getKillBehaviour() { + public String getKillBehaviour() { return killBehaviour; } 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 index eee4634188..782bce0857 100644 --- 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 @@ -26,18 +26,15 @@ @XmlRootElement(name = "dependencies") public class DependencyDefinitions implements Serializable { - private List startupOrder; + /** + * + */ + private static final long serialVersionUID = 1L; + + private List startupOrders; private String killBehaviour; - public List getStartupOrder() { - return startupOrder; - } - - public void setStartupOrder(List startupOrder) { - this.startupOrder = startupOrder; - } - public String getKillBehaviour() { return killBehaviour; } @@ -45,4 +42,12 @@ public String getKillBehaviour() { public void setKillBehaviour(String killBehaviour) { this.killBehaviour = killBehaviour; } + + public List getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(List startupOrders) { + this.startupOrders = startupOrders; + } } 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 index f944288953..f4d42f63e9 100644 --- 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 @@ -31,7 +31,6 @@ import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.pojo.Dependencies; -import org.apache.stratos.cloud.controller.stub.pojo.StartupOrder; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; @@ -242,6 +241,7 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro List subGroupsDef = serviceGroupDefinition.getSubGroups(); List cartridgesDef = serviceGroupDefinition.getCartridges(); + if (subGroupsDef == null) { subGroupsDef = new ArrayList(0); } @@ -260,20 +260,14 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro servicegroup.setCartridges(cartridges); DependencyDefinitions depDefs = serviceGroupDefinition.getDependencies(); + if (depDefs != null) { - List startDefs = depDefs.getStartupOrder(); - Dependencies deps = new Dependencies(); - if (startDefs != null) { - StartupOrder [] startups = new StartupOrder [startDefs.size()]; - for (int i = 0; i < startDefs.size(); i++) { - StartupOrderDefinition stDef = startDefs.get(i); - StartupOrder st = new StartupOrder(); - st.setStart(stDef.getStart()); - st.setAfter(stDef.getAfter()); - startups[i] = st; - } - deps.setStartupOrder(startups); + List startupOrdersDef = depDefs.getStartupOrders(); + if (startupOrdersDef != null) { + String [] startupOrders = new String [startupOrdersDef.size()]; + startupOrders = startupOrdersDef.toArray(startupOrders); + deps.setStartupOrders(startupOrders); } deps.setKillBehaviour(depDefs.getKillBehaviour()); servicegroup.setDependencies(deps); @@ -291,19 +285,10 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup if (deps != null) { DependencyDefinitions depsDef = new DependencyDefinitions(); - StartupOrder [] startupOrders = deps.getStartupOrder(); + String [] startupOrders = deps.getStartupOrders(); if (startupOrders != null && startupOrders.length > 0) { - List startupsDef = new ArrayList(); - for (StartupOrder startupOrder : startupOrders) { - if (startupOrder != null) { - StartupOrderDefinition astartupDef = new StartupOrderDefinition(); - astartupDef.setAfter(startupOrder.getAfter()); - astartupDef.setStart(startupOrder.getStart()); - startupsDef.add(astartupDef); - } - } - - depsDef.setStartupOrder(startupsDef); + List startupOrdersDef = Arrays.asList(startupOrders); + depsDef.setStartupOrders(startupOrdersDef); } depsDef.setKillBehaviour(deps.getKillBehaviour()); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index a100a93553..3524bf4ae2 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -734,27 +734,16 @@ private static DependencyContext getDependencyContextFromDependencyDefinition (D DependencyContext dependencyContext = new DependencyContext(); dependencyContext.setKillBehaviour(dependencyDefinitions.getKillBehaviour()); - if (dependencyDefinitions.getStartupOrder() != null) { - dependencyContext.setStartupOrderContext(getStartupOrderContextArrFromStartupDefinition(dependencyDefinitions.getStartupOrder())); + + if (dependencyDefinitions != null && dependencyDefinitions.getStartupOrders() != null) { + String [] startupOrders = new String [dependencyDefinitions.getStartupOrders().size()]; + startupOrders = dependencyDefinitions.getStartupOrders().toArray(startupOrders); + dependencyContext.setStartupOrdersContexts(startupOrders); } return dependencyContext; } - private static StartupOrderContext[] getStartupOrderContextArrFromStartupDefinition (List startupOrderDefinitions) { - - StartupOrderContext[] startupOrderContexts = new StartupOrderContext[startupOrderDefinitions.size()]; - int i = 0; - for (StartupOrderDefinition startupOrderDefinition : startupOrderDefinitions) { - StartupOrderContext startupOrderContext = new StartupOrderContext(); - startupOrderContext.setStart(startupOrderDefinition.getStart()); - startupOrderContext.setAfter(startupOrderDefinition.getAfter()); - startupOrderContexts[i++] = startupOrderContext; - } - - return startupOrderContexts; - } - private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List groupDefinitions) { GroupContext[] groupContexts = new GroupContext[groupDefinitions.size()]; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd index 0b78f88ca8..83155e01da 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd @@ -213,7 +213,7 @@ - + @@ -247,17 +247,10 @@ - + - - - - - - - diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index f57808e235..b3906ac4cb 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,1581 +1,1569 @@ - + CloudControllerService - - - - - - - + + + + + + + - - - + + + - - - - - - - - + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - + + + + + + - + - + - + - + - + + + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + - - + + + + + - + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + + + - + - - + - + - - - - - - - - + + + - + - - + - + - - + + - + - - - - + + - + - - - - - - - - + + - + - - - - - - - - - - - - - - - - - + + + + + + + + - + - - + + + - + - - + + + + + + + + + + + + + + + + + - + - - - + + - - - - + + + + - + - - - + + + - - + + - - + + - + - - - - - - - - - - - - - - - - - - + + + + + + + + - + - - - - - - - - - - - + + + + - + - + + - + - - - + + + + + + + + + + + + + - - - - + - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - - - - - - + + + - - + + + + + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file From c3105c89c619ff8a85e339c64442974f4d062e5d Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 8 Oct 2014 15:33:59 +0530 Subject: [PATCH 153/436] add Http connection manager --- .../client/rest/DefaultRestClient.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index 64e25679f9..a6f0fb4072 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -29,11 +29,14 @@ import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; +import org.apache.http.conn.HttpClientConnectionManager; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.exception.RestClientException; @@ -46,6 +49,9 @@ public class DefaultRestClient implements RestClient { private static final String APPLICATION_JSON = "application/json"; + public static final int MAX_TOTAL_CONNECTIONS = 100; + public static final int DEFAULT_MAX_PER_ROUTE = 20; + private static Log log = LogFactory.getLog(DefaultRestClient.class); private HttpClient httpClient; @@ -65,7 +71,18 @@ public DefaultRestClient() throws RestClientException{ } catch (KeyStoreException e) { throw new RestClientException(e); } - this.httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build(); + CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslsf).setConnectionManager(getHttpConnectionManager()).build(); + this.httpClient = closableHttpClient; + } + + private HttpClientConnectionManager getHttpConnectionManager(){ + PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); + // TODO: Introduce configurable variable for Max total and max per router variables. + cm.setMaxTotal(MAX_TOTAL_CONNECTIONS); + cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE); + //HttpHost localhost = new HttpHost("locahost", 80); + //cm.setMaxPerRoute(new HttpRoute(localhost), 50); + return cm; } public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException { From d100cd0ee6ff6cdbd8f8a1eb44d0fee3deef3051 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 8 Oct 2014 21:05:13 +0530 Subject: [PATCH 154/436] refactoring Group and Application to a common super type 'ParentComponent' --- .../dependency/DependencyBuilder.java | 14 +- .../context/ApplicationContextFactory.java | 4 +- .../AutoscalerTopologyEventReceiver.java | 12 +- .../stratos/autoscaler/monitor/Monitor.java | 11 +- .../application/ApplicationMonitor.java | 2 +- .../status/checker/StatusChecker.java | 2 +- .../controller/topology/TopologyBuilder.java | 10 +- .../StratosManagerTopologyEventReceiver.java | 6 +- .../domain/topology/Application.java | 143 ++--------- .../messaging/domain/topology/Group.java | 114 +-------- .../domain/topology/ParentBehavior.java | 116 --------- .../domain/topology/ParentComponent.java | 222 ++++++++++++++++++ .../messaging/domain/topology/Topology.java | 4 +- .../topology/ApplicationCreatedEvent.java | 2 +- .../ApplicationCreatedMessageProcessor.java | 8 +- .../CompleteTopologyMessageProcessor.java | 2 +- 16 files changed, 281 insertions(+), 391 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 59b9bf8af3..a4f9b54da3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -53,20 +53,16 @@ public static DependencyBuilder getInstance() { * @param component it will give the necessary information to build the tree * @return the dependency tree out of the dependency orders */ - public DependencyTree buildDependency(ParentBehavior component) { - String alias = null; - if(component instanceof Application) { - alias = ((Application)component).getId(); - } else if(component instanceof Group) { - alias = ((Group) component).getAlias(); - } - DependencyTree dependencyTree = new DependencyTree(alias); + public DependencyTree buildDependency(ParentComponent component) { + + String identifier = component.getUniqueIdentifier(); + DependencyTree dependencyTree = new DependencyTree(identifier); DependencyOrder dependencyOrder = component.getDependencyOrder(); if (dependencyOrder != null) { if (log.isDebugEnabled()) { log.debug("Building dependency for the Application/Group " + - alias); + identifier); } //Parsing the kill behaviour diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java index 737a27d1b3..dfd8fa9367 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -19,7 +19,7 @@ package org.apache.stratos.autoscaler.grouping.dependency.context; import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; -import org.apache.stratos.messaging.domain.topology.ParentBehavior; +import org.apache.stratos.messaging.domain.topology.ParentComponent; /** * Factory to create new GroupContext or ClusterContext @@ -27,7 +27,7 @@ public class ApplicationContextFactory { public static ApplicationContext getApplicationContext(String startOrder, - ParentBehavior component, + ParentComponent component, DependencyTree dependencyTree) { String id; ApplicationContext applicationContext = null; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 4064510c55..d4616b2cc6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -120,7 +120,7 @@ protected void onEvent(Event event) { //acquire read lock //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForApplication(applicationCreatedEvent.getApplication().getId()); + TopologyManager.acquireReadLockForApplication(applicationCreatedEvent.getApplication().getUniqueIdentifier()); try { //start the application monitor @@ -129,7 +129,7 @@ protected void onEvent(Event event) { } finally { //release read lock - TopologyManager.releaseReadLockForApplication(applicationCreatedEvent.getApplication().getId()); + TopologyManager.releaseReadLockForApplication(applicationCreatedEvent.getApplication().getUniqueIdentifier()); //TopologyManager.releaseReadLock(); } @@ -582,7 +582,7 @@ public void terminate() { protected synchronized void startApplicationMonitor(Application application) { Thread th = null; if (!AutoscalerContext.getInstance() - .appMonitorExist(application.getId())) { + .appMonitorExist(application.getUniqueIdentifier())) { th = new Thread( new ApplicationMonitorAdder(application)); } @@ -596,7 +596,7 @@ protected synchronized void startApplicationMonitor(Application application) { if (log.isDebugEnabled()) { log.debug(String .format("Application monitor thread has been started successfully: " + - "[application] %s ", application.getId())); + "[application] %s ", application.getUniqueIdentifier())); } } } @@ -621,7 +621,7 @@ public void run() { long start = System.currentTimeMillis(); if(log.isDebugEnabled()) { log.debug("application monitor is going to be started for [application] " + - application.getId()); + application.getUniqueIdentifier()); } applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); long end = System.currentTimeMillis(); @@ -637,7 +637,7 @@ public void run() { if (applicationMonitor == null) { String msg = "Application monitor creation failed, even after retrying for 5 times, " - + "for Application: " + application.getId(); + + "for Application: " + application.getUniqueIdentifier(); log.error(msg); throw new RuntimeException(msg); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 05544067ba..57285830c2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -34,7 +34,6 @@ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.application.status.StatusEvent; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.*; @@ -58,11 +57,11 @@ public abstract class Monitor implements EventHandler { //The monitors dependency tree with all the startable/killable dependencies protected DependencyTree dependencyTree; //application/group reference from the Topology - protected ParentBehavior component; + protected ParentComponent component; //status of the monitor whether it is running/in_maintainable/terminated protected Status status; - public Monitor(ParentBehavior component) { + public Monitor(ParentComponent component) { aliasToGroupMonitorsMap = new HashMap(); clusterIdToClusterMonitorsMap = new HashMap(); //preOrderTraverse = new LinkedList(); @@ -165,7 +164,7 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } } - protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentBehavior component) { + protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentComponent component) { ScheduledExecutorService adder = Executors.newSingleThreadScheduledExecutor(); if (!this.aliasToGroupMonitorsMap.containsKey(dependency)) { @@ -294,9 +293,9 @@ public void run() { private class GroupMonitorAdder implements Runnable { private String dependency; private Monitor parent; - private ParentBehavior component; + private ParentComponent component; - public GroupMonitorAdder(Monitor parent, String dependency, ParentBehavior group) { + public GroupMonitorAdder(Monitor parent, String dependency, ParentComponent group) { this.dependency = dependency; this.parent = parent; this.component = group; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index a0f0a399fd..13967d2977 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -40,7 +40,7 @@ public class ApplicationMonitor extends Monitor { public ApplicationMonitor(Application application) { super(application); - this.id = application.getId(); + this.id = application.getUniqueIdentifier(); startDependency(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 7f179553e0..bb9c01699d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -157,7 +157,7 @@ public void run() { } private boolean updateChildStatus(String appId, String id, Map groups, - Map clusterData, ParentBehavior parent) { + Map clusterData, ParentComponent parent) { boolean groupActive = false; boolean clustersActive; boolean groupsActive; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 4aa70233e1..0913c0041f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -617,15 +617,15 @@ public static synchronized void handleApplicationDeployed(Application applicatio try { TopologyManager.acquireWriteLock(); - if (topology.applicationExists(application.getId())) { - log.warn("Application with id [ " + application.getId() + " ] already exists in Topology"); + if (topology.applicationExists(application.getUniqueIdentifier())) { + log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology"); return; } List clusters = new ArrayList(); for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName(), application.getId()); + applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); cluster.setStatus(Status.Created); cluster.addHostName(applicationClusterContext.getHostName()); cluster.setTenantRange(applicationClusterContext.getTenantRange()); @@ -634,7 +634,7 @@ public static synchronized void handleApplicationDeployed(Application applicatio Service service = topology.getService(applicationClusterContext.getCartridgeType()); if (service != null) { service.addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getId()); + log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier()); } else { log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); return; @@ -645,7 +645,7 @@ public static synchronized void handleApplicationDeployed(Application applicatio topology.addApplication(application); TopologyManager.updateTopology(topology); - log.info("Application with id [ " + application.getId() + " ] added to Topology successfully"); + log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully"); TopologyEventPublisher.sendApplicationCreatedEvent(application ,clusters); 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 index d61f474670..e7bc5a299e 100644 --- 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 @@ -319,13 +319,13 @@ protected void onEvent(Event event) { try { //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForApplication(appCreateEvent.getApplication().getId()); + TopologyManager.acquireReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier()); // create and persist Application subscritpion CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); ApplicationSubscription compositeAppSubscription; Application app = appCreateEvent.getApplication(); - String appId = app.getId(); + String appId = app.getUniqueIdentifier(); int tenantId = app.getTenantId(); String domain = app.getTenantDomain(); @@ -350,7 +350,7 @@ protected void onEvent(Event event) { } } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getId()); + TopologyManager.releaseReadLockForApplication(appCreateEvent.getApplication().getUniqueIdentifier()); } } }); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index dd7d6ea6fe..c30d5b712a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -27,7 +27,7 @@ * Represents an Application in the Topology */ -public class Application implements ParentBehavior { +public class Application extends ParentComponent { private static final long serialVersionUID = -5092959597171649688L; // Unique id for the Application, defined in Application Definition @@ -40,126 +40,14 @@ public class Application implements ParentBehavior { private String tenantDomain; // tenant admin user private String tenantAdminUserName; - // Dependency Order - private DependencyOrder dependencyOrder; - // Group Map, key = Group.alias - private Map aliasToGroupMap; - // Cluster Id map, key = subscription alias for the cartridge type - private Map aliasToClusterDataMap; - // Application status - private Status status; public Application (String id) { + super(); this.id = id; this.key = RandomStringUtils.randomAlphanumeric(16); - this.status = Status.Created; - aliasToGroupMap = new HashMap(); - aliasToClusterDataMap = new HashMap(); } - @Override - public void addGroup(Group group) { - aliasToGroupMap.put(group.getName(), group); - } - - @Override - public void setGroups(Map groupAliasToGroup) { - aliasToGroupMap.putAll(groupAliasToGroup); - } - - @Override - public Group getGroup(String groupAlias) { - return aliasToGroupMap.get(groupAlias); - } - - @Override - public Map getAliasToGroupMap() { - return this.aliasToGroupMap; - } - - @Override - public Map getClusterDataMap() { - return this.aliasToClusterDataMap; - } - - public Set getClusterDataRecursively () { - - Set appClusterData = new HashSet(); - - // get top level Cluster Data - if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) { - appClusterData.addAll(this.aliasToClusterDataMap.values()); - } - - // find other nested Cluster Data (in the Groups) - if (getGroups() != null) { - getClusterData(appClusterData, getGroups()); - } - - return appClusterData; - } - - private void getClusterData (Set clusterData, Collection groups) { - - for (Group group : groups) { - if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) { - clusterData.addAll(group.getClusterDataMap().values()); - if (group.getGroups() != null) { - getClusterData(clusterData, group.getGroups()); - } - } - } - } - - @Override - public Group getGroupRecursively(String groupAlias) { - - return travereAndCheckRecursively(aliasToGroupMap, groupAlias); - } - - private Group travereAndCheckRecursively (Map aliasToGroupMap, String groupAlias) { - - if (aliasToGroupMap.containsKey(groupAlias)) { - synchronized (aliasToGroupMap) { - if (aliasToGroupMap.containsKey(groupAlias)) { - return aliasToGroupMap.get(groupAlias); - } - } - } else { - for (Group group : aliasToGroupMap.values()) { - travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); - } - } - - return null; - } - - @Override - public Collection getGroups() { - return aliasToGroupMap.values(); - } - - @Override - public void setDependencyOrder(DependencyOrder dependencyOrder) { - this.dependencyOrder = dependencyOrder; - } - - @Override - public DependencyOrder getDependencyOrder() { - return dependencyOrder; - } - - @Override - public void setClusterData(Map aliasToClusterData) { - this.aliasToClusterDataMap.putAll(aliasToClusterData); - } - - @Override - public ClusterDataHolder getClusterData(String alias) { - return aliasToClusterDataMap.get(alias); - } - - public String getId() { + public String getUniqueIdentifier() { return id; } @@ -167,14 +55,6 @@ public String getKey() { return key; } - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - public int getTenantId() { return tenantId; } @@ -198,4 +78,21 @@ public String getTenantAdminUserName() { public void setTenantAdminUserName(String tenantAdminUserName) { this.tenantAdminUserName = tenantAdminUserName; } + + public boolean equals(Object other) { + if(other == null || !(other instanceof Application)) { + return false; + } + + if(this == other) { + return true; + } + + Application that = (Application)other; + return this.id.equals(that.id); + } + + public int hashCode () { + return id.hashCode(); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index cd849b69c3..17e1a90e60 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -19,13 +19,11 @@ package org.apache.stratos.messaging.domain.topology; -import java.util.*; - /** * Represents a Group/nested Group in an Application/Group */ -public class Group implements ParentBehavior { +public class Group extends ParentComponent { private static final long serialVersionUID = 8347096598203655846L; // Name of the Group, specified in Group Definition @@ -36,113 +34,14 @@ public class Group implements ParentBehavior { private String deploymentPolicy; // Group level autoscaling policy private String autoscalingPolicy; - // Dependency Order - private DependencyOrder dependencyOrder; - // Sub Group Map, key = Group.alias - private Map aliasToGroupMap; - // Cluster Id map, key = subscription alias for the cartridge type - private Map aliasToClusterDataMap; - // Group status - private Status status; public Group (String name, String alias) { + super(); this.name = name; this.alias = alias; - this.status = Status.Created; - aliasToGroupMap = new HashMap(); - aliasToClusterDataMap = new HashMap(); - } - - @Override - public void addGroup(Group group) { - aliasToGroupMap.put(group.name, group); - } - - @Override - public void setGroups(Map groupAliasToGroup) { - aliasToGroupMap.putAll(groupAliasToGroup); - } - - @Override - public Group getGroup(String groupAlias) { - return aliasToGroupMap.get(groupAlias); - } - - @Override - public Map getAliasToGroupMap() { - return this.aliasToGroupMap; - } - - @Override - public Map getClusterDataMap() { - return this.aliasToClusterDataMap; - } - - @Override - public Group getGroupRecursively(String groupAlias) { - - return travereAndCheckRecursively(aliasToGroupMap, groupAlias); } - private Group travereAndCheckRecursively (Map aliasToGroupMap, String groupAlias) { - - if (aliasToGroupMap.containsKey(groupAlias)) { - synchronized (aliasToGroupMap) { - if (aliasToGroupMap.containsKey(groupAlias)) { - return aliasToGroupMap.get(groupAlias); - } - } - } else { - for (Group group : aliasToGroupMap.values()) { - travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); - } - } - - return null; - } - - @Override - public Collection getGroups() { - return aliasToGroupMap.values(); - } - - @Override - public void setDependencyOrder(DependencyOrder dependencyOrder) { - this.dependencyOrder = dependencyOrder; - } - - @Override - public DependencyOrder getDependencyOrder() { - return dependencyOrder; - } - -// @Override -// public void addClusterId(String serviceName, String clusterId) { -// -// synchronized (serviceNameToClusterIdsMap) { -// if (serviceNameToClusterIdsMap.get(serviceName) == null) { -// // not found, create -// Set clusterIds = new HashSet(); -// clusterIds.add(clusterId); -// serviceNameToClusterIdsMap.put(serviceName, clusterIds); -// } else { -// // the cluster id set already exists, update -// serviceNameToClusterIdsMap.get(serviceName).add(clusterId); -// } -// } -// } - - @Override - public void setClusterData(Map aliasToClusterData) { - this.aliasToClusterDataMap.putAll(aliasToClusterData); - } - - @Override - public ClusterDataHolder getClusterData(String alias) { - return aliasToClusterDataMap.get(alias); - } - - public String getName() { + public String getUniqueIdentifier() { return name; } @@ -183,11 +82,4 @@ public int hashCode () { return name.hashCode() + alias.hashCode(); } - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.java deleted file mode 100644 index 5fbdf0c0fa..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentBehavior.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.messaging.domain.topology; - -import java.io.Serializable; -import java.util.Collection; -import java.util.Map; - -/** - * Abstraction for a an entity that can have child entities - * in an Application withing the Topology - */ - -public interface ParentBehavior extends Serializable { - - /** - * Adds a group - * - * @param group Group instance to be added - */ - public void addGroup (Group group); - - /** - * Setter for Group alias to Group map - * - * @param groupAliasToGroup Map, key = alias given to the Group, value = Group - */ - public void setGroups (Map groupAliasToGroup); - - /** - * Get the Group for the given alias in the context of the parent entity. - * Will not search recursively in the nested levels. - * - * @param groupAlias alias of the Group - * @return Group, if exists for the given alias, else null - */ - public Group getGroup (String groupAlias); - - /** - * Get the Group for the given alias in the context of the parent entity. - * Will search recursively in the nested levels. - * - * @param groupAlias alias of the Group - * @return Group, if exists for the given alias, else null - */ - public Group getGroupRecursively (String groupAlias); - - /** - * Getter for alias to Group map - * Will not search recursively in the nested levels. - * - * @return Map, key = alias given to the Group, value = Group - */ - public Map getAliasToGroupMap(); - - /** - * Getter for cluster alias to ClusterData map for this level - * - * @return Map, key = alias given to the cluster, value = ClusterData object - */ - public Map getClusterDataMap(); - - /** - * Collection of Groups in this level - * - * @return Group Collection object, empty if no Groups are found - */ - public Collection getGroups (); - - /** - * Setter for Dependency Order - * - * @param dependencyOrder Dependency Order object - */ - public void setDependencyOrder (DependencyOrder dependencyOrder); - - /** - * Getter for Dependency Order for this level - * - * @return Dependency Order object - */ - public DependencyOrder getDependencyOrder (); - - /** - * Setter for alias to Cluster Data map - * - * @param aliasToClusterData Map, key = alias given to the cluster, value = ClusterData object - */ - public void setClusterData (Map aliasToClusterData); - - /** - * Getter for Cluster Data instance for the given alias - * Will not search recursively in the nested levels. - * - * @param alias - * @return - */ - public ClusterDataHolder getClusterData (String alias); -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java new file mode 100644 index 0000000000..d76663ca60 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java @@ -0,0 +1,222 @@ +/* + * 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.messaging.domain.topology; + +import java.io.Serializable; +import java.util.*; + +/** + * Abstraction for a an entity that can have child entities + * in an Application withing the Topology + */ + +public abstract class ParentComponent implements Serializable { + + // Dependency Order + private DependencyOrder dependencyOrder; + // Group Map, key = Group.alias + private Map aliasToGroupMap; + // Cluster Id map, key = subscription alias for the cartridge type + private Map aliasToClusterDataMap; + // Application status + private Status status; + + public ParentComponent () { + this.status = Status.Created; + aliasToGroupMap = new HashMap(); + aliasToClusterDataMap = new HashMap(); + } + + /** + * This method should be implemented in each concrete child class + * to return the unique identifier for each implementation + * ex.: group alias for a Group, app id for an Application + * + * @return unique identifier String + */ + public abstract String getUniqueIdentifier (); + + /** + * Adds a group + * + * @param group Group instance to be added + */ + public void addGroup(Group group) { + aliasToGroupMap.put(group.getUniqueIdentifier(), group); + } + + /** + * Setter for Group alias to Group map + * + * @param groupAliasToGroup Map, key = alias given to the Group, value = Group + */ + public void setGroups(Map groupAliasToGroup) { + aliasToGroupMap.putAll(groupAliasToGroup); + } + + /** + * Get the Group for the given alias in the context of the parent entity. + * Will not search recursively in the nested levels. + * + * @param groupAlias alias of the Group + * @return Group, if exists for the given alias, else null + */ + public Group getGroup(String groupAlias) { + return aliasToGroupMap.get(groupAlias); + } + + /** + * Get the Group for the given alias in the context of the parent entity. + * Will search recursively in the nested levels. + * + * @param groupAlias alias of the Group + * @return Group, if exists for the given alias, else null + */ + public Group getGroupRecursively(String groupAlias) { + + return travereAndCheckRecursively(aliasToGroupMap, groupAlias); + } + + private Group travereAndCheckRecursively (Map aliasToGroupMap, String groupAlias) { + + if (aliasToGroupMap.containsKey(groupAlias)) { + synchronized (aliasToGroupMap) { + if (aliasToGroupMap.containsKey(groupAlias)) { + return aliasToGroupMap.get(groupAlias); + } + } + } else { + for (Group group : aliasToGroupMap.values()) { + travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); + } + } + + return null; + } + + /** + * Getter for alias to Group map + * Will not search recursively in the nested levels. + * + * @return Map, key = alias given to the Group, value = Group + */ + public Map getAliasToGroupMap() { + return this.aliasToGroupMap; + } + + /** + * Getter for cluster alias to ClusterData map for this level + * + * @return Map, key = alias given to the cluster, value = ClusterData object + */ + public Map getClusterDataMap() { + return this.aliasToClusterDataMap; + } + + /** + * Collection of Groups in this level + * + * @return Group Collection object, empty if no Groups are found + */ + public Collection getGroups() { + return aliasToGroupMap.values(); + } + + /** + * Setter for Dependency Order + * + * @param dependencyOrder Dependency Order object + */ + public void setDependencyOrder(DependencyOrder dependencyOrder) { + this.dependencyOrder = dependencyOrder; + } + + /** + * Getter for Dependency Order for this level + * + * @return Dependency Order object + */ + public DependencyOrder getDependencyOrder() { + return dependencyOrder; + } + + /** + * Setter for alias to Cluster Data map + * + * @param aliasToClusterData Map, key = alias given to the cluster, value = ClusterData object + */ + public void setClusterData(Map aliasToClusterData) { + this.aliasToClusterDataMap.putAll(aliasToClusterData); + } + + /** + * Getter for Cluster Data instance for the given alias + * Will not search recursively in the nested levels. + * + * @param alias + * @return + */ + public ClusterDataHolder getClusterData(String alias) { + return aliasToClusterDataMap.get(alias); + } + + /** + * Collects the Cluster Data for the parent component and all the + * child components recursively + * + * @return Set of ClusterDataHolder objects if available, else null + */ + public Set getClusterDataRecursively () { + + Set appClusterData = new HashSet(); + + // get top level Cluster Data + if (this.aliasToClusterDataMap != null && !this.aliasToClusterDataMap.isEmpty()) { + appClusterData.addAll(this.aliasToClusterDataMap.values()); + } + + // find other nested Cluster Data (in the Groups) + if (getGroups() != null) { + getClusterData(appClusterData, getGroups()); + } + + return appClusterData; + } + + private void getClusterData (Set clusterData, Collection groups) { + + for (Group group : groups) { + if (group.getClusterDataMap() != null && !group.getClusterDataMap().isEmpty()) { + clusterData.addAll(group.getClusterDataMap().values()); + if (group.getGroups() != null) { + getClusterData(clusterData, group.getGroups()); + } + } + } + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index dabf611b47..76d73fe2e8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -53,8 +53,8 @@ public Topology() { } public void addApplication (Application application) { - this.applicationMap.put(application.getId(), application); - TopologyLockHierarchy.getInstance().addApplicationLock(application.getId(), new TopologyLock()); + this.applicationMap.put(application.getUniqueIdentifier(), application); + TopologyLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(), new TopologyLock()); } public Application getApplication (String applicationId) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index a36e65f8e4..23f115fd6e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -40,7 +40,7 @@ public Application getApplication() { } public String toString() { - return "ApplicationCreatedEvent [app id= " + application.getId() + ", groups= " + application.getGroups() + ", clusters= " + + return "ApplicationCreatedEvent [app id= " + application.getUniqueIdentifier() + ", groups= " + application.getGroups() + ", clusters= " + application.getClusterDataMap().values() + "]"; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 587d6f3fe5..34ed3ef1ce 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -96,15 +96,15 @@ private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { throw new RuntimeException(errorMsg); } - if (event.getApplication().getId() == null || event.getApplication().getId().isEmpty()) { - String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getId() + " ]"; + if (event.getApplication().getUniqueIdentifier() == null || event.getApplication().getUniqueIdentifier().isEmpty()) { + String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getUniqueIdentifier() + " ]"; log.error(errorMsg); throw new RuntimeException(errorMsg); } // check if an Application with same name exists in topology - if (topology.applicationExists(event.getApplication().getId())) { - log.warn("Application with id [ " + event.getApplication().getId() + " ] already exists in Topology"); + if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) { + log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology"); } else { // add application and the clusters to Topology diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 6d5cb8f6aa..74daa48b30 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -147,7 +147,7 @@ private boolean doProcess (CompleteTopologyEvent event, Topology topology) { for (Application application : applications) { topology.addApplication(application); if (log.isDebugEnabled()) { - log.debug("Application with id [ " + application.getId() + " ] added to Topology"); + log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology"); } } } else { From e8465eb0c15e868f80af7c40e0625e4df35fd08a Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 8 Oct 2014 21:19:06 +0530 Subject: [PATCH 155/436] running messaging threads concurrently --- components/org.apache.stratos.messaging/pom.xml | 13 ++++++++----- .../topology/locking/TopologyLockingTest.java | 10 ++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.messaging/pom.xml b/components/org.apache.stratos.messaging/pom.xml index b2d851b3c1..4ff4cb8d55 100644 --- a/components/org.apache.stratos.messaging/pom.xml +++ b/components/org.apache.stratos.messaging/pom.xml @@ -78,15 +78,18 @@ - + methods + 15 - + org.apache.felix maven-scr-plugin diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index 5d33904724..e82699c2a6 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -26,8 +26,6 @@ import java.util.HashMap; import java.util.Map; -//@RunWith(ConcurrentRunner.class) -//@Concurrent(threads = 12) public class TopologyLockingTest { private static Topology topology; @@ -159,8 +157,8 @@ public void testAqcuireAndReleaseWriteLocksForClustersOfService1 () { TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); - TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); - TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); + TopologyManager.releaseWriteLockForCluster("service1", "service1.cluster1.domain"); + TopologyManager.releaseWriteLockForCluster("service1", "service1.cluster2.domain"); } @Test @@ -169,8 +167,8 @@ public void testAqcuireAndReleaseWriteLocksForClustersOfService2 () { TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); - TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); - TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); + TopologyManager.releaseWriteLockForCluster("service2", "service2.cluster1.domain"); + TopologyManager.releaseWriteLockForCluster("service2", "service2.cluster2.domain"); } @Test From cb67a8096220a4cc0a57344c64ed34956169dc0d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 8 Oct 2014 22:08:42 +0530 Subject: [PATCH 156/436] setting timeout of test methods to 10 seconds --- .../topology/locking/TopologyLockingTest.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index e82699c2a6..88b47f9841 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -91,7 +91,7 @@ public static void setUpBeforeClass() { topology.addApplication(app2); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseReadLocksForServices1To2 () { TopologyManager.acquireReadLockForService("service1"); @@ -101,7 +101,7 @@ public void testAqcuireAndReleaseReadLocksForServices1To2 () { TopologyManager.releaseReadLockForService("service2"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseReadLocksForServices3To4 () { TopologyManager.acquireReadLockForService("service3"); @@ -111,7 +111,7 @@ public void testAqcuireAndReleaseReadLocksForServices3To4 () { TopologyManager.releaseReadLockForService("service4"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForServices1To2 () { TopologyManager.acquireWriteLockForService("service1"); @@ -121,7 +121,7 @@ public void testAqcuireAndReleaseWriteLocksForServices1To2 () { TopologyManager.releaseWriteLockForService("service2"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForServices3To4 () { TopologyManager.acquireWriteLockForService("service3"); @@ -131,7 +131,7 @@ public void testAqcuireAndReleaseWriteLocksForServices3To4 () { TopologyManager.releaseWriteLockForService("service4"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseReadLocksForClustersOfService1 () { TopologyManager.acquireReadLockForCluster("service1", "service1.cluster1.domain"); @@ -141,7 +141,7 @@ public void testAqcuireAndReleaseReadLocksForClustersOfService1 () { TopologyManager.releaseReadLockForCluster("service1", "service1.cluster2.domain"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseReadLocksForClustersOfService2 () { TopologyManager.acquireReadLockForCluster("service2", "service2.cluster1.domain"); @@ -151,7 +151,7 @@ public void testAqcuireAndReleaseReadLocksForClustersOfService2 () { TopologyManager.releaseReadLockForCluster("service2", "service2.cluster2.domain"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForClustersOfService1 () { TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); @@ -161,7 +161,7 @@ public void testAqcuireAndReleaseWriteLocksForClustersOfService1 () { TopologyManager.releaseWriteLockForCluster("service1", "service1.cluster2.domain"); } - @Test + @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForClustersOfService2 () { TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); @@ -171,14 +171,14 @@ public void testAqcuireAndReleaseWriteLocksForClustersOfService2 () { TopologyManager.releaseWriteLockForCluster("service2", "service2.cluster2.domain"); } - @Test + @Test(timeout=10000) public void testAcquireAndReleaseReadLockForApp1 () { TopologyManager.acquireReadLockForApplication("app1"); TopologyManager.releaseReadLockForApplication("app1"); } - @Test + @Test(timeout=10000) public void testAcquireAndReleaseWriteLockForApp1 () { TopologyManager.acquireWriteLockForApplication("app1"); @@ -192,7 +192,7 @@ public void testAcquireAndReleaseReadLockForApp2 () { TopologyManager.releaseReadLockForApplication("app2"); } - @Test + @Test(timeout=10000) public void testAcquireAndReleaseWriteLockForApp2 () { TopologyManager.acquireWriteLockForApplication("app2"); From cff0ace658e805738b939289b2bb1d95afb83463 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Wed, 8 Oct 2014 17:50:22 -0700 Subject: [PATCH 157/436] startupOrder format change II --- .../dependency/DependencyBuilder.java | 44 +++++------- .../parser/DefaultApplicationParser.java | 70 +++++-------------- .../application/parser/ParserUtils.java | 2 + .../cloud/controller/pojo/StartupOrder.java | 3 + .../deployer/DefaultServiceGroupDeployer.java | 1 - .../domain/topology/DependencyOrder.java | 39 +++++++---- .../domain/topology/StartupOrder.java | 3 + 7 files changed, 65 insertions(+), 97 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index a4f9b54da3..7c087ec3c4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -81,43 +81,31 @@ public DependencyTree buildDependency(ParentComponent component) { } //Parsing the start up order - Set startupOrderSet = dependencyOrder.getStartupOrders(); - ApplicationContext foundContext = null; - for (StartupOrder startupOrder : startupOrderSet) { + String [] startupOrders = dependencyOrder.getStartupOrders(); + ApplicationContext foundContext = null; + if (startupOrders == null) { + if (log.isDebugEnabled()) { + log.debug("startupOrders is null, returning default dependency tree (empty)"); + } + + return dependencyTree; + } + for (String startupOrder : startupOrders) { + String start = dependencyOrder.getStartStartupOrder(startupOrder); foundContext = null; - for (String start : startupOrder.getStartList()) { + + if (start != null) { ApplicationContext applicationContext = ApplicationContextFactory. getApplicationContext(start, component, dependencyTree); String id = applicationContext.getId(); //TODO change the id + + ApplicationContext existingApplicationContext = dependencyTree.findApplicationContextWithId(id); - if (existingApplicationContext == null) { - if (foundContext != null) { - //appending the start up order to existing group/cluster - foundContext.addApplicationContext(applicationContext); - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + foundContext.getId() + - " and adding the [dependency] " + id + " as the child"); - } - } else { + if (existingApplicationContext == null) { //adding list of startup order to the dependency tree dependencyTree.addApplicationContext(applicationContext); - } - } else { - if (foundContext == null) { - //assigning the found context to the later use. - foundContext = existingApplicationContext; - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + id + " and setting it " + - "for the next dependency to follow"); - } - } else { - //TODO Throw exception, since another same start order already found - log.warn("Startup order is not consistent. It contains the group/cluster " + - "which has been used more than one in another startup order"); - } - } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index d01674d2d2..efeccd7d90 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -268,9 +268,17 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, // get top level Dependency definitions if (appCtxt.getComponents().getDependencyContext() != null) { DependencyOrder appDependencyOrder = new DependencyOrder(); - Set startupOrders = getStartupOrderForApplicationComponents(appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts()); + String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts(); if (startupOrders != null) { + if (log.isDebugEnabled()) { + log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + + appCtxt.getAlias() + " #: " + startupOrders.length); + } appDependencyOrder.setStartupOrders(startupOrders); + } else { + if (log.isDebugEnabled()) { + log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias()); + } } appDependencyOrder.setKillbehavior(appCtxt.getComponents().getDependencyContext().getKillBehaviour()); @@ -391,7 +399,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); DependencyOrder dependencyOrder = new DependencyOrder(); // create the Dependency Ordering - Set startupOrders = getStartupOrderForGroup(groupCtxt); + String [] startupOrders = getStartupOrderForGroup(groupCtxt); if (startupOrders != null) { dependencyOrder.setStartupOrders(startupOrders); } @@ -434,7 +442,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g * * @throws ApplicationDefinitionException */ - private Set getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { + private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(groupContext.getName()); @@ -448,23 +456,14 @@ private Set getStartupOrderForGroup(GroupContext groupContext) thr assert serviceGroup != null; if (serviceGroup.getDependencies() != null) { + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " ); + } if (serviceGroup.getDependencies().getStartupOrders() != null) { - Set startupOrders = new HashSet(); - String [] st = serviceGroup.getDependencies().getStartupOrders(); - + String [] startupOrders = serviceGroup.getDependencies().getStartupOrders(); if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForGroup # of startupOrders: " + st.length); - } - - for (String startupOrderContext : st) { - - String [] order = startupOrderContext.split(","); - - startupOrders.add(new StartupOrder(order[0], order[1])); - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForGroup startupOrders:start: " + order[0] + " after: " + order[1]); - } + log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " + startupOrders.length); } return startupOrders; } @@ -473,43 +472,6 @@ private Set getStartupOrderForGroup(GroupContext groupContext) thr return null; } - /** - * Find the startup order for an Application - * - * @param startupOrderCtxts Startup Order information related to the Application - * @return Set of Startup Orders - * - * @throws ApplicationDefinitionException if an error occurs - */ - private Set getStartupOrderForApplicationComponents (String [] startupOrdersCtxts) - throws ApplicationDefinitionException { - - if (startupOrdersCtxts == null) { - return null; - } - - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForApplicationComponents: # of: " + startupOrdersCtxts.length); - } - - Set startupOrders = new HashSet(); - - /* - for (StartupOrderContext startupOrderContext : startupOrderCtxts) { - startupOrders.add(new StartupOrder(startupOrderContext.getStart(), startupOrderContext.getAfter())); - } - */ - for (String startupOrderContext : startupOrdersCtxts) { - String [] order = startupOrderContext.split(","); - startupOrders.add(new StartupOrder(order[0], order[1])); - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForApplicationComponents: start: " + order[0] + " /after: " + order[1]); - } - } - - return startupOrders; - } - /** * Get kill behaviour related to a Group * diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index f47970c7f1..707fd0a80b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -28,6 +28,7 @@ public class ParserUtils { + /* public static Set convert (org.apache.stratos.cloud.controller.pojo.StartupOrder [] startupOrderArr, GroupContext groupContext) { Set startupOrders = new HashSet(); @@ -108,6 +109,7 @@ private static String getAliasForGroupName (String groupName, GroupContext group return null; } +*/ private static String getAliasForServiceType (String serviceType, GroupContext groupContext) { for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java index 0f1c64719d..ed9626b900 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java @@ -24,6 +24,8 @@ public class StartupOrder implements Serializable { private static final long serialVersionUID = 280860334002791396L; + + /* private String start; @@ -44,4 +46,5 @@ public String getAfter() { public void setAfter(String after) { this.after = after; } + */ } 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 index f4d42f63e9..8885ebd2a0 100644 --- 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 @@ -28,7 +28,6 @@ import org.apache.stratos.manager.exception.ServiceGroupDefinitioException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; -import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.pojo.Dependencies; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java index 5fb694ae2a..ff08a4c7a2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -25,24 +25,17 @@ public class DependencyOrder implements Serializable { - private Set startupOrders; + /** + * + */ + private static final long serialVersionUID = -599600831844477527L; + + private String [] startupOrders; private String killbehavior; public DependencyOrder () { - this.startupOrders = new HashSet(); - } - - public void setStartupOrders (Set startupOrders) { - this.startupOrders.addAll(startupOrders); - } - - public Set getStartupOrders() { - return startupOrders; - } - - public void addStartupOrders(StartupOrder startupOrder) { - this.startupOrders.add(startupOrder); + this.setStartupOrders(null); } public String getKillbehavior() { @@ -52,4 +45,22 @@ public String getKillbehavior() { public void setKillbehavior(String killbehavior) { this.killbehavior = killbehavior; } + + public String [] getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(String [] startupOrders) { + this.startupOrders = startupOrders; + } + + public String getStartStartupOrder(String startupOrder) { + String [] splitStartupOrder = startupOrder.split(","); + return splitStartupOrder[0]; + } + + public String getAfterStartupOrder(String startupOrder) { + String [] splitStartupOrder = startupOrder.split(","); + return splitStartupOrder[1]; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java index 220380e862..6263070a48 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java @@ -23,6 +23,8 @@ import java.util.List; public class StartupOrder implements Serializable { + + /* private String start; @@ -50,4 +52,5 @@ public List getStartList() { public void setStartList(List startList) { this.startList = startList; } + */ } From bdca0f2521b384a4daa6430aba1368b27510c5aa Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 10:19:57 +0530 Subject: [PATCH 158/436] removing synchronization in releaseWriteLockForApplication and acquireWriteLockForApplication --- .../messaging/message/receiver/topology/TopologyManager.java | 4 ++-- .../messaging/topology/locking/TopologyLockingTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index e86d9dfc23..e39351f4e2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -464,7 +464,7 @@ public static void releaseReadLockForApplication (String appId) { * * @param appId Application id */ - public static synchronized void acquireWriteLockForApplication (String appId) { + public static void acquireWriteLockForApplication (String appId) { // acquire read lock for all Applications acquireReadLockForApplications(); @@ -487,7 +487,7 @@ public static synchronized void acquireWriteLockForApplication (String appId) { * * @param appId Application id */ - public static synchronized void releaseWriteLockForApplication (String appId) { + public static void releaseWriteLockForApplication (String appId) { TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); if (topologyAppLock == null) { diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index 88b47f9841..cde7b4791f 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -185,7 +185,7 @@ public void testAcquireAndReleaseWriteLockForApp1 () { TopologyManager.releaseWriteLockForApplication("app1"); } - @Test + @Test(timeout=10000) public void testAcquireAndReleaseReadLockForApp2 () { TopologyManager.acquireReadLockForApplication("app2"); From 81428ba2d5e38ec7230ebd692923e9fdb9f48bff Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 9 Oct 2014 10:21:25 +0530 Subject: [PATCH 159/436] adding exception and fixing monitor startup issues --- .../exception/DependencyBuilderException.java | 48 +++++++++++++ .../TopologyInConsistentException.java | 47 +++++++++++++ .../dependency/DependencyBuilder.java | 51 ++------------ .../AutoscalerTopologyEventReceiver.java | 61 ++++++++-------- .../stratos/autoscaler/monitor/Monitor.java | 44 +++++++----- .../application/ApplicationMonitor.java | 38 +++++----- .../monitor/group/GroupMonitor.java | 70 +++++++++++-------- .../autoscaler/util/AutoscalerUtil.java | 12 +++- 8 files changed, 226 insertions(+), 145 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/DependencyBuilderException.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/TopologyInConsistentException.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/DependencyBuilderException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/DependencyBuilderException.java new file mode 100644 index 0000000000..cb535cc004 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/DependencyBuilderException.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.autoscaler.exception; + +/** + * This will use to throw any exception when building dependencies + */ +public class DependencyBuilderException extends Exception { + + private static final long serialVersionUID = -7521673271244696906L; + private String message; + + public DependencyBuilderException(String message, Exception exception){ + super(message, exception); + this.message = message; + } + + + public DependencyBuilderException(Exception exception){ + super(exception); + } + + public DependencyBuilderException(String msg){ + super(msg); + this.message = msg; + } + + @Override + public String getMessage() { + return this.message; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/TopologyInConsistentException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/TopologyInConsistentException.java new file mode 100644 index 0000000000..ab2d32d2fd --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/TopologyInConsistentException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.autoscaler.exception; + +/** + * This will use to throw when Topology in consistency found. + */ +public class TopologyInConsistentException extends Exception { + private static final long serialVersionUID = -7521673271244696906L; + private String message; + + public TopologyInConsistentException(String message, Exception exception){ + super(message, exception); + this.message = message; + } + + + public TopologyInConsistentException(Exception exception){ + super(exception); + } + + public TopologyInConsistentException(String msg){ + super(msg); + this.message = msg; + } + + @Override + public String getMessage() { + return this.message; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 59b9bf8af3..cf8004ede4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.*; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; @@ -53,7 +54,7 @@ public static DependencyBuilder getInstance() { * @param component it will give the necessary information to build the tree * @return the dependency tree out of the dependency orders */ - public DependencyTree buildDependency(ParentBehavior component) { + public DependencyTree buildDependency(ParentBehavior component) throws DependencyBuilderException { String alias = null; if(component instanceof Application) { alias = ((Application)component).getId(); @@ -117,9 +118,9 @@ public DependencyTree buildDependency(ParentBehavior component) { "for the next dependency to follow"); } } else { - //TODO Throw exception, since another same start order already found - log.warn("Startup order is not consistent. It contains the group/cluster " + - "which has been used more than one in another startup order"); + String msg = "Startup order is not consistent. It contains the group/cluster " + + "which has been used more than one in another startup order"; + throw new DependencyBuilderException(msg); } } @@ -149,46 +150,4 @@ public DependencyTree buildDependency(ParentBehavior component) { } return dependencyTree; } - - /*public static Queue getStartupOrder(ParentBehavior component) { - - - Queue startup = new LinkedList(); - DependencyOrder dependencyOrder = component.getDependencyOrder(); - if (dependencyOrder != null) { - Set startupOrderSet = dependencyOrder.getStartupOrders(); - for (StartupOrder startupOrder : startupOrderSet) { - - String start = startupOrder.getStart(); - String after = startupOrder.getAfter(); - - if (!startup.contains(start)) { - startup.add(start); - if (!startup.contains(after)) { - startup.add(after); - - } else { - //TODO throw exception since after is there before start - } - } else { - if (!startup.contains(after)) { - startup.add(after); - } else { - //TODO throw exception since start and after already there - } - } - } - } - //TODO adding all the missed groups or clusters as the top child to the list - //TODO handle by application and group itself groupName and serviceName - - if (component instanceof Application) { - - } else if (component instanceof Group) { - - } - return startup; - - }*/ - } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 3e1bfe2c58..9098a048fa 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -24,7 +24,9 @@ import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TerminationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; @@ -92,8 +94,8 @@ private void addEventListeners() { protected void onEvent(Event event) { try { TopologyManager.acquireReadLock(); - if(!topologyInitialized) { - topologyInitialized = true; + if (!topologyInitialized) { + topologyInitialized = true; for (Application application : TopologyManager.getTopology().getApplications()) { startApplicationMonitor(application); } @@ -187,7 +189,6 @@ protected void onEvent(Event event) { }); - topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override protected void onEvent(Event event) { @@ -203,10 +204,10 @@ protected void onEvent(Event event) { //TODO remove monitors as well as any starting or pending threads ApplicationMonitor monitor = AutoscalerContext.getInstance(). getAppMonitor(applicationRemovedEvent.getApplicationId()); - if(monitor != null) { + if (monitor != null) { List clusters = monitor. findClustersOfApplication(applicationRemovedEvent.getApplicationId()); - for(String clusterId: clusters) { + for (String clusterId : clusters) { //stopping the cluster monitor and remove it from the AS AutoscalerContext.getInstance().getMonitor(clusterId).setDestroyed(true); AutoscalerContext.getInstance().removeMonitor(clusterId); @@ -233,7 +234,7 @@ protected void onEvent(Event event) { protected void onEvent(Event event) { try { MemberReadyToShutdownEvent memberReadyToShutdownEvent = - (MemberReadyToShutdownEvent) event; + (MemberReadyToShutdownEvent) event; AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; String clusterId = memberReadyToShutdownEvent.getClusterId(); @@ -253,7 +254,7 @@ protected void onEvent(Event event) { NetworkPartitionContext nwPartitionCtxt; nwPartitionCtxt = monitor.getNetworkPartitionCtxt( - memberReadyToShutdownEvent.getNetworkPartitionId()); + memberReadyToShutdownEvent.getNetworkPartitionId()); // start a new member in the same Partition String partitionId = monitor.getPartitionOfMember(memberId); @@ -291,11 +292,11 @@ protected void onEvent(Event event) { Cluster cluster = service.getCluster(e.getClusterId()); if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getMonitor(e.getClusterId()). - setStatus(e.getStatus()); + setStatus(e.getStatus()); } else if (AutoscalerContext.getInstance(). - lbMonitorExist((cluster.getClusterId()))) { + lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(e.getClusterId()). - setStatus(e.getStatus()); + setStatus(e.getStatus()); } else { log.error("cluster monitor not exists for the cluster: " + cluster.toString()); } @@ -323,7 +324,7 @@ protected void onEvent(Event event) { if (e.isLbCluster()) { DeploymentPolicy depPolicy = PolicyManager.getInstance(). - getDeploymentPolicy(deploymentPolicy); + getDeploymentPolicy(deploymentPolicy); if (depPolicy != null) { List lbHolders = PartitionManager.getInstance() .getNetworkPartitionLbHolders(depPolicy); @@ -396,10 +397,10 @@ protected void onEvent(Event event) { } NetworkPartitionContext networkPartitionContext = monitor. - getNetworkPartitionCtxt(networkPartitionId); + getNetworkPartitionCtxt(networkPartitionId); PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); + getPartitionCtxt(partitionId); String memberId = e.getMemberId(); partitionContext.removeMemberStatsContext(memberId); @@ -471,7 +472,7 @@ protected void onEvent(Event event) { if (log.isInfoEnabled()) { log.info(String.format("Member stat context has been added " + - "successfully: [member] %s", memberId)); + "successfully: [member] %s", memberId)); } // partitionContext.incrementCurrentActiveMemberCount(1); partitionContext.movePendingMemberToActiveMembers(memberId); @@ -505,16 +506,16 @@ protected void onEvent(Event event) { if (AutoscalerContext.getInstance().monitorExist(clusterId)) { monitor = AutoscalerContext.getInstance().getMonitor(clusterId); partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). - getPartitionCtxt(partitionId); + getPartitionCtxt(partitionId); } else { monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). - getPartitionCtxt(partitionId); + getPartitionCtxt(partitionId); } partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isDebugEnabled()) { log.debug(String.format("Member has been moved as pending termination: " + - "[member] %s", memberId)); + "[member] %s", memberId)); } partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); @@ -553,7 +554,7 @@ protected synchronized void startApplicationMonitor(Application application) { if (log.isDebugEnabled()) { log.debug(String .format("Application monitor thread has been started successfully: " + - "[application] %s ", application.getId())); + "[application] %s ", application.getId())); } } } @@ -569,23 +570,28 @@ public void run() { ApplicationMonitor applicationMonitor = null; int retries = 5; boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } try { long start = System.currentTimeMillis(); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("application monitor is going to be started for [application] " + application.getId()); } applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); + long end = System.currentTimeMillis(); - log.info("Time taken to start Napp monitor: " + (end - start)/1000); + log.info("Time taken to start Napp monitor: " + (end - start) / 1000); success = true; //TODO exception handling - } catch (Exception e) { + } catch (DependencyBuilderException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { String msg = "Application monitor creation failed for Application: "; log.warn(msg, e); retries--; @@ -600,11 +606,10 @@ public void run() { } AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); - //TODO should start the appMonitor if (log.isInfoEnabled()) { log.info(String.format("Application monitor has been added successfully: " + - "[application] %s", applicationMonitor.getId())); + "[application] %s", applicationMonitor.getId())); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 05544067ba..bdf2099784 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -21,8 +21,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; @@ -62,16 +64,17 @@ public abstract class Monitor implements EventHandler { //status of the monitor whether it is running/in_maintainable/terminated protected Status status; - public Monitor(ParentBehavior component) { + public Monitor(ParentBehavior component) throws DependencyBuilderException { aliasToGroupMonitorsMap = new HashMap(); clusterIdToClusterMonitorsMap = new HashMap(); - //preOrderTraverse = new LinkedList(); this.component = component; + //Building the dependency for this monitor within the immediate children dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } /** - * + * Will monitor the immediate children upon any event triggers from parent/children + * @param statusEvent will be sent by parent/children with the current status */ protected abstract void monitor(MonitorStatusEvent statusEvent); @@ -81,7 +84,7 @@ public Monitor(ParentBehavior component) { * it will get invoked when the monitor starts up only. * //TODO restarting the whole group */ - public void startDependency() { + public void startDependency() throws TopologyInConsistentException { //start the first dependency List applicationContexts = this.dependencyTree.getStarAbleDependencies(); startDependency(applicationContexts); @@ -93,9 +96,9 @@ public void startDependency() { * * @param id alias/clusterId of which receive the activated event */ - public void startDependency(String id) { + public boolean startDependency(String id) throws TopologyInConsistentException { List applicationContexts = this.dependencyTree.getStarAbleDependencies(id); - startDependency(applicationContexts); + return startDependency(applicationContexts); } /** @@ -103,10 +106,13 @@ public void startDependency(String id) { * * @param applicationContexts the found applicationContexts to be started */ - private void startDependency(List applicationContexts) { + private boolean startDependency(List applicationContexts) + throws TopologyInConsistentException{ if (applicationContexts == null) { //all the groups/clusters have been started and waiting for activation - log.warn("There is no child found for the [group]: " + this.id); + log.info("There is no child found for the [group]: " + this.id); + return false; + } for (ApplicationContext context : applicationContexts) { if (log.isDebugEnabled()) { @@ -130,15 +136,19 @@ private void startDependency(List applicationContexts) { } startClusterMonitor(this, cluster); } else { - log.warn("[Cluster] " + clusterId + " cannot be found in the " + - "Topology for [service] " + serviceName); + String msg = "[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName; + throw new TopologyInConsistentException(msg); } } else { - log.warn("[Service] " + serviceName + " cannot be found in the Topology"); + String msg = "[Service] " + serviceName + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } //TopologyManager.releaseReadLock(); } } + return true; } @@ -321,13 +331,14 @@ public void run() { monitor.setParent(parent); //monitor.addObserver(parent); success = true; - - } catch (Exception e) { + } catch (DependencyBuilderException e) { + String msg = "Group monitor creation failed for group: " + dependency; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { String msg = "Group monitor creation failed for group: " + dependency; log.warn(msg, e); retries--; - - } } while (!success && retries != 0); @@ -335,7 +346,8 @@ public void run() { String msg = "Group monitor creation failed, even after retrying for 5 times, " + "for group: " + dependency; log.error(msg); - //TODO parent.notify(); + //TODO parent.notify(); as it got to failed + throw new RuntimeException(msg); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index a0f0a399fd..fbfb2f0a41 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -20,6 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; @@ -38,30 +40,14 @@ public class ApplicationMonitor extends Monitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); - public ApplicationMonitor(Application application) { + public ApplicationMonitor(Application application) throws DependencyBuilderException, + TopologyInConsistentException { super(application); this.id = application.getId(); + //starting the first set of dependencies from its children startDependency(); } - /*@Override - public void update(Observable observable, Object event) { - if (event instanceof MonitorStatusEvent1111) { - MonitorStatusEvent1111 statusEvent = (MonitorStatusEvent1111) event; - Status childStatus = statusEvent.getStatus(); - String notifier = statusEvent.getNotifierId(); - log.info(String.format("[Monitor] %s got notified from the [child] %s" + - "on its state change from %s to %s", id, notifier, this.status, status)); - if (childStatus == Status.Activated) { - //update the notifier as active in the dependency tree - - //start the next dependency - startDependency(notifier); - } - } - }*/ - - /** * To find all the clusters of an application * @@ -234,7 +220,7 @@ public void setStatus(Status status) { @Override public void onEvent(MonitorStatusEvent statusEvent) { - this.monitor(statusEvent); + monitor(statusEvent); } @Override @@ -242,9 +228,17 @@ protected void monitor(MonitorStatusEvent statusEvent) { ApplicationContext context = this.dependencyTree. findApplicationContextWithId(statusEvent.getId()); if(context.getStatusLifeCycle().isEmpty()) { - startDependency(statusEvent.getId()); + try { + //if life cycle is empty, need to start the monitor + startDependency(statusEvent.getId()); + //updating the life cycle + context.addStatusToLIfeCycle(statusEvent.getStatus()); + } catch (TopologyInConsistentException e) { + //TODO revert the siblings + log.error(e); + } } else { - //TODO act based on life cyle events + //TODO act based on life cycle events } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 735bcd682a..2774f209a5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -20,6 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.Monitor; @@ -38,63 +40,69 @@ public class GroupMonitor extends Monitor implements EventHandler { private static final Log log = LogFactory.getLog(GroupMonitor.class); + //Parent monitor of this monitor private Monitor parent; - public GroupMonitor(Group group) { + /** + * Constructor of GroupMonitor + * @param group Takes the group from the Topology + * @throws DependencyBuilderException throws when couldn't build the Topology + * @throws TopologyInConsistentException throws when topology is inconsistent + */ + public GroupMonitor(Group group) throws DependencyBuilderException, + TopologyInConsistentException { super(group); this.id = group.getAlias(); startDependency(); } - /*@Override - public void update(Observable observable, Object event) { - MonitorStatusEvent1111 statusEvent = (MonitorStatusEvent1111) event; - Status childStatus = statusEvent.getStatus(); - String notifier = statusEvent.getNotifierId(); - log.info(String.format("[Monitor] %s got notified from the [child] %s" + - "on its state change from %s to %s", id, notifier, this.status, status)); - if (childStatus == Status.Activated) { - //start the next dependency - startDependency(notifier); - } else if(childStatus == Status.In_Maintenance) { - - } - }*/ - - + /** + * Will set the status of the monitor based on Topology Group status/child status like scaling + * @param status + */ public void setStatus(Status status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); this.status = status; //notifying the parent MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); - //setChanged(); - //notifyObservers(new MonitorStatusEvent1111(status, id)); } @Override public void onEvent(MonitorStatusEvent statusEvent) { - this.monitor(statusEvent); - } - - public Monitor getParent() { - return parent; - } - - public void setParent(Monitor parent) { - this.parent = parent; + monitor(statusEvent); } @Override protected void monitor(MonitorStatusEvent statusEvent) { ApplicationContext context = this.dependencyTree. - findApplicationContextWithId(statusEvent.getId()); + findApplicationContextWithId(statusEvent.getId()); if(context.getStatusLifeCycle().isEmpty()) { - startDependency(statusEvent.getId()); + try { + //if life cycle is empty, need to start the monitor + boolean startDep = startDependency(statusEvent.getId()); + //updating the life cycle + context.addStatusToLIfeCycle(statusEvent.getStatus()); + if(!startDep) { + + } + } catch (TopologyInConsistentException e) { + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error(e); + } } else { - //TODO act based on life cyle events + //TODO act based on life cycle events } } + + public Monitor getParent() { + return parent; + } + + public void setParent(Monitor parent) { + this.parent = parent; + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 6a05371d00..5fd74aefcc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -28,8 +28,10 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; @@ -320,20 +322,26 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic return clusterMonitor; } - public static GroupMonitor getGroupMonitor(Group group) { + //TODO moving it into factory class + public static GroupMonitor getGroupMonitor(Group group) throws DependencyBuilderException, + TopologyInConsistentException { GroupMonitor groupMonitor = new GroupMonitor(group); return groupMonitor; } - public static ApplicationMonitor getApplicationMonitor(Application application) { + public static ApplicationMonitor getApplicationMonitor(Application application) + throws DependencyBuilderException, + TopologyInConsistentException { ApplicationMonitor applicationMonitor = new ApplicationMonitor(application); return applicationMonitor; } + + public static Properties getProperties(final OMElement elt) { Iterator it = elt.getChildrenWithName(new QName(AutoScalerConstants.PROPERTY_ELEMENT)); From 47f302a6b18352d4f88f648efccfa72d80f2fd3c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 10:36:37 +0530 Subject: [PATCH 160/436] putting API method details in the TopologyManager class --- .../receiver/topology/TopologyManager.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index e39351f4e2..d636912076 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -52,41 +52,31 @@ * * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - * acquiring: - * 1. acquire read lock for all Services - * 2. acquire read lock for the particular Service, to which the cluster belongs to - * 3. acquire write lock for the Cluster + * public static void acquireWriteLockForCluster (String serviceName, String clusterId) * * releasing: - * 1. release write lock for the Cluster - * 2. release read lock for the particular Service - * 3. release read lock for all Services + * public static void releaseWriteLockForCluster (String serviceName, String clusterId) * * Example 2: Acquiring write lock to add a new Cluster object - * acquiring: - * 1. acquire read lock for all Services - * 2. acquire write lock for the particular Service, to which the cluster belongs to + * public static void acquireWriteLockForService (String serviceName) * * releasing: - * 1. release write lock for the particular Service - * 2. release read lock for all Services + * public static void releaseWriteLockForService (String serviceName) * * Example 3: Acquiring read lock to read Cluster information * acquiring: - * 1. acquire read lock for all Services - * 2. acquire read lock for the particular Service, to which the cluster belongs to - * 3. acquire read lock for the relevant Cluster + * public static void acquireReadLockForCluster (String serviceName, String clusterId) * * releasing: - * 1. release read lock for the relevant Cluster - * 2. release read lock for the particular Service - * 3. release read lock for all Services + * public static void releaseReadLockForCluster (String serviceName, String clusterId) * * Example 4: Acquiring the write lock to add a deploy a Cartridge (add a new Service) * acquire: - * 1. acquire write lock for all Services + * public static void acquireWriteLockForServices() * * release: - * 1. release write lock for all Services + * public static void releaseWriteLockForServices() */ public class TopologyManager { private static final Log log = LogFactory.getLog(TopologyManager.class); From 0b15aa05733477494c9c94b757657094bf863cff Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 11:25:38 +0530 Subject: [PATCH 161/436] using hierarchical locking correctly in Stratos Topology event listeners --- .../AutoscalerTopologyEventReceiver.java | 4 ++-- .../LoadBalancerTopologyEventReceiver.java | 24 +++++++++---------- .../ApplicationCreatedMessageProcessor.java | 1 + .../topology/ClusterActivatedProcessor.java | 4 ++-- ...lusterMaintenanceModeMessageProcessor.java | 4 ++-- .../CompleteTopologyMessageProcessor.java | 6 ++++- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index b7d671f963..4a27c81424 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -300,7 +300,7 @@ protected void onEvent(Event event) { log.info("Event received: " + event); clusterMaitenanceEvent = (ClusterMaintenanceModeEvent) event; //TopologyManager.acquireReadLock(); - TopologyManager.acquireWriteLockForCluster(clusterMaitenanceEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(clusterMaitenanceEvent.getServiceName(), clusterMaitenanceEvent.getClusterId()); Service service = TopologyManager.getTopology().getService(clusterMaitenanceEvent.getServiceName()); @@ -319,7 +319,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(clusterMaitenanceEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(clusterMaitenanceEvent.getServiceName(), clusterMaitenanceEvent.getClusterId()); } } diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java index 4222075bb2..f2b3072fb9 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/LoadBalancerTopologyEventReceiver.java @@ -122,7 +122,7 @@ protected void onEvent(Event event) { MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; //TopologyManager.acquireReadLock(); - TopologyManager.acquireWriteLockForCluster(memberActivatedEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId()); try { @@ -173,7 +173,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(memberActivatedEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId()); } } @@ -184,7 +184,7 @@ protected void onEvent(Event event) { MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; - TopologyManager.acquireWriteLockForCluster(memberMaintenanceModeEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId()); try { @@ -200,7 +200,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(memberMaintenanceModeEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId()); } } @@ -210,7 +210,7 @@ protected void onEvent(Event event) { protected void onEvent(Event event) { MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; - TopologyManager.acquireWriteLockForCluster(memberSuspendedEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(memberSuspendedEvent.getServiceName(), memberSuspendedEvent.getClusterId()); try { @@ -225,7 +225,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(memberSuspendedEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(memberSuspendedEvent.getServiceName(), memberSuspendedEvent.getClusterId()); } } @@ -237,7 +237,7 @@ protected void onEvent(Event event) { //TopologyManager.acquireReadLock(); MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; - TopologyManager.acquireWriteLockForCluster(memberTerminatedEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), memberTerminatedEvent.getClusterId()); try { @@ -251,7 +251,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(memberTerminatedEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), memberTerminatedEvent.getClusterId()); } } @@ -262,7 +262,7 @@ protected void onEvent(Event event) { // Remove cluster from context ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event; - TopologyManager.acquireWriteLockForCluster(clusterRemovedEvent.getServiceName(), + TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), clusterRemovedEvent.getClusterId()); try { @@ -283,7 +283,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForCluster(clusterRemovedEvent.getServiceName(), + TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), clusterRemovedEvent.getClusterId()); } } @@ -293,7 +293,7 @@ protected void onEvent(Event event) { protected void onEvent(Event event) { ServiceRemovedEvent serviceRemovedEvent = (ServiceRemovedEvent) event; - TopologyManager.acquireWriteLockForServices(); + TopologyManager.acquireReadLockForService(serviceRemovedEvent.getServiceName()); try { //TopologyManager.acquireReadLock(); @@ -317,7 +317,7 @@ protected void onEvent(Event event) { log.error("Error processing event", e); } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseWriteLockForServices(); + TopologyManager.releaseReadLockForService(serviceRemovedEvent.getServiceName()); } } }); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 34ed3ef1ce..55786fae37 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -58,6 +58,7 @@ public boolean process(String type, String message, Object object) { } TopologyManager.acquireWriteLockForApplications(); + // since the Clusters will also get modified, acquire write locks for each Service Type Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 601cfb20fb..ef4bba2164 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -58,12 +58,12 @@ public boolean process(String type, String message, Object object) { ClusterActivatedEvent event = (ClusterActivatedEvent) Util. jsonToObject(message, ClusterActivatedEvent.class); - TopologyManager.acquireWriteLockForService(event.getServiceName()); + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 0b10504e82..15819ff09a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -50,12 +50,12 @@ public boolean process(String type, String message, Object object) { ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util. jsonToObject(message, ClusterMaintenanceModeEvent.class); - TopologyManager.acquireWriteLockForService(event.getServiceName()); + TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 74daa48b30..999415d99d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -55,7 +55,11 @@ public boolean process(String type, String message, Object object) { TopologyManager.acquireWriteLock(); try { - return doProcess(event, topology); + if (!topology.isInitialized()) { + return doProcess(event, topology); + } else { + return true; + } } finally { TopologyManager.releaseWriteLock(); From 2414be552cb84234cb48fd337e8e214b6a3fb5cf Mon Sep 17 00:00:00 2001 From: gayan Date: Thu, 9 Oct 2014 13:10:28 +0530 Subject: [PATCH 162/436] Re-factoring of the meta data service --- .../services/MetaDataAdmin.java | 119 +++++++++++++----- 1 file changed, 86 insertions(+), 33 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index cc341ec967..ce04abd7f0 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -1,9 +1,28 @@ +/* + * 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.metadataservice.services; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; @@ -24,36 +43,67 @@ public class MetaDataAdmin { @Context UriInfo uriInfo; - private static Log log = LogFactory.getLog(MetaDataAdmin.class); - @Context - HttpServletRequest httpServletRequest; + private static Log log = LogFactory.getLog(MetaDataAdmin.class); + @Context + HttpServletRequest httpServletRequest; - private final String DEFAULT_REG_TYPE = "carbon"; - private XMLConfiguration conf; - DataStore registry; + private DataStore registry; + /** + * Meta data admin configuration loading + */ public MetaDataAdmin(){ - conf = ConfUtil.getInstance(null).getConfiguration(); + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + String DEFAULT_REG_TYPE = "carbon"; String registryType = conf.getString("metadataservice.govenanceregistrytype", DEFAULT_REG_TYPE); registry = DataRegistryFactory.getDataRegistryFactory(registryType); } - @POST - @Path("/init") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public void initialize() throws RestAPIException { - } + @POST + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response addCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws RestAPIException { + + + URI url = uriInfo.getAbsolutePathBuilder().path(applicationName + "/" + cartridgeType).build(); + try { + registry.addCartridgeMetaDataDetails(applicationName, cartridgeType, cartridgeMetaData); + } catch (Exception err) { + log.error("Error occurred while adding meta data details ", err); + } + + return Response.created(url).build(); + + } + + @GET + @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, + @PathParam("cartridgetype") String cartridgeType) throws RestAPIException { - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - conf = ConfUtil.getInstance(null).getConfiguration(); - String registryType = - conf.getString("metadataservice.govenanceregistrytype", - DEFAULT_REG_TYPE); - return registry.removeCartridgeMetaDataDetails(applicationName, cartridgeType); + String result = null; + try { + result = registry.getCartridgeMetaDataDetails(applicationName, cartridgeType); + } catch (Exception err) { + log.error("Error occurred while adding meta data details ", err); + } + Response.ResponseBuilder rb; + if (result == null) { + rb = Response.status(Response.Status.NOT_FOUND); + } else { + rb = Response.ok().entity(result); + } + return rb.build(); - } + } @GET @Path("/application/{application_id}/cluster/{cluster_id}/properties") @@ -67,7 +117,7 @@ public Response getClusterProperties(@PathParam("application_id") String applica try { properties = registry .getPropertiesOfCluster(applicationId, clusterId); - if(properties != null) { + if (properties != null) { propertiesArr = new NewProperty[properties.size()]; propertiesArr = properties.toArray(propertiesArr); } @@ -75,10 +125,10 @@ public Response getClusterProperties(@PathParam("application_id") String applica log.error("Error occurred while getting properties ", e); } - Response.ResponseBuilder rb=null; - if(propertiesArr == null){ + Response.ResponseBuilder rb; + if (propertiesArr == null) { rb = Response.status(Response.Status.NOT_FOUND); - }else{ + } else { rb = Response.ok().entity(propertiesArr); } return rb.build(); @@ -89,18 +139,21 @@ public Response getClusterProperties(@PathParam("application_id") String applica @Produces("application/json") @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getClusterProperty(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, @PathParam("property_name") String propertyName){ - List properties = null; + List properties; + + NewProperty property = null; try { properties = registry .getPropertiesOfCluster(applicationId, clusterId); - if(properties == null){ + if (properties == null) { return Response.status(Response.Status.NOT_FOUND).build(); } - for(NewProperty p : properties){ - if(propertyName.equals(p.getKey())){ + for (NewProperty p : properties) { + if (propertyName.equals(p.getKey())) { property = p; break; } @@ -109,10 +162,10 @@ public Response getClusterProperty(@PathParam("application_id") String applicati log.error("Error occurred while getting property ", e); } - Response.ResponseBuilder rb=null; - if(property == null){ + Response.ResponseBuilder rb; + if (property == null) { rb = Response.status(Response.Status.NOT_FOUND); - }else{ + } else { rb = Response.ok().entity(property); } return rb.build(); @@ -145,12 +198,12 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response addPropertiesToACluster(@PathParam("application_id") String applicationId, @PathParam("cluster_id") String clusterId, NewProperty[] properties) throws RestAPIException { - URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); + URI url = uriInfo.getAbsolutePathBuilder().path(applicationId + "/" + clusterId).build(); try { registry.addPropertiesToCluster(applicationId, clusterId, properties); } catch (Exception e) { - log.error("Error occurred while adding properties ", e); + log.error("Error occurred while adding properties ", e); } From 86dbc56e2ae378b6b5c0a823cf313b7b7fbc3b5f Mon Sep 17 00:00:00 2001 From: gayan Date: Thu, 9 Oct 2014 13:10:37 +0530 Subject: [PATCH 163/436] Re-factoring of the meta data service --- .../stratos/metadataservice/Constants.java | 3 +- .../definition/CartridgeMetaData.java | 15 +- .../listener/TopologyAgent.java | 30 ++- .../listener/TopologyListener.java | 119 +++------ .../registry/CarbonRegistry.java | 192 +++++++++++--- .../metadataservice/registry/DataStore.java | 8 + .../registry/GRegRegistry.java | 242 +++++++++++++----- .../src/main/conf/metadataservice.xml | 2 +- .../all/repository/conf/metadataservice.xml | 2 +- 9 files changed, 395 insertions(+), 218 deletions(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java index bd84c5f3c5..f526d9e4c2 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/Constants.java @@ -23,7 +23,6 @@ */ public class Constants { - public static final String SUPER_TENANT_SERVICE = "super.tenant.service"; - public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml"; + public static final String METADATASERVICE_CONFIG_FILE_NAME = "metadataservice.xml"; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java index fbe15ba9e1..1875434b20 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/definition/CartridgeMetaData.java @@ -1,6 +1,8 @@ package org.apache.stratos.metadataservice.definition; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.xml.bind.annotation.XmlRootElement; @@ -20,24 +22,15 @@ public class CartridgeMetaData { public String version; - public List properties; + public String properties; @Override public String toString() { return "applicationName: " + applicationName + ", displayName: " + displayName + ", description: " + description + ", type: " + type + ", provider: " + provider + - ", host: " + host + ", Version: " + version + ", properties: " + getProperties(); + ", host: " + host + ", Version: " + version + ", properties: " + properties; } - private String getProperties() { - StringBuilder propertyBuilder = new StringBuilder(); - if (properties != null) { - for (PropertyBean propertyBean : properties) { - propertyBuilder.append(propertyBean.toString()); - } - } - return propertyBuilder.toString(); - } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java index 8e3936489c..f9afd7892d 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -1,5 +1,3 @@ -package org.apache.stratos.metadataservice.listener; - /* * * Licensed to the Apache Software Foundation (ASF) under one @@ -20,6 +18,9 @@ * under the License. */ +package org.apache.stratos.metadataservice.listener; + +import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.event.Event; @@ -29,7 +30,8 @@ import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.apache.stratos.metadataservice.services.MetaDataAdmin; +import org.apache.stratos.metadataservice.registry.DataRegistryFactory; +import org.apache.stratos.metadataservice.util.ConfUtil; /** * Cartridge agent runnable. @@ -38,7 +40,6 @@ public class TopologyAgent implements Runnable { private static final Log log = LogFactory.getLog(TopologyAgent.class); - private boolean terminated; @Override public void run() { @@ -51,10 +52,24 @@ public void run() { } - protected void registerTopologyEventListeners() { + /** + * Register the topology event listener + */ + private void registerTopologyEventListeners() { + final String defaultRegType = "carbon"; + + XMLConfiguration conf; + log.info("==================Starting topology event message receiver thread================="); if (log.isDebugEnabled()) { log.debug("Starting topology event message receiver thread"); } + conf = ConfUtil.getInstance(null).getConfiguration(); + + final String registryType = + conf.getString("metadataservice.govenanceregistrytype", + defaultRegType); + + TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { @@ -71,7 +86,7 @@ protected void onEvent(Event event) { log.debug("Terminated event :::::::::::::::::::: " + memberTerminatedEvent.getServiceName()); } - new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); + DataRegistryFactory.getDataRegistryFactory(registryType).removeCartridgeMetaDataDetails("appA", "php"); } catch (Exception e) { if (log.isErrorEnabled()) { @@ -93,7 +108,8 @@ protected void onEvent(Event event) { log.debug("Member suspended event received"); } MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; - // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); + //TODO : Add the funtionalilty for the suspended event + } catch (Exception e) { if (log.isErrorEnabled()) { log.error("Error processing member suspended event", e); diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java index fbca388a94..6c018b4b39 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyListener.java @@ -1,3 +1,24 @@ +/* + * + * 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.metadataservice.listener; import javax.servlet.ServletContextEvent; @@ -5,16 +26,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.topology.MemberStartedEvent; -import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; -import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; -import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberSuspendedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; -import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.apache.stratos.metadataservice.services.MetaDataAdmin; public class TopologyListener implements ServletContextListener { @@ -23,6 +34,10 @@ public class TopologyListener implements ServletContextListener { private TopologyAgent topologyThread = null; private Thread thread = null; + /** + * Initialization of the context + * @param arg0 ServletContextEvent + */ @Override public void contextInitialized(ServletContextEvent arg0) { log.info("Topology literner started...."); @@ -39,88 +54,16 @@ public void contextInitialized(ServletContextEvent arg0) { } + /** + * Destroy the context + * @param arg0 ServletContextEvent + */ @Override - public void contextDestroyed(ServletContextEvent arg0) { + public void contextDestroyed(ServletContextEvent arg0) + { thread.stop(); } - protected void registerTopologyEventListeners() { - if (log.isDebugEnabled()) { - log.debug("Starting topology event message receiver thread"); - } - TopologyEventReceiver topologyEventReceiver = new TopologyEventReceiver(); - - topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - TopologyManager.acquireReadLock(); - if (log.isDebugEnabled()) { - log.debug("Member terminated event received"); - } - MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; - if(log.isDebugEnabled()){ - log.info("Terminated event :::::::::::::::::::: " + - memberTerminatedEvent.getServiceName()); - } - new MetaDataAdmin().removeCartridgeMetaDataDetails("appA", "php"); - // extensionHandler.onMemberTerminatedEvent(memberTerminatedEvent); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Error processing member terminated event", e); - } - } finally { - TopologyManager.releaseReadLock(); - } - } - }); - - topologyEventReceiver.addEventListener(new MemberSuspendedEventListener() { - @Override - protected void onEvent(Event event) { - try { - TopologyManager.acquireReadLock(); - if (log.isDebugEnabled()) { - log.debug("Member suspended event received"); - } - MemberSuspendedEvent memberSuspendedEvent = (MemberSuspendedEvent) event; - // extensionHandler.onMemberSuspendedEvent(memberSuspendedEvent); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Error processing member suspended event", e); - } - } finally { - TopologyManager.releaseReadLock(); - } - } - }); - - topologyEventReceiver.addEventListener(new MemberStartedEventListener() { - @Override - protected void onEvent(Event event) { - try { - TopologyManager.acquireReadLock(); - if (log.isDebugEnabled()) { - log.debug("Member started event received"); - } - MemberStartedEvent memberStartedEvent = (MemberStartedEvent) event; - // extensionHandler.onMemberStartedEvent(memberStartedEvent); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Error processing member started event", e); - } - } finally { - TopologyManager.releaseReadLock(); - } - } - }); - - Thread thread = new Thread(topologyEventReceiver); - thread.start(); - if (log.isDebugEnabled()) { - log.info("Cartridge Agent topology receiver thread started"); - } - } } 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 3ae47ce726..e1526aa0ed 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 @@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.Context; -import org.apache.axis2.context.ConfigurationContext; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.definition.*; @@ -31,44 +31,121 @@ import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.service.RegistryService; + + +/** + * Carbon registry implementation + */ public class CarbonRegistry extends AbstractAdmin implements DataStore { - private static Log log = LogFactory.getLog(CarbonRegistry.class); - @Context - HttpServletRequest httpServletRequest; + private static Log log = LogFactory.getLog(CarbonRegistry.class); + @Context + HttpServletRequest httpServletRequest; - private static ConfigurationContext configContext = null; + private static final String mainResource = "/startos/"; - private static String defaultAxis2Repo = "repository/deployment/client"; - private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; - private static final String defaultUsername = "admin@org.com"; - private static final String defaultPassword = "admin123"; - private static final String serverURL = "https://localhost:9445/services/"; - private static final String mainResource = "/stratos/"; - private static final int defaultRank = 3; - private RegistryService registryService; + public CarbonRegistry() { - public CarbonRegistry() { + } - } - /* + /** + * Add the meta data to governance registry * + * @param applicationName Application Name + * @param cartridgeType Cartridge Type + * @param cartridgeMetaData Cartridge Meta Data + * @throws Exception + */ + @Override + public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + log.debug("Adding meta data details"); + + Registry tempRegistry = getGovernanceUserRegistry(); + + + Resource resource = tempRegistry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("Host", cartridgeMetaData.host); + resource.addProperty("Properties", cartridgeMetaData.properties); + + tempRegistry.put(resourcePath, resource); + + if (log.isDebugEnabled()) { + log.debug("A resource added to: " + resourcePath); + } + + + } + + /** + * Get the meta data from the registry + * + * @param applicationName name of the application + * @param cartridgeType cartridge type + * @return + * @throws Exception + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + cartridgeMetaData.properties = getResource.getProperty("Properties"); + + + } + + + return cartridgeMetaData.toString(); + } + + + /** * Remove the meta data from the registry * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + * @param applicationName name of the application + * @param cartridgeType cartridge type + * @return + * @throws Exception */ - @Override - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationName + "/" + cartridgeType; + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry != null) { - registry.delete(resourcePath); + registry.delete(resourcePath); return true; } else { if (log.isDebugEnabled()) { @@ -76,14 +153,20 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car } return false; } - } - - + } + /** + * Get Properties of clustor + * @param applicationName + * @param clusterId + * @return + * @throws RegistryException + */ + @Override public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; - if(!tempRegistry.resourceExists(resourcePath)){ + if (!tempRegistry.resourceExists(resourcePath)) { return null; //throw new RegistryException("Cluster does not exist at " + resourcePath); } @@ -93,10 +176,9 @@ public List getPropertiesOfCluster(String applicationName, String c Properties props = regResource.getProperties(); Enumeration x = props.propertyNames(); - while(x.hasMoreElements()) - { + while (x.hasMoreElements()) { String key = (String) x.nextElement(); - List values = regResource.getPropertyValues(key); + List values = regResource.getPropertyValues(key); NewProperty property = new NewProperty(); property.setKey(key); String[] valueArr = new String[values.size()]; @@ -108,6 +190,14 @@ public List getPropertiesOfCluster(String applicationName, String c return newProperties; } + /** + * Add property to cluster + * @param applicationId + * @param clusterId + * @param property + * @throws RegistryException + */ + @Override public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationId + "/" + clusterId; @@ -119,6 +209,13 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp } + /** + * Add properties to clustor + * @param applicationName + * @param clusterId + * @param properties + * @throws RegistryException + */ @Override public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); @@ -126,7 +223,7 @@ public void addPropertiesToCluster(String applicationName, String clusterId, New Resource regResource; regResource = createOrGetResourceforCluster(tempRegistry, resourcePath); - for(NewProperty property : properties){ + for (NewProperty property : properties) { regResource.setProperty(property.getKey(), (Arrays.asList(property.getValues()))); } @@ -134,31 +231,44 @@ public void addPropertiesToCluster(String applicationName, String clusterId, New log.info(String.format("Properties are added to cluster %s of application %s", clusterId, applicationName)); } - + /** + * Create or get resource for application + * @param tempRegistry + * @param resourcePath + * @return + * @throws RegistryException + */ private Resource createOrGetResourceforApplication(Registry tempRegistry, String resourcePath) throws RegistryException { Resource regResource; - if(tempRegistry.resourceExists(resourcePath)) { + if (tempRegistry.resourceExists(resourcePath)) { regResource = tempRegistry.get(resourcePath); - }else{ + } else { regResource = tempRegistry.newCollection(); - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Registry resource is create at path " + regResource.getPath() + " for application"); } } return regResource; } + /** + * Create and get resources for Clustor + * @param tempRegistry + * @param resourcePath + * @return + * @throws RegistryException + */ private Resource createOrGetResourceforCluster(Registry tempRegistry, String resourcePath) throws RegistryException { int index = resourcePath.lastIndexOf('/'); - String applicationResourcePath = resourcePath.substring(0,index); + String applicationResourcePath = resourcePath.substring(0, index); createOrGetResourceforApplication(tempRegistry, applicationResourcePath); Resource regResource; - if(tempRegistry.resourceExists(resourcePath)) { + if (tempRegistry.resourceExists(resourcePath)) { regResource = tempRegistry.get(resourcePath); - }else{ + } else { regResource = tempRegistry.newResource(); - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Registry resource is create at path for cluster" + regResource.getPath() + " for cluster"); } } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index e1b1218fb2..ea905a09be 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -18,6 +18,8 @@ */ package org.apache.stratos.metadataservice.registry; + +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.wso2.carbon.registry.api.RegistryException; @@ -28,6 +30,12 @@ */ public interface DataStore { + public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception; + + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception; + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) throws Exception; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 1726d10418..2be8d272e9 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -18,91 +18,199 @@ */ package org.apache.stratos.metadataservice.registry; -import java.io.File; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Context; - import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.context.ConfigurationContextFactory; import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + +import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.util.ConfUtil; import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; +import org.wso2.carbon.registry.api.Resource; +import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; +import java.io.File; +import java.util.List; + /** - * * Governance registry implementation for the registry factory - * */ public class GRegRegistry implements DataStore { - private static Log log = LogFactory.getLog(GRegRegistry.class); - @Context - HttpServletRequest httpServletRequest; - - private static ConfigurationContext configContext = null; - - private static String defaultAxis2Repo = "repository/deployment/client"; - private static String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; - - private static final String defaultUsername = "admin@org.com"; - private static final String defaultPassword = "admin123"; - private static final String serverURL = "https://localhost:9445/services/"; - private static final String mainResource = "/startos/"; - private static final int defaultRank = 3; - - /* - * Registry initiation - */ - private static WSRegistryServiceClient setRegistry() throws Exception { - - XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); - - String gregUsername = conf.getString("metadataservice.username", defaultUsername); - String gregPassword = conf.getString("metadataservice.password", defaultPassword); - String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); - String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); - String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); - String defaultTrustStore = - "repository" + File.separator + "resources" + File.separator + - "security" + File.separator + "wso2carbon.jks"; - String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); - String trustStorePassword = - conf.getString("metadataservice.trustStorePassword", - "wso2carbon"); - String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); - - System.setProperty("javax.net.ssl.trustStore", trustStorePath); - System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" - System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" - System.setProperty("carbon.repo.write.mode", "true"); - configContext = - ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, - axis2Conf); - return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); - } + + private static Log log = LogFactory.getLog(GRegRegistry.class); + @Context + HttpServletRequest httpServletRequest; + + private static ConfigurationContext configContext; + + static { + configContext = null; + } + + private static final String defaultUsername = "admin@org.com"; + private static final String defaultPassword = "admin123"; + private static final String serverURL = "https://localhost:9445/services/"; + private static final String mainResource = "/startos/"; + private static final int defaultRank = 3; /* - * - * Remove the meta data from the registry - * - * @see org.apache.stratos.metadataservice.registry.DataStore# - * removeCartridgeMetaDataDetails(java.lang.String, java.lang.String) + * Registry initiation */ - @Override - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = setRegistry(); - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - registry.delete(resourcePath); - return false; - } + private static WSRegistryServiceClient setRegistry() throws Exception { + + XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); + + String gregUsername = conf.getString("metadataservice.username", defaultUsername); + String gregPassword = conf.getString("metadataservice.password", defaultPassword); + String gregServerURL = conf.getString("metadataservice.serverurl", serverURL); + String defaultAxis2Repo = "repository/deployment/client"; + String axis2Repo = conf.getString("metadataservice.axis2Repo", defaultAxis2Repo); + String defaultAxis2Conf = "repository/conf/axis2/axis2_client.xml"; + String axis2Conf = conf.getString("metadataservice.axis2Conf", defaultAxis2Conf); + String defaultTrustStore = + "repository" + File.separator + "resources" + File.separator + + "security" + File.separator + "wso2carbon.jks"; + String trustStorePath = conf.getString("metadataservice.trustStore", defaultTrustStore); + String trustStorePassword = + conf.getString("metadataservice.trustStorePassword", + "wso2carbon"); + String trustStoreType = conf.getString("metadataservice.trustStoreType", "JKS"); + + System.setProperty("javax.net.ssl.trustStore", trustStorePath); + System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);// "wso2carbon" + System.setProperty("javax.net.ssl.trustStoreType", trustStoreType);// "JKS" + System.setProperty("carbon.repo.write.mode", "true"); + configContext = + ConfigurationContextFactory.createConfigurationContextFromFileSystem(axis2Repo, + axis2Conf); + return new WSRegistryServiceClient(gregServerURL, gregUsername, gregPassword, configContext); + } + + + + /** + * Add the meta data to governance registry + * @param applicationName + * @param cartridgeType + * @param cartridgeMetaData + * @throws Exception + */ + @Override + public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, + CartridgeMetaData cartridgeMetaData) throws Exception { + + Registry registry = setRegistry(); + try { + + Resource resource = registry.newResource(); + + String type = cartridgeMetaData.type; + + resource.setContent("Application description :: " + type); + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + + resource.addProperty("Application Name", cartridgeMetaData.applicationName); + resource.addProperty("Display Name", cartridgeMetaData.displayName); + resource.addProperty("Description", cartridgeMetaData.description); + resource.addProperty("Cartidge Type", cartridgeMetaData.type); + resource.addProperty("provider", cartridgeMetaData.provider); + resource.addProperty("Version", cartridgeMetaData.version); + resource.addProperty("Host", cartridgeMetaData.host); + resource.addProperty("Properties", cartridgeMetaData.properties); + registry.put(resourcePath, resource); + + registry.rateResource(resourcePath, defaultRank); + + Comment comment = new Comment(); + comment.setText("Added the " + applicationName + " " + type + " cartridge"); + registry.addComment(resourcePath, comment); + + } catch (Exception e) { + + if (log.isErrorEnabled()) { + log.error("addCartridgeMetaDataDetails", e); + } + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + + + } + + /** + * Get the meta data from the registry + * @param applicationName + * @param cartridgeType + * @return + * @throws Exception + */ + @Override + public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); + try { + + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + if (registry.resourceExists(resourcePath)) { + + Resource getResource = registry.get(resourcePath); + if (log.isDebugEnabled()) { + log.debug("Resource retrived"); + log.debug("Printing retrieved resource content: " + + new String((byte[]) getResource.getContent())); + } + + cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); + cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); + cartridgeMetaData.description = getResource.getProperty("Description"); + cartridgeMetaData.displayName = getResource.getProperty("Display Name"); + cartridgeMetaData.host = getResource.getProperty("Host"); + cartridgeMetaData.provider = getResource.getProperty("provider"); + cartridgeMetaData.version = getResource.getProperty("Version"); + cartridgeMetaData.properties = getResource.getProperty("Properties"); + + + + } + + } catch (Exception e) { + + if (log.isErrorEnabled()) { + log.error("getCartridgeMetaDataDetails", e); + } + } finally { + // Close the session + ((WSRegistryServiceClient) registry).logut(); + } + return cartridgeMetaData.toString(); + } + + /** + * Remove catridge meta data details from the registry + * @param applicationName + * @param cartridgeType + * @return + * @throws Exception + */ + @Override + public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) + throws Exception { + Registry registry = setRegistry(); + String resourcePath = mainResource + applicationName + "/" + cartridgeType; + registry.delete(resourcePath); + return false; + } + public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { @@ -113,7 +221,7 @@ public List getPropertiesOfCluster(String applicationName, String c } public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { - + } } diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml index d871bc0b9f..5e8bb1d689 100644 --- a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml +++ b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml @@ -19,7 +19,7 @@ --> - OWN + carbon https://localhost:9445/services/ admin admin diff --git a/tools/stratos-installer/config/all/repository/conf/metadataservice.xml b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml index 690e056579..5e8bb1d689 100644 --- a/tools/stratos-installer/config/all/repository/conf/metadataservice.xml +++ b/tools/stratos-installer/config/all/repository/conf/metadataservice.xml @@ -19,7 +19,7 @@ --> - GREG + carbon https://localhost:9445/services/ admin admin From dc8067a9a382597aa9eb3ef89fe098ad40d900b7 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 9 Oct 2014 15:10:23 +0530 Subject: [PATCH 164/436] fixing application/group activation and locking --- .../apache/stratos/autoscaler/Constants.java | 4 + .../dependency/DependencyBuilder.java | 9 +- .../grouping/dependency/DependencyTree.java | 1 - .../context/ApplicationContextFactory.java | 52 +++++++--- .../AutoscalerTopologyEventReceiver.java | 44 ++++----- .../monitor/AbstractClusterMonitor.java | 1 + .../stratos/autoscaler/monitor/Monitor.java | 97 +++++++++++-------- .../application/ApplicationMonitor.java | 6 +- .../monitor/group/GroupMonitor.java | 12 ++- .../status/checker/StatusChecker.java | 34 +++---- .../autoscaler/util/AutoscalerUtil.java | 1 + 11 files changed, 157 insertions(+), 104 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java index a44840600e..59717f754a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java @@ -76,4 +76,8 @@ public class Constants { public static final String KILL_NONE = "kill-none"; public static final String KILL_ALL = "kill-all"; public static final String KILL_DEPENDENTS = "kill-dependents"; + public static final String GROUP = "group"; + public static final String CARTRIDGE = "cartridge"; + + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index fcdaadef80..5a1e4fda7d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -32,7 +32,7 @@ /** * This is to build the startup/termination dependencies - * across all the groups and clusters + * across immediate children according to the start order defined. */ public class DependencyBuilder { private static final Log log = LogFactory.getLog(DependencyBuilder.class); @@ -97,8 +97,9 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen if (start != null) { ApplicationContext applicationContext = ApplicationContextFactory. - getApplicationContext(start, component, dependencyTree); - String id = applicationContext.getId(); //TODO change the id + getApplicationContext(start, component, + dependencyTree.isKillDependent()); + String id = applicationContext.getId(); ApplicationContext existingApplicationContext = dependencyTree.findApplicationContextWithId(id); @@ -131,7 +132,7 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen } } } - //TODO need to parser the scalable dependencies + //TODO need to parser the scalable dependencies } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index a5b9ce23d5..d3dded3ee0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -166,7 +166,6 @@ public List findAllChildrenOfAppContext(List(); @@ -73,6 +74,7 @@ public Monitor(ParentComponent component) throws DependencyBuilderException { /** * Will monitor the immediate children upon any event triggers from parent/children + * * @param statusEvent will be sent by parent/children with the current status */ protected abstract void monitor(MonitorStatusEvent statusEvent); @@ -106,7 +108,7 @@ public boolean startDependency(String id) throws TopologyInConsistentException { * @param applicationContexts the found applicationContexts to be started */ private boolean startDependency(List applicationContexts) - throws TopologyInConsistentException{ + throws TopologyInConsistentException { if (applicationContexts == null) { //all the groups/clusters have been started and waiting for activation log.info("There is no child found for the [group]: " + this.id); @@ -124,27 +126,32 @@ private boolean startDependency(List applicationContexts) String clusterId = clusterDataHolder.getClusterId(); String serviceName = clusterDataHolder.getServiceType(); Cluster cluster; - //TopologyManager.acquireReadLock(); - Topology topology = TopologyManager.getTopology(); - if (topology.serviceExists(serviceName)) { - Service service = topology.getService(serviceName); - if (service.clusterExists(clusterId)) { - cluster = service.getCluster(clusterId); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); + //acquire read lock for the service and cluster + TopologyManager.acquireReadLockForCluster(clusterId, serviceName); + try { + Topology topology = TopologyManager.getTopology(); + if (topology.serviceExists(serviceName)) { + Service service = topology.getService(serviceName); + if (service.clusterExists(clusterId)) { + cluster = service.getCluster(clusterId); + if (log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); + } + startClusterMonitor(this, cluster); + } else { + String msg = "[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName; + throw new TopologyInConsistentException(msg); } - startClusterMonitor(this, cluster); } else { - String msg = "[Cluster] " + clusterId + " cannot be found in the " + - "Topology for [service] " + serviceName; + String msg = "[Service] " + serviceName + " cannot be found in the Topology"; throw new TopologyInConsistentException(msg); - } - } else { - String msg = "[Service] " + serviceName + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); + } + } finally { + //release read lock for the service and cluster + TopologyManager.releaseReadLockForCluster(clusterId, serviceName); } - //TopologyManager.releaseReadLock(); } } return true; @@ -152,22 +159,27 @@ private boolean startDependency(List applicationContexts) } protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { - ScheduledExecutorService adder = Executors.newSingleThreadScheduledExecutor(); + Thread th = null; if (cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - adder.scheduleAtFixedRate(new LBClusterMonitorAdder( - cluster), 5, 5, TimeUnit.SECONDS); + th = new Thread(new LBClusterMonitorAdder( + cluster)); } else if (!cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - adder.scheduleAtFixedRate(new ClusterMonitorAdder(parent, cluster), 5, 5, TimeUnit.SECONDS); - + th = new Thread( + new ClusterMonitorAdder(parent, cluster)); if (log.isDebugEnabled()) { log.debug(String .format("Cluster monitor Adder has been added: [cluster] %s ", cluster.getClusterId())); } } - if (adder != null) { - //adderIdToExecutorServiceMap.put(cluster.getClusterId(), adder); + if (th != null) { + th.start(); + /*try { + th.join(); + } catch (InterruptedException ignore) { + }*/ + log.info(String .format("Cluster monitor thread has been started successfully: [cluster] %s ", cluster.getClusterId())); @@ -175,25 +187,24 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentComponent component) { - ScheduledExecutorService adder = Executors.newSingleThreadScheduledExecutor(); - + Thread th = null; if (!this.aliasToGroupMonitorsMap.containsKey(dependency)) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor Adder has been added: [group] %s ", dependency)); } - adder.scheduleAtFixedRate(new GroupMonitorAdder(parent, dependency, component), 5, 5, TimeUnit.SECONDS); - + th = new Thread( + new GroupMonitorAdder(parent, dependency, component)); } - if (adder != null) { + if (th != null) { + th.start(); /*try { - adder.awaitTermination(30, TimeUnit.SECONDS); - } catch (InterruptedException e) { - e.printStackTrace(); + th.join(); + } catch (InterruptedException ignore) { }*/ - //adderIdToExecutorServiceMap.put(((Group)component).getAlias(), adder); + log.info(String .format("Group monitor thread has been started successfully: [group] %s ", dependency)); @@ -236,6 +247,14 @@ public AbstractClusterMonitor getAbstractMonitor(String clusterId) { return this.clusterIdToClusterMonitorsMap.get(clusterId); } + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + private class ClusterMonitorAdder implements Runnable { private Cluster cluster; private Monitor parent; @@ -250,10 +269,10 @@ public void run() { int retries = 5; boolean success = false; do { - /*try { + try { Thread.sleep(5000); } catch (InterruptedException e1) { - }*/ + } try { if (log.isDebugEnabled()) { log.debug("CLuster monitor is going to be started for [cluster] " diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 90390e062d..2ad2a0e98a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -230,7 +230,11 @@ protected void monitor(MonitorStatusEvent statusEvent) { if(context.getStatusLifeCycle().isEmpty()) { try { //if life cycle is empty, need to start the monitor - startDependency(statusEvent.getId()); + boolean dependencyStarted = startDependency(statusEvent.getId()); + if(!dependencyStarted) { + //Have to check whether all other dependencies started + + } //updating the life cycle context.addStatusToLIfeCycle(statusEvent.getStatus()); } catch (TopologyInConsistentException e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 99d5305959..f9a1a67e57 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.Status; import org.apache.stratos.messaging.event.application.status.StatusEvent; @@ -76,16 +77,20 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { + String id = statusEvent.getId(); ApplicationContext context = this.dependencyTree. - findApplicationContextWithId(statusEvent.getId()); + findApplicationContextWithId(id); if(context.getStatusLifeCycle().isEmpty()) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); - //updating the life cycle + //updating the life cycle and current status + context.setStatus(status); context.addStatusToLIfeCycle(statusEvent.getStatus()); if(!startDep) { - + //Checking in the children whether all are active, + // since no dependency found to be started. + StatusChecker.getInstance().onChildStatusChange(id, this.component, this.appId); } } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription @@ -103,6 +108,7 @@ public Monitor getParent() { public void setParent(Monitor parent) { this.parent = parent; + this.appId = parent.getAppId(); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index bb9c01699d..78e9793bb6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -86,28 +86,28 @@ public void run() { } /** - * @param groupId - * @param appId - */ - public void onGroupStatusChange(final String groupId, final String appId) { - updateChild(groupId, appId); - } - - /** - * @param clusterId - * @param appId + * @param idOfChild + * @param component */ - public void onClusterStatusChange(final String clusterId, final String appId) { - updateChild(clusterId, appId); + public void onChildStatusChange(final String idOfChild, final ParentComponent component, + final String appId) { + updateChild(idOfChild, component, appId); } - private void updateChild(final String clusterId, final String appId) { + private void updateChild(final String idOfChild, final ParentComponent component, final String appId) { Runnable group = new Runnable() { public void run() { - Application application = TopologyManager.getTopology().getApplication(appId); - Map clusterIds = application.getClusterDataMap(); - Map groups = application.getAliasToGroupMap(); - updateChildStatus(appId, clusterId, groups, clusterIds, application); + try { + //TODO getting lock + TopologyManager.acquireReadLockForApplication(appId); + Map clusterIds = component.getClusterDataMap(); + Map groups = component.getAliasToGroupMap(); + updateChildStatus(appId, idOfChild, groups, clusterIds, component); + } finally { + TopologyManager.releaseReadLockForApplication(appId); + + } + } }; Thread groupThread = new Thread(group); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 5fd74aefcc..cd8578ef58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -336,6 +336,7 @@ public static ApplicationMonitor getApplicationMonitor(Application application) TopologyInConsistentException { ApplicationMonitor applicationMonitor = new ApplicationMonitor(application); + applicationMonitor.setAppId(application.getUniqueIdentifier()); return applicationMonitor; } From f11401a342ec74e17fd6dc8dcf3c4d6477e221bf Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 15:12:54 +0530 Subject: [PATCH 165/436] bringing back alias based Startup Order conversion --- .../dependency/DependencyBuilder.java | 73 ++++++++-------- .../parser/DefaultApplicationParser.java | 5 +- .../application/parser/ParserUtils.java | 83 +++++++++---------- .../cloud/controller/pojo/StartupOrder.java | 50 ----------- .../pojo/application/StartupOrderContext.java | 47 ----------- .../domain/topology/DependencyOrder.java | 22 ++--- .../domain/topology/StartupOrder.java | 20 +---- 7 files changed, 88 insertions(+), 212 deletions(-) delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 5a1e4fda7d..30709e786a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -82,8 +82,8 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen } //Parsing the start up order - String [] startupOrders = dependencyOrder.getStartupOrders(); - ApplicationContext foundContext = null; + Set startupOrders = dependencyOrder.getStartupOrders(); + ApplicationContext foundContext; if (startupOrders == null) { if (log.isDebugEnabled()) { log.debug("startupOrders is null, returning default dependency tree (empty)"); @@ -91,46 +91,49 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen return dependencyTree; } - for (String startupOrder : startupOrders) { - String start = dependencyOrder.getStartStartupOrder(startupOrder); + for (StartupOrder startupOrder : startupOrders) { + foundContext = null; - - if (start != null) { - ApplicationContext applicationContext = ApplicationContextFactory. - getApplicationContext(start, component, - dependencyTree.isKillDependent()); - String id = applicationContext.getId(); - - ApplicationContext existingApplicationContext = - dependencyTree.findApplicationContextWithId(id); - if (existingApplicationContext == null) { - if (foundContext != null) { - //appending the start up order to existing group/cluster - foundContext.addApplicationContext(applicationContext); - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + foundContext.getId() + - " and adding the [dependency] " + id + " as the child"); + + for (String start : startupOrder.getStartList()) { + + if (start != null) { + ApplicationContext applicationContext = ApplicationContextFactory. + getApplicationContext(start, component, dependencyTree.isKillDependent()); + String id = applicationContext.getId(); //TODO change the id + + ApplicationContext existingApplicationContext = + dependencyTree.findApplicationContextWithId(id); + if (existingApplicationContext == null) { + if (foundContext != null) { + //appending the start up order to existing group/cluster + foundContext.addApplicationContext(applicationContext); + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + foundContext.getId() + + " and adding the [dependency] " + id + " as the child"); + } + } else { + //adding list of startup order to the dependency tree + dependencyTree.addApplicationContext(applicationContext); } } else { - //adding list of startup order to the dependency tree - dependencyTree.addApplicationContext(applicationContext); - } - } else { - if (foundContext == null) { - //assigning the found context to the later use. - foundContext = existingApplicationContext; - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + id + " and setting it " + - "for the next dependency to follow"); + if (foundContext == null) { + //assigning the found context to the later use. + foundContext = existingApplicationContext; + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + id + " and setting it " + + "for the next dependency to follow"); + } + } else { + String msg = "Startup order is not consistent. It contains the group/cluster " + + "which has been used more than one in another startup order"; + throw new DependencyBuilderException(msg); } - } else { - String msg = "Startup order is not consistent. It contains the group/cluster " + - "which has been used more than one in another startup order"; - throw new DependencyBuilderException(msg); - } + } } } + } //TODO need to parser the scalable dependencies } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index efeccd7d90..9d909caabb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -34,7 +34,6 @@ import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.StartupOrder; import java.util.*; @@ -274,7 +273,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + appCtxt.getAlias() + " #: " + startupOrders.length); } - appDependencyOrder.setStartupOrders(startupOrders); + appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders)); } else { if (log.isDebugEnabled()) { log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias()); @@ -401,7 +400,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g // create the Dependency Ordering String [] startupOrders = getStartupOrderForGroup(groupCtxt); if (startupOrders != null) { - dependencyOrder.setStartupOrders(startupOrders); + dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt)); } dependencyOrder.setKillbehavior(getKillbehaviour(groupCtxt.getName())); group.setDependencyOrder(dependencyOrder); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index 707fd0a80b..62a98ab791 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -23,13 +23,11 @@ import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; import org.apache.stratos.messaging.domain.topology.StartupOrder; -import java.util.HashSet; -import java.util.Set; +import java.util.*; public class ParserUtils { - /* - public static Set convert (org.apache.stratos.cloud.controller.pojo.StartupOrder [] startupOrderArr, GroupContext groupContext) { + public static Set convert (String [] startupOrderArr) { Set startupOrders = new HashSet(); @@ -37,65 +35,66 @@ public static Set convert (org.apache.stratos.cloud.controller.poj return startupOrders; } + for (String commaSeparatedStartupOrder : startupOrderArr) { + startupOrders.add(new StartupOrder(Arrays.asList(commaSeparatedStartupOrder.split(",")))); + } + + return startupOrders; + } + + public static Set convert (String [] startupOrderArr, GroupContext groupContext) { + + Set startupOrders = new HashSet(); - for (int i = 0; i < startupOrderArr.length ; i++) { + if (startupOrderArr == null) { + return startupOrders; + } + + + for (String commaSeparatedStartupOrder : startupOrderArr) { // convert all Startup Orders to aliases-based - // start - String startAlias; - if (startupOrderArr[i].getStart().startsWith("cartridge.")) { - String cartridgeType = startupOrderArr[i].getStart().substring(10); - startAlias = getAliasForServiceType(cartridgeType, groupContext); - if (startAlias == null) { - throw new RuntimeException("Unable convert Startup Order to alias-based; " + - "cannot find the matching alias for Service type " + cartridgeType); - } + List components = Arrays.asList(commaSeparatedStartupOrder.split(",")); + startupOrders.add(getStartupOrder(components, groupContext)); + } - startAlias = "cartridge.".concat(startAlias); + return startupOrders; + } - } else if (startupOrderArr[i].getStart().startsWith("group.")) { - String groupName = startupOrderArr[i].getStart().substring(6); - startAlias = getAliasForGroupName(groupName, groupContext); - if (startAlias == null) { - throw new RuntimeException("Unable convert Startup Order to alias-based; " + - "cannot find the matching alias for Group name " + groupName); - } + private static StartupOrder getStartupOrder (List components, GroupContext groupContext) { - startAlias = "group.".concat(startAlias); + List aliasBasedComponents = new ArrayList(); - } else { - throw new RuntimeException("Incorrect Startup Order specified"); - } + for (String component : components) { + component = component.trim(); - // after - String afterAlias; - if (startupOrderArr[i].getAfter().startsWith("cartridge.")) { - String cartridgeType = startupOrderArr[i].getAfter().substring(10); - afterAlias = getAliasForServiceType(cartridgeType, groupContext); - if (afterAlias == null) { + String aliasBasedComponent; + if (component.startsWith("cartridge.")) { + String cartridgeType = component.substring(10); + aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext); + if (aliasBasedComponent == null) { throw new RuntimeException("Unable convert Startup Order to alias-based; " + "cannot find the matching alias for Service type " + cartridgeType); } - afterAlias = "cartridge.".concat(afterAlias); + aliasBasedComponent = "cartridge.".concat(aliasBasedComponent); - } else if (startupOrderArr[i].getAfter().startsWith("group.")) { - String groupName = startupOrderArr[i].getAfter().substring(6); - afterAlias = getAliasForGroupName(groupName, groupContext); - if (afterAlias == null) { + } else if (component.startsWith("group.")) { + String groupName = component.substring(6); + aliasBasedComponent = getAliasForGroupName(groupName, groupContext); + if (aliasBasedComponent == null) { throw new RuntimeException("Unable convert Startup Order to alias-based; " + "cannot find the matching alias for Group name " + groupName); } - afterAlias = "group.".concat(afterAlias); + aliasBasedComponent = "group.".concat(aliasBasedComponent); } else { throw new RuntimeException("Incorrect Startup Order specified"); } - - startupOrders.add(new StartupOrder(startAlias, afterAlias)); + aliasBasedComponents.add(aliasBasedComponent); } - return startupOrders; + return new StartupOrder(aliasBasedComponents); } private static String getAliasForGroupName (String groupName, GroupContext groupContext) { @@ -109,7 +108,7 @@ private static String getAliasForGroupName (String groupName, GroupContext group return null; } -*/ + private static String getAliasForServiceType (String serviceType, GroupContext groupContext) { for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.java deleted file mode 100644 index ed9626b900..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/StartupOrder.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.cloud.controller.pojo; - -import java.io.Serializable; - -public class StartupOrder implements Serializable { - - private static final long serialVersionUID = 280860334002791396L; - - /* - - 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; - } - */ -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.java deleted file mode 100644 index 3c2a2da36b..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/StartupOrderContext.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.cloud.controller.pojo.application; - -public class StartupOrderContext { - - private String start; - - private String after; - - public StartupOrderContext () { - - } - - 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; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java index ff08a4c7a2..1d8699fe92 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -21,21 +21,19 @@ import java.io.Serializable; import java.util.HashSet; +import java.util.List; import java.util.Set; public class DependencyOrder implements Serializable { - /** - * - */ private static final long serialVersionUID = -599600831844477527L; - private String [] startupOrders; + private Set startupOrders; private String killbehavior; public DependencyOrder () { - this.setStartupOrders(null); + } public String getKillbehavior() { @@ -46,21 +44,11 @@ public void setKillbehavior(String killbehavior) { this.killbehavior = killbehavior; } - public String [] getStartupOrders() { + public Set getStartupOrders() { return startupOrders; } - public void setStartupOrders(String [] startupOrders) { + public void setStartupOrders(Set startupOrders) { this.startupOrders = startupOrders; } - - public String getStartStartupOrder(String startupOrder) { - String [] splitStartupOrder = startupOrder.split(","); - return splitStartupOrder[0]; - } - - public String getAfterStartupOrder(String startupOrder) { - String [] splitStartupOrder = startupOrder.split(","); - return splitStartupOrder[1]; - } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java index 6263070a48..4f55b6c325 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java @@ -23,26 +23,11 @@ import java.util.List; public class StartupOrder implements Serializable { - - /* - - private String start; - - private String after; private List startList; - public StartupOrder (String start, String after) { - this.start = start; - this.after = after; - } - - public String getStart() { - return start; - } - - public String getAfter() { - return after; + public StartupOrder (List startList) { + this.startList = startList; } public List getStartList() { @@ -52,5 +37,4 @@ public List getStartList() { public void setStartList(List startList) { this.startList = startList; } - */ } From 03593990145938ef1355444a7abd64264ed4e575 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 15:26:31 +0530 Subject: [PATCH 166/436] removing Topology write locks to an messaging-internal class --- .../conf/LoadBalancerConfiguration.java | 7 +- .../StratosManagerTopologyEventReceiver.java | 67 +++-- .../org.apache.stratos.messaging/pom.xml | 7 +- .../domain/topology/locking/TopologyLock.java | 4 +- .../locking/TopologyLockHierarchy.java | 7 + .../ApplicationActivatedMessageProcessor.java | 6 +- .../ApplicationCreatedMessageProcessor.java | 10 +- .../ApplicationRemovedMessageProcessor.java | 10 +- .../topology/ClusterActivatedProcessor.java | 6 +- .../ClusterCreatedMessageProcessor.java | 6 +- ...lusterMaintenanceModeMessageProcessor.java | 6 +- .../ClusterRemovedMessageProcessor.java | 6 +- .../CompleteTopologyMessageProcessor.java | 12 +- .../topology/GroupActivatedProcessor.java | 6 +- .../InstanceSpawnedMessageProcessor.java | 6 +- .../MemberActivatedMessageProcessor.java | 6 +- .../MemberMaintenanceModeProcessor.java | 6 +- ...MemberReadyToShutdownMessageProcessor.java | 6 +- .../MemberStartedMessageProcessor.java | 6 +- .../MemberSuspendedMessageProcessor.java | 6 +- .../MemberTerminatedMessageProcessor.java | 6 +- .../ServiceCreatedMessageProcessor.java | 6 +- .../ServiceRemovedMessageProcessor.java | 6 +- .../topology/updater/TopologyUpdater.java | 272 ++++++++++++++++++ .../receiver/topology/TopologyManager.java | 245 +--------------- .../topology/locking/TopologyLockingTest.java | 41 +-- 26 files changed, 411 insertions(+), 361 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java index c269419f77..ed8aa0553c 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java @@ -496,12 +496,15 @@ private LoadBalancerConfiguration transform(Node loadBalancerNode) { // Add service to topology manager if not exists try { - TopologyManager.acquireWriteLock(); + // TODO - fix properly! + // this lock is not needed since, this Topology is not shared. This is + // used by LB only + //TopologyManager.acquireWriteLock(); if (!TopologyManager.getTopology().serviceExists(service.getServiceName())) { TopologyManager.getTopology().addService(service); } } finally { - TopologyManager.releaseWriteLock(); + //TopologyManager.releaseWriteLock(); } // Add cluster to load balancer context 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 index e7bc5a299e..699af72fe5 100644 --- 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 @@ -28,7 +28,6 @@ import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; @@ -265,39 +264,39 @@ protected void onEvent(Event event) { 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()); - } - } +// 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 diff --git a/components/org.apache.stratos.messaging/pom.xml b/components/org.apache.stratos.messaging/pom.xml index 4ff4cb8d55..2143925adc 100644 --- a/components/org.apache.stratos.messaging/pom.xml +++ b/components/org.apache.stratos.messaging/pom.xml @@ -104,11 +104,12 @@ ${project.artifactId} ${project.artifactId} + !org.apache.stratos.messaging.message.processor.topology.updater, org.apache.stratos.messaging.*, - + + org.apache.stratos.messaging.message.processor.topology.updater; + !org.apache.commons.logging, org.apache.commons.logging; version=0.0.0, diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java index e1b90ad51d..92a2f0a598 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java @@ -34,9 +34,7 @@ public void acquireWriteLock() { } public void releaseWritelock() { - if (lock.isWriteLockedByCurrentThread()) { - lock.writeLock().unlock(); - } + lock.writeLock().unlock(); } public void acquireReadLock() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java index aa0f7a1f64..d7ab0a1869 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -29,6 +29,8 @@ public class TopologyLockHierarchy { private static final Log log = LogFactory.getLog(TopologyLockHierarchy.class); + private TopologyLock completeTopologyLock; + // lock for Services private TopologyLock serviceLock; @@ -48,6 +50,7 @@ public class TopologyLockHierarchy { private TopologyLockHierarchy () { + this.completeTopologyLock = new TopologyLock(); this.serviceLock = new TopologyLock(); this.applicatioLock = new TopologyLock(); this.serviceNameToTopologyLockMap = new ConcurrentHashMap(); @@ -144,4 +147,8 @@ public TopologyLock getServiceLock() { public TopologyLock getApplicatioLock() { return applicatioLock; } + + public TopologyLock getCompleteTopologyLock() { + return completeTopologyLock; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index 4211830e61..d32cecff5f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -25,7 +25,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -57,13 +57,13 @@ public boolean process(String type, String message, Object object) { ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. jsonToObject(message, ApplicationActivatedEvent.class); - TopologyManager.acquireWriteLockForApplication(event.getAppId()); + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForApplication(event.getAppId()); + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 55786fae37..7d06fd5604 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; import java.util.Set; @@ -57,12 +57,12 @@ public boolean process(String type, String message, Object object) { return false; } - TopologyManager.acquireWriteLockForApplications(); + TopologyUpdater.acquireWriteLockForApplications(); // since the Clusters will also get modified, acquire write locks for each Service Type Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); } } @@ -72,10 +72,10 @@ public boolean process(String type, String message, Object object) { } finally { if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); } } - TopologyManager.releaseWriteLockForApplications(); + TopologyUpdater.releaseWriteLockForApplications(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java index 062c7e1e6d..5e02565f4a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; import java.util.Set; @@ -65,11 +65,11 @@ public boolean process(String type, String message, Object object) { return false; } - TopologyManager.acquireWriteLockForApplications(); + TopologyUpdater.acquireWriteLockForApplications(); Set clusterDataHolders = event.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.acquireWriteLockForService(clusterData.getServiceType()); + TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); } } @@ -79,10 +79,10 @@ public boolean process(String type, String message, Object object) { } finally { if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.releaseWriteLockForService(clusterData.getServiceType()); + TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); } } - TopologyManager.releaseWriteLockForApplications(); + TopologyUpdater.releaseWriteLockForApplications(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index ef4bba2164..cb8eb5f9fe 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -28,7 +28,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -58,12 +58,12 @@ public boolean process(String type, String message, Object object) { ClusterActivatedEvent event = (ClusterActivatedEvent) Util. jsonToObject(message, ClusterActivatedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index 6eddfd3878..71df7ce871 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -27,7 +27,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class ClusterCreatedMessageProcessor extends MessageProcessor { @@ -53,12 +53,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterCreatedEvent event = (ClusterCreatedEvent) Util.jsonToObject(message, ClusterCreatedEvent.class); - TopologyManager.acquireWriteLockForService(event.getServiceName()); + TopologyUpdater.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyUpdater.releaseWriteLockForService(event.getServiceName()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 15819ff09a..57d7c4548e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -25,7 +25,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class ClusterMaintenanceModeMessageProcessor extends MessageProcessor { @@ -50,12 +50,12 @@ public boolean process(String type, String message, Object object) { ClusterMaintenanceModeEvent event = (ClusterMaintenanceModeEvent) Util. jsonToObject(message, ClusterMaintenanceModeEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java index fb45cd38ad..d81f4841e4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterRemovedMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class ClusterRemovedMessageProcessor extends MessageProcessor { @@ -51,12 +51,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterRemovedEvent event = (ClusterRemovedEvent) Util.jsonToObject(message, ClusterRemovedEvent.class); - TopologyManager.acquireWriteLockForService(event.getServiceName()); + TopologyUpdater.acquireWriteLockForService(event.getServiceName()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForService(event.getServiceName()); + TopologyUpdater.releaseWriteLockForService(event.getServiceName()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 999415d99d..f0df6eb097 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; import java.util.ArrayList; @@ -52,17 +52,13 @@ public boolean process(String type, String message, Object object) { CompleteTopologyEvent event = (CompleteTopologyEvent) Util.jsonToObject(message, CompleteTopologyEvent.class); if (!topology.isInitialized()) { - TopologyManager.acquireWriteLock(); + TopologyUpdater.acquireWriteLock(); try { - if (!topology.isInitialized()) { - return doProcess(event, topology); - } else { - return true; - } + return topology.isInitialized() || doProcess(event, topology); } finally { - TopologyManager.releaseWriteLock(); + TopologyUpdater.releaseWriteLock(); } } else { return true; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 3bf5fad791..ba9554f9ab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -23,7 +23,7 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -51,13 +51,13 @@ public boolean process(String type, String message, Object object) { GroupActivatedEvent event = (GroupActivatedEvent) Util. jsonToObject(message, GroupActivatedEvent.class); - TopologyManager.acquireWriteLockForApplication(event.getAppId()); + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForApplication(event.getAppId()); + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java index 2d3f8b3f5a..3135ba5608 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class InstanceSpawnedMessageProcessor extends MessageProcessor { @@ -51,12 +51,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event InstanceSpawnedEvent event = (InstanceSpawnedEvent) Util.jsonToObject(message, InstanceSpawnedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java index ec1b5ec49a..c3f884495f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java @@ -30,7 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberActivatedMessageProcessor extends MessageProcessor { @@ -55,12 +55,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberActivatedEvent event = (MemberActivatedEvent) Util.jsonToObject(message, MemberActivatedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java index b252a6176a..2a080fe370 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java @@ -27,7 +27,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberMaintenanceModeProcessor extends MessageProcessor { @@ -52,12 +52,12 @@ public boolean process(String type, String message, Object object) { MemberMaintenanceModeEvent event = (MemberMaintenanceModeEvent) Util. jsonToObject(message, MemberMaintenanceModeEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java index f0c3580f41..8f9f149c21 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java @@ -26,7 +26,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberReadyToShutdownMessageProcessor extends MessageProcessor{ @@ -51,12 +51,12 @@ public boolean process(String type, String message, Object object) { MemberReadyToShutdownEvent event = (MemberReadyToShutdownEvent) Util. jsonToObject(message, MemberReadyToShutdownEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java index 508ec39938..649a5b2367 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java @@ -30,7 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberStartedMessageProcessor extends MessageProcessor { @@ -55,12 +55,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberStartedEvent event = (MemberStartedEvent) Util.jsonToObject(message, MemberStartedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java index 4473add066..b3421040dc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java @@ -30,7 +30,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberSuspendedMessageProcessor extends MessageProcessor { @@ -55,12 +55,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberSuspendedEvent event = (MemberSuspendedEvent) Util.jsonToObject(message, MemberSuspendedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java index 3619b537cf..c7a910eb99 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberTerminatedMessageProcessor.java @@ -29,7 +29,7 @@ import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class MemberTerminatedMessageProcessor extends MessageProcessor { @@ -54,12 +54,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event MemberTerminatedEvent event = (MemberTerminatedEvent) Util.jsonToObject(message, MemberTerminatedEvent.class); - TopologyManager.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java index 1c4be8f8f0..b93d7c26bc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceCreatedMessageProcessor.java @@ -25,7 +25,7 @@ import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class ServiceCreatedMessageProcessor extends MessageProcessor { @@ -51,12 +51,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ServiceCreatedEvent event = (ServiceCreatedEvent) Util.jsonToObject(message, ServiceCreatedEvent.class); - TopologyManager.acquireWriteLockForServices(); + TopologyUpdater.acquireWriteLockForServices(); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForServices(); + TopologyUpdater.releaseWriteLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java index a38cbdcd13..d609812083 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ServiceRemovedMessageProcessor.java @@ -25,7 +25,7 @@ import org.apache.stratos.messaging.event.topology.ServiceRemovedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; public class ServiceRemovedMessageProcessor extends MessageProcessor { @@ -50,12 +50,12 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ServiceRemovedEvent event = (ServiceRemovedEvent) Util.jsonToObject(message, ServiceRemovedEvent.class); - TopologyManager.acquireWriteLockForServices(); + TopologyUpdater.acquireWriteLockForServices(); try { return doProcess(event, topology); } finally { - TopologyManager.releaseWriteLockForServices(); + TopologyUpdater.releaseWriteLockForServices(); } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java new file mode 100644 index 0000000000..3da5835716 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java @@ -0,0 +1,272 @@ +/* + * 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.messaging.message.processor.topology.updater; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +/** + * Used to lock the Topology for writes by messaging component + * + * Acquire a write lock: + * + * From root level, acquire read lock, and acquire a write lock only for the + * relevant sub tree. + * + * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - + * acquiring: + * public static void acquireWriteLockForCluster (String serviceName, String clusterId) + * + * releasing: + * public static void releaseWriteLockForCluster (String serviceName, String clusterId) + * + * Example 2: Acquiring write lock to add a new Cluster object - + * acquiring: + * public static void acquireWriteLockForService (String serviceName) + * + * releasing: + * public static void releaseWriteLockForService (String serviceName) + * + * Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service) + * acquire: + * public static void acquireWriteLockForServices() + * + * release: + * public static void releaseWriteLockForServices() + */ + +public class TopologyUpdater { + + private static final Log log = LogFactory.getLog(TopologyUpdater.class); + + private static final TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance(); + + // Top level locks - should be used to lock the entire Topology + + /** + * Acquires write lock for the Complete Topology + */ + public static void acquireWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Topology"); + } + topologyLockHierarchy.getCompleteTopologyLock().acquireWriteLock(); + } + + /** + * Releases write lock for the Complete Topology + */ + public static void releaseWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Topology"); + } + topologyLockHierarchy.getCompleteTopologyLock().releaseWritelock(); + } + + // Application and Service write locks + /** + * Acquires write lock for the all Applications + */ + public static void acquireWriteLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Applications"); + } + topologyLockHierarchy.getApplicatioLock().acquireWriteLock(); + } + + /** + * Releases write lock for the all Applications + */ + public static void releaseWriteLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Applications"); + } + topologyLockHierarchy.getApplicatioLock().releaseWritelock(); + } + + /** + * Acquires write lock for the all Services + */ + public static void acquireWriteLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Services"); + } + topologyLockHierarchy.getServiceLock().acquireWriteLock(); + } + + /** + * Releases write lock for the all Services + */ + public static void releaseWriteLockForServices() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Services"); + } + topologyLockHierarchy.getServiceLock().releaseWritelock(); + } + + /** + * Acquires write lock for a Service + * + * @param serviceName service name to acquire write lock + */ + public static void acquireWriteLockForService (String serviceName) { + + // acquire read lock for all Applications + TopologyManager.acquireReadLockForServices(); + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Service " + serviceName); + } + } + } + + /** + * Releases write lock for a Service + * + * @param serviceName service name to release write lock + */ + public static void releaseWriteLockForService (String serviceName) { + + TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); + if (topologyServiceLock == null) { + handleLockNotFound("Topology lock not found for Service " + serviceName); + + } else { + topologyServiceLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Service " + serviceName); + } + } + + // release read lock for all Services + TopologyManager.releaseReadLockForServices(); + } + + /** + * Acquires write lock for a Cluster. This will acquire the write lock in the following order + * 1. for the Service + * 2. for the Cluster + * + * @param serviceName service name to acquire write lock + * @param clusterId cluster id to acquire write lock + */ + public static void acquireWriteLockForCluster (String serviceName, String clusterId) { + + // acquire read lock for the relevant Services + TopologyManager.acquireReadLockForService(serviceName); + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + topologyClusterLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Cluster " + clusterId); + } + } + } + + /** + * Releases write lock for a Cluster. This will release the write lock in the following order + * 1. for the Cluster + * 2. for the Service + * + * @param serviceName service name to release write lock + * @param clusterId cluster id to release write lock + */ + public static void releaseWriteLockForCluster (String serviceName, String clusterId) { + + TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); + if (topologyClusterLock == null) { + handleLockNotFound("Topology lock not found for Cluster " + clusterId); + + } else { + topologyClusterLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Cluster " + clusterId); + } + } + + // release read lock for relevant Service + TopologyManager.releaseReadLockForService(serviceName); + } + + /** + * Acquires write lock for the Application + * + * @param appId Application id + */ + public static void acquireWriteLockForApplication (String appId) { + + // acquire read lock for all Applications + TopologyManager.acquireReadLockForApplications(); + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // now, lock Application + topologyAppLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Application " + appId); + } + } + } + + /** + * Releases write lock for the Application + * + * @param appId Application id + */ + public static void releaseWriteLockForApplication (String appId) { + + TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); + if (topologyAppLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // release App lock + topologyAppLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Application " + appId); + } + } + + // release read lock for all Applications + TopologyManager.releaseReadLockForApplications(); + } + + private static void handleLockNotFound (String errorMsg) { + log.warn(errorMsg); + //throw new RuntimeException(errorMsg); + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index d636912076..fbb2faf6f1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -25,8 +25,6 @@ import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; -import java.util.concurrent.locks.ReentrantReadWriteLock; - /** * A singleton class for managing the topology data structure. * @@ -39,44 +37,26 @@ * Stratos supports hierarchical locking. As per the practice, we need to lock the * hierarchy from root level till the relevant sub tree. * - * Acquire a write lock: - * - * From root level, acquire read lock, and acquire a write lock only for the - * relevant sub tree. - * * Acquire a read lock: * * From root level, acquire read locks till the relevant sub tree * * Examples - * - * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - - * acquiring: - * public static void acquireWriteLockForCluster (String serviceName, String clusterId) - * - * releasing: - * public static void releaseWriteLockForCluster (String serviceName, String clusterId) - * - * Example 2: Acquiring write lock to add a new Cluster object - - * acquiring: - * public static void acquireWriteLockForService (String serviceName) - * - * releasing: - * public static void releaseWriteLockForService (String serviceName) - * - * Example 3: Acquiring read lock to read Cluster information + * Example 1: Acquiring read lock to read Cluster information * acquiring: * public static void acquireReadLockForCluster (String serviceName, String clusterId) * * releasing: * public static void releaseReadLockForCluster (String serviceName, String clusterId) * - * Example 4: Acquiring the write lock to add a deploy a Cartridge (add a new Service) - * acquire: - * public static void acquireWriteLockForServices() * - * release: - * public static void releaseWriteLockForServices() + * Example 2: Acquiring read lock for a particular Service + * acquiring: + * public static void acquireReadLockForService (String serviceName) + * + * releasing: + * public static void releaseReadLockForService (String serviceName) */ public class TopologyManager { private static final Log log = LogFactory.getLog(TopologyManager.class); @@ -84,12 +64,6 @@ public class TopologyManager { private static volatile Topology topology; private static final TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance(); - private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); - private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); - private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); - - - // Top level locks - should be used to lock the entire Topology /** * Acquires read lock for the Complete Topology @@ -98,7 +72,7 @@ public static void acquireReadLock() { if(log.isDebugEnabled()) { log.debug("Read lock acquired for Topology"); } - readLock.lock(); + topologyLockHierarchy.getCompleteTopologyLock().acquireReadLock(); } /** @@ -108,27 +82,7 @@ public static void releaseReadLock() { if(log.isDebugEnabled()) { log.debug("Read lock released for Topology"); } - readLock.unlock(); - } - - /** - * Acquires write lock for the Complete Topology - */ - public static void acquireWriteLock() { - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Topology"); - } - writeLock.lock(); - } - - /** - * Releases write lock for the Complete Topology - */ - public static void releaseWriteLock() { - if(log.isDebugEnabled()) { - log.debug("Write lock released for Topology"); - } - writeLock.unlock(); + topologyLockHierarchy.getCompleteTopologyLock().releaseReadLock(); } // Application and Service read locks @@ -172,47 +126,6 @@ public static void releaseReadLockForServices() { topologyLockHierarchy.getServiceLock().releaseReadLock(); } - // Application and Service write locks - /** - * Acquires write lock for the all Applications - */ - public static void acquireWriteLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Applications"); - } - topologyLockHierarchy.getApplicatioLock().acquireWriteLock(); - } - - /** - * Releases write lock for the all Applications - */ - public static void releaseWriteLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Write lock released for Applications"); - } - topologyLockHierarchy.getApplicatioLock().releaseWritelock(); - } - - /** - * Acquires write lock for the all Services - */ - public static void acquireWriteLockForServices() { - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Services"); - } - topologyLockHierarchy.getServiceLock().acquireWriteLock(); - } - - /** - * Releases write lock for the all Services - */ - public static void releaseWriteLockForServices() { - if(log.isDebugEnabled()) { - log.debug("Write lock released for Services"); - } - topologyLockHierarchy.getServiceLock().releaseWritelock(); - } - /** * Acquires read lock for a Service * @@ -257,50 +170,6 @@ public static void releaseReadLockForService (String serviceName) { releaseReadLockForServices(); } - /** - * Acquires write lock for a Service - * - * @param serviceName service name to acquire write lock - */ - public static void acquireWriteLockForService (String serviceName) { - - // acquire read lock for all Applications - acquireReadLockForServices(); - - TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); - if (topologyServiceLock == null) { - handleLockNotFound("Topology lock not found for Service " + serviceName); - - } else { - topologyServiceLock.acquireWriteLock(); - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Service " + serviceName); - } - } - } - - /** - * Releases write lock for a Service - * - * @param serviceName service name to release write lock - */ - public static void releaseWriteLockForService (String serviceName) { - - TopologyLock topologyServiceLock = topologyLockHierarchy.getTopologyLockForService(serviceName); - if (topologyServiceLock == null) { - handleLockNotFound("Topology lock not found for Service " + serviceName); - - } else { - topologyServiceLock.releaseWritelock(); - if(log.isDebugEnabled()) { - log.debug("Write lock released for Service " + serviceName); - } - } - - // release read lock for all Services - releaseReadLockForServices(); - } - /** * Acquires read lock for a Cluster. This will acquire the read lock in the following order * 1. for the Service @@ -353,56 +222,6 @@ public static void releaseReadLockForCluster (String serviceName, String cluster releaseReadLockForService(serviceName); } - /** - * Acquires write lock for a Cluster. This will acquire the write lock in the following order - * 1. for the Service - * 2. for the Cluster - * - * @param serviceName service name to acquire write lock - * @param clusterId cluster id to acquire write lock - */ - public static void acquireWriteLockForCluster (String serviceName, String clusterId) { - - // acquire read lock for the relevant Services - acquireReadLockForService(serviceName); - - TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); - if (topologyClusterLock == null) { - handleLockNotFound("Topology lock not found for Cluster " + clusterId); - - } else { - topologyClusterLock.acquireWriteLock(); - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Cluster " + clusterId); - } - } - } - - /** - * Releases write lock for a Cluster. This will release the write lock in the following order - * 1. for the Cluster - * 2. for the Service - * - * @param serviceName service name to release write lock - * @param clusterId cluster id to release write lock - */ - public static void releaseWriteLockForCluster (String serviceName, String clusterId) { - - TopologyLock topologyClusterLock = topologyLockHierarchy.getTopologyLockForCluster(clusterId); - if (topologyClusterLock == null) { - handleLockNotFound("Topology lock not found for Cluster " + clusterId); - - } else { - topologyClusterLock.releaseWritelock(); - if(log.isDebugEnabled()) { - log.debug("Write lock released for Cluster " + clusterId); - } - } - - // release read lock for relevant Service - releaseReadLockForService(serviceName); - } - /** * Acquires read lock for the Application * @@ -449,52 +268,6 @@ public static void releaseReadLockForApplication (String appId) { releaseReadLockForApplications(); } - /** - * Acquires write lock for the Application - * - * @param appId Application id - */ - public static void acquireWriteLockForApplication (String appId) { - - // acquire read lock for all Applications - acquireReadLockForApplications(); - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // now, lock Application - topologyAppLock.acquireWriteLock(); - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Application " + appId); - } - } - } - - /** - * Releases write lock for the Application - * - * @param appId Application id - */ - public static void releaseWriteLockForApplication (String appId) { - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // release App lock - topologyAppLock.releaseWritelock(); - if(log.isDebugEnabled()) { - log.debug("Write lock released for Application " + appId); - } - } - - // release read lock for all Applications - releaseReadLockForApplications(); - } - private static void handleLockNotFound (String errorMsg) { log.warn(errorMsg); //throw new RuntimeException(errorMsg); diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index cde7b4791f..8f25af11bf 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.topology.locking; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.junit.*; @@ -114,21 +115,21 @@ public void testAqcuireAndReleaseReadLocksForServices3To4 () { @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForServices1To2 () { - TopologyManager.acquireWriteLockForService("service1"); - TopologyManager.acquireWriteLockForService("service2"); + TopologyUpdater.acquireWriteLockForService("service1"); + TopologyUpdater.acquireWriteLockForService("service2"); - TopologyManager.releaseWriteLockForService("service1"); - TopologyManager.releaseWriteLockForService("service2"); + TopologyUpdater.releaseWriteLockForService("service1"); + TopologyUpdater.releaseWriteLockForService("service2"); } @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForServices3To4 () { - TopologyManager.acquireWriteLockForService("service3"); - TopologyManager.acquireWriteLockForService("service4"); + TopologyUpdater.acquireWriteLockForService("service3"); + TopologyUpdater.acquireWriteLockForService("service4"); - TopologyManager.releaseWriteLockForService("service3"); - TopologyManager.releaseWriteLockForService("service4"); + TopologyUpdater.releaseWriteLockForService("service3"); + TopologyUpdater.releaseWriteLockForService("service4"); } @Test(timeout=10000) @@ -154,21 +155,21 @@ public void testAqcuireAndReleaseReadLocksForClustersOfService2 () { @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForClustersOfService1 () { - TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); - TopologyManager.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); + TopologyUpdater.acquireWriteLockForCluster("service1", "service1.cluster1.domain"); + TopologyUpdater.acquireWriteLockForCluster("service1", "service1.cluster2.domain"); - TopologyManager.releaseWriteLockForCluster("service1", "service1.cluster1.domain"); - TopologyManager.releaseWriteLockForCluster("service1", "service1.cluster2.domain"); + TopologyUpdater.releaseWriteLockForCluster("service1", "service1.cluster1.domain"); + TopologyUpdater.releaseWriteLockForCluster("service1", "service1.cluster2.domain"); } @Test(timeout=10000) public void testAqcuireAndReleaseWriteLocksForClustersOfService2 () { - TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); - TopologyManager.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); + TopologyUpdater.acquireWriteLockForCluster("service2", "service2.cluster1.domain"); + TopologyUpdater.acquireWriteLockForCluster("service2", "service2.cluster2.domain"); - TopologyManager.releaseWriteLockForCluster("service2", "service2.cluster1.domain"); - TopologyManager.releaseWriteLockForCluster("service2", "service2.cluster2.domain"); + TopologyUpdater.releaseWriteLockForCluster("service2", "service2.cluster1.domain"); + TopologyUpdater.releaseWriteLockForCluster("service2", "service2.cluster2.domain"); } @Test(timeout=10000) @@ -181,8 +182,8 @@ public void testAcquireAndReleaseReadLockForApp1 () { @Test(timeout=10000) public void testAcquireAndReleaseWriteLockForApp1 () { - TopologyManager.acquireWriteLockForApplication("app1"); - TopologyManager.releaseWriteLockForApplication("app1"); + TopologyUpdater.acquireWriteLockForApplication("app1"); + TopologyUpdater.releaseWriteLockForApplication("app1"); } @Test(timeout=10000) @@ -195,8 +196,8 @@ public void testAcquireAndReleaseReadLockForApp2 () { @Test(timeout=10000) public void testAcquireAndReleaseWriteLockForApp2 () { - TopologyManager.acquireWriteLockForApplication("app2"); - TopologyManager.releaseWriteLockForApplication("app2"); + TopologyUpdater.acquireWriteLockForApplication("app2"); + TopologyUpdater.releaseWriteLockForApplication("app2"); } @AfterClass From a70bf6489ad0d14aa820719051f87add32494c1c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 17:09:32 +0530 Subject: [PATCH 167/436] adding some commits and making fields in TopologyLockHierarchy as final --- .../domain/topology/locking/TopologyLock.java | 16 ++++++++++++++++ .../topology/locking/TopologyLockHierarchy.java | 13 +++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java index 92a2f0a598..e73404c943 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLock.java @@ -21,6 +21,10 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; +/** + * Represents a lock in the Topology + */ + public class TopologyLock { private final ReentrantReadWriteLock lock; @@ -29,18 +33,30 @@ public TopologyLock () { lock = new ReentrantReadWriteLock(true); } + /** + * acquires write lock + */ public void acquireWriteLock() { lock.writeLock().lock(); } + /** + * releases write lock + */ public void releaseWritelock() { lock.writeLock().unlock(); } + /** + * acquires read lock + */ public void acquireReadLock() { lock.readLock().lock(); } + /** + * releases read lock + */ public void releaseReadLock() { lock.readLock().unlock(); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java index d7ab0a1869..4a2fc5869e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -29,22 +29,23 @@ public class TopologyLockHierarchy { private static final Log log = LogFactory.getLog(TopologyLockHierarchy.class); - private TopologyLock completeTopologyLock; + // lock for te full Topology + private final TopologyLock completeTopologyLock; // lock for Services - private TopologyLock serviceLock; + private final TopologyLock serviceLock; // lock for Applications - private TopologyLock applicatioLock; + private final TopologyLock applicatioLock; // key = Service.name - private Map serviceNameToTopologyLockMap; + private final Map serviceNameToTopologyLockMap; // key = Application.id - private Map applicationIdToTopologyLockMap; + private final Map applicationIdToTopologyLockMap; // key = Cluster.id - private Map clusterIdToTopologyLockMap; + private final Map clusterIdToTopologyLockMap; private static volatile TopologyLockHierarchy topologyLockHierarchy; From 9934c2ab7a20a42cbee5226d2aec7a9a088db838 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 9 Oct 2014 19:26:45 +0530 Subject: [PATCH 168/436] fixing hierarchical monitor issue --- .../dependency/DependencyBuilder.java | 85 ++++++++++--------- .../context/ApplicationContextFactory.java | 4 +- .../AutoscalerTopologyEventReceiver.java | 3 +- .../stratos/autoscaler/monitor/Monitor.java | 10 ++- .../messaging/domain/topology/Group.java | 2 +- 5 files changed, 56 insertions(+), 48 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 30709e786a..275b8c3f58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -84,56 +84,61 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen //Parsing the start up order Set startupOrders = dependencyOrder.getStartupOrders(); ApplicationContext foundContext; - if (startupOrders == null) { + ApplicationContext parentContext; + /*if (startupOrders == null) { if (log.isDebugEnabled()) { log.debug("startupOrders is null, returning default dependency tree (empty)"); } - - return dependencyTree; - } - for (StartupOrder startupOrder : startupOrders) { - - foundContext = null; - - for (String start : startupOrder.getStartList()) { - - if (start != null) { - ApplicationContext applicationContext = ApplicationContextFactory. - getApplicationContext(start, component, dependencyTree.isKillDependent()); - String id = applicationContext.getId(); //TODO change the id - - ApplicationContext existingApplicationContext = - dependencyTree.findApplicationContextWithId(id); - if (existingApplicationContext == null) { - if (foundContext != null) { - //appending the start up order to existing group/cluster - foundContext.addApplicationContext(applicationContext); - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + foundContext.getId() + - " and adding the [dependency] " + id + " as the child"); + return dependencyTree; + }*/ + if (startupOrders != null) { + for (StartupOrder startupOrder : startupOrders) { + foundContext = null; + parentContext = null; + for (String start : startupOrder.getStartList()) { + + if (start != null) { + ApplicationContext applicationContext = ApplicationContextFactory. + getApplicationContext(start, component, dependencyTree.isKillDependent()); + String id = applicationContext.getId(); + + ApplicationContext existingApplicationContext = + dependencyTree.findApplicationContextWithId(id); + if (existingApplicationContext == null) { + if (parentContext != null) { + //appending the start up order to already added parent group/cluster + parentContext.addApplicationContext(applicationContext); + parentContext = applicationContext; + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + parentContext.getId() + + " and adding the [dependency] " + id + " as the child"); + } + } else { + //adding list of startup order to the dependency tree + dependencyTree.addApplicationContext(applicationContext); + parentContext = applicationContext; } } else { - //adding list of startup order to the dependency tree - dependencyTree.addApplicationContext(applicationContext); - } - } else { - if (foundContext == null) { - //assigning the found context to the later use. - foundContext = existingApplicationContext; - if (log.isDebugEnabled()) { - log.debug("Found an existing [dependency] " + id + " and setting it " + - "for the next dependency to follow"); + if (foundContext == null) { + //if existing context found, add it to child of existing context and + //set the existing context as the next parent + existingApplicationContext.addApplicationContext(applicationContext); + parentContext = existingApplicationContext; + if (log.isDebugEnabled()) { + log.debug("Found an existing [dependency] " + id + " and setting it " + + "for the next dependency to follow"); + } + } else { + String msg = "Startup order is not consistent. It contains the group/cluster " + + "which has been used more than one in another startup order"; + throw new DependencyBuilderException(msg); } - } else { - String msg = "Startup order is not consistent. It contains the group/cluster " + - "which has been used more than one in another startup order"; - throw new DependencyBuilderException(msg); - } + } } } - } + } } //TODO need to parser the scalable dependencies } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java index 6e1063351a..685f131d71 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -42,12 +42,12 @@ public static ApplicationContext getApplicationContext(String startOrder, boolean isKillDependent) { String id; ApplicationContext applicationContext = null; - if (startOrder.contains(Constants.GROUP)) { + if (startOrder.startsWith(Constants.GROUP + ".")) { //getting the group alias id = getGroupFromStartupOrder(startOrder); applicationContext = new GroupContext(id, isKillDependent); - } else if (startOrder.contains(Constants.CARTRIDGE)) { + } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) { //getting the cluster alias id = getClusterFromStartupOrder(startOrder); //getting the cluster-id from cluster alias diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index df9a3c3bb6..91189fb730 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -624,9 +624,8 @@ public void run() { applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); long end = System.currentTimeMillis(); - log.info("Time taken to start Napp monitor: " + (end - start) / 1000); + log.info("Time taken to start app monitor: " + (end - start) / 1000); success = true; - //TODO exception handling } catch (DependencyBuilderException e) { String msg = "Application monitor creation failed for Application: "; log.warn(msg, e); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 65ab790c15..800ed64f90 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -122,9 +122,13 @@ private boolean startDependency(List applicationContexts) if (context instanceof GroupContext) { startGroupMonitor(this, context.getId(), component); } else if (context instanceof ClusterContext) { - ClusterDataHolder clusterDataHolder = component.getClusterData(context.getId()); - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); + String clusterId = context.getId(); + String serviceName = null; + for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + if(dataHolder.getClusterId().equals(clusterId)) { + serviceName = dataHolder.getServiceType(); + } + } Cluster cluster; //acquire read lock for the service and cluster TopologyManager.acquireReadLockForCluster(clusterId, serviceName); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 17e1a90e60..9b5a29ee3f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -42,7 +42,7 @@ public Group (String name, String alias) { } public String getUniqueIdentifier() { - return name; + return alias; } public String getAlias() { From 57794fc29287f56a071765c290acc7c9f11c35d8 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 9 Oct 2014 19:32:14 +0530 Subject: [PATCH 169/436] fixing issue while setting the status of cluster monitor --- .../stratos/autoscaler/monitor/cluster/ClusterMonitor.java | 2 ++ .../java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 0c81334fd8..b9e99481e9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -31,6 +31,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; import java.util.List; @@ -64,6 +65,7 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); } networkPartitionCtxts = new ConcurrentHashMap(); + status = Status.Created; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index cd8578ef58..3cfdecea71 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -114,7 +114,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal cluster.getServiceName(), deploymentPolicy, policy); clusterMonitor.setAppId(cluster.getAppId()); - clusterMonitor.setStatus(Status.Created); + //clusterMonitor.setStatus(Status.Created); for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){ From 62387055a5d94eb012263812eb03b17b4c5a9d0d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 9 Oct 2014 20:46:04 +0530 Subject: [PATCH 170/436] fixing a bug in CompleteTopologyMessageProcessor --- .../CompleteTopologyMessageProcessor.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index f0df6eb097..641495145a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -55,15 +55,19 @@ public boolean process(String type, String message, Object object) { TopologyUpdater.acquireWriteLock(); try { - return topology.isInitialized() || doProcess(event, topology); + if (!topology.isInitialized()) { + doProcess(event, topology); + } } finally { TopologyUpdater.releaseWriteLock(); } - } else { - return true; } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { if (nextProcessor != null) { // ask the next processor to take care of the message. @@ -73,7 +77,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (CompleteTopologyEvent event, Topology topology) { + private void doProcess (CompleteTopologyEvent event, Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -162,9 +166,5 @@ private boolean doProcess (CompleteTopologyEvent event, Topology topology) { // Set topology initialized topology.setInitialized(true); - - // Notify event listeners - notifyEventListeners(event); - return true; } } From d11103577c1f86e59d0fdcdb3aa4db96bbef086e Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 10 Oct 2014 15:14:26 +0530 Subject: [PATCH 171/436] fixing bugs --- .../stratos/autoscaler/monitor/Monitor.java | 4 +-- .../CompleteTopologyMessageProcessor.java | 27 ++++++++++++++++--- .../topology/updater/TopologyUpdater.java | 2 +- .../receiver/topology/TopologyManager.java | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 800ed64f90..3cdcdc5c44 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -131,7 +131,7 @@ private boolean startDependency(List applicationContexts) } Cluster cluster; //acquire read lock for the service and cluster - TopologyManager.acquireReadLockForCluster(clusterId, serviceName); + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); try { Topology topology = TopologyManager.getTopology(); if (topology.serviceExists(serviceName)) { @@ -154,7 +154,7 @@ private boolean startDependency(List applicationContexts) } } finally { //release read lock for the service and cluster - TopologyManager.releaseReadLockForCluster(clusterId, serviceName); + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 641495145a..f6af30012e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -21,6 +21,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -55,9 +57,7 @@ public boolean process(String type, String message, Object object) { TopologyUpdater.acquireWriteLock(); try { - if (!topology.isInitialized()) { - doProcess(event, topology); - } + doProcess(event, topology); } finally { TopologyUpdater.releaseWriteLock(); @@ -79,6 +79,9 @@ public boolean process(String type, String message, Object object) { private void doProcess (CompleteTopologyEvent event, Topology topology) { + // add locks for all the Clusters currently in Topology + addTopologyLocksForClusters(event.getTopology().getServices()); + // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { // Add services included in service filter @@ -167,4 +170,22 @@ private void doProcess (CompleteTopologyEvent event, Topology topology) { // Set topology initialized topology.setInitialized(true); } + + + private void addTopologyLocksForClusters (Collection services) { + + if (services == null) { + return; + } + + for (Service service : services) { + // get all the clusters and add locks + if (service.getClusters() != null) { + for (Cluster aCluster: service.getClusters()) { + TopologyLockHierarchy.getInstance().addClusterLock(aCluster.getClusterId(), + new TopologyLock()); + } + } + } + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java index 3da5835716..9867223f06 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java @@ -59,7 +59,7 @@ public class TopologyUpdater { private static final Log log = LogFactory.getLog(TopologyUpdater.class); - private static final TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance(); + private static volatile TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance(); // Top level locks - should be used to lock the entire Topology diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index fbb2faf6f1..1d74616f70 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -62,7 +62,7 @@ public class TopologyManager { private static final Log log = LogFactory.getLog(TopologyManager.class); private static volatile Topology topology; - private static final TopologyLockHierarchy topologyLockHierarchy = + private static volatile TopologyLockHierarchy topologyLockHierarchy = TopologyLockHierarchy.getInstance(); /** From 4e1ac4813039f353e3955443527926eaa17908f2 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 10 Oct 2014 16:27:20 +0530 Subject: [PATCH 172/436] removing a thread join in AutoscalerTopologyEventReceiver#startApplicationMonitor() --- .../topology/AutoscalerTopologyEventReceiver.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 91189fb730..a7b6eda0d8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -584,19 +584,19 @@ protected synchronized void startApplicationMonitor(Application application) { th = new Thread( new ApplicationMonitorAdder(application)); } - if (th != null) { + // if (th != null) { th.start(); - try { - th.join(); - } catch (InterruptedException ignore) { - } + // try { + // th.join(); + // } catch (InterruptedException ignore) { + // } if (log.isDebugEnabled()) { log.debug(String .format("Application monitor thread has been started successfully: " + "[application] %s ", application.getUniqueIdentifier())); } - } + // } } private class ApplicationMonitorAdder implements Runnable { From 4ec03a1da8be0ad6fce8fe8e332f14f09b0aacaf Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 10 Oct 2014 17:22:19 +0530 Subject: [PATCH 173/436] fixing monitors status update issue and Topology issue --- .../stratos/autoscaler/monitor/Monitor.java | 16 +++++++++++++--- .../autoscaler/monitor/group/GroupMonitor.java | 2 +- .../stratos/autoscaler/util/AutoscalerUtil.java | 4 ++-- ...tionStatusGroupActivatedMessageProcessor.java | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 800ed64f90..486036a550 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -109,7 +109,7 @@ public boolean startDependency(String id) throws TopologyInConsistentException { */ private boolean startDependency(List applicationContexts) throws TopologyInConsistentException { - if (applicationContexts == null) { + if (applicationContexts != null && applicationContexts.isEmpty()) { //all the groups/clusters have been started and waiting for activation log.info("There is no child found for the [group]: " + this.id); return false; @@ -131,7 +131,7 @@ private boolean startDependency(List applicationContexts) } Cluster cluster; //acquire read lock for the service and cluster - TopologyManager.acquireReadLockForCluster(clusterId, serviceName); + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); try { Topology topology = TopologyManager.getTopology(); if (topology.serviceExists(serviceName)) { @@ -154,7 +154,7 @@ private boolean startDependency(List applicationContexts) } } finally { //release read lock for the service and cluster - TopologyManager.releaseReadLockForCluster(clusterId, serviceName); + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); } } } @@ -284,6 +284,11 @@ public void run() { } monitor = AutoscalerUtil.getClusterMonitor(cluster); monitor.setParent(parent); + //setting the status of cluster monitor w.r.t Topology cluster + if(cluster.getStatus() != Status.Created) { + //updating the status, so that it will notify the parent + monitor.setStatus(cluster.getStatus()); + } //monitor.addObserver(parent); success = true; //TODO start the status checker @@ -351,6 +356,11 @@ public void run() { } monitor = AutoscalerUtil.getGroupMonitor(component.getGroup(dependency)); monitor.setParent(parent); + //setting the status of cluster monitor w.r.t Topology cluster + if(component.getStatus() != Status.Created) { + //updating the status, so that it will notify the parent + monitor.setStatus(component.getStatus()); + } //monitor.addObserver(parent); success = true; } catch (DependencyBuilderException e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index f9a1a67e57..70dc0a94a6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -85,7 +85,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); //updating the life cycle and current status - context.setStatus(status); + context.setStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); if(!startDep) { //Checking in the children whether all are active, diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 3cfdecea71..f574367e11 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -114,8 +114,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal cluster.getServiceName(), deploymentPolicy, policy); clusterMonitor.setAppId(cluster.getAppId()); - //clusterMonitor.setStatus(Status.Created); - + for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){ NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), @@ -163,6 +162,7 @@ public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyVal } clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); + //clusterMonitor.setStatus(Status.Created); if(log.isInfoEnabled()){ log.info(String.format("Network partition context has been added: [network partition] %s", networkPartitionContext.getId())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java index 3d6b069798..01c3fa6e60 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java @@ -38,7 +38,7 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ClusterActivatedEvent.class.getName().equals(type)) { + if (GroupActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event GroupActivatedEvent event = (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); From 7f2cb13c754a593fd7c90c1588d9cfb8484a83ba Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 10 Oct 2014 18:00:44 +0530 Subject: [PATCH 174/436] validating if the TopologyLock has already been removed --- .../locking/TopologyLockHierarchy.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java index 4a2fc5869e..015fa2e9de 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -127,18 +127,27 @@ public TopologyLock getTopologyLockForCluster (String clusterId) { } public void removeTopologyLockForApplication (String appId) { - applicationIdToTopologyLockMap.remove(appId); - log.info("Removed lock for Application " + appId); + if (applicationIdToTopologyLockMap.remove(appId) != null) { + log.info("Removed lock for Application " + appId); + } else { + log.info("Lock already removed for Application " + appId); + } } public void removeTopologyLockForService (String serviceName) { - serviceNameToTopologyLockMap.remove(serviceName); - log.info("Removed lock for Service " + serviceName); + if (serviceNameToTopologyLockMap.remove(serviceName) != null) { + log.info("Removed lock for Service " + serviceName); + } else { + log.info("Lock already removed for Service " + serviceName); + } } public void removeTopologyLockForCluster (String clusterId) { - clusterIdToTopologyLockMap.remove(clusterId); - log.info("Removed lock for Cluster " + clusterId); + if (clusterIdToTopologyLockMap.remove(clusterId) != null) { + log.info("Removed lock for Cluster " + clusterId); + } else { + log.info("Lock already removed for Cluster " + clusterId); + } } public TopologyLock getServiceLock() { From 7a201c29499f6a3ea63716f6efd7a77388bec5ab Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 10 Oct 2014 18:05:05 +0530 Subject: [PATCH 175/436] fixing GroupActivatedEvent issue and GroupMonitor issue upon GroupActivation --- .../autoscaler/monitor/application/ApplicationMonitor.java | 2 +- .../stratos/cloud/controller/topology/TopologyBuilder.java | 2 +- .../stratos/messaging/domain/topology/ParentComponent.java | 2 +- .../message/processor/topology/GroupActivatedProcessor.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 2ad2a0e98a..1505a43eff 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -126,7 +126,7 @@ public GroupMonitor findGroupMonitorWithId(String groupId) { private GroupMonitor findGroupMonitor(String id, Collection monitors) { for (GroupMonitor monitor : monitors) { // check if alias is equal, if so, return - if (monitor.equals(id)) { + if (monitor.getId().equals(id)) { return monitor; } else { // check if this Group has nested sub Groups. If so, traverse them as well diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 0913c0041f..5a90264f1a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -773,7 +773,7 @@ public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedE return; } - Group group = application.getGroup(groupActivatedEvent.getGroupId()); + Group group = application.getGroupRecursively(groupActivatedEvent.getGroupId()); if (group == null) { log.warn(String.format("Group %s does not exist", groupActivatedEvent.getGroupId())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java index d76663ca60..7ce813e20f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java @@ -104,7 +104,7 @@ private Group travereAndCheckRecursively (Map aliasToGroupMap, Str } } else { for (Group group : aliasToGroupMap.values()) { - travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); + return travereAndCheckRecursively(group.getAliasToGroupMap(), groupAlias); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index ba9554f9ab..230fcf21ed 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -30,7 +30,7 @@ * This processor will act upon the Group activation events */ public class GroupActivatedProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ClusterActivatedProcessor.class); + private static final Log log = LogFactory.getLog(GroupActivatedProcessor.class); private MessageProcessor nextProcessor; @Override @@ -81,7 +81,7 @@ private boolean doProcess (GroupActivatedEvent event,Topology topology) { } return false; } - Group group = application.getGroup(event.getGroupId()); + Group group = application.getGroupRecursively(event.getGroupId()); if (group == null) { if (log.isWarnEnabled()) { From fade19d7916109a06b66656168aacc0f81572d30 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 10 Oct 2014 18:35:45 +0530 Subject: [PATCH 176/436] fixing group activation issue --- .../apache/stratos/autoscaler/status/checker/StatusChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 78e9793bb6..9bf2241651 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -207,7 +207,7 @@ private boolean updateChildStatus(String appId, String id, Map gr private boolean getGroupStatus(Map groups) { boolean groupActiveStatus = false; for (Group group : groups.values()) { - if (group.getStatus().equals(GroupStatus.Active)) { + if (group.getStatus() == Status.Activated) { groupActiveStatus = true; } else { groupActiveStatus = false; From 26a093993e57fa21e488ed4a72e6a6f5b205ee68 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Fri, 10 Oct 2014 11:07:13 -0700 Subject: [PATCH 177/436] fixing NPE when deploying group without dependencies --- .../impl/CloudControllerServiceImpl.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 72874e52bb..68ccc5e64f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -308,17 +308,19 @@ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceG log.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); } - String [] startupOrders = dependencies.getStartupOrders(); - - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); - - if (startupOrders != null) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); - } else { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); - } - } + if (dependencies != null) { + String [] startupOrders = dependencies.getStartupOrders(); + + if(log.isDebugEnabled()) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); + + if (startupOrders != null) { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); + } else { + log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); + } + } + } dataHolder.addServiceGroup(servicegroup); From 59d3134ef5d8f32787f39957f5f08db52d21e6c2 Mon Sep 17 00:00:00 2001 From: reka Date: Sun, 12 Oct 2014 11:04:09 +0530 Subject: [PATCH 178/436] fixing application created event --- .../application/ApplicationMonitor.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 1505a43eff..01422cc597 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Status; @@ -225,9 +226,10 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { - ApplicationContext context = this.dependencyTree. + /*ApplicationContext context = this.dependencyTree. findApplicationContextWithId(statusEvent.getId()); - if(context.getStatusLifeCycle().isEmpty()) { + //TODO remove activated + if(context.getStatusLifeCycle().isEmpty() || context.getStatus() == Status.Activated) { try { //if life cycle is empty, need to start the monitor boolean dependencyStarted = startDependency(statusEvent.getId()); @@ -243,7 +245,31 @@ protected void monitor(MonitorStatusEvent statusEvent) { } } else { //TODO act based on life cycle events + }*/ + + String id = statusEvent.getId(); + ApplicationContext context = this.dependencyTree. + findApplicationContextWithId(id); + if(context.getStatusLifeCycle().isEmpty()) { + try { + //if life cycle is empty, need to start the monitor + boolean startDep = startDependency(statusEvent.getId()); + //updating the life cycle and current status + context.setStatus(statusEvent.getStatus()); + context.addStatusToLIfeCycle(statusEvent.getStatus()); + if(!startDep) { + //Checking in the children whether all are active, + // since no dependency found to be started. + StatusChecker.getInstance().onChildStatusChange(id, this.component, this.appId); + } + } catch (TopologyInConsistentException e) { + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error(e); + } + } else { + //TODO act based on life cycle events } + } } From 8db9180853b464eeae124814588b295a0e49e8cc Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 12 Oct 2014 17:04:12 +0530 Subject: [PATCH 179/436] adding simple tests for application parsing. not complet yet --- .../CompositeApplicationParseTest.java | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java new file mode 100644 index 0000000000..c2b76aff96 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; +import org.apache.stratos.cloud.controller.pojo.Cartridge; +import org.apache.stratos.cloud.controller.pojo.Dependencies; +import org.apache.stratos.cloud.controller.pojo.ServiceGroup; +import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.pojo.application.ComponentContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; +import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; +import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class CompositeApplicationParseTest { + + private static FasterLookUpDataHolder dataHolder = null; + + @BeforeClass + public static void setUpBeforeClass() { + + dataHolder = FasterLookUpDataHolder.getInstance(); + // add cartridges + // add php cartridge + dataHolder.addCartridge(new Cartridge("php", "stratos.com", "php-provider" , "1.0.0", false)); + // add tomcat cartridge + dataHolder.addCartridge(new Cartridge("tomcat", "stratos.com", "apache" , "1.0.0", false)); + // add mysql cartridge + dataHolder.addCartridge(new Cartridge("mysql", "stratos.com", "apache" , "1.0.0", false)); + + // add groups + // add group1 + ServiceGroup group1 = new ServiceGroup(); + group1.setName("group1"); + group1.setCartridges(new String[]{"mysql"}); + Dependencies group1Dependencies = new Dependencies(); + group1Dependencies.setKillBehaviour("kill-none"); + group1.setDependencies(group1Dependencies); + dataHolder.addServiceGroup(group1); + // add group2 + ServiceGroup group2 = new ServiceGroup(); + group2.setName("group2"); + group2.setCartridges(new String[]{"php"}); + group2.setSubGroups(new String[]{"group1"}); + Dependencies group2Dependencies = new Dependencies(); + group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"}); + group2Dependencies.setKillBehaviour("kill-dependents"); + group2.setDependencies(group2Dependencies); + dataHolder.addServiceGroup(group2); + } + + @Test + public void testParseSimpleApplication () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test(expected = ApplicationDefinitionException.class) + public void testParseSimpleInvalidCartridgeApplication() throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleInvalidApp"); + simpleAppCtxt.setAlias("simpleInvalidAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + // give invalid cartridge type + simpleAppSubscribableContext.setType("php1"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @AfterClass + public static void tearDownAfterClass() { + + dataHolder = null; + } +} From 91a8babd73f4c094c976865d337833ff4210ea05 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 12 Oct 2014 19:14:25 +0530 Subject: [PATCH 180/436] tests for parsing Applications --- .../application/parser/ParserUtils.java | 33 ++++- .../CompositeApplicationParseTest.java | 134 +++++++++++++++++- 2 files changed, 155 insertions(+), 12 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index 62a98ab791..dd72508d56 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -19,6 +19,7 @@ package org.apache.stratos.cloud.controller.application.parser; +import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.pojo.application.GroupContext; import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; import org.apache.stratos.messaging.domain.topology.StartupOrder; @@ -27,7 +28,7 @@ public class ParserUtils { - public static Set convert (String [] startupOrderArr) { + public static Set convert (String [] startupOrderArr) throws ApplicationDefinitionException { Set startupOrders = new HashSet(); @@ -36,13 +37,30 @@ public static Set convert (String [] startupOrderArr) { } for (String commaSeparatedStartupOrder : startupOrderArr) { - startupOrders.add(new StartupOrder(Arrays.asList(commaSeparatedStartupOrder.split(",")))); + startupOrders.add(getStartupOrder(commaSeparatedStartupOrder)); } return startupOrders; } - public static Set convert (String [] startupOrderArr, GroupContext groupContext) { + private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) throws ApplicationDefinitionException{ + + List startupOrders = new ArrayList(); + + for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) { + startupOrder = startupOrder.trim(); + if (!startupOrder.startsWith("cartridge.")) { + throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.'"); + } + + startupOrders.add(startupOrder); + } + + return new StartupOrder(startupOrders); + } + + public static Set convert (String [] startupOrderArr, GroupContext groupContext) + throws ApplicationDefinitionException { Set startupOrders = new HashSet(); @@ -60,7 +78,8 @@ public static Set convert (String [] startupOrderArr, GroupContext return startupOrders; } - private static StartupOrder getStartupOrder (List components, GroupContext groupContext) { + private static StartupOrder getStartupOrder (List components, GroupContext groupContext) + throws ApplicationDefinitionException { List aliasBasedComponents = new ArrayList(); @@ -72,7 +91,7 @@ private static StartupOrder getStartupOrder (List components, GroupConte String cartridgeType = component.substring(10); aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext); if (aliasBasedComponent == null) { - throw new RuntimeException("Unable convert Startup Order to alias-based; " + + throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + "cannot find the matching alias for Service type " + cartridgeType); } @@ -82,14 +101,14 @@ private static StartupOrder getStartupOrder (List components, GroupConte String groupName = component.substring(6); aliasBasedComponent = getAliasForGroupName(groupName, groupContext); if (aliasBasedComponent == null) { - throw new RuntimeException("Unable convert Startup Order to alias-based; " + + throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + "cannot find the matching alias for Group name " + groupName); } aliasBasedComponent = "group.".concat(aliasBasedComponent); } else { - throw new RuntimeException("Incorrect Startup Order specified"); + throw new ApplicationDefinitionException("Incorrect Startup Order specified"); } aliasBasedComponents.add(aliasBasedComponent); } diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index c2b76aff96..a2dc30a804 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -25,10 +25,7 @@ import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.Dependencies; import org.apache.stratos.cloud.controller.pojo.ServiceGroup; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; -import org.apache.stratos.cloud.controller.pojo.application.ComponentContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; +import org.apache.stratos.cloud.controller.pojo.application.*; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.junit.AfterClass; import org.junit.BeforeClass; @@ -104,7 +101,7 @@ public void testParseSimpleApplication () throws ApplicationDefinitionException } @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleInvalidCartridgeApplication() throws ApplicationDefinitionException { + public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException { ApplicationParser applicationParser = new DefaultApplicationParser(); ApplicationContext simpleAppCtxt = new ApplicationContext(); @@ -136,6 +133,133 @@ public void testParseSimpleInvalidCartridgeApplication() throws ApplicationDefin applicationParser.parse(simpleAppCtxt); } + @Test(expected = ApplicationDefinitionException.class) + public void testParseSimpleApplicationWithoutSubcriptionInformation() throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleInvalidApp"); + simpleAppCtxt.setAlias("simpleInvalidAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + // give invalid cartridge type + simpleAppSubscribableContext.setType("php1"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // invalid Subscription information + SubscribableInfoContext simpleAppEmptySubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppEmptySubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test + public void testParseSimpleApplicationWithMultipleSubsriptions () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleInvalidApp"); + simpleAppCtxt.setAlias("simpleInvalidAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); + simpleAppPhpSubscribableContext.setType("php"); + simpleAppPhpSubscribableContext.setAlias("myphp"); + SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); + simpleAppMySqlSubscribableContext.setType("mysql"); + simpleAppMySqlSubscribableContext.setAlias("mysql1"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, + simpleAppMySqlSubscribableContext}); + + DependencyContext simpleAppDependecyCtxt = new DependencyContext(); + simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"}); + simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); + + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + + // subscribable information + SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); + simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); + simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); + simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, + simpleAppMySqlSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test(expected = ApplicationDefinitionException.class) + public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrder () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleInvalidApp"); + simpleAppCtxt.setAlias("simpleInvalidAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); + simpleAppPhpSubscribableContext.setType("php"); + simpleAppPhpSubscribableContext.setAlias("myphp"); + SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); + simpleAppMySqlSubscribableContext.setType("mysql"); + simpleAppMySqlSubscribableContext.setAlias("mysql1"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, + simpleAppMySqlSubscribableContext}); + + DependencyContext simpleAppDependecyCtxt = new DependencyContext(); + simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + // startup order is invalid, without prefix 'cartridge.' for mysql1 + simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"}); + simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); + + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + + // subscribable information + SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); + simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); + simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); + simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, + simpleAppMySqlSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + @AfterClass public static void tearDownAfterClass() { From a0f91a208c20114e8a53975ec68646d5ae272e0b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 12 Oct 2014 19:18:28 +0530 Subject: [PATCH 181/436] adding a more meaningful exception message for Startup Order issues --- .../cloud/controller/application/parser/ParserUtils.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index dd72508d56..edc0486af3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -108,7 +108,8 @@ private static StartupOrder getStartupOrder (List components, GroupConte aliasBasedComponent = "group.".concat(aliasBasedComponent); } else { - throw new ApplicationDefinitionException("Incorrect Startup Order specified"); + throw new ApplicationDefinitionException("Incorrect Startup Order specified, " + + "should start with 'cartridge.' or 'group.'"); } aliasBasedComponents.add(aliasBasedComponent); } From 0403bc8eaf9aa03b0aefc6d34f053dec1a208011 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 12 Oct 2014 19:30:27 +0530 Subject: [PATCH 182/436] tests for parsing Applications --- .../CompositeApplicationParseTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index a2dc30a804..1859c7220d 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -100,6 +100,31 @@ public void testParseSimpleApplication () throws ApplicationDefinitionException applicationParser.parse(simpleAppCtxt); } + @Test(expected = ApplicationDefinitionException.class) + public void testParseSimpleApplicationWithNullAppId () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // no app id + simpleAppCtxt.setAlias("simpleAppAlias"); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test(expected = ApplicationDefinitionException.class) + public void testParseSimpleApplicationWithEmptyAppId () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // empty app id + simpleAppCtxt.setApplicationId(""); + simpleAppCtxt.setAlias("simpleAppAlias"); + + // parse + applicationParser.parse(simpleAppCtxt); + } + @Test(expected = ApplicationDefinitionException.class) public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException { From e5cec49351816c8d9bcdd791499696e766c7cb5b Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 00:44:10 +0530 Subject: [PATCH 183/436] fixing group activation issue --- .../stratos/autoscaler/monitor/Monitor.java | 11 +++++--- .../monitor/group/GroupMonitor.java | 3 +++ .../status/checker/StatusChecker.java | 26 +++++++++++++++---- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 486036a550..cc30f7b38b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -285,7 +285,8 @@ public void run() { monitor = AutoscalerUtil.getClusterMonitor(cluster); monitor.setParent(parent); //setting the status of cluster monitor w.r.t Topology cluster - if(cluster.getStatus() != Status.Created) { + //if(cluster.getStatus() != Status.Created && + if(cluster.getStatus() != monitor.getStatus()) { //updating the status, so that it will notify the parent monitor.setStatus(cluster.getStatus()); } @@ -354,12 +355,14 @@ public void run() { log.debug("Group monitor is going to be started for [group] " + dependency); } - monitor = AutoscalerUtil.getGroupMonitor(component.getGroup(dependency)); + Group group = component.getGroup(dependency); + monitor = AutoscalerUtil.getGroupMonitor(group); monitor.setParent(parent); //setting the status of cluster monitor w.r.t Topology cluster - if(component.getStatus() != Status.Created) { + //if(group.getStatus() != Status.Created && + if(group.getStatus() != monitor.getStatus()) { //updating the status, so that it will notify the parent - monitor.setStatus(component.getStatus()); + monitor.setStatus(group.getStatus()); } //monitor.addObserver(parent); success = true; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 70dc0a94a6..90876cb29e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -55,6 +55,7 @@ public GroupMonitor(Group group) throws DependencyBuilderException, super(group); this.id = group.getAlias(); startDependency(); + this.status = Status.Created; } @@ -84,6 +85,8 @@ protected void monitor(MonitorStatusEvent statusEvent) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); + log.info("started a child: " + startDep + " by the group/cluster: " + id); + //updating the life cycle and current status context.setStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 9bf2241651..4607f47493 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -26,7 +26,6 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.util.GroupStatus; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.Map; @@ -100,9 +99,11 @@ public void run() { try { //TODO getting lock TopologyManager.acquireReadLockForApplication(appId); - Map clusterIds = component.getClusterDataMap(); - Map groups = component.getAliasToGroupMap(); - updateChildStatus(appId, idOfChild, groups, clusterIds, component); + ParentComponent component1 = TopologyManager.getTopology(). + getApplication(appId).getGroupRecursively(component.getUniqueIdentifier()); + Map clusterIds = component1.getClusterDataMap(); + Map groups = component1.getAliasToGroupMap(); + updateChildStatus(appId, idOfChild, groups, clusterIds, component1); } finally { TopologyManager.releaseReadLockForApplication(appId); @@ -169,17 +170,30 @@ private boolean updateChildStatus(String appId, String id, Map gr clusterFound = true; } } + log.info("cluster found: " + clusterFound); if (clusterFound || groups.containsKey(id)) { childFound = true; if (!clusterData.isEmpty() && !groups.isEmpty()) { + if(log.isDebugEnabled()) { + log.debug("group active found: " + clusterFound); + } clustersActive = getClusterStatus(clusterData); groupsActive = getGroupStatus(groups); + if(log.isDebugEnabled()) { + log.debug("Active cluster" + clustersActive + " and group: " + groupActive); + } groupActive = clustersActive && groupsActive; } else if (!groups.isEmpty()) { groupsActive = getGroupStatus(groups); + if(log.isDebugEnabled()) { + log.info("group active found: " + clusterFound); + } groupActive = groupsActive; } else if (!clusterData.isEmpty()) { clustersActive = getClusterStatus(clusterData); + if(log.isDebugEnabled()) { + log.debug("Active cluster" + clustersActive + " and group: " + groupActive); + } groupActive = clustersActive; } else { log.warn("Clusters/groups not found in this [component] "+ appId); @@ -187,10 +201,12 @@ private boolean updateChildStatus(String appId, String id, Map gr //send the activation event if (parent instanceof Application && groupActive) { //send application activated event + log.info("sending app activate found: " + appId); StatusEventPublisher.sendApplicationActivatedEvent(appId); } else if (parent instanceof Group && groupActive) { //send activation to the parent - StatusEventPublisher.sendGroupActivatedEvent(appId, ((Group) parent).getAlias()); + log.info("sending group activate found: " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); } return childFound; } else { From 82701ff975c47a4339315d6170859e2facb0557f Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 13 Oct 2014 09:03:07 +0530 Subject: [PATCH 184/436] add mysql-python puppet changes --- tools/puppet3/modules/mysql/manifests/init.pp | 10 ++ .../mysql/templates/instance-activated.sh.erb | 28 ++++++ .../mysql/templates/instance-started.sh.erb | 43 +++++++++ .../mysql_root_password_setter.sh.erb | 16 ++++ .../mysql/templates/publish-metadata.py.erb | 95 +++++++++++++++++++ 5 files changed, 192 insertions(+) create mode 100755 tools/puppet3/modules/mysql/templates/instance-activated.sh.erb create mode 100755 tools/puppet3/modules/mysql/templates/instance-started.sh.erb create mode 100755 tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb create mode 100755 tools/puppet3/modules/mysql/templates/publish-metadata.py.erb diff --git a/tools/puppet3/modules/mysql/manifests/init.pp b/tools/puppet3/modules/mysql/manifests/init.pp index 070862be34..be6c77f4e9 100644 --- a/tools/puppet3/modules/mysql/manifests/init.pp +++ b/tools/puppet3/modules/mysql/manifests/init.pp @@ -17,6 +17,14 @@ class mysql{ + require java + + $custom_agent_templates = ['extensions/instance-started.sh','extensions/instance-activated.sh', 'extensions/publish-metadata.py', 'extensions/mysql_root_password_setter.sh'] + class {'agent': + custom_templates => $custom_agent_templates, + module=>'mysql' + } + if $stratos_mysql_password { $root_password = $stratos_mysql_password } @@ -96,4 +104,6 @@ require => File['/etc/apache2/sites-enabled/000-default']; } + # install stratos_base before java before mysql before agent + Class['stratos_base'] -> Class['java'] -> Class['agent'] -> Class['mysql'] } diff --git a/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb b/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb new file mode 100755 index 0000000000..7bd6ef64ba --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/instance-activated.sh.erb @@ -0,0 +1,28 @@ +#!/bin/bash +# -------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------- +# This extension script will be executed once the instance is started. +# -------------------------------------------------------------- +# + +log=/var/log/apache-stratos/cartridge-agent-extensions.log +echo `date`": Instance Activated Event: " | tee -a $log +python publish-metadata.py diff --git a/tools/puppet3/modules/mysql/templates/instance-started.sh.erb b/tools/puppet3/modules/mysql/templates/instance-started.sh.erb new file mode 100755 index 0000000000..1babac506a --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/instance-started.sh.erb @@ -0,0 +1,43 @@ +#!/bin/bash +# -------------------------------------------------------------- +# +# 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. +# +# -------------------------------------------------------------- +# This extension script will be executed once the instance is started. +# -------------------------------------------------------------- +# + +log=/var/log/apache-stratos/cartridge-agent-extensions.log +echo `date`": Instance Started Event: " | tee -a $log + +export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin' + +PASSWD=`facter -p stratos_mysql_password` + +/etc/init.d/mysql start + +# Set mysql password +mysqladmin -uroot password "$PASSWD" + +# Remove other users +mysql -uroot -p"$PASSWD" -Bse "DELETE from mysql.user WHERE password=''" + +# Set root user with remote access +mysql -uroot -p"$PASSWD" -Bse "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWD}'" + diff --git a/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb b/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb new file mode 100755 index 0000000000..427e31e1b8 --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/mysql_root_password_setter.sh.erb @@ -0,0 +1,16 @@ +#!/bin/bash + +export PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin' + +PASSWD=$1 + +service mysql start +echo $PASSWD> /tmp/udara +# Set mysql password +mysqladmin -uroot password "$PASSWD" + +# Remove other users +mysql -uroot -p"$PASSWD" -Bse "DELETE from mysql.user WHERE password=''" + +# Set root user with remote access +mysql -uroot -p"$PASSWD" -Bse "CREATE USER 'root'@'%' IDENTIFIED BY '${PASSWD}'" diff --git a/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb b/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb new file mode 100755 index 0000000000..2a4f73474f --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/publish-metadata.py.erb @@ -0,0 +1,95 @@ +__author__ = 'udara' + +import urllib2 +from urllib2 import URLError, HTTPError +import json +import base64 +import logging +import os,subprocess +from subprocess import Popen, PIPE +import random,string + +logging.basicConfig(filename='publish_metadata.log',level=logging.DEBUG,format='%(asctime)s: [%(levelname)s] %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') + +def get_launch_param_file_location(): + launch_params_file = os.path.abspath(os.path.dirname(__file__)).split("extensions")[0] + "payload/launch-params" + logging.debug("Launch param file location " + launch_params_file) + return launch_params_file + +def get_paylod_property(name): + logging.debug("[property " + name + " = " + properties[name] + "]") + return properties[name] + + +def get_metadataserviceurl(): + return properties['METADATASERVICE_URL'] + +def do_post(url, data): + req = urllib2.Request(url) + base64string = base64.encodestring('%s:%s' % ("admin", "admin")).replace('\n', '') + req.add_header("Authorization", "Basic %s" % base64string) + req.add_header('Content-Type', 'application/json') + + try: + logging.info('sending to ' + url) + logging.info('sent data ' + json.dumps(data)) + response = urllib2.urlopen(req, json.dumps(data)) + except HTTPError as e: + logging.error('The server couldn\'t fulfill the request.') + logging.error('Error code .' + e.code) + except URLError as e: + print 'We failed to reach a server.' + logging.error('We failed to reach a server.') + logging.error('Reason: ' + e.reason) + +def generate_mysql_password(size=6, chars=string.ascii_uppercase + string.digits): + return ''.join(random.choice(chars) for _ in range(size)) + +def set_mysql_password(password): + command = "./mysql_root_password_setter.sh " + password + logging.debug(" Setting mysql password [" + command + "]") + p = subprocess.Popen(command , stdout=PIPE, stderr=PIPE, shell=True) + stdout_data, stderr_data = p.communicate() + if p.returncode != 0: + logging.error(" failed, status code %s stdout %r stderr %r" % ( p.returncode, stdout_data, stderr_data)) + raise RuntimeError(" failed, status code %s stdout %r stderr %r" % ( p.returncode, stdout_data, stderr_data)) + print(stdout_data) + +param_file = get_launch_param_file_location() +print param_file +try: + metadata_file = open(param_file, "r") +except IOError: + logging.error( 'Cannot open' + param_file) + raise RuntimeError("Could not open payload params, halting....") + +metadata_payload_content = metadata_file.read() +logging.debug("Payload : " + metadata_payload_content) +properties = {} +for param in metadata_payload_content.split(","): + if param.strip() != "": + param_value = param.strip().split("=") + properties[param_value[0]] = param_value[1] + +logging.debug("Payload properties : ") +logging.debug(properties) + +my_alias = get_paylod_property('CARTRIDGE_ALIAS') + +my_ip = urllib2.urlopen('http://ip.42.pl/raw').read() +my_username = "root" +my_password = generate_mysql_password() +set_mysql_password(my_password) +app_id= get_paylod_property('APP_ID') + +resource_url = get_metadataserviceurl()+ "/stratosmetadataservice/application/" + app_id + "/cluster/" + my_alias + "/property" +data = {"key":"MYSQL_IP","values":my_ip} +do_post(resource_url, data) +data = {"key":"MYSQL_PASS","values":my_password} +do_post(resource_url, data) + +data = {"key":"MYSQL_UNAME","values":my_username} +do_post(resource_url, data) + +logging.info("************************") + From c063ac59fedd7362f0d49f8319971301eed811c8 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 13 Oct 2014 11:30:05 +0530 Subject: [PATCH 185/436] adding parsing tests for applicaitons with groups --- .../application/parser/ParserUtils.java | 4 +- .../CompositeApplicationParseTest.java | 209 ++++++++++++++++++ 2 files changed, 211 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index edc0486af3..23b0babb87 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -49,8 +49,8 @@ private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) { startupOrder = startupOrder.trim(); - if (!startupOrder.startsWith("cartridge.")) { - throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.'"); + if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group.")) { + throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.' or 'group.'"); } startupOrders.add(startupOrder); diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index 1859c7220d..d6f7928a42 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -285,6 +285,215 @@ public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrde applicationParser.parse(simpleAppCtxt); } + @Test + public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + // top level cartridges + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + // top level group + GroupContext simpleGroupContext = new GroupContext(); + simpleGroupContext.setName("group1"); + simpleGroupContext.setAlias("mygroup1"); + simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); + simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); + SubscribableContext groupSubscribableCtxt = new SubscribableContext(); + groupSubscribableCtxt.setType("mysql"); + groupSubscribableCtxt.setAlias("mygroup1mysql"); + simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); + simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); + simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); + simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, + simpleAppGroupSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test + public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + // top level cartridges + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + // top level group + GroupContext simpleGroupContext = new GroupContext(); + simpleGroupContext.setName("group1"); + simpleGroupContext.setAlias("mygroup1"); + simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); + simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); + SubscribableContext groupSubscribableCtxt = new SubscribableContext(); + groupSubscribableCtxt.setType("mysql"); + groupSubscribableCtxt.setAlias("mygroup1mysql"); + simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); + simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // dependencies + DependencyContext simpleAppDependecyCtxt = new DependencyContext(); + simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"}); + simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); + simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); + simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, + simpleAppGroupSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test (expected = ApplicationDefinitionException.class) + public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + // top level cartridges + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + // top level group + GroupContext simpleGroupContext = new GroupContext(); + simpleGroupContext.setName("group1"); + simpleGroupContext.setAlias("mygroup1"); + simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); + simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); + SubscribableContext groupSubscribableCtxt = new SubscribableContext(); + groupSubscribableCtxt.setType("mysql"); + groupSubscribableCtxt.setAlias("mygroup1mysql"); + simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); + simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // dependencies + DependencyContext simpleAppDependecyCtxt = new DependencyContext(); + simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + // invalid startup order, starting with 'group1' + simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"}); + simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); + simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); + simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, + simpleAppGroupSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + + @Test (expected = ApplicationDefinitionException.class) + public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + // top level cartridges + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + // top level group + GroupContext simpleGroupContext = new GroupContext(); + simpleGroupContext.setName("group1"); + simpleGroupContext.setAlias("mygroup1"); + simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); + simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); + SubscribableContext groupSubscribableCtxt = new SubscribableContext(); + groupSubscribableCtxt.setType("mysql"); + groupSubscribableCtxt.setAlias("mygroup1mysql"); + simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); + simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + @AfterClass public static void tearDownAfterClass() { From 34c141ce7b21eb7a74f07df3dca491a492a6e475 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 11:48:50 +0530 Subject: [PATCH 186/436] fixing the calculating activation for application and group --- .../dependency/DependencyBuilder.java | 18 ++---- .../application/ApplicationMonitor.java | 6 +- .../monitor/group/GroupMonitor.java | 6 +- .../status/checker/StatusChecker.java | 62 +++++++++++++++---- 4 files changed, 65 insertions(+), 27 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 275b8c3f58..71c73a245b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -61,10 +61,7 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen DependencyOrder dependencyOrder = component.getDependencyOrder(); if (dependencyOrder != null) { - if (log.isDebugEnabled()) { - log.debug("Building dependency for the Application/Group " + - identifier); - } + log.info("Building dependency for the Application/Group " + identifier); //Parsing the kill behaviour String killBehavior = dependencyOrder.getKillbehavior(); @@ -76,21 +73,16 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen } else if (Constants.KILL_DEPENDENTS.equals(killBehavior)) { dependencyTree.setKillDependent(true); } - if (log.isDebugEnabled()) { - log.debug("Setting the [killBehavior] " + killBehavior + " to the " + + + log.info("Setting the [killBehavior] " + killBehavior + " to the " + "[dependency-tree] " + dependencyTree.getId()); - } + //Parsing the start up order Set startupOrders = dependencyOrder.getStartupOrders(); ApplicationContext foundContext; ApplicationContext parentContext; - /*if (startupOrders == null) { - if (log.isDebugEnabled()) { - log.debug("startupOrders is null, returning default dependency tree (empty)"); - } - return dependencyTree; - }*/ + if (startupOrders != null) { for (StartupOrder startupOrder : startupOrders) { foundContext = null; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 01422cc597..7a73e2b2a6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -254,13 +254,17 @@ protected void monitor(MonitorStatusEvent statusEvent) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); + if(log.isDebugEnabled()) { + log.debug("started a child: " + startDep + " by the group/cluster: " + id); + + } //updating the life cycle and current status context.setStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); if(!startDep) { //Checking in the children whether all are active, // since no dependency found to be started. - StatusChecker.getInstance().onChildStatusChange(id, this.component, this.appId); + StatusChecker.getInstance().onChildStatusChange(id, this.appId); } } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 90876cb29e..58038229eb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -85,15 +85,17 @@ protected void monitor(MonitorStatusEvent statusEvent) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); - log.info("started a child: " + startDep + " by the group/cluster: " + id); + if(log.isDebugEnabled()) { + log.debug("started a child: " + startDep + " by the group/cluster: " + id); + } //updating the life cycle and current status context.setStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); if(!startDep) { //Checking in the children whether all are active, // since no dependency found to be started. - StatusChecker.getInstance().onChildStatusChange(id, this.component, this.appId); + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); } } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 4607f47493..16c294a0bb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -85,22 +85,34 @@ public void run() { } /** + * * @param idOfChild - * @param component + * @param groupId + * @param appId */ - public void onChildStatusChange(final String idOfChild, final ParentComponent component, + public void onChildStatusChange(final String idOfChild, final String groupId, final String appId) { - updateChild(idOfChild, component, appId); + updateChild(idOfChild, groupId, appId); + } + + /** + * This will calculate whether the children of an application are active or not. If active, then + * it will send the ApplicationActivatedEvent. + * @param idOfChild + * @param appId + */ + public void onChildStatusChange(final String idOfChild, final String appId) { + updateChild(idOfChild, appId); } - private void updateChild(final String idOfChild, final ParentComponent component, final String appId) { + private void updateChild(final String idOfChild, final String groupId, final String appId) { Runnable group = new Runnable() { public void run() { try { //TODO getting lock TopologyManager.acquireReadLockForApplication(appId); ParentComponent component1 = TopologyManager.getTopology(). - getApplication(appId).getGroupRecursively(component.getUniqueIdentifier()); + getApplication(appId).getGroupRecursively(groupId); Map clusterIds = component1.getClusterDataMap(); Map groups = component1.getAliasToGroupMap(); updateChildStatus(appId, idOfChild, groups, clusterIds, component1); @@ -115,6 +127,29 @@ public void run() { groupThread.start(); } + private void updateChild(final String idOfChild, final String appId) { + Runnable group = new Runnable() { + public void run() { + try { + //TODO getting lock + TopologyManager.acquireReadLockForApplication(appId); + ParentComponent component = TopologyManager.getTopology(). + getApplication(appId); + Map clusterIds = component.getClusterDataMap(); + Map groups = component.getAliasToGroupMap(); + updateChildStatus(appId, idOfChild, groups, clusterIds, component); + } finally { + TopologyManager.releaseReadLockForApplication(appId); + + } + + } + }; + Thread groupThread = new Thread(group); + groupThread.start(); + } + + /** * @param clusterId * @param appId @@ -157,6 +192,15 @@ public void run() { faultHandlingThread.start(); } + /** + * This will use to calculate whether all children of a particular component is active by travesing Top + * @param appId + * @param id + * @param groups + * @param clusterData + * @param parent + * @return + */ private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { boolean groupActive = false; @@ -210,12 +254,8 @@ private boolean updateChildStatus(String appId, String id, Map gr } return childFound; } else { - if (!groups.isEmpty()) { - for (Group group : groups.values()) { - return updateChildStatus(appId, id, group.getAliasToGroupMap(), group.getClusterDataMap(), group); - - } - } + log.warn("There is no child found in the [group/cluster] " + id + " found in the " + + "[component]" + parent.getUniqueIdentifier()); } return childFound; } From 67b281e813b5c432190a02001c62ef16cc4420e2 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 11:50:08 +0530 Subject: [PATCH 187/436] fixing group id issue --- .../message/processor/topology/GroupActivatedProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 230fcf21ed..5c8de02ded 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -91,9 +91,9 @@ private boolean doProcess (GroupActivatedEvent event,Topology topology) { } else { // Apply changes to the topology group.setStatus(Status.Activated); - if (log.isInfoEnabled()) { + if (log.isInfoEnabled()) { log.info(String.format("Group updated as activated : %s", - group.toString())); + group.getUniqueIdentifier())); } } From c80c05d7f9c1a68256332711fcce07fdb2d4389c Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 12:36:03 +0530 Subject: [PATCH 188/436] committing the automationscripts with sameples --- .../deployment_script.sh | 35 ++++++ .../m1-samples/ec2/autoscale-policy.json | 14 +++ .../m1-samples/ec2/deployment-policy.json | 14 +++ .../ec2/m1_single_subsciption_app.json | 19 ++++ .../m1-samples/ec2/p1.json | 10 ++ .../m1-samples/ec2/php-cart.json | 38 +++++++ .../m1-samples/os/autoscale-policy.json | 14 +++ .../m1-samples/os/deployment-policy.json | 14 +++ .../os/m1_single_subsciption_app.json | 19 ++++ .../m1-samples/os/p1.json | 10 ++ .../m1-samples/os/php-cart.json | 46 ++++++++ .../samples/ec2/autoscale-policy 2.json | 17 +++ .../samples/ec2/autoscale-policy.json | 14 +++ .../samples/ec2/deployment-policy 2.json | 14 +++ .../samples/ec2/deployment-policy.json | 14 +++ .../samples/ec2/group1.json | 9 ++ .../samples/ec2/group2.json | 15 +++ .../ec2/m1_single_subsciption_app.json | 19 ++++ .../ec2/m2_single_subsciption_app.json | 107 ++++++++++++++++++ .../samples/ec2/mysql.json | 33 ++++++ .../samples/ec2/mytest.json | 33 ++++++ .../samples/ec2/p1.json | 10 ++ .../samples/ec2/php-cart.json | 38 +++++++ .../samples/ec2/tomcat.json | 33 ++++++ .../samples/os/autoscale-policy.json | 14 +++ .../samples/os/deployment-policy.json | 14 +++ .../samples/os/m1_single_subsciption_app.json | 19 ++++ .../samples/os/p1.json | 10 ++ .../samples/os/php-cart.json | 46 ++++++++ 29 files changed, 692 insertions(+) create mode 100755 tools/automation-sripts/grouping-automation-script/deployment_script.sh create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/ec2/autoscale-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/ec2/deployment-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/ec2/m1_single_subsciption_app.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/ec2/p1.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/ec2/php-cart.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/os/autoscale-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/os/deployment-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/os/m1_single_subsciption_app.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/os/p1.json create mode 100755 tools/automation-sripts/grouping-automation-script/m1-samples/os/php-cart.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy 2.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy 2.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/m1_single_subsciption_app.json create mode 100644 tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/mysql.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/mytest.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/p1.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/php-cart.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/os/autoscale-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/os/deployment-policy.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/os/m1_single_subsciption_app.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/os/p1.json create mode 100755 tools/automation-sripts/grouping-automation-script/samples/os/php-cart.json diff --git a/tools/automation-sripts/grouping-automation-script/deployment_script.sh b/tools/automation-sripts/grouping-automation-script/deployment_script.sh new file mode 100755 index 0000000000..79c039dbcd --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/deployment_script.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +curl -X POST -H "Content-Type: application/json" -d@'samples/ec2/p1.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/policy/deployment/partition + +sleep 15 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/autoscale-policy.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/policy/autoscale + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d@'samples/ec2/deployment-policy.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/policy/deployment + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/php-cart.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/cartridge/definition + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/tomcat.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/cartridge/definition + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/mytest.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/cartridge/definition + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/group1.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/group/definition + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/group2.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/group/definition + +sleep 5 + +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/m2_single_subsciption_app.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/application/definition diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/autoscale-policy.json b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/autoscale-policy.json new file mode 100755 index 0000000000..ba5664aa1a --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/autoscale-policy.json @@ -0,0 +1,14 @@ +{ + "id": "autoscale_policy_1", + "loadThresholds": { + "requestsInFlight": { + "average": 50 + }, + "memoryConsumption": { + "average": 700 + }, + "loadAverage": { + "average": 1000 + } + } +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/deployment-policy.json b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/deployment-policy.json new file mode 100755 index 0000000000..30d62b414c --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/deployment-policy.json @@ -0,0 +1,14 @@ +{ + "id": "deployment_policy_1", + "partitionGroup": { + "id": "openstack", + "partitionAlgo": "one-after-another", + "partition": [ + { + "id": "P1", + "partitionMax": "10", + "partitionMin": "1" + } + ] + } +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/m1_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/m1_single_subsciption_app.json new file mode 100755 index 0000000000..1648b67afc --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/m1_single_subsciption_app.json @@ -0,0 +1,19 @@ +{ + "applicationId": "test_app_1", + "alias": "mytestapp1", + "components": { + "subscribables": [ + { + "type": "php", + "alias": "myphp" + } + ], + }, + "subscribableInfo": [ + { + "alias": "myphp", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/p1.json b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/p1.json new file mode 100755 index 0000000000..8a42c546b4 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/p1.json @@ -0,0 +1,10 @@ +{ + "id": "P1", + "provider": "ec2", + "property": [ + { + "name": "region", + "value": "ap-southeast-1" + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/php-cart.json b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/php-cart.json new file mode 100755 index 0000000000..45985d93b0 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/ec2/php-cart.json @@ -0,0 +1,38 @@ +{ + "type": "php", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "PHP", + "description": "PHP Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + }, + { + "protocol": "https", + "port": "443", + "proxyPort": "8243" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/os/autoscale-policy.json b/tools/automation-sripts/grouping-automation-script/m1-samples/os/autoscale-policy.json new file mode 100755 index 0000000000..ba5664aa1a --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/os/autoscale-policy.json @@ -0,0 +1,14 @@ +{ + "id": "autoscale_policy_1", + "loadThresholds": { + "requestsInFlight": { + "average": 50 + }, + "memoryConsumption": { + "average": 700 + }, + "loadAverage": { + "average": 1000 + } + } +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/os/deployment-policy.json b/tools/automation-sripts/grouping-automation-script/m1-samples/os/deployment-policy.json new file mode 100755 index 0000000000..30d62b414c --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/os/deployment-policy.json @@ -0,0 +1,14 @@ +{ + "id": "deployment_policy_1", + "partitionGroup": { + "id": "openstack", + "partitionAlgo": "one-after-another", + "partition": [ + { + "id": "P1", + "partitionMax": "10", + "partitionMin": "1" + } + ] + } +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/os/m1_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/m1-samples/os/m1_single_subsciption_app.json new file mode 100755 index 0000000000..1648b67afc --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/os/m1_single_subsciption_app.json @@ -0,0 +1,19 @@ +{ + "applicationId": "test_app_1", + "alias": "mytestapp1", + "components": { + "subscribables": [ + { + "type": "php", + "alias": "myphp" + } + ], + }, + "subscribableInfo": [ + { + "alias": "myphp", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/os/p1.json b/tools/automation-sripts/grouping-automation-script/m1-samples/os/p1.json new file mode 100755 index 0000000000..0fa8c5b089 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/os/p1.json @@ -0,0 +1,10 @@ +{ + "id": "P1", + "provider": "openstack", + "property": [ + { + "name": "region", + "value": "RegionOne" + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/m1-samples/os/php-cart.json b/tools/automation-sripts/grouping-automation-script/m1-samples/os/php-cart.json new file mode 100755 index 0000000000..cbfab113a3 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/m1-samples/os/php-cart.json @@ -0,0 +1,46 @@ +{ + "type": "php", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "PHP", + "description": "PHP Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + }, + { + "protocol": "https", + "port": "443", + "proxyPort": "8243" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "openstack", + "imageId": "RegionOne/f2ddf72a-4e76-4893-a9fa-e5f4352f1a86", + "maxInstanceLimit": "2", + "property": [ + { + "name": "instanceType", + "value": "RegionOne/3" + }, + { + "name": "keyPair", + "value": "isuruh" + } + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy 2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy 2.json new file mode 100755 index 0000000000..f18d134457 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy 2.json @@ -0,0 +1,17 @@ +{ + "id": "autoscale_policy_mysql", + "loadThresholds": { + "requestsInFlight": { + "upperLimit": 30, + "lowerLimit": 5 + }, + "memoryConsumption": { + "upperLimit": 40, + "lowerLimit": 15 + }, + "loadAverage": { + "upperLimit": 150, + "lowerLimit": 100 + } + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy.json new file mode 100755 index 0000000000..ba5664aa1a --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/autoscale-policy.json @@ -0,0 +1,14 @@ +{ + "id": "autoscale_policy_1", + "loadThresholds": { + "requestsInFlight": { + "average": 50 + }, + "memoryConsumption": { + "average": 700 + }, + "loadAverage": { + "average": 1000 + } + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy 2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy 2.json new file mode 100755 index 0000000000..9cceeb7b10 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy 2.json @@ -0,0 +1,14 @@ +{ + "id": "dep_policy_mysql", + "partitionGroup": { + "id": "openstack", + "partitionAlgo": "one-after-another", + "partition": [ + { + "id": "P1", + "partitionMax": "10", + "partitionMin": "1" + } + ] + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy.json new file mode 100755 index 0000000000..2a24807848 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/deployment-policy.json @@ -0,0 +1,14 @@ +{ + "id": "deployment_policy_1", + "partitionGroup": { + "id": "ec2", + "partitionAlgo": "one-after-another", + "partition": [ + { + "id": "P1", + "partitionMax": "10", + "partitionMin": "1" + } + ] + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json new file mode 100755 index 0000000000..4be9ea5743 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json @@ -0,0 +1,9 @@ +{ + "name": "group1", + "cartridges": [ + "mytest","tomcat" + ], + "dependencies": { + "killBehaviour": "kill-none" + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json new file mode 100755 index 0000000000..9e27497516 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json @@ -0,0 +1,15 @@ +{ + "name": "group2", + "subGroups": [ + "group1" + ], + "cartridges": [ + "tomcat","mytest" + ], + "dependencies": { + "startupOrders": [ + "group.group1,cartridge.tomcat" + ], + "killBehaviour": "kill-dependents" + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/m1_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/m1_single_subsciption_app.json new file mode 100755 index 0000000000..1648b67afc --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/m1_single_subsciption_app.json @@ -0,0 +1,19 @@ +{ + "applicationId": "test_app_1", + "alias": "mytestapp1", + "components": { + "subscribables": [ + { + "type": "php", + "alias": "myphp" + } + ], + }, + "subscribableInfo": [ + { + "alias": "myphp", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json new file mode 100644 index 0000000000..852da9125a --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json @@ -0,0 +1,107 @@ +{ + "applicationId": "test_app_3", + "alias": "mytestapp2", + "components": { + "groups": [ + { + "name": "group2", + "alias": "mygroup2", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + "subscribables": [ + { + "type": "tomcat", + "alias": "mygroup2tomcat" + + }, + { + "type": "mytest", + "alias": "mygroup2mytest" + + } + ], + "subGroups": [ + { + "name": "group1", + "alias": "mygroup1" + + } + ] + + }, + { + "name": "group1", + "alias": "mygroup1", + "deploymentPolicy": "dep_policy_group1", + "autoscalingPolicy": "autoscale_policy_group1", + "subscribables": [ + { + "type": "tomcat", + "alias": "mygroup1tomcat" + + }, + { + "type": "mytest", + "alias": "mygroup1mytest" + + } + + ] + + } + + ], + "subscribables": [ + { + "type": "tomcat", + "alias": "mytomcat" + } + ], + "dependencies": { + "startupOrders": [ + "group.mygroup2,cartridge.mytomcat" + ], + "killBehaviour": "kill-dependents" + } + + }, + "subscribableInfo": [ + { + "alias": "mygroup1tomcat", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1" + }, + { + "alias": "mygroup2tomcat", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + "repoURL": "www.mygit.com/php.git", + "privateRepo": "true", + "repoUsername": "admin", + "repoPassword": "xxxx" + }, + { + "alias": "mytomcat", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + "repoURL": "www.mygit.com/tomcat.git", + "privateRepo": "false", + "repoUsername": "admin", + "repoPassword": "yyyy" + }, + { + "alias": "mygroup1mytest", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1" + }, + { + "alias": "mygroup2mytest", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + "repoURL": "www.mygit.com/php.git", + "privateRepo": "true", + "repoUsername": "admin", + "repoPassword": "xxxx" + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/mysql.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/mysql.json new file mode 100755 index 0000000000..f2de7f6eda --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/mysql.json @@ -0,0 +1,33 @@ +{ + "type": "mysql", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "mysql", + "description": "mysql Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "3306", + "proxyPort": "8280" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/mytest.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/mytest.json new file mode 100755 index 0000000000..0197ab15d6 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/mytest.json @@ -0,0 +1,33 @@ +{ + "type": "mytest", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "mytest", + "description": "mytest Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/p1.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/p1.json new file mode 100755 index 0000000000..8a42c546b4 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/p1.json @@ -0,0 +1,10 @@ +{ + "id": "P1", + "provider": "ec2", + "property": [ + { + "name": "region", + "value": "ap-southeast-1" + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/php-cart.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/php-cart.json new file mode 100755 index 0000000000..45985d93b0 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/php-cart.json @@ -0,0 +1,38 @@ +{ + "type": "php", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "PHP", + "description": "PHP Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + }, + { + "protocol": "https", + "port": "443", + "proxyPort": "8243" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat.json new file mode 100755 index 0000000000..308b94ea13 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat.json @@ -0,0 +1,33 @@ +{ + "type": "tomcat", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "tomcat", + "description": "tomcat Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/os/autoscale-policy.json b/tools/automation-sripts/grouping-automation-script/samples/os/autoscale-policy.json new file mode 100755 index 0000000000..ba5664aa1a --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/os/autoscale-policy.json @@ -0,0 +1,14 @@ +{ + "id": "autoscale_policy_1", + "loadThresholds": { + "requestsInFlight": { + "average": 50 + }, + "memoryConsumption": { + "average": 700 + }, + "loadAverage": { + "average": 1000 + } + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/os/deployment-policy.json b/tools/automation-sripts/grouping-automation-script/samples/os/deployment-policy.json new file mode 100755 index 0000000000..30d62b414c --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/os/deployment-policy.json @@ -0,0 +1,14 @@ +{ + "id": "deployment_policy_1", + "partitionGroup": { + "id": "openstack", + "partitionAlgo": "one-after-another", + "partition": [ + { + "id": "P1", + "partitionMax": "10", + "partitionMin": "1" + } + ] + } +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/os/m1_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/os/m1_single_subsciption_app.json new file mode 100755 index 0000000000..1648b67afc --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/os/m1_single_subsciption_app.json @@ -0,0 +1,19 @@ +{ + "applicationId": "test_app_1", + "alias": "mytestapp1", + "components": { + "subscribables": [ + { + "type": "php", + "alias": "myphp" + } + ], + }, + "subscribableInfo": [ + { + "alias": "myphp", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1", + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/os/p1.json b/tools/automation-sripts/grouping-automation-script/samples/os/p1.json new file mode 100755 index 0000000000..0fa8c5b089 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/os/p1.json @@ -0,0 +1,10 @@ +{ + "id": "P1", + "provider": "openstack", + "property": [ + { + "name": "region", + "value": "RegionOne" + } + ] +} diff --git a/tools/automation-sripts/grouping-automation-script/samples/os/php-cart.json b/tools/automation-sripts/grouping-automation-script/samples/os/php-cart.json new file mode 100755 index 0000000000..cbfab113a3 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/os/php-cart.json @@ -0,0 +1,46 @@ +{ + "type": "php", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "PHP", + "description": "PHP Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + }, + { + "protocol": "https", + "port": "443", + "proxyPort": "8243" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "openstack", + "imageId": "RegionOne/f2ddf72a-4e76-4893-a9fa-e5f4352f1a86", + "maxInstanceLimit": "2", + "property": [ + { + "name": "instanceType", + "value": "RegionOne/3" + }, + { + "name": "keyPair", + "value": "isuruh" + } + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} From 983d51ded39b26826d69379ffc1feda8a3767c2d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 13 Oct 2014 13:12:55 +0530 Subject: [PATCH 189/436] test for App with invalid Group --- .../CompositeApplicationParseTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index d6f7928a42..7798274ce5 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -336,6 +336,58 @@ public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionEx applicationParser.parse(simpleAppCtxt); } + @Test (expected = ApplicationDefinitionException.class) + public void testAppWithOneCartridgeAndInvalidGroup () throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + ApplicationContext simpleAppCtxt = new ApplicationContext(); + // app id + simpleAppCtxt.setApplicationId("simpleApp"); + simpleAppCtxt.setAlias("simpleAppAlias"); + // tenant info + simpleAppCtxt.setTenantId(-1234); + // components + ComponentContext simpleAppComponentCtxt = new ComponentContext(); + // top level cartridges + SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); + simpleAppSubscribableContext.setType("php"); + simpleAppSubscribableContext.setAlias("myphp"); + simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); + // top level group + GroupContext simpleGroupContext = new GroupContext(); + // invalid Group 'group11' + simpleGroupContext.setName("group11"); + simpleGroupContext.setAlias("mygroup1"); + simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); + simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); + SubscribableContext groupSubscribableCtxt = new SubscribableContext(); + groupSubscribableCtxt.setType("mysql"); + groupSubscribableCtxt.setAlias("mygroup1mysql"); + simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); + simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); + simpleAppCtxt.setComponents(simpleAppComponentCtxt); + // subscribable information + SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppSubscribableInfoCtxt.setAlias("myphp"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); + simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); + simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); + simpleAppSubscribableInfoCtxt.setPrivateRepo(true); + simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); + simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); + + SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); + simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); + simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); + simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); + + simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, + simpleAppGroupSubscribableInfoCtxt}); + + // parse + applicationParser.parse(simpleAppCtxt); + } + @Test public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException { From d212c2cd1b08bb1e06c8b608198aa99a2072c63b Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 15:16:47 +0530 Subject: [PATCH 190/436] updating the deployment scripts --- .../deployment_script.sh | 3 ++- .../samples/ec2/group1.json | 2 +- .../samples/ec2/group2.json | 2 +- .../ec2/m2_single_subsciption_app.json | 26 +++++-------------- tools/test.json | 0 5 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 tools/test.json diff --git a/tools/automation-sripts/grouping-automation-script/deployment_script.sh b/tools/automation-sripts/grouping-automation-script/deployment_script.sh index 79c039dbcd..a0740cfa68 100755 --- a/tools/automation-sripts/grouping-automation-script/deployment_script.sh +++ b/tools/automation-sripts/grouping-automation-script/deployment_script.sh @@ -20,7 +20,8 @@ curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/tomcat.json' - sleep 5 -curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/mytest.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/cartridge/definition +curl -X POST -H "Content-Type: application/json" -d @'samples/ec2/tomcat1.json' -k -v -u admin:admin https://localhost:9443/stratos/admin/cartridge/definition + sleep 5 diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json index 4be9ea5743..dc8eded2db 100755 --- a/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group1.json @@ -1,7 +1,7 @@ { "name": "group1", "cartridges": [ - "mytest","tomcat" + "tomcat1","tomcat" ], "dependencies": { "killBehaviour": "kill-none" diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json index 9e27497516..942ef8be72 100755 --- a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json @@ -4,7 +4,7 @@ "group1" ], "cartridges": [ - "tomcat","mytest" + "tomcat" ], "dependencies": { "startupOrders": [ diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json index 852da9125a..b234c49403 100644 --- a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json @@ -1,6 +1,6 @@ { "applicationId": "test_app_3", - "alias": "mytestapp2", + "alias": "phpapp2", "components": { "groups": [ { @@ -13,11 +13,6 @@ "type": "tomcat", "alias": "mygroup2tomcat" - }, - { - "type": "mytest", - "alias": "mygroup2mytest" - } ], "subGroups": [ @@ -41,8 +36,8 @@ }, { - "type": "mytest", - "alias": "mygroup1mytest" + "type": "tomcat1", + "alias": "mygroup1tomcat1" } @@ -90,18 +85,11 @@ "repoPassword": "yyyy" }, { - "alias": "mygroup1mytest", + "alias": "mygroup1tomcat1", "deploymentPolicy": "deployment_policy_1", "autoscalingPolicy": "autoscale_policy_1" - }, - { - "alias": "mygroup2mytest", - "deploymentPolicy": "deployment_policy_1", - "autoscalingPolicy": "autoscale_policy_1", - "repoURL": "www.mygit.com/php.git", - "privateRepo": "true", - "repoUsername": "admin", - "repoPassword": "xxxx" } - ] + + ] } + diff --git a/tools/test.json b/tools/test.json deleted file mode 100644 index e69de29bb2..0000000000 From 961e584834c027fbd99f5626a4b399a3fdaea558 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 13 Oct 2014 18:04:36 +0530 Subject: [PATCH 191/436] fixing parallel monitors activation issue --- .../status/checker/StatusChecker.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 16c294a0bb..ee04fff2fc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; +import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -48,40 +49,38 @@ public static StatusChecker getInstance() { } /** - * - * @param clusterId1 + * Calculating whether the cluster has all min instances as active and send the + * ClusterActivatedEvent. + * @param clusterId id of the cluster */ - public void onMemberStatusChange(String clusterId1) { - final String clusterId = clusterId1; - Runnable exCluster = new Runnable() { - public void run() { - ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterActive = false; - for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { - //minimum check per partition - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - if (partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { - clusterActive = true; - } else if (partitionContext.getActiveMemberCount() > partitionContext.getMinimumMemberCount()) { - log.info("cluster already activated..."); - clusterActive = true; - } else { - clusterActive = false; - } - } - } - // if active then notify upper layer - if (clusterActive) { - //send event to cluster status topic - StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), - monitor.getServiceId(), monitor.getClusterId()); + public void onMemberStatusChange(String clusterId) { + ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterActive = clusterActive(monitor); + // if active then notify upper layer + if (clusterActive) { + //send event to cluster status topic + StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), + monitor.getServiceId(), monitor.getClusterId()); + } + } + private boolean clusterActive(AbstractClusterMonitor monitor) { + boolean clusterActive = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { + //minimum check per partition + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + if (partitionContext.getMinimumMemberCount() == partitionContext.getActiveMemberCount()) { + clusterActive = true; + } else if (partitionContext.getActiveMemberCount() > partitionContext.getMinimumMemberCount()) { + log.info("cluster already activated..."); + clusterActive = true; + } else { + clusterActive = false; + return clusterActive; } - } - }; - Thread clusterThread = new Thread(exCluster); - clusterThread.start(); + } + return clusterActive; } /** @@ -267,6 +266,7 @@ private boolean getGroupStatus(Map groups) { groupActiveStatus = true; } else { groupActiveStatus = false; + break; } } return groupActiveStatus; @@ -282,6 +282,7 @@ private boolean getClusterStatus(Map clusterData) { clusterActiveStatus = true; } else { clusterActiveStatus = false; + break; } } return clusterActiveStatus; From 7002c68d52c078d4c384616080a8a2c7c1fbd4d5 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 15 Oct 2014 08:25:48 +0530 Subject: [PATCH 192/436] refactor metadata client --- .../pom.xml | 51 +++++----- .../client/DefaultMetaDataServiceClient.java | 35 ++----- .../client/MetaDataServiceClient.java | 25 ++--- .../metadata/client/beans/PropertyBean.java | 23 ++--- .../client/config/MetaDataClientConfig.java | 74 +++++---------- .../data/extractor/MetaDataExtractor.java | 36 -------- .../exception/MetaDataExtractorException.java | 47 ---------- .../factory/MetaDataExtractorFactory.java | 51 ---------- .../metadata/client/pojo/DataContext.java | 88 ------------------ .../client/rest/DefaultRestClient.java | 40 ++++---- .../metadata/client/rest/RestClient.java | 6 +- .../sample/DefaultMetaDataExtractor.java | 45 --------- .../sample/MetaDataServiceClientSample.java | 92 ------------------- .../client/util/MetaDataClientConstants.java | 2 - 14 files changed, 107 insertions(+), 508 deletions(-) delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml index fcafdaa816..4f92ca75be 100644 --- a/components/org.apache.stratos.metadata.client/pom.xml +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -1,5 +1,5 @@ - + org.apache.stratos @@ -7,32 +7,31 @@ 4.1.0-SNAPSHOT - org.apache.stratos - org.apache.stratos.metadata.client - bundle - 4.0.0 + org.apache.stratos.metadata.client + bundle + 4.0.0 - Apache Stratos - Metadata Client + Apache Stratos - Metadata Client - - - org.apache.httpcomponents - httpclient - 4.3.5 - provided - - - commons-configuration - commons-configuration - 1.9 - provided - - - com.google.code.gson - gson - 2.2.4 - - + + + org.apache.httpcomponents + httpclient + 4.3.5 + provided + + + commons-configuration + commons-configuration + 1.9 + provided + + + com.google.code.gson + gson + 2.2.4 + + diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java index d60dfb2240..6c43915708 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.http.HttpResponse; import org.apache.stratos.metadata.client.beans.PropertyBean; import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; import org.apache.stratos.metadata.client.exception.RestClientException; @@ -34,14 +33,19 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient { - private static Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); + private static final Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); private RestClient restClient; - private String baseUrl; + private final String baseUrl; - public DefaultMetaDataServiceClient (String baseUrl) throws RestClientException { + public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException { this.baseUrl = baseUrl; - restClient = new DefaultRestClient(); + this.restClient = new DefaultRestClient(); + } + + public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient) throws RestClientException { + this.baseUrl = baseUrl; + this.restClient = restClient; } public void initialize() { @@ -59,32 +63,11 @@ public void addPropertyToCluster(String appId, String clusterId, String property } } - public void addPropertyToApplication(String appId, String propertyKey, String propertyValue) - throws MetaDataServiceClientExeption { - String applicationPath = baseUrl.concat("application/").concat(appId).concat("/property"); - PropertyBean property = new PropertyBean(propertyKey, propertyValue); - HttpResponse x; - try { - x = restClient.doPost(applicationPath, property); - } catch (RestClientException e) { - log.error(String.format("Error occurred while adding property %s", propertyKey)); - } - } - -// public void addPropertyToCluster(String appId, String propertyKey, String propertyValue) -// throws MetaDataServiceClientExeption { -// //To change body of implemented methods use File | Settings | File Templates. -// } - public Map> getProperties(String appId, String clusterId) throws MetaDataServiceClientExeption { return null; //To change body of implemented methods use File | Settings | File Templates. } -// public Map> getProperties(String appId) throws MetaDataServiceClientExeption { -// return null; //To change body of implemented methods use File | Settings | File Templates. -// } - public Set getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption { return null; //To change body of implemented methods use File | Settings | File Templates. } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java index fa89f965c4..01ea3e3e9c 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java @@ -28,22 +28,23 @@ public interface MetaDataServiceClient { /** * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. + * * @throws MetaDataServiceClientExeption */ - public void initialize (); + public void initialize(); /** * Adds a property key value pair for the relevant cluster of the specified app * - * @param appId Application id - * @param clusterId Cluster id - * @param propertyKey Key of the Property + * @param appId Application id + * @param clusterId Cluster id + * @param propertyKey Key of the Property * @param propertyValue Value of the Property * @throws MetaDataServiceClientExeption */ public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; -// /** + // /** // * Adds a property key value pair for the specified app // * // * @param appId Application id @@ -61,9 +62,9 @@ public interface MetaDataServiceClient { // * @return Map of Keys and Values for the specified cluster in the relevant app. Each key can have multiple Values. // * @throws MetaDataServiceClientExeption // */ - public Map> getProperties (String appId, String clusterId) throws MetaDataServiceClientExeption; + public Map> getProperties(String appId, String clusterId) throws MetaDataServiceClientExeption; -// /** + // /** // * Retrieves the property key value pairs of the specified app // * // * @param appId Application id @@ -80,23 +81,23 @@ public interface MetaDataServiceClient { // * @return Set of Values for specified Key of the relevant app. // * @throws MetaDataServiceClientExeption // */ - public Set getProperty (String appId, String propertyKey) throws MetaDataServiceClientExeption; + public Set getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption; /** * Retrieves the property values for the specified key of the relevant cluster and app * - * @param appId Application id - * @param clusterId Cluster id + * @param appId Application id + * @param clusterId Cluster id * @param propertyKey Key of the Property * @return Set of Values for specified Key of the relevant cluster in the relevant app. * @throws MetaDataServiceClientExeption */ - public Set getProperty (String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption; + public Set getProperty(String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption; /** * Shutdown the MetaDataServiceClient. Should be called once after using the client. * * @throws MetaDataServiceClientExeption */ - public void terminate () throws MetaDataServiceClientExeption; + public void terminate() throws MetaDataServiceClientExeption; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java index dd2d777789..7fae6a6193 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/beans/PropertyBean.java @@ -24,14 +24,16 @@ import java.util.Arrays; import java.util.List; -@XmlRootElement(name="properties") +@XmlRootElement(name = "properties") public class PropertyBean { private String key; private List values = new ArrayList(); - public PropertyBean(){} - public PropertyBean(String key, String value){ - this.key=key; + public PropertyBean() { + } + + public PropertyBean(String key, String value) { + this.key = key; this.values.add(value); } @@ -43,22 +45,21 @@ public void setKey(String key) { this.key = key; } - public String[] getValues(){ + public String[] getValues() { String[] values = new String[this.values.size()]; values = this.values.toArray(values); return values; } - public void setValues(String[] values) { - this.values.addAll(Arrays.asList(values)); - } - - public void setValues(String value) { this.values.add(value); } - public void addValue(String value){ + public void setValues(String[] values) { + this.values.addAll(Arrays.asList(values)); + } + + public void addValue(String value) { this.values.add(value); } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java index 2596ca9847..4324e5d265 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -21,35 +21,40 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadata.client.sample.MetaDataServiceClientSample; import org.apache.stratos.metadata.client.util.MetaDataClientConstants; - import java.io.File; public class MetaDataClientConfig { - private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class); - + private static final Log log = LogFactory.getLog(MetaDataClientConfig.class); + private static volatile MetaDataClientConfig metaDataClientConfig; private String metaDataServiceBaseUrl; - - private String dataExtractorClass; - private String username; - private String password; - private XMLConfiguration config; - private static volatile MetaDataClientConfig metaDataClientConfig; - - private MetaDataClientConfig () { + private MetaDataClientConfig() { readConfig(); } - private void readConfig () throws RuntimeException{ + public static MetaDataClientConfig getInstance() { + + if (metaDataClientConfig == null) { + synchronized (MetaDataClientConfig.class) { + if (metaDataClientConfig == null) { + metaDataClientConfig = new MetaDataClientConfig(); + } + } + } + + return metaDataClientConfig; + } + + private void readConfig() throws RuntimeException { // the config file path is found from a system property String configFilePath = System.getProperty(MetaDataClientConstants.METADATA_CLIENT_CONFIG_FILE); @@ -62,7 +67,7 @@ private void readConfig () throws RuntimeException{ metaDataServiceBaseUrl = config.getString(MetaDataClientConstants.METADATA_SERVICE_BASE_URL); if (metaDataServiceBaseUrl == null) { throw new RuntimeException("Unable to find metadata service base URL [ " + - MetaDataClientConstants.METADATA_SERVICE_BASE_URL + " ] in the config file"); + MetaDataClientConstants.METADATA_SERVICE_BASE_URL + " ] in the config file"); } username = config.getString(MetaDataClientConstants.METADATA_SERVICE_USERNAME); @@ -74,56 +79,25 @@ private void readConfig () throws RuntimeException{ if (password == null) { throw new RuntimeException("Meta data service password not defined in the configuration"); } - - dataExtractorClass = config.getString(MetaDataClientConstants.METADATA_CLIENT_DATA_EXTRACTOR_CLASS); - if (dataExtractorClass == null) { - if(log.isDebugEnabled()) { - log.debug("No custom Data Extractor class detected in the configuration"); - } - } } - private void loadConfig (String configFilePath) { + private void loadConfig(String configFilePath) { + if(StringUtils.isEmpty(configFilePath)){ + throw new IllegalArgumentException("Confguration file path can not be null or empaty"); + } try { - - File confFile; - if (configFilePath != null && !configFilePath.isEmpty()) { - confFile = new File(configFilePath); - - } else { - confFile = new File(configFilePath); - } - - config = new XMLConfiguration(confFile); - + config = new XMLConfiguration(new File(configFilePath)); } catch (ConfigurationException e) { String errorMsg = "Unable to load configuration file at " + configFilePath; throw new RuntimeException(errorMsg); } } - public static MetaDataClientConfig getInstance () { - - if (metaDataClientConfig == null) { - synchronized (MetaDataClientConfig.class) { - if (metaDataClientConfig == null) { - metaDataClientConfig = new MetaDataClientConfig(); - } - } - } - - return metaDataClientConfig; - } - public String getMetaDataServiceBaseUrl() { return metaDataServiceBaseUrl; } - public String getDataExtractorClass() { - return dataExtractorClass; - } - public String getUsername() { return username; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java deleted file mode 100644 index 13bc7257c6..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/data/extractor/MetaDataExtractor.java +++ /dev/null @@ -1,36 +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.metadata.client.data.extractor; - -import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; -import org.apache.stratos.metadata.client.pojo.DataContext; - -import java.util.Collection; - -public interface MetaDataExtractor { - - public void initialize (); - - public Collection getAllData (Object object) throws MetaDataExtractorException; - - public DataContext getData (Object object) throws MetaDataExtractorException; - - public void terminate () throws MetaDataExtractorException; -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.java deleted file mode 100644 index c1273f50fb..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataExtractorException.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.metadata.client.exception; - -public class MetaDataExtractorException extends Exception { - - private String message; - - public MetaDataExtractorException() { - super(); - } - - public MetaDataExtractorException(String message, Throwable cause) { - super(message, cause); - this.message = message; - } - - public MetaDataExtractorException(String message) { - super(message); - this.message = message; - } - - public MetaDataExtractorException(Throwable cause) { - super(cause); - } - - public String getMessage() { - return message; - } -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.java deleted file mode 100644 index 90d39d106b..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/factory/MetaDataExtractorFactory.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.metadata.client.factory; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; - -public class MetaDataExtractorFactory { - - private static final Log log = LogFactory.getLog(MetaDataExtractorFactory.class); - - public static MetaDataExtractor getMetaDataServiceClient (String clazzName) throws RuntimeException { - - try { - return (MetaDataExtractor) MetaDataExtractor.class.getClassLoader().loadClass(clazzName).newInstance(); - - } catch (InstantiationException e) { - String errorMsg = "Unable to instatiate class " + clazzName; - log.error(errorMsg, e); - throw new RuntimeException(errorMsg, e); - - } catch (IllegalAccessException e) { - String errorMsg = "Unable to instatiate class " + clazzName; - log.error(errorMsg, e); - throw new RuntimeException(errorMsg, e); - - } catch (ClassNotFoundException e) { - String errorMsg = "Unable to instatiate class " + clazzName; - log.error(errorMsg, e); - throw new RuntimeException(errorMsg, e); - } - } -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.java deleted file mode 100644 index f5194c8225..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/pojo/DataContext.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.metadata.client.pojo; - -import java.util.Set; - -public class DataContext { - - private String appId; - - private String clusterId; - - private String propertyKey; - - private Set propertyValues; - - private String propertyValue; - - - public DataContext (String appId, String propertyKey, Set propertyValues) { - - this.appId = appId; - this.propertyKey = propertyKey; - this.propertyValues = propertyValues; - - } - - public DataContext (String appId, String clusterId, String propertyKey, Set propertyValues) { - - this.appId = appId; - this.clusterId = clusterId; - this.propertyKey = propertyKey; - this.propertyValues = propertyValues; - } - - public DataContext (String appId, String propertyKey, String propertyValue) { - - this.appId = appId; - this.propertyKey = propertyKey; - this.propertyValue = propertyValue; - } - - public DataContext (String appId, String clusterId, String propertyKey, String propertyValue) { - - this.appId = appId; - this.clusterId = clusterId; - this.propertyKey = propertyKey; - this.propertyValue = propertyValue; - } - - public String getAppId() { - return appId; - } - - public String getClusterId() { - return clusterId; - } - - public String getPropertyKey() { - return propertyKey; - } - - public Set getPropertyValues() { - return propertyValues; - } - - public String getPropertyValue() { - return propertyValue; - } - -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index a6f0fb4072..29f5415fdf 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -48,34 +48,32 @@ public class DefaultRestClient implements RestClient { + private static final int MAX_TOTAL_CONNECTIONS = 100; + private static final int DEFAULT_MAX_PER_ROUTE = 20; private static final String APPLICATION_JSON = "application/json"; - public static final int MAX_TOTAL_CONNECTIONS = 100; - public static final int DEFAULT_MAX_PER_ROUTE = 20; - - private static Log log = LogFactory.getLog(DefaultRestClient.class); + private static final Log log = LogFactory.getLog(DefaultRestClient.class); private HttpClient httpClient; - public DefaultRestClient() throws RestClientException{ + public DefaultRestClient() throws RestClientException { SSLContextBuilder builder = new SSLContextBuilder(); - SSLConnectionSocketFactory sslsf = null; + SSLConnectionSocketFactory sslConnectionFactory; try { builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); - sslsf = new SSLConnectionSocketFactory( - builder.build()); + sslConnectionFactory = new SSLConnectionSocketFactory(builder.build()); } catch (NoSuchAlgorithmException e) { - throw new RestClientException(e); + throw new RestClientException(e); } catch (KeyManagementException e) { - throw new RestClientException(e); + throw new RestClientException(e); } catch (KeyStoreException e) { - throw new RestClientException(e); + throw new RestClientException(e); } - CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslsf).setConnectionManager(getHttpConnectionManager()).build(); + CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory).setConnectionManager(getHttpConnectionManager()).build(); this.httpClient = closableHttpClient; } - private HttpClientConnectionManager getHttpConnectionManager(){ + private HttpClientConnectionManager getHttpConnectionManager() { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); // TODO: Introduce configurable variable for Max total and max per router variables. cm.setMaxTotal(MAX_TOTAL_CONNECTIONS); @@ -97,7 +95,7 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien String errorMsg = "Error while executing POST statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); - }finally { + } finally { post.releaseConnection(); } } @@ -105,7 +103,7 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien private void setAuthHeader(HttpPost post) { String username = getUsername(); String password = getPassword(); - String identity = username+":"+password; + String identity = username + ":" + password; String encoding = new String(Base64.encodeBase64(identity.getBytes())); post.setHeader("Authorization", "Basic " + encoding); } @@ -122,7 +120,7 @@ private void addPayloadJsonString(Object payload, HttpPost post) { GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); - String payloadText = gson.toJson(payload, payload.getClass()); + String payloadText = gson.toJson(payload, payload.getClass()); addStringPayload(post, payloadText); } @@ -137,7 +135,7 @@ public HttpResponse doGet(String resourcePath) throws RestClientException { String errorMsg = "Error while executing GET statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); - }finally { + } finally { get.releaseConnection(); } } @@ -153,20 +151,24 @@ public HttpResponse doDelete(String resourcePath) throws RestClientException { String errorMsg = "Error while executing DELETE statement"; log.error(errorMsg, e); throw new RestClientException(errorMsg, e); - }finally { + } finally { delete.releaseConnection(); } } private void addStringPayload(HttpPost post, String payloadText) { + if(org.apache.commons.lang.StringUtils.isEmpty(payloadText)){ + throw new IllegalArgumentException("Payload text can not be null or empty"); + } StringEntity stringEntity = null; try { stringEntity = new StringEntity(payloadText); + stringEntity.setContentType(APPLICATION_JSON); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - stringEntity.setContentType(APPLICATION_JSON); + post.setEntity(stringEntity); } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java index 502773501f..4c8fb6e196 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java @@ -24,9 +24,9 @@ public interface RestClient { - public HttpResponse doPost (String resourcePath, Object payload) throws RestClientException; + public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException; - public HttpResponse doGet (String resourcePath) throws RestClientException; + public HttpResponse doGet(String resourcePath) throws RestClientException; - public HttpResponse doDelete (String resourcePath) throws RestClientException; + public HttpResponse doDelete(String resourcePath) throws RestClientException; } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.java deleted file mode 100644 index 1594601859..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/DefaultMetaDataExtractor.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.metadata.client.sample; - -import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; -import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; -import org.apache.stratos.metadata.client.pojo.DataContext; - -import java.util.Collection; - -public class DefaultMetaDataExtractor implements MetaDataExtractor { - - public void initialize() { - //To change body of implemented methods use File | Settings | File Templates. - } - - public Collection getAllData(Object object) throws MetaDataExtractorException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public DataContext getData(Object object) throws MetaDataExtractorException { - return null; //To change body of implemented methods use File | Settings | File Templates. - } - - public void terminate() throws MetaDataExtractorException { - //To change body of implemented methods use File | Settings | File Templates. - } -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java deleted file mode 100644 index 6c0215d8ac..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/sample/MetaDataServiceClientSample.java +++ /dev/null @@ -1,92 +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.metadata.client.sample; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadata.client.DefaultMetaDataServiceClient; -import org.apache.stratos.metadata.client.MetaDataServiceClient; -import org.apache.stratos.metadata.client.config.MetaDataClientConfig; -import org.apache.stratos.metadata.client.data.extractor.MetaDataExtractor; -import org.apache.stratos.metadata.client.exception.MetaDataExtractorException; -import org.apache.stratos.metadata.client.exception.RestClientException; -import org.apache.stratos.metadata.client.factory.MetaDataExtractorFactory; -import org.apache.stratos.metadata.client.pojo.DataContext; - -import java.util.Collection; - -public class MetaDataServiceClientSample { - - private static final Log log = LogFactory.getLog(MetaDataServiceClientSample.class); - - private MetaDataServiceClient metaDataServiceClient; - - private MetaDataExtractor metaDataExtractor; - - private MetaDataClientConfig metaDataClientConfig; - - - public MetaDataServiceClientSample() throws RestClientException { - //initialize(); - } - - private void initialize() throws RestClientException { - - metaDataClientConfig = MetaDataClientConfig.getInstance(); - metaDataServiceClient = new DefaultMetaDataServiceClient(metaDataClientConfig. - getMetaDataServiceBaseUrl()); - metaDataServiceClient.initialize(); - - if (MetaDataClientConfig.getInstance().getDataExtractorClass() != null) { - metaDataExtractor = MetaDataExtractorFactory.getMetaDataServiceClient(metaDataClientConfig. - getDataExtractorClass()); - metaDataExtractor.initialize(); - } - } - - public Collection getAllData (Object someObj) { - - Collection dataContexts = null; - - try { - dataContexts = metaDataExtractor.getAllData(someObj); - - } catch (MetaDataExtractorException e) { - log.error("Unable to get extracted data", e); - } - - return dataContexts; - } - - public DataContext getData (Object someObj) { - - DataContext dataContext = null; - - try { - dataContext = metaDataExtractor.getData(someObj); - - } catch (MetaDataExtractorException e) { - log.error("Unable to get extracted data", e); - } - - return dataContext; - } - -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java index c027bed00f..5cd29fb7b9 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/util/MetaDataClientConstants.java @@ -29,6 +29,4 @@ public class MetaDataClientConstants { public static final String METADATA_SERVICE_PASSWORD = "metadataService.password"; - public static final String METADATA_CLIENT_DATA_EXTRACTOR_CLASS = "metadataClient.dataExtractorClass"; - } From f5ae1b93df20ef78687a26aecd846117ae97f392 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 15 Oct 2014 13:47:31 +0530 Subject: [PATCH 193/436] making transactionmanager singleton --- .../client/DefaultMetaDataServiceClient.java | 8 +++- .../client/rest/DefaultRestClient.java | 31 +++++------- .../client/rest/HTTPConnectionManager.java | 47 +++++++++++++++++++ .../metadata/client/rest/RestClient.java | 20 +++++++- 4 files changed, 83 insertions(+), 23 deletions(-) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java index 6c43915708..d509533a66 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadata.client.beans.PropertyBean; +import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; import org.apache.stratos.metadata.client.exception.RestClientException; import org.apache.stratos.metadata.client.rest.DefaultRestClient; @@ -39,8 +40,11 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient { private final String baseUrl; public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException { - this.baseUrl = baseUrl; - this.restClient = new DefaultRestClient(); + MetaDataClientConfig metaDataClientConfig = MetaDataClientConfig.getInstance(); + this.baseUrl = metaDataClientConfig.getMetaDataServiceBaseUrl(); + String username = metaDataClientConfig.getUsername(); + String password = metaDataClientConfig.getPassword(); + this.restClient = new DefaultRestClient(username, password); } public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient) throws RestClientException { diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index 29f5415fdf..b671219177 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -29,14 +29,13 @@ import org.apache.http.client.methods.HttpDelete; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.SSLContextBuilder; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; -import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; import org.apache.stratos.metadata.client.exception.RestClientException; @@ -48,16 +47,19 @@ public class DefaultRestClient implements RestClient { - private static final int MAX_TOTAL_CONNECTIONS = 100; - private static final int DEFAULT_MAX_PER_ROUTE = 20; private static final String APPLICATION_JSON = "application/json"; private static final Log log = LogFactory.getLog(DefaultRestClient.class); + private final String username; + private final String password; + private HttpClient httpClient; - public DefaultRestClient() throws RestClientException { - SSLContextBuilder builder = new SSLContextBuilder(); + public DefaultRestClient(String username, String password) throws RestClientException { + this.username =username; + this.password=password; + SSLContextBuilder builder = new SSLContextBuilder(); SSLConnectionSocketFactory sslConnectionFactory; try { builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); @@ -69,20 +71,11 @@ public DefaultRestClient() throws RestClientException { } catch (KeyStoreException e) { throw new RestClientException(e); } - CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory).setConnectionManager(getHttpConnectionManager()).build(); + CloseableHttpClient closableHttpClient = HttpClients.custom().setSSLSocketFactory(sslConnectionFactory) + .setConnectionManager(HTTPConnectionManager.getInstance().getHttpConnectionManager()).build(); this.httpClient = closableHttpClient; } - private HttpClientConnectionManager getHttpConnectionManager() { - PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); - // TODO: Introduce configurable variable for Max total and max per router variables. - cm.setMaxTotal(MAX_TOTAL_CONNECTIONS); - cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE); - //HttpHost localhost = new HttpHost("locahost", 80); - //cm.setMaxPerRoute(new HttpRoute(localhost), 50); - return cm; - } - public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException { HttpPost post = new HttpPost(resourcePath); @@ -100,9 +93,7 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien } } - private void setAuthHeader(HttpPost post) { - String username = getUsername(); - String password = getPassword(); + private void setAuthHeader(HttpRequestBase post) { String identity = username + ":" + password; String encoding = new String(Base64.encodeBase64(identity.getBytes())); post.setHeader("Authorization", "Basic " + encoding); diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java new file mode 100644 index 0000000000..aadfa49f66 --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.metadata.client.rest; + +import org.apache.http.conn.HttpClientConnectionManager; +import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; + +public class HTTPConnectionManager { + + private static final int MAX_TOTAL_CONNECTIONS = 100; + private static final int DEFAULT_MAX_PER_ROUTE = 20; + + private static class InstanceHolder { + public static HTTPConnectionManager instance = new HTTPConnectionManager(); + } + + public static HTTPConnectionManager getInstance() { + return InstanceHolder.instance; + } + + public HttpClientConnectionManager getHttpConnectionManager(){ + PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); + // TODO: Introduce configurable variable for Max total and max per router variables. + cm.setMaxTotal(MAX_TOTAL_CONNECTIONS); + cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE); + //HttpHost localhost = new HttpHost("locahost", 80); + //cm.setMaxPerRoute(new HttpRoute(localhost), 50); + return cm; + } + +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java index 4c8fb6e196..3189218d1c 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java @@ -23,10 +23,28 @@ import org.apache.stratos.metadata.client.exception.RestClientException; public interface RestClient { - + /** + * Perform a HTTP POST request to @resourcePath with request body containing @payload converted to JSON. + * @param resourcePath Resource path to where is request is sent. + * @param payload request message body. + * @return Response of the request. + * @throws RestClientException + */ public HttpResponse doPost(String resourcePath, Object payload) throws RestClientException; + /** + * Perform a HTTP GET request to @resourcePath. + * @param resourcePath + * @return Response of the request. + * @throws RestClientException + */ public HttpResponse doGet(String resourcePath) throws RestClientException; + /** + * Perform a HTTP DELETE request to @resourcePath. + * @param resourcePath + * @return Response of the request. + * @throws RestClientException + */ public HttpResponse doDelete(String resourcePath) throws RestClientException; } From 014e15627e4f9c6bdbb3bab9c4f0b7d634e4be3f Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 15 Oct 2014 15:29:41 +0530 Subject: [PATCH 194/436] removing the local references to Topology from Monitors --- .../AutoscalerTopologyEventReceiver.java | 24 +++---- .../stratos/autoscaler/monitor/Monitor.java | 69 +++++++++++-------- .../application/ApplicationMonitor.java | 4 +- .../monitor/group/GroupMonitor.java | 15 ++-- .../autoscaler/util/AutoscalerUtil.java | 39 +++++++++-- 5 files changed, 100 insertions(+), 51 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index a7b6eda0d8..801af0ee86 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -97,7 +97,7 @@ protected void onEvent(Event event) { TopologyManager.acquireReadLock(); try { for (Application application : TopologyManager.getTopology().getApplications()) { - startApplicationMonitor(application); + startApplicationMonitor(application.getUniqueIdentifier()); } topologyInitialized = true; @@ -123,7 +123,7 @@ protected void onEvent(Event event) { TopologyManager.acquireReadLockForApplication( applicationCreatedEvent.getApplication().getUniqueIdentifier()); //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication()); + startApplicationMonitor(applicationCreatedEvent.getApplication().getUniqueIdentifier()); } catch (Exception e) { String msg = "Error processing event " + e.getLocalizedMessage(); log.error(msg, e); @@ -577,12 +577,12 @@ public void terminate() { terminated = true; } - protected synchronized void startApplicationMonitor(Application application) { + protected synchronized void startApplicationMonitor(String applicationId) { Thread th = null; if (!AutoscalerContext.getInstance() - .appMonitorExist(application.getUniqueIdentifier())) { + .appMonitorExist(applicationId)) { th = new Thread( - new ApplicationMonitorAdder(application)); + new ApplicationMonitorAdder(applicationId)); } // if (th != null) { th.start(); @@ -594,16 +594,16 @@ protected synchronized void startApplicationMonitor(Application application) { if (log.isDebugEnabled()) { log.debug(String .format("Application monitor thread has been started successfully: " + - "[application] %s ", application.getUniqueIdentifier())); + "[application] %s ", applicationId)); } // } } private class ApplicationMonitorAdder implements Runnable { - private Application application; + private String appId; - public ApplicationMonitorAdder(Application application) { - this.application = application; + public ApplicationMonitorAdder(String appId) { + this.appId = appId; } public void run() { @@ -619,9 +619,9 @@ public void run() { long start = System.currentTimeMillis(); if (log.isDebugEnabled()) { log.debug("application monitor is going to be started for [application] " + - application.getUniqueIdentifier()); + appId); } - applicationMonitor = AutoscalerUtil.getApplicationMonitor(application); + applicationMonitor = AutoscalerUtil.getApplicationMonitor(appId); long end = System.currentTimeMillis(); log.info("Time taken to start app monitor: " + (end - start) / 1000); @@ -639,7 +639,7 @@ public void run() { if (applicationMonitor == null) { String msg = "Application monitor creation failed, even after retrying for 5 times, " - + "for Application: " + application.getUniqueIdentifier(); + + "for Application: " + appId; log.error(msg); throw new RuntimeException(msg); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index cc30f7b38b..4f501d2230 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -57,8 +57,6 @@ public abstract class Monitor implements EventHandler { protected Map clusterIdToClusterMonitorsMap; //The monitors dependency tree with all the startable/killable dependencies protected DependencyTree dependencyTree; - //application/group reference from the Topology - protected ParentComponent component; //status of the monitor whether it is running/in_maintainable/terminated protected Status status; //Application id of this particular monitor @@ -67,7 +65,8 @@ public abstract class Monitor implements EventHandler { public Monitor(ParentComponent component) throws DependencyBuilderException { aliasToGroupMonitorsMap = new HashMap(); clusterIdToClusterMonitorsMap = new HashMap(); - this.component = component; + this.id = component.getUniqueIdentifier(); + this.status = component.getStatus(); //Building the dependency for this monitor within the immediate children dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } @@ -120,15 +119,18 @@ private boolean startDependency(List applicationContexts) log.debug("Dependency check for the Group " + context.getId() + " started"); } if (context instanceof GroupContext) { - startGroupMonitor(this, context.getId(), component); + startGroupMonitor(this, context.getId()); } else if (context instanceof ClusterContext) { String clusterId = context.getId(); String serviceName = null; - for(ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { + Group group = getGroupFromTopology(this.id); + + for(ClusterDataHolder dataHolder : group.getClusterDataMap().values()) { if(dataHolder.getClusterId().equals(clusterId)) { serviceName = dataHolder.getServiceType(); } } + Cluster cluster; //acquire read lock for the service and cluster TopologyManager.acquireReadLockForCluster(serviceName, clusterId); @@ -162,6 +164,22 @@ private boolean startDependency(List applicationContexts) } + private Group getGroupFromTopology(String groupId) throws TopologyInConsistentException { + Application application = TopologyManager.getTopology().getApplication(this.appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group != null) { + return group; + } else { + String msg = "[Group] " + groupId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + } else { + String msg = "[Application] " + this.appId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + } + protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { Thread th = null; if (cluster.isLbCluster() @@ -190,16 +208,17 @@ protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) } } - protected synchronized void startGroupMonitor(Monitor parent, String dependency, ParentComponent component) { + protected synchronized void startGroupMonitor(Monitor parent, String groupId) { Thread th = null; - if (!this.aliasToGroupMonitorsMap.containsKey(dependency)) { + //String groupId = group.getUniqueIdentifier(); + if (!this.aliasToGroupMonitorsMap.containsKey(groupId)) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor Adder has been added: [group] %s ", - dependency)); + groupId)); } th = new Thread( - new GroupMonitorAdder(parent, dependency, component)); + new GroupMonitorAdder(parent, groupId, this.appId)); } if (th != null) { @@ -211,7 +230,7 @@ protected synchronized void startGroupMonitor(Monitor parent, String dependency, log.info(String .format("Group monitor thread has been started successfully: [group] %s ", - dependency)); + groupId)); } } @@ -330,14 +349,14 @@ public void run() { } private class GroupMonitorAdder implements Runnable { - private String dependency; private Monitor parent; - private ParentComponent component; + private String groupId; + private String appId; - public GroupMonitorAdder(Monitor parent, String dependency, ParentComponent group) { - this.dependency = dependency; + public GroupMonitorAdder(Monitor parent, String groupId, String appId) { this.parent = parent; - this.component = group; + this.groupId = groupId; + this.appId = appId; } public void run() { @@ -353,25 +372,21 @@ public void run() { try { if (log.isDebugEnabled()) { log.debug("Group monitor is going to be started for [group] " - + dependency); + + groupId); } - Group group = component.getGroup(dependency); - monitor = AutoscalerUtil.getGroupMonitor(group); + monitor = AutoscalerUtil.getGroupMonitor(groupId, appId); monitor.setParent(parent); //setting the status of cluster monitor w.r.t Topology cluster //if(group.getStatus() != Status.Created && - if(group.getStatus() != monitor.getStatus()) { - //updating the status, so that it will notify the parent - monitor.setStatus(group.getStatus()); - } + //monitor.addObserver(parent); success = true; } catch (DependencyBuilderException e) { - String msg = "Group monitor creation failed for group: " + dependency; + String msg = "Group monitor creation failed for group: " + groupId; log.warn(msg, e); retries--; } catch (TopologyInConsistentException e) { - String msg = "Group monitor creation failed for group: " + dependency; + String msg = "Group monitor creation failed for group: " + groupId; log.warn(msg, e); retries--; } @@ -379,19 +394,19 @@ public void run() { if (monitor == null) { String msg = "Group monitor creation failed, even after retrying for 5 times, " - + "for group: " + dependency; + + "for group: " + groupId; log.error(msg); //TODO parent.notify(); as it got to failed throw new RuntimeException(msg); } - aliasToGroupMonitorsMap.put(dependency, monitor); + aliasToGroupMonitorsMap.put(groupId, monitor); //parent.addObserver(monitor); if (log.isInfoEnabled()) { log.info(String.format("Group monitor has been added successfully: [group] %s", - dependency)); + groupId)); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 7a73e2b2a6..5b6598aff7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ParentComponent; import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; @@ -44,9 +45,10 @@ public class ApplicationMonitor extends Monitor { public ApplicationMonitor(Application application) throws DependencyBuilderException, TopologyInConsistentException { super(application); + this.appId = application.getUniqueIdentifier(); //starting the first set of dependencies from its children - this.id = application.getUniqueIdentifier(); startDependency(); + } /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 58038229eb..0bdad16e23 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -43,6 +43,9 @@ public class GroupMonitor extends Monitor implements EventHandler { //Parent monitor of this monitor private Monitor parent; + //Application id of this particular monitor + protected String appId; + /** * Constructor of GroupMonitor @@ -53,10 +56,7 @@ public class GroupMonitor extends Monitor implements EventHandler { public GroupMonitor(Group group) throws DependencyBuilderException, TopologyInConsistentException { super(group); - this.id = group.getAlias(); startDependency(); - this.status = Status.Created; - } /** @@ -113,7 +113,14 @@ public Monitor getParent() { public void setParent(Monitor parent) { this.parent = parent; - this.appId = parent.getAppId(); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index f574367e11..cb0315879e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -45,6 +45,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import javax.xml.namespace.QName; @@ -323,20 +324,44 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic } //TODO moving it into factory class - public static GroupMonitor getGroupMonitor(Group group) throws DependencyBuilderException, + public static GroupMonitor getGroupMonitor(String groupId, String appId) throws DependencyBuilderException, TopologyInConsistentException { - GroupMonitor groupMonitor = - new GroupMonitor(group); + GroupMonitor groupMonitor; + TopologyManager.acquireReadLockForApplication(appId); + + try { + Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId); + groupMonitor = new GroupMonitor(group); + groupMonitor.setAppId(appId); + if(group.getStatus() != groupMonitor.getStatus()) { + //updating the status, so that it will notify the parent + groupMonitor.setStatus(group.getStatus()); + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + + } return groupMonitor; } - public static ApplicationMonitor getApplicationMonitor(Application application) + public static ApplicationMonitor getApplicationMonitor(String appId) throws DependencyBuilderException, TopologyInConsistentException { - ApplicationMonitor applicationMonitor = - new ApplicationMonitor(application); - applicationMonitor.setAppId(application.getUniqueIdentifier()); + ApplicationMonitor applicationMonitor; + TopologyManager.acquireReadLockForApplication(appId); + try { + Application application = TopologyManager.getTopology().getApplication(appId); + if(application != null) { + applicationMonitor = new ApplicationMonitor(application); + } else { + String msg = "[Application] " + appId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + return applicationMonitor; } From 24d47c29b54159fbb2b6ef6e5d86c660d2dd9a27 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 15 Oct 2014 16:08:14 +0530 Subject: [PATCH 195/436] formating changes --- .../client/MetaDataServiceClient.java | 103 ------------------ .../client/config/MetaDataClientConfig.java | 4 +- .../DefaultMetaDataServiceClient.java | 72 ++++++++---- .../defaults/MetaDataServiceClient.java | 67 ++++++++++++ ...va => MetaDataServiceClientException.java} | 10 +- .../client/rest/DefaultRestClient.java | 6 +- .../client/rest/HTTPConnectionManager.java | 11 +- .../metadata/client/rest/RestClient.java | 9 +- 8 files changed, 142 insertions(+), 140 deletions(-) delete mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/{ => defaults}/DefaultMetaDataServiceClient.java (50%) create mode 100644 components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java rename components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/{MetaDataServiceClientExeption.java => MetaDataServiceClientException.java} (78%) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java deleted file mode 100644 index 01ea3e3e9c..0000000000 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/MetaDataServiceClient.java +++ /dev/null @@ -1,103 +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.metadata.client; - -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; - -import java.util.Map; -import java.util.Set; - -public interface MetaDataServiceClient { - - /** - * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. - * - * @throws MetaDataServiceClientExeption - */ - public void initialize(); - - /** - * Adds a property key value pair for the relevant cluster of the specified app - * - * @param appId Application id - * @param clusterId Cluster id - * @param propertyKey Key of the Property - * @param propertyValue Value of the Property - * @throws MetaDataServiceClientExeption - */ - public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; - - // /** -// * Adds a property key value pair for the specified app -// * -// * @param appId Application id -// * @param propertyKey Key of the Property -// * @param propertyValue Value of the Property -// * @throws MetaDataServiceClientExeption -// */ -// public void addPropertyToCluster (String appId, String propertyKey, String propertyValue) throws MetaDataServiceClientExeption; -// -// /** -// * Retrieves the property key value pairs for the relevant cluster of the specified app -// * -// * @param appId Application id -// * @param clusterId Cluster id -// * @return Map of Keys and Values for the specified cluster in the relevant app. Each key can have multiple Values. -// * @throws MetaDataServiceClientExeption -// */ - public Map> getProperties(String appId, String clusterId) throws MetaDataServiceClientExeption; - - // /** -// * Retrieves the property key value pairs of the specified app -// * -// * @param appId Application id -// * @return Map of Keys and Values for the specified app. Each key can have multiple Values. -// * @throws MetaDataServiceClientExeption -// */ -// public Map> getProperties (String appId) throws MetaDataServiceClientExeption; -// -// /** -// * Retrieves the property values for the specified key of the relevant app -// * -// * @param appId Application id -// * @param propertyKey Key of the Property -// * @return Set of Values for specified Key of the relevant app. -// * @throws MetaDataServiceClientExeption -// */ - public Set getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption; - - /** - * Retrieves the property values for the specified key of the relevant cluster and app - * - * @param appId Application id - * @param clusterId Cluster id - * @param propertyKey Key of the Property - * @return Set of Values for specified Key of the relevant cluster in the relevant app. - * @throws MetaDataServiceClientExeption - */ - public Set getProperty(String appId, String clusterId, String propertyKey) throws MetaDataServiceClientExeption; - - /** - * Shutdown the MetaDataServiceClient. Should be called once after using the client. - * - * @throws MetaDataServiceClientExeption - */ - public void terminate() throws MetaDataServiceClientExeption; -} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java index 4324e5d265..7b53147356 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/config/MetaDataClientConfig.java @@ -83,8 +83,8 @@ private void readConfig() throws RuntimeException { private void loadConfig(String configFilePath) { - if(StringUtils.isEmpty(configFilePath)){ - throw new IllegalArgumentException("Confguration file path can not be null or empaty"); + if (StringUtils.isEmpty(configFilePath)) { + throw new IllegalArgumentException("Configuration file path can not be null or empty"); } try { config = new XMLConfiguration(new File(configFilePath)); diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java similarity index 50% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java index d509533a66..a23178981c 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java @@ -17,29 +17,32 @@ * under the License. */ -package org.apache.stratos.metadata.client; +package org.apache.stratos.metadata.client.defaults; +import com.google.gson.Gson; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.http.HttpResponse; import org.apache.stratos.metadata.client.beans.PropertyBean; import org.apache.stratos.metadata.client.config.MetaDataClientConfig; -import org.apache.stratos.metadata.client.exception.MetaDataServiceClientExeption; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientException; import org.apache.stratos.metadata.client.exception.RestClientException; import org.apache.stratos.metadata.client.rest.DefaultRestClient; import org.apache.stratos.metadata.client.rest.RestClient; -import java.util.Map; -import java.util.Set; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.List; public class DefaultMetaDataServiceClient implements MetaDataServiceClient { private static final Log log = LogFactory.getLog(DefaultMetaDataServiceClient.class); - - private RestClient restClient; private final String baseUrl; + private RestClient restClient; - public DefaultMetaDataServiceClient(String baseUrl) throws RestClientException { + public DefaultMetaDataServiceClient() throws RestClientException { MetaDataClientConfig metaDataClientConfig = MetaDataClientConfig.getInstance(); this.baseUrl = metaDataClientConfig.getMetaDataServiceBaseUrl(); String username = metaDataClientConfig.getUsername(); @@ -57,32 +60,61 @@ public void initialize() { } public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) - throws MetaDataServiceClientExeption { - String applicationPath = baseUrl.concat("application/").concat(appId).concat("/cluster/").concat(clusterId).concat("/property"); + throws MetaDataServiceClientException { + + StringBuilder applicationPath = new StringBuilder(baseUrl).append("application/").append(appId).append("/cluster/").append(clusterId).append("/property"); + PropertyBean property = new PropertyBean(propertyKey, propertyValue); try { - restClient.doPost(applicationPath, property); + restClient.doPost(applicationPath.toString(), property); } catch (RestClientException e) { - log.error(String.format("Error occurred while adding property %s", propertyKey)); + String message = "Error occurred while adding property " + property.getKey(); + log.error(message); + throw new MetaDataServiceClientException(message, e); } } - public Map> getProperties(String appId, String clusterId) - throws MetaDataServiceClientExeption { - return null; //To change body of implemented methods use File | Settings | File Templates. + public PropertyBean getProperty(String appId, String clusterId, String propertyName) throws MetaDataServiceClientException { + StringBuilder applicationPath = new StringBuilder(baseUrl). + append("application/").append(appId).append("/cluster/"). + append(clusterId).append("/property/").append(propertyName); + HttpResponse response; + try { + response = restClient.doGet(applicationPath.toString()); + } catch (RestClientException e) { + String message = "Error occurred while fetching property " + propertyName; + throw new MetaDataServiceClientException(message, e); + } + + String responseContent; + try { + responseContent = readResponseContent(response); + } catch (IOException e) { + throw new MetaDataServiceClientException("Error occurred while reading the response from metadata service", e); + } + Gson gson = new Gson(); + return gson.fromJson(responseContent, PropertyBean.class); } - public Set getProperty(String appId, String propertyKey) throws MetaDataServiceClientExeption { - return null; //To change body of implemented methods use File | Settings | File Templates. + private String readResponseContent(HttpResponse response) throws IOException { + + BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); + StringBuilder builder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line).append("\n"); + } + + return builder.toString(); } - public Set getProperty(String appId, String clusterId, String propertyKey) - throws MetaDataServiceClientExeption { + public List getProperties(String appId, String clusterId) + throws MetaDataServiceClientException { return null; //To change body of implemented methods use File | Settings | File Templates. } - - public void terminate() throws MetaDataServiceClientExeption { + public void terminate() { + log.info("Terminating the metadata client"); restClient = null; } } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java new file mode 100644 index 0000000000..d1a9e25c6e --- /dev/null +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.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.metadata.client.defaults; + +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientException; + +public interface MetaDataServiceClient { + + /** + * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. + */ + public void initialize(); + + /** + * Adds a property key value pair for the relevant cluster of the specified app + * + * @param appId Application id + * @param clusterId Cluster id + * @param propertyKey Key of the Property + * @param propertyValue Value of the Property + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientException; + + /** + * Get all properties from metadata service. + * + * @param appId Application id + * @param clusterId Cluster id + * @return List of properties + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public java.util.List getProperties(String appId, String clusterId) throws MetaDataServiceClientException; + + /** + * Fetch a given property from metadata service. + * + * @param appId Application id + * @param clusterID Cluster Id + * @param propertyKey Name of the property + * @return property + * @throws org.apache.stratos.metadata.client.exception.MetaDataServiceClientException + */ + public org.apache.stratos.metadata.client.beans.PropertyBean getProperty(String appId, String clusterID, String propertyKey) throws MetaDataServiceClientException; + + /** + * Shutdown the MetaDataServiceClient. Should be called once after using the client. + */ + public void terminate(); +} diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java similarity index 78% rename from components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java rename to components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java index 8ef5e37d96..b0f7599a1e 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientExeption.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/exception/MetaDataServiceClientException.java @@ -19,25 +19,25 @@ package org.apache.stratos.metadata.client.exception; -public class MetaDataServiceClientExeption extends Exception { +public class MetaDataServiceClientException extends Exception { private String message; - public MetaDataServiceClientExeption() { + public MetaDataServiceClientException() { super(); } - public MetaDataServiceClientExeption(String message, Throwable cause) { + public MetaDataServiceClientException(String message, Throwable cause) { super(message, cause); this.message = message; } - public MetaDataServiceClientExeption(String message) { + public MetaDataServiceClientException(String message) { super(message); this.message = message; } - public MetaDataServiceClientExeption(Throwable cause) { + public MetaDataServiceClientException(Throwable cause) { super(cause); } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index b671219177..e6279d7549 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -56,8 +56,8 @@ public class DefaultRestClient implements RestClient { private HttpClient httpClient; public DefaultRestClient(String username, String password) throws RestClientException { - this.username =username; - this.password=password; + this.username = username; + this.password = password; SSLContextBuilder builder = new SSLContextBuilder(); SSLConnectionSocketFactory sslConnectionFactory; @@ -149,7 +149,7 @@ public HttpResponse doDelete(String resourcePath) throws RestClientException { private void addStringPayload(HttpPost post, String payloadText) { - if(org.apache.commons.lang.StringUtils.isEmpty(payloadText)){ + if (org.apache.commons.lang.StringUtils.isEmpty(payloadText)) { throw new IllegalArgumentException("Payload text can not be null or empty"); } StringEntity stringEntity = null; diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java index aadfa49f66..f6f00936ea 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/HTTPConnectionManager.java @@ -26,22 +26,25 @@ public class HTTPConnectionManager { private static final int MAX_TOTAL_CONNECTIONS = 100; private static final int DEFAULT_MAX_PER_ROUTE = 20; - private static class InstanceHolder { - public static HTTPConnectionManager instance = new HTTPConnectionManager(); + private HTTPConnectionManager() { } public static HTTPConnectionManager getInstance() { return InstanceHolder.instance; } - public HttpClientConnectionManager getHttpConnectionManager(){ + public HttpClientConnectionManager getHttpConnectionManager() { PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(); // TODO: Introduce configurable variable for Max total and max per router variables. cm.setMaxTotal(MAX_TOTAL_CONNECTIONS); cm.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE); - //HttpHost localhost = new HttpHost("locahost", 80); + //HttpHost localhost = new HttpHost("localhost", 80); //cm.setMaxPerRoute(new HttpRoute(localhost), 50); return cm; } + private static class InstanceHolder { + public static HTTPConnectionManager instance = new HTTPConnectionManager(); + } + } diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java index 3189218d1c..e6b01c24b9 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/RestClient.java @@ -25,8 +25,9 @@ public interface RestClient { /** * Perform a HTTP POST request to @resourcePath with request body containing @payload converted to JSON. + * * @param resourcePath Resource path to where is request is sent. - * @param payload request message body. + * @param payload request message body. * @return Response of the request. * @throws RestClientException */ @@ -34,7 +35,8 @@ public interface RestClient { /** * Perform a HTTP GET request to @resourcePath. - * @param resourcePath + * + * @param resourcePath Resource path to where is request is sent. * @return Response of the request. * @throws RestClientException */ @@ -42,7 +44,8 @@ public interface RestClient { /** * Perform a HTTP DELETE request to @resourcePath. - * @param resourcePath + * + * @param resourcePath Resource path to where is request is sent. * @return Response of the request. * @throws RestClientException */ From 5f4c859605a72d6ae1ac23a1a2097bed63edec2c Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 15 Oct 2014 17:15:01 +0530 Subject: [PATCH 196/436] string.utils to check empty --- .../java/org/apache/stratos/metadataservice/util/ConfUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java index 1abbf0777e..b6d4ce059a 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/util/ConfUtil.java @@ -21,6 +21,7 @@ import org.apache.commons.configuration.ConfigurationException; import org.apache.commons.configuration.XMLConfiguration; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.Constants; @@ -45,7 +46,7 @@ private ConfUtil(String configFilePath) { try { File confFile; - if (configFilePath != null && !configFilePath.isEmpty()) { + if (StringUtils.isNotEmpty(configFilePath)) { confFile = new File(configFilePath); } else { From 35ef227936d438159571ce27b7dd7612d7a2d65c Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 16 Oct 2014 11:54:34 +0530 Subject: [PATCH 197/436] refactor metadata client --- .../DefaultMetaDataServiceClient.java | 14 +- .../defaults/MetaDataServiceClient.java | 2 +- .../listener/TopologyAgent.java | 2 +- .../registry/CarbonRegistry.java | 121 +---------------- .../metadataservice/registry/DataStore.java | 10 -- .../registry/GRegRegistry.java | 122 ------------------ .../services/MetaDataAdmin.java | 48 ------- 7 files changed, 15 insertions(+), 304 deletions(-) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java index a23178981c..fbebab9ae3 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java @@ -42,23 +42,23 @@ public class DefaultMetaDataServiceClient implements MetaDataServiceClient { private final String baseUrl; private RestClient restClient; - public DefaultMetaDataServiceClient() throws RestClientException { + public DefaultMetaDataServiceClient() throws MetaDataServiceClientException { MetaDataClientConfig metaDataClientConfig = MetaDataClientConfig.getInstance(); this.baseUrl = metaDataClientConfig.getMetaDataServiceBaseUrl(); String username = metaDataClientConfig.getUsername(); String password = metaDataClientConfig.getPassword(); - this.restClient = new DefaultRestClient(username, password); + try { + this.restClient = new DefaultRestClient(username, password); + } catch (RestClientException e) { + throw new MetaDataServiceClientException("Error occurred while creating REST client ", e); + } } - public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient) throws RestClientException { + public DefaultMetaDataServiceClient(String baseUrl, RestClient restClient){ this.baseUrl = baseUrl; this.restClient = restClient; } - public void initialize() { - // initialization, if any - } - public void addPropertyToCluster(String appId, String clusterId, String propertyKey, String propertyValue) throws MetaDataServiceClientException { diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java index d1a9e25c6e..8fdb9a7dfe 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java @@ -26,7 +26,7 @@ public interface MetaDataServiceClient { /** * Initialize the MetaDataServiceClient. Should be called once before using the MetaDataServiceClient. */ - public void initialize(); + //public void initialize(); /** * Adds a property key value pair for the relevant cluster of the specified app diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java index f9afd7892d..f39594aeae 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/listener/TopologyAgent.java @@ -86,7 +86,7 @@ protected void onEvent(Event event) { log.debug("Terminated event :::::::::::::::::::: " + memberTerminatedEvent.getServiceName()); } - DataRegistryFactory.getDataRegistryFactory(registryType).removeCartridgeMetaDataDetails("appA", "php"); + //DataRegistryFactory.getDataRegistryFactory(registryType).removeCartridgeMetaDataDetails("appA", "php"); } catch (Exception e) { if (log.isErrorEnabled()) { 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 e1526aa0ed..e9d590d5ba 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 @@ -18,20 +18,18 @@ */ package org.apache.stratos.metadataservice.registry; -import java.util.*; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Context; - - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.*; +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.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.core.Context; +import java.util.*; + /** * Carbon registry implementation @@ -43,7 +41,7 @@ public class CarbonRegistry extends AbstractAdmin implements DataStore { @Context HttpServletRequest httpServletRequest; - private static final String mainResource = "/startos/"; + private static final String mainResource = "/stratos/"; public CarbonRegistry() { @@ -51,110 +49,6 @@ public CarbonRegistry() { } - /** - * Add the meta data to governance registry - * - * @param applicationName Application Name - * @param cartridgeType Cartridge Type - * @param cartridgeMetaData Cartridge Meta Data - * @throws Exception - */ - @Override - public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception { - log.debug("Adding meta data details"); - - Registry tempRegistry = getGovernanceUserRegistry(); - - - Resource resource = tempRegistry.newResource(); - - String type = cartridgeMetaData.type; - - resource.setContent("Application description :: " + type); - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - - resource.addProperty("Application Name", cartridgeMetaData.applicationName); - resource.addProperty("Display Name", cartridgeMetaData.displayName); - resource.addProperty("Description", cartridgeMetaData.description); - resource.addProperty("Cartidge Type", cartridgeMetaData.type); - resource.addProperty("provider", cartridgeMetaData.provider); - resource.addProperty("Version", cartridgeMetaData.version); - resource.addProperty("Host", cartridgeMetaData.host); - resource.addProperty("Properties", cartridgeMetaData.properties); - - tempRegistry.put(resourcePath, resource); - - if (log.isDebugEnabled()) { - log.debug("A resource added to: " + resourcePath); - } - - - } - - /** - * Get the meta data from the registry - * - * @param applicationName name of the application - * @param cartridgeType cartridge type - * @return - * @throws Exception - */ - @Override - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = getGovernanceUserRegistry(); - CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); - - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - if (registry.resourceExists(resourcePath)) { - - Resource getResource = registry.get(resourcePath); - - cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); - cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); - cartridgeMetaData.description = getResource.getProperty("Description"); - cartridgeMetaData.displayName = getResource.getProperty("Display Name"); - cartridgeMetaData.host = getResource.getProperty("host"); - cartridgeMetaData.provider = getResource.getProperty("provider"); - cartridgeMetaData.version = getResource.getProperty("Version"); - cartridgeMetaData.properties = getResource.getProperty("Properties"); - - - } - - - return cartridgeMetaData.toString(); - } - - - /** - * Remove the meta data from the registry - * - * @param applicationName name of the application - * @param cartridgeType cartridge type - * @return - * @throws Exception - */ - @Override - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = getGovernanceUserRegistry(); - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - - if (registry != null) { - registry.delete(resourcePath); - return true; - } else { - if (log.isDebugEnabled()) { - log.debug("Unable to delete the meta data since the Registry is NULL"); - } - return false; - } - } - /** * Get Properties of clustor * @param applicationName @@ -162,7 +56,6 @@ public boolean removeCartridgeMetaDataDetails(String applicationName, String car * @return * @throws RegistryException */ - @Override public List getPropertiesOfCluster(String applicationName, String clusterId) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; @@ -197,7 +90,6 @@ public List getPropertiesOfCluster(String applicationName, String c * @param property * @throws RegistryException */ - @Override public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationId + "/" + clusterId; @@ -216,7 +108,6 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp * @param properties * @throws RegistryException */ - @Override public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { Registry tempRegistry = getGovernanceUserRegistry(); String resourcePath = mainResource + applicationName + "/" + clusterId; diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index ea905a09be..0ad845914e 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -19,7 +19,6 @@ package org.apache.stratos.metadataservice.registry; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.wso2.carbon.registry.api.RegistryException; @@ -30,15 +29,6 @@ */ public interface DataStore { - public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception; - - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception; - - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception; - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException; public List getPropertiesOfCluster(String applicationName, String clusterId) diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index 2be8d272e9..ffe38f110a 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -24,13 +24,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.util.ConfUtil; -import org.wso2.carbon.registry.api.Registry; import org.wso2.carbon.registry.api.RegistryException; -import org.wso2.carbon.registry.api.Resource; -import org.wso2.carbon.registry.core.Comment; import org.wso2.carbon.registry.ws.client.registry.WSRegistryServiceClient; import javax.servlet.http.HttpServletRequest; @@ -94,124 +90,6 @@ private static WSRegistryServiceClient setRegistry() throws Exception { } - - /** - * Add the meta data to governance registry - * @param applicationName - * @param cartridgeType - * @param cartridgeMetaData - * @throws Exception - */ - @Override - public void addCartridgeMetaDataDetails(String applicationName, String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws Exception { - - Registry registry = setRegistry(); - try { - - Resource resource = registry.newResource(); - - String type = cartridgeMetaData.type; - - resource.setContent("Application description :: " + type); - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - - resource.addProperty("Application Name", cartridgeMetaData.applicationName); - resource.addProperty("Display Name", cartridgeMetaData.displayName); - resource.addProperty("Description", cartridgeMetaData.description); - resource.addProperty("Cartidge Type", cartridgeMetaData.type); - resource.addProperty("provider", cartridgeMetaData.provider); - resource.addProperty("Version", cartridgeMetaData.version); - resource.addProperty("Host", cartridgeMetaData.host); - resource.addProperty("Properties", cartridgeMetaData.properties); - registry.put(resourcePath, resource); - - registry.rateResource(resourcePath, defaultRank); - - Comment comment = new Comment(); - comment.setText("Added the " + applicationName + " " + type + " cartridge"); - registry.addComment(resourcePath, comment); - - } catch (Exception e) { - - if (log.isErrorEnabled()) { - log.error("addCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - ((WSRegistryServiceClient) registry).logut(); - } - - - } - - /** - * Get the meta data from the registry - * @param applicationName - * @param cartridgeType - * @return - * @throws Exception - */ - @Override - public String getCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = setRegistry(); - CartridgeMetaData cartridgeMetaData = new CartridgeMetaData(); - try { - - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - if (registry.resourceExists(resourcePath)) { - - Resource getResource = registry.get(resourcePath); - if (log.isDebugEnabled()) { - log.debug("Resource retrived"); - log.debug("Printing retrieved resource content: " + - new String((byte[]) getResource.getContent())); - } - - cartridgeMetaData.type = getResource.getProperty("Cartidge Type"); - cartridgeMetaData.applicationName = getResource.getProperty("Application Name"); - cartridgeMetaData.description = getResource.getProperty("Description"); - cartridgeMetaData.displayName = getResource.getProperty("Display Name"); - cartridgeMetaData.host = getResource.getProperty("Host"); - cartridgeMetaData.provider = getResource.getProperty("provider"); - cartridgeMetaData.version = getResource.getProperty("Version"); - cartridgeMetaData.properties = getResource.getProperty("Properties"); - - - - } - - } catch (Exception e) { - - if (log.isErrorEnabled()) { - log.error("getCartridgeMetaDataDetails", e); - } - } finally { - // Close the session - ((WSRegistryServiceClient) registry).logut(); - } - return cartridgeMetaData.toString(); - } - - /** - * Remove catridge meta data details from the registry - * @param applicationName - * @param cartridgeType - * @return - * @throws Exception - */ - @Override - public boolean removeCartridgeMetaDataDetails(String applicationName, String cartridgeType) - throws Exception { - Registry registry = setRegistry(); - String resourcePath = mainResource + applicationName + "/" + cartridgeType; - registry.delete(resourcePath); - return false; - } - - public void addPropertiesToCluster(String applicationName, String clusterId, NewProperty[] properties) throws RegistryException { } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index ce04abd7f0..55887a3eeb 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.metadataservice.annotation.AuthorizationAction; -import org.apache.stratos.metadataservice.definition.CartridgeMetaData; import org.apache.stratos.metadataservice.definition.NewProperty; import org.apache.stratos.metadataservice.exception.RestAPIException; import org.apache.stratos.metadataservice.registry.DataRegistryFactory; @@ -60,51 +59,6 @@ public MetaDataAdmin(){ registry = DataRegistryFactory.getDataRegistryFactory(registryType); } - @POST - @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response addCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, - @PathParam("cartridgetype") String cartridgeType, - CartridgeMetaData cartridgeMetaData) throws RestAPIException { - - - URI url = uriInfo.getAbsolutePathBuilder().path(applicationName + "/" + cartridgeType).build(); - try { - registry.addCartridgeMetaDataDetails(applicationName, cartridgeType, cartridgeMetaData); - } catch (Exception err) { - log.error("Error occurred while adding meta data details ", err); - } - - return Response.created(url).build(); - - } - - @GET - @Path("/cartridge/metadata/{applicationname}/{cartridgetype}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - public Response getCartridgeMetaDataDetails(@PathParam("applicationname") String applicationName, - @PathParam("cartridgetype") String cartridgeType) throws RestAPIException { - - String result = null; - try { - result = registry.getCartridgeMetaDataDetails(applicationName, cartridgeType); - } catch (Exception err) { - log.error("Error occurred while adding meta data details ", err); - } - Response.ResponseBuilder rb; - if (result == null) { - rb = Response.status(Response.Status.NOT_FOUND); - } else { - rb = Response.ok().entity(result); - } - return rb.build(); - - } - @GET @Path("/application/{application_id}/cluster/{cluster_id}/properties") @Produces("application/json") @@ -188,7 +142,6 @@ public Response addPropertyToACluster(@PathParam("application_id") String applic } return Response.created(url).build(); - } @POST @@ -206,7 +159,6 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl log.error("Error occurred while adding properties ", e); } - return Response.created(url).build(); } From fa5a741200d0936c9f17ce1c50eb8b1c65735bf9 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 17 Oct 2014 16:58:35 +0530 Subject: [PATCH 198/436] refactoring monitor hierarchy and adding status to monitor's monitor methos --- .../stratos/autoscaler/AutoscalerContext.java | 91 ++-- .../dependency/DependencyBuilder.java | 10 +- .../grouping/dependency/DependencyTree.java | 38 +- .../context/ApplicationContext.java | 23 +- .../context/ApplicationContextFactory.java | 31 +- .../dependency/context/ClusterContext.java | 12 +- .../AutoscalerHealthStatEventReceiver.java | 4 +- .../AutoscalerTopologyEventReceiver.java | 57 +- .../monitor/AbstractClusterMonitor.java | 9 +- .../monitor/ApplicationMonitorFactory.java | 245 ++++++++- .../stratos/autoscaler/monitor/Monitor.java | 426 +-------------- .../monitor/MonitorStatusEventBuilder.java | 8 +- .../monitor/ParentComponentMonitor.java | 499 ++++++++++++++++++ .../application/ApplicationMonitor.java | 107 +--- .../monitor/group/GroupMonitor.java | 124 +++-- .../status/checker/StatusChecker.java | 85 +-- .../autoscaler/util/AutoscalerUtil.java | 181 ------- 17 files changed, 1085 insertions(+), 865 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 1145204b2c..ff59ecfa5f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -22,9 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; @@ -37,9 +36,18 @@ public class AutoscalerContext { private static final Log log = LogFactory.getLog(AutoscalerContext.class); + // Map + private Map monitors; + // Map + private Map statusCheckers; + // Map + private Map lbMonitors; + private Map appMonitors; + + private AutoscalerContext() { try { - setMonitors(new HashMap()); + setMonitors(new HashMap()); setLbMonitors(new HashMap()); setAppMonitors(new HashMap()); } catch (Exception e) { @@ -47,49 +55,34 @@ private AutoscalerContext() { } } - // Map - private Map monitors; - - // Map - private Map statusCheckers; - // Map - private Map lbMonitors; - - - private Map appMonitors; + public static AutoscalerContext getInstance() { + return Holder.INSTANCE; + } public Map getAppMonitors() { return appMonitors; } - public ApplicationMonitor getAppMonitor(String applicationId) { - return appMonitors.get(applicationId); - } - public void setAppMonitors(Map appMonitors) { this.appMonitors = appMonitors; } + public ApplicationMonitor getAppMonitor(String applicationId) { + return appMonitors.get(applicationId); + } + public Map getStatusCheckers() { return statusCheckers; } - private static class Holder { - private static final AutoscalerContext INSTANCE = new AutoscalerContext(); - } - - public static AutoscalerContext getInstance() { - return Holder.INSTANCE; - } - - public void addMonitor(ClusterMonitor monitor) { - monitors.put(monitor.getClusterId(), monitor); + public void addMonitor(Monitor monitor) { + monitors.put(monitor.getId(), monitor); } - public ClusterMonitor getMonitor(String clusterId) { + public Monitor getMonitor(String clusterId) { return monitors.get(clusterId); } - + public boolean monitorExist(String clusterId) { return monitors.containsKey(clusterId); } @@ -101,38 +94,38 @@ public void addAppMonitor(ApplicationMonitor appMonitor) { public boolean appMonitorExist(String appId) { return appMonitors.containsKey(appId); } - + public boolean lbMonitorExist(String clusterId) { return lbMonitors.containsKey(clusterId); } - + public LbClusterMonitor getLBMonitor(String clusterId) { return lbMonitors.get(clusterId); } - public ClusterMonitor removeMonitor(String clusterId) { - if(!monitorExist(clusterId)) { - log.fatal("Cluster monitor not found for cluster id: "+clusterId); - return null; - } - log.info("Removed monitor [cluster id]: " + clusterId); + public Monitor removeMonitor(String clusterId) { + if (!monitorExist(clusterId)) { + log.fatal("Cluster monitor not found for cluster id: " + clusterId); + return null; + } + log.info("Removed monitor [cluster id]: " + clusterId); return monitors.remove(clusterId); } + public LbClusterMonitor removeLbMonitor(String clusterId) { - if(!lbMonitorExist(clusterId)) { - log.fatal("LB monitor not found for cluster id: "+clusterId); - return null; - } - log.info("Removed LB monitor [cluster id]: " + clusterId); + if (!lbMonitorExist(clusterId)) { + log.fatal("LB monitor not found for cluster id: " + clusterId); + return null; + } + log.info("Removed LB monitor [cluster id]: " + clusterId); return lbMonitors.remove(clusterId); } - public Map getMonitors() { + public Map getMonitors() { return monitors; } - - public void setMonitors(Map monitors) { + public void setMonitors(Map monitors) { this.monitors = monitors; } @@ -145,12 +138,16 @@ public void addLbMonitor(LbClusterMonitor monitor) { } public ApplicationMonitor removeAppMonitor(String appId) { - if(!appMonitorExist(appId)) { - log.fatal("LB monitor not found for App id: "+ appId); + if (!appMonitorExist(appId)) { + log.fatal("LB monitor not found for App id: " + appId); return null; } log.info("Removed APP monitor [App id]: " + appId); return appMonitors.remove(appId); } + private static class Holder { + private static final AutoscalerContext INSTANCE = new AutoscalerContext(); + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 71c73a245b..14fc90eeb0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -140,14 +140,16 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen // as they can start in parallel. for (Group group1 : component.getAliasToGroupMap().values()) { if (dependencyTree.findApplicationContextWithId(group1.getAlias()) == null) { - dependencyTree.addApplicationContext(new GroupContext(group1.getAlias(), - dependencyTree.isKillDependent())); + ApplicationContext context = ApplicationContextFactory. + getGroupContext(group1.getAlias(), dependencyTree.isKillDependent()); + dependencyTree.addApplicationContext(context); } } for (ClusterDataHolder dataHolder : component.getClusterDataMap().values()) { if (dependencyTree.findApplicationContextWithId(dataHolder.getClusterId()) == null) { - dependencyTree.addApplicationContext(new ClusterContext(dataHolder.getClusterId(), - dependencyTree.isKillDependent())); + ApplicationContext context = ApplicationContextFactory.getClusterContext(dataHolder, + dependencyTree.isKillDependent()); + dependencyTree.addApplicationContext(context); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index d3dded3ee0..156f3a50be 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -46,6 +46,10 @@ public class DependencyTree { private boolean killDependent; + private boolean startupOder; + + private boolean reverseStartupOrder; + private String id; public DependencyTree(String id) { @@ -88,7 +92,7 @@ public ApplicationContext findApplicationContextWithId(String id) { */ private ApplicationContext findApplicationContextWithId(String id, List contexts) { for (ApplicationContext context : contexts) { - if (context.getId().equals(id)) { + if (context.getId().equals(id) && context.getCurrentStatus() == null) { return context; } } @@ -130,23 +134,23 @@ public List getStarAbleDependencies() { * @param id the alias/id of group/cluster in which terminated event received * @return all the kill able children dependencies */ - public List getKillDependencies(String id) { + public List getTerminationDependencies(String id) { List allChildrenOfAppContext = new ArrayList(); + ApplicationContext applicationContext = findApplicationContextWithId(id); - if (killDependent) { + if (this.killDependent) { //finding the ApplicationContext of the given id - ApplicationContext applicationContext = findApplicationContextWithId(id); //finding all the children of the found application context - findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), - allChildrenOfAppContext); - return allChildrenOfAppContext; - } else if (killAll) { + findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), + allChildrenOfAppContext); + return allChildrenOfAppContext; + } else if (this.killAll) { //killall will be killed by the monitor from it's list. findAllChildrenOfAppContext(this.applicationContextList, allChildrenOfAppContext); } - //return empty for the kill-none case + //return empty for the kill-none case, what ever returns here will be killed in return allChildrenOfAppContext; } @@ -221,4 +225,20 @@ public String getId() { public void setId(String id) { this.id = id; } + + public boolean isStartupOder() { + return startupOder; + } + + public void setStartupOder(boolean startupOder) { + this.startupOder = startupOder; + } + + public boolean isReverseStartupOrder() { + return reverseStartupOrder; + } + + public void setReverseStartupOrder(boolean reverseStartupOrder) { + this.reverseStartupOrder = reverseStartupOrder; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java index f923bb0833..5b98264cde 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Stack; /** * This is to keep track of the @@ -35,13 +36,13 @@ public abstract class ApplicationContext { private Status status; - private List statusLifeCycle; + private Stack statusLifeCycle; protected boolean killDependent; public ApplicationContext(String id, boolean killDependent) { applicationContextList = new ArrayList(); - statusLifeCycle = new ArrayList(); + statusLifeCycle = new Stack(); this.killDependent = killDependent; this.id = id; } @@ -60,7 +61,7 @@ public void addApplicationContext(ApplicationContext applicationContext) { } public void addStatusToLIfeCycle(Status status) { - this.statusLifeCycle.add(status); + this.statusLifeCycle.push(status); } public String getId() { @@ -71,11 +72,11 @@ public void setId(String id) { this.id = id; } - public Status getStatus() { + public Status getCurrentStatus() { return status; } - public void setStatus(Status status) { + public void setCurrentStatus(Status status) { this.status = status; } @@ -83,7 +84,15 @@ public List getStatusLifeCycle() { return statusLifeCycle; } - public void setStatusLifeCycle(List statusLifeCycle) { - this.statusLifeCycle = statusLifeCycle; + public boolean hasChild() { + boolean hasChild; + if(this.applicationContextList.isEmpty()) { + hasChild = false; + } else { + hasChild = true; + } + return hasChild; } + + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java index 685f131d71..970d5931e1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.ParentComponent; /** @@ -32,8 +33,9 @@ public class ApplicationContextFactory { /** * Will return the GroupContext/ClusterContext based on the type in start order - * @param startOrder reference of group/cluster in the start order - * @param component The component which used to build the dependency + * + * @param startOrder reference of group/cluster in the start order + * @param component The component which used to build the dependency * @param isKillDependent kill dependent behaviour of this component * @return Context */ @@ -45,15 +47,14 @@ public static ApplicationContext getApplicationContext(String startOrder, if (startOrder.startsWith(Constants.GROUP + ".")) { //getting the group alias id = getGroupFromStartupOrder(startOrder); - applicationContext = new GroupContext(id, - isKillDependent); + applicationContext = getGroupContext(id, isKillDependent); } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) { //getting the cluster alias id = getClusterFromStartupOrder(startOrder); //getting the cluster-id from cluster alias ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id); - applicationContext = new ClusterContext(clusterDataHolder.getClusterId(), - isKillDependent); + applicationContext = getClusterContext(clusterDataHolder, isKillDependent); + } else { log.warn("[Startup Order]: " + startOrder + " contains unknown reference"); } @@ -63,6 +64,7 @@ public static ApplicationContext getApplicationContext(String startOrder, /** * Utility method to get the group alias from the startup order Eg: group.mygroup + * * @param startupOrder startup order * @return group alias */ @@ -72,10 +74,27 @@ public static String getGroupFromStartupOrder(String startupOrder) { /** * Utility method to get the cluster alias from startup order Eg: cartridge.myphp + * * @param startupOrder startup order * @return cluster alias */ public static String getClusterFromStartupOrder(String startupOrder) { return startupOrder.substring(Constants.CARTRIDGE.length() + 1); } + + public static ApplicationContext getClusterContext(ClusterDataHolder dataHolder, + boolean isKillDependent) { + ApplicationContext applicationContext; + applicationContext = new ClusterContext(dataHolder.getClusterId(), + isKillDependent); + ((ClusterContext) applicationContext).setServiceName(dataHolder.getServiceType()); + return applicationContext; + } + + public static ApplicationContext getGroupContext(String id, boolean isKillDependent) { + ApplicationContext applicationContext; + applicationContext = new GroupContext(id, + isKillDependent); + return applicationContext; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java index 23ea039757..d11389d3bf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java @@ -19,10 +19,20 @@ package org.apache.stratos.autoscaler.grouping.dependency.context; /** - * Created by reka on 10/1/14. + * ClusterContext to keep cluster level context information */ public class ClusterContext extends ApplicationContext { + private String serviceName; + public ClusterContext(String id, boolean killDependent) { super(id ,killDependent); } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index a1213f69bc..b9097496d5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -485,7 +485,7 @@ private AbstractClusterMonitor getMonitor(String clusterId) { AbstractClusterMonitor monitor; if(asCtx.monitorExist(clusterId)){ - monitor = asCtx.getMonitor(clusterId); + monitor = (AbstractClusterMonitor) asCtx.getMonitor(clusterId); }else if(asCtx.lbMonitorExist(clusterId)){ monitor = asCtx.getLBMonitor(clusterId); }else{ @@ -558,7 +558,7 @@ private MemoryConsumption findMemoryConsumption(String memberId) { } return null; } - AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(member.getClusterId()); + AbstractClusterMonitor monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(member.getClusterId()); if(null == monitor){ monitor = AutoscalerContext.getInstance().getLBMonitor(member.getClusterId()); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 801af0ee86..1e209377f7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -28,12 +28,12 @@ import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Service; @@ -150,7 +150,7 @@ protected void onEvent(Event event) { String appId = clusterActivatedEvent.getAppId(); String clusterId = clusterActivatedEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getMonitor(clusterId); + (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor clusterMonitor.setStatus(Status.Activated); @@ -171,7 +171,7 @@ protected void onEvent(Event event) { String groupId = groupActivatedEvent.getGroupId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - GroupMonitor monitor = appMonitor.findGroupMonitorWithId(groupId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor monitor.setStatus(Status.Activated); @@ -209,7 +209,7 @@ protected void onEvent(Event event) { try { //TODO remove monitors as well as any starting or pending threads - ApplicationMonitor monitor = AutoscalerContext.getInstance(). + /*ApplicationMonitor monitor = AutoscalerContext.getInstance(). getAppMonitor(applicationRemovedEvent.getApplicationId()); if (monitor != null) { List clusters = monitor. @@ -225,7 +225,7 @@ protected void onEvent(Event event) { } else { log.warn("Application Monitor cannot be found for the removed [application] " + applicationRemovedEvent.getApplicationId()); - } + }*/ } finally { @@ -248,7 +248,7 @@ protected void onEvent(Event event) { String memberId = memberReadyToShutdownEvent.getMemberId(); if (asCtx.monitorExist(clusterId)) { - monitor = asCtx.getMonitor(clusterId); + monitor = (AbstractClusterMonitor) asCtx.getMonitor(clusterId); } else if (asCtx.lbMonitorExist(clusterId)) { monitor = asCtx.getLBMonitor(clusterId); } else { @@ -303,13 +303,14 @@ protected void onEvent(Event event) { Service service = TopologyManager.getTopology().getService(clusterMaitenanceEvent.getServiceName()); Cluster cluster = service.getCluster(clusterMaitenanceEvent.getClusterId()); + AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()). - setStatus(clusterMaitenanceEvent.getStatus()); + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); + monitor.setStatus(Status.In_Active); } else if (AutoscalerContext.getInstance(). - lbMonitorExist((cluster.getClusterId()))) { + lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). - setStatus(clusterMaitenanceEvent.getStatus()); + setStatus(clusterMaitenanceEvent.getStatus()); } else { log.error("cluster monitor not exists for the cluster: " + cluster.toString()); } @@ -369,7 +370,7 @@ protected void onEvent(Event event) { .removeLbMonitor(clusterId); } else { - monitor = AutoscalerContext.getInstance() + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() .removeMonitor(clusterId); } @@ -402,7 +403,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - MemberTerminatedEvent memberTerminatedEvent = null; + MemberTerminatedEvent memberTerminatedEvent = null; try { //TopologyManager.acquireReadLock(); @@ -416,7 +417,7 @@ protected void onEvent(Event event) { memberTerminatedEvent.getClusterId()); if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); } else { //This is LB member monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); @@ -426,10 +427,11 @@ protected void onEvent(Event event) { getNetworkPartitionCtxt(networkPartitionId); PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); + getPartitionCtxt(partitionId); String memberId = memberTerminatedEvent.getMemberId(); partitionContext.removeMemberStatsContext(memberId); + if (partitionContext.removeTerminationPendingMember(memberId)) { if (log.isDebugEnabled()) { log.debug(String.format("Member is removed from termination pending " + @@ -452,6 +454,9 @@ protected void onEvent(Event event) { log.info(String.format("Member stat context has been removed " + " successfully: [member] %s", memberId)); } + //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated + StatusChecker.getInstance().onMemberTermination(clusterId); + // partitionContext.decrementCurrentActiveMemberCount(1); @@ -486,7 +491,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); } else { //This is LB member monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); @@ -542,7 +547,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). getPartitionCtxt(partitionId); } else { @@ -584,23 +589,23 @@ protected synchronized void startApplicationMonitor(String applicationId) { th = new Thread( new ApplicationMonitorAdder(applicationId)); } - // if (th != null) { - th.start(); + // if (th != null) { + th.start(); // try { // th.join(); // } catch (InterruptedException ignore) { // } - if (log.isDebugEnabled()) { - log.debug(String - .format("Application monitor thread has been started successfully: " + - "[application] %s ", applicationId)); - } - // } + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread has been started successfully: " + + "[application] %s ", applicationId)); + } + // } } private class ApplicationMonitorAdder implements Runnable { - private String appId; + private String appId; public ApplicationMonitorAdder(String appId) { this.appId = appId; @@ -621,7 +626,7 @@ public void run() { log.debug("application monitor is going to be started for [application] " + appId); } - applicationMonitor = AutoscalerUtil.getApplicationMonitor(appId); + applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); long end = System.currentTimeMillis(); log.info("Time taken to start app monitor: " + (end - start) / 1000); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 9aa75b4c71..e470d7feff 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; @@ -44,7 +43,7 @@ * and perform minimum instance check and scaling check using the underlying * rules engine. */ -abstract public class AbstractClusterMonitor implements EventHandler, Runnable { +abstract public class AbstractClusterMonitor extends Monitor implements Runnable { private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); // Map @@ -68,7 +67,7 @@ abstract public class AbstractClusterMonitor implements EventHandler, Runnable { protected Status status; - protected Monitor parent; + protected ParentComponentMonitor parent; protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; @@ -249,11 +248,11 @@ public void setStatus(Status status) { } - public Monitor getParent() { + public ParentComponentMonitor getParent() { return parent; } - public void setParent(Monitor parent) { + public void setParent(ParentComponentMonitor parent) { this.parent = parent; this.appId = parent.getAppId(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index d75780ee12..7cdf0cf0ad 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -20,11 +20,254 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.MemberStatsContext; +import org.apache.stratos.autoscaler.NetworkPartitionContext; +import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; +import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.PartitionValidationException; +import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.partition.PartitionGroup; +import org.apache.stratos.autoscaler.policy.PolicyManager; +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; +import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; +import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.util.Constants; + +import java.util.Map; /** - * Created by reka on 10/2/14. + * Factory class to get the Monitors. */ public class ApplicationMonitorFactory { private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class); + public static Monitor getMonitor(ApplicationContext context, String appId) + throws TopologyInConsistentException, + DependencyBuilderException, PolicyValidationException, PartitionValidationException { + Monitor monitor; + + if (context instanceof GroupContext) { + monitor = getGroupMonitor(context.getId(), appId); + } else if (context instanceof ClusterContext) { + monitor = getClusterMonitor((ClusterContext) context, appId); + } else { + monitor = getApplicationMonitor(appId); + } + return monitor; + } + + public static Monitor getGroupMonitor(String groupId, String appId) throws DependencyBuilderException, + TopologyInConsistentException { + GroupMonitor groupMonitor; + TopologyManager.acquireReadLockForApplication(appId); + + try { + Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId); + groupMonitor = new GroupMonitor(group, appId); + groupMonitor.setAppId(appId); + if (group.getStatus() != groupMonitor.getStatus()) { + //updating the status, so that it will notify the parent + groupMonitor.setStatus(group.getStatus()); + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + + } + return groupMonitor; + + } + + public static ApplicationMonitor getApplicationMonitor(String appId) + throws DependencyBuilderException, + TopologyInConsistentException { + ApplicationMonitor applicationMonitor; + TopologyManager.acquireReadLockForApplication(appId); + try { + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + applicationMonitor = new ApplicationMonitor(application); + } else { + String msg = "[Application] " + appId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + + return applicationMonitor; + + } + + /** + * Updates ClusterContext for given cluster + * + * @param context + * @return ClusterMonitor - Updated ClusterContext + * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException + * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException + */ + public static ClusterMonitor getClusterMonitor(ClusterContext context, String appId) + throws PolicyValidationException, + PartitionValidationException, + TopologyInConsistentException { + //Retrieving the Cluster from Topology + String clusterId = context.getId(); + String serviceName = context.getServiceName(); + + Cluster cluster; + //acquire read lock for the service and cluster + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + try { + Topology topology = TopologyManager.getTopology(); + if (topology.serviceExists(serviceName)) { + Service service = topology.getService(serviceName); + if (service.clusterExists(clusterId)) { + cluster = service.getCluster(clusterId); + if (log.isDebugEnabled()) { + log.debug("Dependency check starting the [cluster]" + clusterId); + } + // startClusterMonitor(this, cluster); + //context.setCurrentStatus(Status.Created); + } else { + String msg = "[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName; + throw new TopologyInConsistentException(msg); + } + } else { + String msg = "[Service] " + serviceName + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + + } + } finally { + //release read lock for the service and cluster + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); + } + + String autoscalePolicyName = cluster.getAutoscalePolicyName(); + String deploymentPolicyName = cluster.getDeploymentPolicyName(); + + if (log.isDebugEnabled()) { + log.debug("Deployment policy name: " + deploymentPolicyName); + log.debug("Autoscaler policy name: " + autoscalePolicyName); + } + + AutoscalePolicy policy = + PolicyManager.getInstance() + .getAutoscalePolicy(autoscalePolicyName); + DeploymentPolicy deploymentPolicy = + PolicyManager.getInstance() + .getDeploymentPolicy(deploymentPolicyName); + + if (deploymentPolicy == null) { + String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; + log.error(msg); + throw new PolicyValidationException(msg); + } + + Partition[] allPartitions = deploymentPolicy.getAllPartitions(); + if (allPartitions == null) { + String msg = + "Deployment Policy's Partitions are null. Policy name: " + + deploymentPolicyName; + log.error(msg); + throw new PolicyValidationException(msg); + } + + CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy); + + ClusterMonitor clusterMonitor = + new ClusterMonitor(cluster.getClusterId(), + cluster.getServiceName(), + deploymentPolicy, policy); + clusterMonitor.setAppId(cluster.getAppId()); + + for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { + + NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), + partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()); + + for (Partition partition : partitionGroup.getPartitions()) { + PartitionContext partitionContext = new PartitionContext(partition); + partitionContext.setServiceName(cluster.getServiceName()); + partitionContext.setProperties(cluster.getProperties()); + partitionContext.setNetworkPartitionId(partitionGroup.getId()); + + for (Member member : cluster.getMembers()) { + String memberId = member.getMemberId(); + if (member.getPartitionId().equalsIgnoreCase(partition.getId())) { + MemberContext memberContext = new MemberContext(); + memberContext.setClusterId(member.getClusterId()); + memberContext.setMemberId(memberId); + memberContext.setPartition(partition); + memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties())); + + if (MemberStatus.Activated.equals(member.getStatus())) { + partitionContext.addActiveMember(memberContext); +// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); +// partitionContext.incrementCurrentActiveMemberCount(1); + + } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) { + partitionContext.addPendingMember(memberContext); + +// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); + } else if (MemberStatus.Suspended.equals(member.getStatus())) { +// partitionContext.addFaultyMember(memberId); + } + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); + if (log.isInfoEnabled()) { + log.info(String.format("Member stat context has been added: [member] %s", memberId)); + } + } + + } + networkPartitionContext.addPartitionContext(partitionContext); + if (log.isInfoEnabled()) { + log.info(String.format("Partition context has been added: [partition] %s", + partitionContext.getPartitionId())); + } + } + + clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); + //clusterMonitor.setCurrentStatus(Status.Created); + if (log.isInfoEnabled()) { + log.info(String.format("Network partition context has been added: [network partition] %s", + networkPartitionContext.getId())); + } + } + + // set hasPrimary property + // hasPrimary is true if there are primary members available in that cluster + if (cluster.getProperties() != null) { + clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(Constants.IS_PRIMARY))); + } + + log.info("Cluster monitor created: " + clusterMonitor.toString()); + return clusterMonitor; + } + + + private static Properties convertMemberPropsToMemberContextProps( + java.util.Properties properties) { + Properties props = new Properties(); + for (Map.Entry e : properties.entrySet()) { + Property prop = new Property(); + prop.setName((String) e.getKey()); + prop.setValue((String) e.getValue()); + props.addProperties(prop); + } + return props; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 4f501d2230..bb09811c4f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -18,257 +18,32 @@ */ package org.apache.stratos.autoscaler.monitor; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.exception.DependencyBuilderException; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; -import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.util.AutoscalerUtil; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.domain.topology.ParentComponent; -import java.util.HashMap; -import java.util.List; import java.util.Map; /** - * Monitor is to monitor it's child monitors and - * control them according to the dependencies respectively. + * Abstract class for the monitoring functionality in autoscaler. */ public abstract class Monitor implements EventHandler { - private static final Log log = LogFactory.getLog(Monitor.class); - - //id of the monitor, it can be alias or the id protected String id; - //GroupMonitor map, key=GroupAlias and value=GroupMonitor - protected Map aliasToGroupMonitorsMap; - //AbstractMonitor map, key=clusterId and value=AbstractMonitors - protected Map clusterIdToClusterMonitorsMap; - //The monitors dependency tree with all the startable/killable dependencies - protected DependencyTree dependencyTree; - //status of the monitor whether it is running/in_maintainable/terminated - protected Status status; - //Application id of this particular monitor - protected String appId; - - public Monitor(ParentComponent component) throws DependencyBuilderException { - aliasToGroupMonitorsMap = new HashMap(); - clusterIdToClusterMonitorsMap = new HashMap(); - this.id = component.getUniqueIdentifier(); - this.status = component.getStatus(); - //Building the dependency for this monitor within the immediate children - dependencyTree = DependencyBuilder.getInstance().buildDependency(component); - } - - /** - * Will monitor the immediate children upon any event triggers from parent/children - * - * @param statusEvent will be sent by parent/children with the current status - */ - protected abstract void monitor(MonitorStatusEvent statusEvent); - - - /** - * This will start the parallel dependencies at once from the top level. - * it will get invoked when the monitor starts up only. - * //TODO restarting the whole group - */ - public void startDependency() throws TopologyInConsistentException { - //start the first dependency - List applicationContexts = this.dependencyTree.getStarAbleDependencies(); - startDependency(applicationContexts); - - } - - /** - * This will get invoked based on the activation event of its one of the child - * - * @param id alias/clusterId of which receive the activated event - */ - public boolean startDependency(String id) throws TopologyInConsistentException { - List applicationContexts = this.dependencyTree.getStarAbleDependencies(id); - return startDependency(applicationContexts); - } - - /** - * To start the dependency of the given application contexts - * - * @param applicationContexts the found applicationContexts to be started - */ - private boolean startDependency(List applicationContexts) - throws TopologyInConsistentException { - if (applicationContexts != null && applicationContexts.isEmpty()) { - //all the groups/clusters have been started and waiting for activation - log.info("There is no child found for the [group]: " + this.id); - return false; - - } - for (ApplicationContext context : applicationContexts) { - if (log.isDebugEnabled()) { - log.debug("Dependency check for the Group " + context.getId() + " started"); - } - if (context instanceof GroupContext) { - startGroupMonitor(this, context.getId()); - } else if (context instanceof ClusterContext) { - String clusterId = context.getId(); - String serviceName = null; - Group group = getGroupFromTopology(this.id); - - for(ClusterDataHolder dataHolder : group.getClusterDataMap().values()) { - if(dataHolder.getClusterId().equals(clusterId)) { - serviceName = dataHolder.getServiceType(); - } - } - - Cluster cluster; - //acquire read lock for the service and cluster - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - try { - Topology topology = TopologyManager.getTopology(); - if (topology.serviceExists(serviceName)) { - Service service = topology.getService(serviceName); - if (service.clusterExists(clusterId)) { - cluster = service.getCluster(clusterId); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); - } - startClusterMonitor(this, cluster); - } else { - String msg = "[Cluster] " + clusterId + " cannot be found in the " + - "Topology for [service] " + serviceName; - throw new TopologyInConsistentException(msg); - } - } else { - String msg = "[Service] " + serviceName + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - - } - } finally { - //release read lock for the service and cluster - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - } - } - } - return true; - } - - private Group getGroupFromTopology(String groupId) throws TopologyInConsistentException { - Application application = TopologyManager.getTopology().getApplication(this.appId); - if(application != null) { - Group group = application.getGroupRecursively(groupId); - if(group != null) { - return group; - } else { - String msg = "[Group] " + groupId + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - } - } else { - String msg = "[Application] " + this.appId + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - } - } - - protected synchronized void startClusterMonitor(Monitor parent, Cluster cluster) { - Thread th = null; - if (cluster.isLbCluster() - && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - th = new Thread(new LBClusterMonitorAdder( - cluster)); - } else if (!cluster.isLbCluster() && !this.clusterIdToClusterMonitorsMap.containsKey(cluster.getClusterId())) { - th = new Thread( - new ClusterMonitorAdder(parent, cluster)); - if (log.isDebugEnabled()) { - log.debug(String - .format("Cluster monitor Adder has been added: [cluster] %s ", - cluster.getClusterId())); - } - } - if (th != null) { - th.start(); - /*try { - th.join(); - } catch (InterruptedException ignore) { - }*/ - - log.info(String - .format("Cluster monitor thread has been started successfully: [cluster] %s ", - cluster.getClusterId())); - } - } - - protected synchronized void startGroupMonitor(Monitor parent, String groupId) { - Thread th = null; - //String groupId = group.getUniqueIdentifier(); - if (!this.aliasToGroupMonitorsMap.containsKey(groupId)) { - if (log.isDebugEnabled()) { - log.debug(String - .format("Group monitor Adder has been added: [group] %s ", - groupId)); - } - th = new Thread( - new GroupMonitorAdder(parent, groupId, this.appId)); - } - - if (th != null) { - th.start(); - /*try { - th.join(); - } catch (InterruptedException ignore) { - }*/ - - log.info(String - .format("Group monitor thread has been started successfully: [group] %s ", - groupId)); - } - } - - public Status getStatus() { - return status; - } + protected String appId; - public Map getAliasToGroupMonitorsMap() { - return aliasToGroupMonitorsMap; - } + protected ParentComponentMonitor parent; - public void setAliasToGroupMonitorsMap(Map aliasToGroupMonitorsMap) { - this.aliasToGroupMonitorsMap = aliasToGroupMonitorsMap; - } + //GroupMonitor map, key=GroupAlias and value=GroupMonitor + protected Map aliasToMonitorsMap; public String getId() { - return this.id; + return id; } public void setId(String id) { this.id = id; } - public Map getClusterIdToClusterMonitorsMap() { - return clusterIdToClusterMonitorsMap; - } - - public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { - this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; - } - - public void addAbstractMonitor(AbstractClusterMonitor monitor) { - this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); - } - - public AbstractClusterMonitor getAbstractMonitor(String clusterId) { - return this.clusterIdToClusterMonitorsMap.get(clusterId); - } public String getAppId() { return appId; @@ -278,188 +53,19 @@ public void setAppId(String appId) { this.appId = appId; } - private class ClusterMonitorAdder implements Runnable { - private Cluster cluster; - private Monitor parent; - - public ClusterMonitorAdder(Monitor parent, Cluster cluster) { - this.parent = parent; - this.cluster = cluster; - } - - public void run() { - ClusterMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - if (log.isDebugEnabled()) { - log.debug("CLuster monitor is going to be started for [cluster] " - + cluster.getClusterId()); - } - monitor = AutoscalerUtil.getClusterMonitor(cluster); - monitor.setParent(parent); - //setting the status of cluster monitor w.r.t Topology cluster - //if(cluster.getStatus() != Status.Created && - if(cluster.getStatus() != monitor.getStatus()) { - //updating the status, so that it will notify the parent - monitor.setStatus(cluster.getStatus()); - } - //monitor.addObserver(parent); - success = true; - //TODO start the status checker - } catch (PolicyValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - - } catch (PartitionValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - } - - } while (!success && retries != 0); - - - if (monitor == null) { - String msg = "Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); - log.error(msg); - //TODO parent.notify(); - throw new RuntimeException(msg); - } - - Thread th = new Thread(monitor); - th.start(); - - AutoscalerContext.getInstance().addMonitor(monitor); - clusterIdToClusterMonitorsMap.put(cluster.getClusterId(), monitor); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); - } - } + public Map getAliasToMonitorsMap() { + return aliasToMonitorsMap; } - private class GroupMonitorAdder implements Runnable { - private Monitor parent; - private String groupId; - private String appId; - - public GroupMonitorAdder(Monitor parent, String groupId, String appId) { - this.parent = parent; - this.groupId = groupId; - this.appId = appId; - } - - public void run() { - GroupMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - - try { - if (log.isDebugEnabled()) { - log.debug("Group monitor is going to be started for [group] " - + groupId); - } - monitor = AutoscalerUtil.getGroupMonitor(groupId, appId); - monitor.setParent(parent); - //setting the status of cluster monitor w.r.t Topology cluster - //if(group.getStatus() != Status.Created && - - //monitor.addObserver(parent); - success = true; - } catch (DependencyBuilderException e) { - String msg = "Group monitor creation failed for group: " + groupId; - log.warn(msg, e); - retries--; - } catch (TopologyInConsistentException e) { - String msg = "Group monitor creation failed for group: " + groupId; - log.warn(msg, e); - retries--; - } - } while (!success && retries != 0); - - if (monitor == null) { - String msg = "Group monitor creation failed, even after retrying for 5 times, " - + "for group: " + groupId; - log.error(msg); - //TODO parent.notify(); as it got to failed - - throw new RuntimeException(msg); - } - - aliasToGroupMonitorsMap.put(groupId, monitor); - //parent.addObserver(monitor); - - if (log.isInfoEnabled()) { - log.info(String.format("Group monitor has been added successfully: [group] %s", - groupId)); - } - } + public void setAliasToMonitorsMap(Map aliasToMonitorsMap) { + this.aliasToMonitorsMap = aliasToMonitorsMap; } - private class LBClusterMonitorAdder implements Runnable { - private Cluster cluster; - - public LBClusterMonitorAdder(Cluster cluster) { - this.cluster = cluster; - } - - public void run() { - LbClusterMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - monitor = AutoscalerUtil.getLBClusterMonitor(cluster); - success = true; - - } catch (PolicyValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - } catch (PartitionValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - } - } while (!success && retries <= 0); - - if (monitor == null) { - String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); - log.error(msg); - throw new RuntimeException(msg); - } - - Thread th = new Thread(monitor); - th.start(); - AutoscalerContext.getInstance().addLbMonitor(monitor); - clusterIdToClusterMonitorsMap.put(cluster.getClusterId(), monitor); - if (log.isInfoEnabled()) { - log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); - } - } + public ParentComponentMonitor getParent() { + return parent; } - + public void setParent(ParentComponentMonitor parent) { + this.parent = parent; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index a3f9e8f716..d8bc6d9d3d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -32,22 +32,22 @@ public class MonitorStatusEventBuilder { private static final Log log = LogFactory.getLog(MonitorStatusEventBuilder.class); - public static void handleClusterStatusEvent(Monitor parent, Status status, String clusterId) { + public static void handleClusterStatusEvent(ParentComponentMonitor parent, Status status, String clusterId) { ClusterStatusEvent clusterStatusEvent = new ClusterStatusEvent(status, clusterId); notifyParent(parent, clusterStatusEvent); } - public static void handleGroupStatusEvent(Monitor parent, Status status, String groupId) { + public static void handleGroupStatusEvent(ParentComponentMonitor parent, Status status, String groupId) { GroupStatusEvent groupStatusEvent = new GroupStatusEvent(status, groupId); notifyParent(parent, groupStatusEvent); } - public static void handleApplicationStatusEvent(Monitor parent, Status status, String appId) { + public static void handleApplicationStatusEvent(ParentComponentMonitor parent, Status status, String appId) { ApplicationStatusEvent applicationStatusEvent = new ApplicationStatusEvent(status, appId); notifyParent(parent, applicationStatusEvent); } - private static void notifyParent(Monitor parent, MonitorStatusEvent statusEvent) { + private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEvent statusEvent) { parent.onEvent(statusEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java new file mode 100644 index 0000000000..1168883874 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -0,0 +1,499 @@ +/* + * 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.autoscaler.monitor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.PartitionValidationException; +import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; +import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; +import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.messaging.domain.topology.ParentComponent; +import org.apache.stratos.messaging.domain.topology.Status; + +import java.util.HashMap; +import java.util.List; + +/** + * Monitor is to monitor it's child monitors and + * control them according to the dependencies respectively. + */ +public abstract class ParentComponentMonitor extends Monitor { + private static final Log log = LogFactory.getLog(ParentComponentMonitor.class); + + //id of the monitor, it can be alias or the id + protected String id; + + //AbstractMonitor map, key=clusterId and value=AbstractMonitors + //protected Map clusterIdToClusterMonitorsMap; + //The monitors dependency tree with all the startable/killable dependencies + protected DependencyTree dependencyTree; + //status of the monitor whether it is running/in_maintainable/terminated + protected Status status; + //Application id of this particular monitor + protected String appId; + + public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException { + aliasToMonitorsMap = new HashMap(); + //clusterIdToClusterMonitorsMap = new HashMap(); + this.id = component.getUniqueIdentifier(); + this.status = component.getStatus(); + //Building the dependency for this monitor within the immediate children + dependencyTree = DependencyBuilder.getInstance().buildDependency(component); + } + + /** + * Will monitor the immediate children upon any event triggers from parent/children + * + * @param statusEvent will be sent by parent/children with the current status + */ + protected abstract void monitor(MonitorStatusEvent statusEvent); + + + /** + * This will start the parallel dependencies at once from the top level. + * it will get invoked when the monitor starts up only. + * //TODO restarting the whole group + */ + public void startDependency() throws TopologyInConsistentException { + //start the first dependency + List applicationContexts = this.dependencyTree.getStarAbleDependencies(); + startDependency(applicationContexts); + + } + + /** + * This will get invoked based on the activation event of its one of the child + * + * @param id alias/clusterId of which receive the activated event + */ + public boolean startDependency(String id) throws TopologyInConsistentException { + List applicationContexts = this.dependencyTree.getStarAbleDependencies(id); + return startDependency(applicationContexts); + } + + /** + * To start the dependency of the given application contexts + * + * @param applicationContexts the found applicationContexts to be started + */ + private boolean startDependency(List applicationContexts) + throws TopologyInConsistentException { + if (applicationContexts != null && applicationContexts.isEmpty()) { + //all the groups/clusters have been started and waiting for activation + log.info("There is no child found for the [group]: " + this.id); + return false; + + } + for (ApplicationContext context : applicationContexts) { + if (log.isDebugEnabled()) { + log.debug("Dependency check for the Group " + context.getId() + " started"); + } + startMonitor(this, context); + //context.setCurrentStatus(Status.Created); + } + + return true; + + } + + public Status getStatus() { + return status; + } + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + protected synchronized void startMonitor(ParentComponentMonitor parent, ApplicationContext context) { + Thread th = null; + if (!this.aliasToMonitorsMap.containsKey(context.getId())) { + th = new Thread( + new MonitorAdder(parent, context, this.appId)); + if (log.isDebugEnabled()) { + log.debug(String + .format("Monitor Adder has been added: [cluster] %s ", + context.getId())); + } + } + if (th != null) { + th.start(); + log.info(String + .format("Monitor thread has been started successfully: [cluster] %s ", + context.getId())); + } + } + + private class MonitorAdder implements Runnable { + private ApplicationContext context; + private ParentComponentMonitor parent; + private String appId; + + public MonitorAdder(ParentComponentMonitor parent, ApplicationContext context, String appId) { + this.parent = parent; + this.context = context; + this.appId = appId; + } + + public void run() { + Monitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + + if (log.isDebugEnabled()) { + log.debug("Monitor is going to be started for [group/cluster] " + + context.getId()); + } + try { + monitor = ApplicationMonitorFactory.getMonitor(context, appId); + monitor.setParent(parent); + //TODO start the status checker + + } catch (DependencyBuilderException e) { + String msg = "Monitor creation failed for: " + context.getId(); + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { + String msg = "Monitor creation failed for: " + context.getId(); + log.warn(msg, e); + retries--; + } catch (PolicyValidationException e) { + String msg = "Monitor creation failed for: " + context.getId(); + log.warn(msg, e); + retries--; + } catch (PartitionValidationException e) { + String msg = "Monitor creation failed for: " + context.getId(); + log.warn(msg, e); + retries--; + + } + success = true; + + } while (!success && retries != 0); + + + if (monitor == null) { + String msg = "Monitor creation failed, even after retrying for 5 times, " + + "for : " + context.getId(); + log.error(msg); + //TODO parent.notify(); + throw new RuntimeException(msg); + } + + AutoscalerContext.getInstance().addMonitor(monitor); + aliasToMonitorsMap.put(context.getId(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("Monitor has been added successfully for: %s", + context.getId())); + } + } + } + + + /*protected synchronized void startGroupMonitor(ParentComponentMonitor parent, GroupContext groupContext) { + Thread th = null; + //String groupId = group.getUniqueIdentifier(); + if (!this.aliasToMonitorsMap.containsKey(groupId)) { + if (log.isDebugEnabled()) { + log.debug(String + .format("Group monitor Adder has been added: [group] %s ", + groupId)); + } + th = new Thread( + new GroupMonitorAdder(parent, groupId, this.appId)); + } + + if (th != null) { + th.start(); + *//*try { + th.join(); + } catch (InterruptedException ignore) { + }*//* + + log.info(String + .format("Group monitor thread has been started successfully: [group] %s ", + groupId)); + } + } +*/ + + /*private Group getGroupFromTopology(String groupId) throws TopologyInConsistentException { + Application application = TopologyManager.getTopology().getApplication(this.appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group != null) { + return group; + } else { + String msg = "[Group] " + groupId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + } else { + String msg = "[Application] " + this.appId + " cannot be found in the Topology"; + throw new TopologyInConsistentException(msg); + } + }*/ + + /*protected synchronized void startClusterMonitor(ParentComponentMonitor parent, ApplicationContext clusterContext) { + Thread th = null; + if (!this.aliasToMonitorsMap.containsKey(clusterContext.getId())) { + th = new Thread( + new ClusterMonitorAdder(parent, clusterContext)); + if (log.isDebugEnabled()) { + log.debug(String + .format("Cluster monitor Adder has been added: [cluster] %s ", + clusterContext.getClusterId())); + } + } + if (th != null) { + th.start(); + log.info(String + .format("Cluster monitor thread has been started successfully: [cluster] %s ", + clusterContext.getClusterId())); + } + }*/ + + + /*public Map getClusterIdToClusterMonitorsMap() { + return clusterIdToClusterMonitorsMap; + } + + public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { + this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; + } + + public void addAbstractMonitor(AbstractClusterMonitor monitor) { + this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); + } + + public AbstractClusterMonitor getAbstractMonitor(String clusterId) { + return this.clusterIdToClusterMonitorsMap.get(clusterId); + } +*/ + + + /*private class ClusterMonitorAdder implements Runnable { + private Cluster cluster; + private ParentComponentMonitor parent; + + public ClusterMonitorAdder(ParentComponentMonitor parent, Cluster cluster) { + this.parent = parent; + this.cluster = cluster; + } + + public void run() { + ClusterMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + if (log.isDebugEnabled()) { + log.debug("CLuster monitor is going to be started for [cluster] " + + cluster.getClusterId()); + } + monitor = AutoscalerUtil.getClusterMonitor(cluster); + monitor.setParent(parent); + //setting the status of cluster monitor w.r.t Topology cluster + //if(cluster.getStatus() != Status.Created && + if(cluster.getStatus() != monitor.getStatus()) { + //updating the status, so that it will notify the parent + monitor.setStatus(cluster.getStatus()); + } + //monitor.addObserver(parent); + success = true; + //TODO start the status checker + } catch (PolicyValidationException e) { + String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.warn(msg, e); + retries--; + + + } catch (PartitionValidationException e) { + String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.warn(msg, e); + retries--; + + } + + } while (!success && retries != 0); + + + if (monitor == null) { + String msg = "Cluster monitor creation failed, even after retrying for 5 times, " + + "for cluster: " + cluster.getClusterId(); + log.error(msg); + //TODO parent.notify(); + throw new RuntimeException(msg); + } + + Thread th = new Thread(monitor); + th.start(); + + AutoscalerContext.getInstance().addMonitor(monitor); + aliasToMonitorsMap.put(cluster.getClusterId(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", + cluster.getClusterId())); + } + } + } +*/ + + + /*private class GroupMonitorAdder implements Runnable { + private ParentComponentMonitor parent; + private String groupId; + private String appId; + + public GroupMonitorAdder(ParentComponentMonitor parent, String groupId, String appId) { + this.parent = parent; + this.groupId = groupId; + this.appId = appId; + } + + public void run() { + GroupMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + + try { + if (log.isDebugEnabled()) { + log.debug("Group monitor is going to be started for [group] " + + groupId ); + } + monitor = AutoscalerUtil.getGroupMonitor(groupId, appId); + //setting the parent monitor + monitor.setParent(parent); + //setting the status of cluster monitor w.r.t Topology cluster + //if(group.getStatus() != Status.Created && + + //monitor.addObserver(parent); + success = true; + } catch (DependencyBuilderException e) { + String msg = "Group monitor creation failed for group: " + groupId; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { + String msg = "Group monitor creation failed for group: " + groupId; + log.warn(msg, e); + retries--; + } + } while (!success && retries != 0); + + if (monitor == null) { + String msg = "Group monitor creation failed, even after retrying for 5 times, " + + "for group: " + groupId; + log.error(msg); + //TODO parent.notify(); as it got to failed + + throw new RuntimeException(msg); + } + + aliasToMonitorsMap.put(groupId, monitor); + //parent.addObserver(monitor); + + if (log.isInfoEnabled()) { + log.info(String.format("Group monitor has been added successfully: [group] %s", + groupId)); + } + } + } + + private class LBClusterMonitorAdder implements Runnable { + private Cluster cluster; + + public LBClusterMonitorAdder(Cluster cluster) { + this.cluster = cluster; + } + + public void run() { + LbClusterMonitor monitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + monitor = AutoscalerUtil.getLBClusterMonitor(cluster); + success = true; + + } catch (PolicyValidationException e) { + String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.warn(msg, e); + retries--; + + } catch (PartitionValidationException e) { + String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); + log.warn(msg, e); + retries--; + } + } while (!success && retries <= 0); + + if (monitor == null) { + String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " + + "for cluster: " + cluster.getClusterId(); + log.error(msg); + throw new RuntimeException(msg); + } + + Thread th = new Thread(monitor); + th.start(); + AutoscalerContext.getInstance().addLbMonitor(monitor); + aliasToMonitorsMap.put(cluster.getClusterId(), monitor); + if (log.isInfoEnabled()) { + log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", + cluster.getClusterId())); + } + } + }*/ + + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 5b6598aff7..92bf6fa558 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -25,11 +25,10 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ParentComponent; import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; @@ -39,7 +38,7 @@ /** * ApplicationMonitor is to control the child monitors */ -public class ApplicationMonitor extends Monitor { +public class ApplicationMonitor extends ParentComponentMonitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); public ApplicationMonitor(Application application) throws DependencyBuilderException, @@ -60,10 +59,10 @@ public ApplicationMonitor(Application application) throws DependencyBuilderExcep public List findClustersOfApplication(String appId) { List clusters = new ArrayList(); //considering only one level - for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) { + /*for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) { clusters.add(monitor.getClusterId()); - } - //TODO rest + }*/ + //TODO restart and read from Topology return clusters; } @@ -75,8 +74,9 @@ public List findClustersOfApplication(String appId) { * @return the found cluster monitor */ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { - return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), - aliasToGroupMonitorsMap.values()); + /*return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), + aliasToMonitorsMap.values());*/ + return null; } @@ -88,9 +88,9 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { * @param groupMonitors group monitors found in the app monitor * @return the found cluster monitor */ - private AbstractClusterMonitor findClusterMonitor(String clusterId, + /*private AbstractClusterMonitor findClusterMonitor(String clusterId, Collection clusterMonitors, - Collection groupMonitors) { + Collection groupMonitors) { for (AbstractClusterMonitor monitor : clusterMonitors) { // check if alias is equal, if so, return if (monitor.equals(clusterId)) { @@ -98,7 +98,7 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, } } - for (GroupMonitor groupMonitor : groupMonitors) { + for (Monitor groupMonitor : groupMonitors) { return findClusterMonitor(clusterId, groupMonitor.getClusterIdToClusterMonitorsMap().values(), groupMonitor.getAliasToGroupMonitorsMap().values()); @@ -106,15 +106,15 @@ private AbstractClusterMonitor findClusterMonitor(String clusterId, return null; } - +*/ /** * Find the group monitor by traversing recursively in the hierarchical monitors. * * @param groupId the unique alias of the Group * @return the found GroupMonitor */ - public GroupMonitor findGroupMonitorWithId(String groupId) { - return findGroupMonitor(groupId, aliasToGroupMonitorsMap.values()); + public Monitor findGroupMonitorWithId(String groupId) { + return findGroupMonitor(groupId, aliasToMonitorsMap.values()); } @@ -126,90 +126,21 @@ public GroupMonitor findGroupMonitorWithId(String groupId) { * @param monitors the group monitors found in the app monitor * @return the found GroupMonitor */ - private GroupMonitor findGroupMonitor(String id, Collection monitors) { - for (GroupMonitor monitor : monitors) { + private Monitor findGroupMonitor(String id, Collection monitors) { + for (Monitor monitor : monitors) { // check if alias is equal, if so, return if (monitor.getId().equals(id)) { return monitor; } else { // check if this Group has nested sub Groups. If so, traverse them as well - if (monitor.getAliasToGroupMonitorsMap() != null) { - return findGroupMonitor(id, monitor.getAliasToGroupMonitorsMap().values()); + if (monitor.getAliasToMonitorsMap() != null) { + return findGroupMonitor(id, monitor.getAliasToMonitorsMap().values()); } } } return null; } - - /** - * To find the parent monitor of a group's associate monitor - * - * @param groupId the id of the group - * @return the found parent monitor of the group - */ - public Monitor findParentMonitorOfGroup(String groupId) { - return findParentMonitorForGroup(groupId, this); - } - - /** - * Find the parent monitor of the given group in the app monitor - * - * @param groupId the id of the group - * @param monitor the app monitor - * @return the found parent monitor of the group - */ - private Monitor findParentMonitorForGroup(String groupId, Monitor monitor) { - //if this monitor has the group, return it as the parent - if (monitor.getAliasToGroupMonitorsMap().containsKey(groupId)) { - return monitor; - } else { - if (monitor.getAliasToGroupMonitorsMap() != null) { - //check whether the children has the group and find its parent - for (GroupMonitor groupMonitor : monitor.getAliasToGroupMonitorsMap().values()) { - return findParentMonitorForGroup(groupId, groupMonitor); - - } - } - } - return null; - - } - - /** - * Find the parent monitor of the given cluster in the app monitor - * - * @param clusterId the id of the cluster - * @return the found parent monitor of the cluster - */ - public Monitor findParentMonitorOfCluster(String clusterId) { - return findParentMonitorForCluster(clusterId, this); - } - - /** - * Find the parent monitor of the given cluster in the app monitor - * - * @param clusterId the id of the cluster - * @param monitor the app monitor - * @return the found parent monitor of the cluster - */ - private Monitor findParentMonitorForCluster(String clusterId, Monitor monitor) { - //if this monitor has the group, return it as the parent - if (monitor.getClusterIdToClusterMonitorsMap().containsKey(clusterId)) { - return monitor; - } else { - if (monitor.getAliasToGroupMonitorsMap() != null) { - //check whether the children has the group and find its parent - for (GroupMonitor groupMonitor : monitor.getAliasToGroupMonitorsMap().values()) { - return findParentMonitorForCluster(clusterId, groupMonitor); - - } - } - } - return null; - - } - /** * To set the status of the application monitor * @@ -261,7 +192,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { } //updating the life cycle and current status - context.setStatus(statusEvent.getStatus()); + context.setCurrentStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); if(!startDep) { //Checking in the children whether all are active, diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 0bdad16e23..619d13ef91 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -24,28 +24,25 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.EventHandler; -import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; -import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; -import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.Status; -import org.apache.stratos.messaging.event.application.status.StatusEvent; + +import java.util.ArrayList; +import java.util.List; /** * This is GroupMonitor to monitor the group which consists of * groups and clusters */ -public class GroupMonitor extends Monitor implements EventHandler { +public class GroupMonitor extends ParentComponentMonitor implements EventHandler { private static final Log log = LogFactory.getLog(GroupMonitor.class); //Parent monitor of this monitor - private Monitor parent; - //Application id of this particular monitor - protected String appId; - + private ParentComponentMonitor parent; /** * Constructor of GroupMonitor @@ -53,9 +50,10 @@ public class GroupMonitor extends Monitor implements EventHandler { * @throws DependencyBuilderException throws when couldn't build the Topology * @throws TopologyInConsistentException throws when topology is inconsistent */ - public GroupMonitor(Group group) throws DependencyBuilderException, + public GroupMonitor(Group group, String appId) throws DependencyBuilderException, TopologyInConsistentException { super(group); + this.appId = appId; startDependency(); } @@ -79,39 +77,87 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); - ApplicationContext context = this.dependencyTree. - findApplicationContextWithId(id); - if(context.getStatusLifeCycle().isEmpty()) { - try { - //if life cycle is empty, need to start the monitor - boolean startDep = startDependency(statusEvent.getId()); - if(log.isDebugEnabled()) { - log.debug("started a child: " + startDep + " by the group/cluster: " + id); + Status status1 = statusEvent.getStatus(); + ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); + //Events coming from parent are In_Active(in faulty detection), Scaling events, termination + //TODO if statusEvent is for active, then start the next one if any available + if(!isParent(id)) { + if(status1 == Status.Activated) { + try { + //if life cycle is empty, need to start the monitor + boolean startDep = startDependency(statusEvent.getId()); + if (log.isDebugEnabled()) { + log.debug("started a child: " + startDep + " by the group/cluster: " + id); + + } + //updating the life cycle and current status + if (startDep) { + context.setCurrentStatus(Status.Created); + context.addStatusToLIfeCycle(Status.Created); + } else { + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } + } catch (TopologyInConsistentException e) { + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error(e); } - //updating the life cycle and current status - context.setStatus(statusEvent.getStatus()); - context.addStatusToLIfeCycle(statusEvent.getStatus()); - if(!startDep) { - //Checking in the children whether all are active, - // since no dependency found to be started. - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if(status1 == Status.In_Active) { + //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and + //TODO need to send in_active for c1. When C1 in_active receives, get dependent and + //TODO check whether dependent in_active. Then kill c1. + //evaluate termination behavior and take action based on that. + + List terminationList = new ArrayList(); + terminationList = this.dependencyTree.getTerminationDependencies(id); + + //check whether all the children are in_active state + for(ApplicationContext terminationContext : terminationList) { + //terminationContext } - } catch (TopologyInConsistentException e) { - //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription - log.error(e); + + /*if(terminationList != null && !terminationList.isEmpty()) { + for(ApplicationContext context1 : terminationList) { + if(context1 instanceof ClusterContext) { + AbstractClusterMonitor monitor = this.clusterIdToClusterMonitorsMap. + get(context1.getId()); + //Whether life cycle change to Created + if(monitor.getStatus() == Status.Created) { + canTerminate = true; + } else { + //TODO sending group in_active event to dependent cluster/group + StatusEventPublisher.sendGroupActivatedEvent(this.appId, this.id); + //not all dependent clusters are in created state. + canTerminate = false; + } + } + } + if(canTerminate) { + // + }*/ + } else { + //TODO get dependents + List dependents = this.dependencyTree.getTerminationDependencies(id); + } + + + + + + } else if(status1 == Status.Created) { + //the dependent goes to be created state, so terminate the dependents } - } else { - //TODO act based on life cycle events } - } - public Monitor getParent() { + + + + public ParentComponentMonitor getParent() { return parent; } - public void setParent(Monitor parent) { + public void setParent(ParentComponentMonitor parent) { this.parent = parent; } @@ -123,4 +169,16 @@ public void setAppId(String appId) { this.appId = appId; } + private boolean isParent(String id) { + if(this.parent.getId().equals(id)) { + return true; + } else { + return false; + } + } + + + + + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index ee04fff2fc..04ed325efd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -54,7 +54,7 @@ public static StatusChecker getInstance() { * @param clusterId id of the cluster */ public void onMemberStatusChange(String clusterId) { - ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); boolean clusterActive = clusterActive(monitor); // if active then notify upper layer if (clusterActive) { @@ -64,6 +64,13 @@ public void onMemberStatusChange(String clusterId) { } } + public void onMemberTermination(String clusterId) { + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + //TODO get Topology status + // if cluster not having any members and if the cluster was in_active then send created Events + // if cluster was in terminating, then send terminated event. + } + private boolean clusterActive(AbstractClusterMonitor monitor) { boolean clusterActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { @@ -83,6 +90,42 @@ private boolean clusterActive(AbstractClusterMonitor monitor) { return clusterActive; } + /** + * @param clusterId + * @param appId + * @param partitionContext is to decide in which partition has less members while others have active members + */ + public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterInActive = getClusterInActive(monitor, partitionContext); + if (clusterInActive) { + //TODO evaluate life cycle + //send cluster In-Active event to cluster status topic + + } else { + boolean clusterActive = clusterActive(monitor); + if(clusterActive) { + //TODO evaluate life cycle + //send clusterActive event to cluster status topic + } + } + } + + private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) { + boolean clusterInActive = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { + for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { + if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && + partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { + clusterInActive = true; + return clusterInActive; + } + } + + } + return clusterInActive; + } + /** * * @param idOfChild @@ -149,47 +192,7 @@ public void run() { } - /** - * @param clusterId - * @param appId - * @param partitionContext is to decide in which partition has less members while others have active members - */ - public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { - Runnable memberFault = new Runnable() { - public void run() { - ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterActive = false; - boolean clusterInMaintenance = false; - for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { - for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { - if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && - partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { - clusterInMaintenance = true; - } else { - log.info(String.format("Hence the [partition] %s, in [networkpartition], " + - "%s has exceeded the [minimum], %d with current active " + - "[members], %d the [cluster], %s is still in active mode." - , partition.getPartitionId(), partition.getNetworkPartitionId(), - partition.getMinimumMemberCount(), partition.getActiveMemberCount(), clusterId)); - } - if (partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) { - clusterActive = true; - } - clusterActive = false; - } - - } - // if in maintenance then notify upper layer - if (clusterActive && clusterInMaintenance) { - //send clusterInmaintenance event to cluster status topic - - } - } - }; - Thread faultHandlingThread = new Thread(memberFault); - faultHandlingThread.start(); - } /** * This will use to calculate whether all children of a particular component is active by travesing Top diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index cb0315879e..050a388ccd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -63,149 +63,8 @@ private AutoscalerUtil() { } - /** - * Updates ClusterContext for given cluster - * - * @param cluster - * @return ClusterMonitor - Updated ClusterContext - * @throws PolicyValidationException - * @throws PartitionValidationException - */ - public static ClusterMonitor getClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { - // FIXME fix the following code to correctly update - // AutoscalerContext context = AutoscalerContext.getInstance(); - if (null == cluster) { - return null; - } - String autoscalePolicyName = cluster.getAutoscalePolicyName(); - String deploymentPolicyName = cluster.getDeploymentPolicyName(); - if (log.isDebugEnabled()) { - log.debug("Deployment policy name: " + deploymentPolicyName); - log.debug("Autoscaler policy name: " + autoscalePolicyName); - } - - AutoscalePolicy policy = - PolicyManager.getInstance() - .getAutoscalePolicy(autoscalePolicyName); - DeploymentPolicy deploymentPolicy = - PolicyManager.getInstance() - .getDeploymentPolicy(deploymentPolicyName); - - if (deploymentPolicy == null) { - String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } - - Partition[] allPartitions = deploymentPolicy.getAllPartitions(); - if (allPartitions == null) { - String msg = - "Deployment Policy's Partitions are null. Policy name: " + - deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } - - CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy); - - ClusterMonitor clusterMonitor = - new ClusterMonitor(cluster.getClusterId(), - cluster.getServiceName(), - deploymentPolicy, policy); - clusterMonitor.setAppId(cluster.getAppId()); - - for (PartitionGroup partitionGroup: deploymentPolicy.getPartitionGroups()){ - - NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), - partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()); - - for(Partition partition: partitionGroup.getPartitions()){ - PartitionContext partitionContext = new PartitionContext(partition); - partitionContext.setServiceName(cluster.getServiceName()); - partitionContext.setProperties(cluster.getProperties()); - partitionContext.setNetworkPartitionId(partitionGroup.getId()); - - for (Member member: cluster.getMembers()){ - String memberId = member.getMemberId(); - if(member.getPartitionId().equalsIgnoreCase(partition.getId())){ - MemberContext memberContext = new MemberContext(); - memberContext.setClusterId(member.getClusterId()); - memberContext.setMemberId(memberId); - memberContext.setPartition(partition); - memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties())); - - if(MemberStatus.Activated.equals(member.getStatus())){ - partitionContext.addActiveMember(memberContext); -// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); -// partitionContext.incrementCurrentActiveMemberCount(1); - - } else if(MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())){ - partitionContext.addPendingMember(memberContext); - -// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); - } else if(MemberStatus.Suspended.equals(member.getStatus())){ -// partitionContext.addFaultyMember(memberId); - } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - if(log.isInfoEnabled()){ - log.info(String.format("Member stat context has been added: [member] %s", memberId)); - } - } - - } - networkPartitionContext.addPartitionContext(partitionContext); - if(log.isInfoEnabled()){ - log.info(String.format("Partition context has been added: [partition] %s", - partitionContext.getPartitionId())); - } - } - - clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); - //clusterMonitor.setStatus(Status.Created); - if(log.isInfoEnabled()){ - log.info(String.format("Network partition context has been added: [network partition] %s", - networkPartitionContext.getId())); - } - } - - - // find lb reference type - /*java.util.Properties props = cluster.getProperties(); - - if(props.containsKey(Constants.LOAD_BALANCER_REF)) { - String value = props.getProperty(Constants.LOAD_BALANCER_REF); - clusterMonitor.setLbReferenceType(value); - if(log.isDebugEnabled()) { - log.debug("Set the lb reference type: "+value); - } - }*/ - - //register a status Checker - - - // set hasPrimary property - // hasPrimary is true if there are primary members available in that cluster - if(cluster.getProperties() != null) { - clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(Constants.IS_PRIMARY))); - } - - log.info("Cluster monitor created: "+clusterMonitor.toString()); - return clusterMonitor; - } - - private static Properties convertMemberPropsToMemberContextProps( - java.util.Properties properties) { - Properties props = new Properties(); - for (Map.Entry e : properties.entrySet() ) { - Property prop = new Property(); - prop.setName((String)e.getKey()); - prop.setValue((String)e.getValue()); - props.addProperties(prop); - } - return props; - } public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { @@ -324,47 +183,7 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic } //TODO moving it into factory class - public static GroupMonitor getGroupMonitor(String groupId, String appId) throws DependencyBuilderException, - TopologyInConsistentException { - GroupMonitor groupMonitor; - TopologyManager.acquireReadLockForApplication(appId); - - try { - Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId); - groupMonitor = new GroupMonitor(group); - groupMonitor.setAppId(appId); - if(group.getStatus() != groupMonitor.getStatus()) { - //updating the status, so that it will notify the parent - groupMonitor.setStatus(group.getStatus()); - } - } finally { - TopologyManager.releaseReadLockForApplication(appId); - } - return groupMonitor; - - } - - public static ApplicationMonitor getApplicationMonitor(String appId) - throws DependencyBuilderException, - TopologyInConsistentException { - ApplicationMonitor applicationMonitor; - TopologyManager.acquireReadLockForApplication(appId); - try { - Application application = TopologyManager.getTopology().getApplication(appId); - if(application != null) { - applicationMonitor = new ApplicationMonitor(application); - } else { - String msg = "[Application] " + appId + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - } - } finally { - TopologyManager.releaseReadLockForApplication(appId); - } - - return applicationMonitor; - - } From 30a6665711d85768fa57f1ee0e2013e499a925d7 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 17 Oct 2014 17:00:33 +0530 Subject: [PATCH 199/436] starting cluster monitor thread --- .../stratos/autoscaler/monitor/ApplicationMonitorFactory.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 7cdf0cf0ad..5f810d72a9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -63,6 +63,9 @@ public static Monitor getMonitor(ApplicationContext context, String appId) monitor = getGroupMonitor(context.getId(), appId); } else if (context instanceof ClusterContext) { monitor = getClusterMonitor((ClusterContext) context, appId); + //Start the thread + Thread th = new Thread((AbstractClusterMonitor)monitor); + th.start(); } else { monitor = getApplicationMonitor(appId); } From f6c0cfcb5e66912ca92a296d0ade55b2c5d08d64 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sat, 18 Oct 2014 10:15:09 +0530 Subject: [PATCH 200/436] fixing a build error due to wrong Status --- .../receiver/topology/AutoscalerTopologyEventReceiver.java | 2 +- .../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 1e209377f7..5b765d441f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -306,7 +306,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(Status.In_Active); + monitor.setStatus(Status.In_Maintenance); } else if (AutoscalerContext.getInstance(). lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 619d13ef91..c76f02be07 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -102,7 +102,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription log.error(e); } - } else if(status1 == Status.In_Active) { + } else if(status1 == Status.In_Maintenance) { //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and //TODO check whether dependent in_active. Then kill c1. From f00e2f369fcde531784fd65c8e38e5e9f61757b9 Mon Sep 17 00:00:00 2001 From: reka Date: Sat, 18 Oct 2014 21:56:01 +0530 Subject: [PATCH 201/436] refacting monitors to have their own status --- .../AutoscalerTopologyEventReceiver.java | 2 +- .../monitor/ApplicationMonitorFactory.java | 202 +++++++++++------- .../stratos/autoscaler/monitor/Monitor.java | 11 +- .../monitor/ParentComponentMonitor.java | 18 +- .../application/ApplicationMonitor.java | 12 +- .../monitor/group/GroupMonitor.java | 76 +++---- .../status/checker/StatusChecker.java | 24 ++- 7 files changed, 188 insertions(+), 157 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 5b765d441f..1e209377f7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -306,7 +306,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(Status.In_Maintenance); + monitor.setStatus(Status.In_Active); } else if (AutoscalerContext.getInstance(). lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 5f810d72a9..86e0931ab4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -38,6 +38,7 @@ import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; @@ -54,17 +55,29 @@ public class ApplicationMonitorFactory { private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class); - public static Monitor getMonitor(ApplicationContext context, String appId) + /** + * Factor method used to create relevant monitors based on the given context + * + * @param context Application/Group/Cluster context + * @param appId appId of the application which requires to create app monitor + * @param parentMonitor parent of the monitor + * @return Monitor which can be ApplicationMonitor/GroupMonitor/ClusterMonitor + * @throws TopologyInConsistentException throws while traversing thr topology + * @throws DependencyBuilderException throws while building dependency for app monitor + * @throws PolicyValidationException throws while validating the policy associated with cluster + * @throws PartitionValidationException throws while validating the partition used in a cluster + */ + public static Monitor getMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId) throws TopologyInConsistentException, DependencyBuilderException, PolicyValidationException, PartitionValidationException { Monitor monitor; if (context instanceof GroupContext) { - monitor = getGroupMonitor(context.getId(), appId); + monitor = getGroupMonitor(parentMonitor, context.getId(), appId); } else if (context instanceof ClusterContext) { - monitor = getClusterMonitor((ClusterContext) context, appId); + monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId); //Start the thread - Thread th = new Thread((AbstractClusterMonitor)monitor); + Thread th = new Thread((AbstractClusterMonitor) monitor); th.start(); } else { monitor = getApplicationMonitor(appId); @@ -72,7 +85,18 @@ public static Monitor getMonitor(ApplicationContext context, String appId) return monitor; } - public static Monitor getGroupMonitor(String groupId, String appId) throws DependencyBuilderException, + /** + * This will create the GroupMonitor based on given groupId by going thr Topology + * + * @param parentMonitor parent of the monitor + * @param groupId groupId of the group + * @param appId appId of the relevant application + * @return Group monitor + * @throws DependencyBuilderException throws while building dependency for app monitor + * @throws TopologyInConsistentException throws while traversing thr topology + */ + public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, String groupId, String appId) + throws DependencyBuilderException, TopologyInConsistentException { GroupMonitor groupMonitor; TopologyManager.acquireReadLockForApplication(appId); @@ -81,8 +105,10 @@ public static Monitor getGroupMonitor(String groupId, String appId) throws Depen Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId); groupMonitor = new GroupMonitor(group, appId); groupMonitor.setAppId(appId); + groupMonitor.setParent(parentMonitor); if (group.getStatus() != groupMonitor.getStatus()) { - //updating the status, so that it will notify the parent + //updating the status, if the group is not in created state when creating group Monitor + //so that groupMonitor will notify the parent (useful when restarting stratos) groupMonitor.setStatus(group.getStatus()); } } finally { @@ -93,6 +119,15 @@ public static Monitor getGroupMonitor(String groupId, String appId) throws Depen } + /** + * This will create a new app monitor based on the give appId by getting the + * application from Topology + * + * @param appId appId of the application which requires to create app monitor + * @return ApplicationMonitor + * @throws DependencyBuilderException throws while building dependency for app monitor + * @throws TopologyInConsistentException throws while traversing thr topology + */ public static ApplicationMonitor getApplicationMonitor(String appId) throws DependencyBuilderException, TopologyInConsistentException { @@ -117,12 +152,14 @@ public static ApplicationMonitor getApplicationMonitor(String appId) /** * Updates ClusterContext for given cluster * + * @param parentMonitor parent of the monitor * @param context * @return ClusterMonitor - Updated ClusterContext * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException */ - public static ClusterMonitor getClusterMonitor(ClusterContext context, String appId) + public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor, + ClusterContext context, String appId) throws PolicyValidationException, PartitionValidationException, TopologyInConsistentException { @@ -131,6 +168,7 @@ public static ClusterMonitor getClusterMonitor(ClusterContext context, String ap String serviceName = context.getServiceName(); Cluster cluster; + ClusterMonitor clusterMonitor; //acquire read lock for the service and cluster TopologyManager.acquireReadLockForCluster(serviceName, clusterId); try { @@ -154,101 +192,111 @@ public static ClusterMonitor getClusterMonitor(ClusterContext context, String ap throw new TopologyInConsistentException(msg); } - } finally { - //release read lock for the service and cluster - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - } - String autoscalePolicyName = cluster.getAutoscalePolicyName(); - String deploymentPolicyName = cluster.getDeploymentPolicyName(); + String autoscalePolicyName = cluster.getAutoscalePolicyName(); + String deploymentPolicyName = cluster.getDeploymentPolicyName(); - if (log.isDebugEnabled()) { - log.debug("Deployment policy name: " + deploymentPolicyName); - log.debug("Autoscaler policy name: " + autoscalePolicyName); - } + if (log.isDebugEnabled()) { + log.debug("Deployment policy name: " + deploymentPolicyName); + log.debug("Autoscaler policy name: " + autoscalePolicyName); + } - AutoscalePolicy policy = - PolicyManager.getInstance() - .getAutoscalePolicy(autoscalePolicyName); - DeploymentPolicy deploymentPolicy = - PolicyManager.getInstance() - .getDeploymentPolicy(deploymentPolicyName); - - if (deploymentPolicy == null) { - String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } + AutoscalePolicy policy = + PolicyManager.getInstance() + .getAutoscalePolicy(autoscalePolicyName); + DeploymentPolicy deploymentPolicy = + PolicyManager.getInstance() + .getDeploymentPolicy(deploymentPolicyName); + + if (deploymentPolicy == null) { + String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; + log.error(msg); + throw new PolicyValidationException(msg); + } - Partition[] allPartitions = deploymentPolicy.getAllPartitions(); - if (allPartitions == null) { - String msg = - "Deployment Policy's Partitions are null. Policy name: " + - deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } + Partition[] allPartitions = deploymentPolicy.getAllPartitions(); + if (allPartitions == null) { + String msg = + "Deployment Policy's Partitions are null. Policy name: " + + deploymentPolicyName; + log.error(msg); + throw new PolicyValidationException(msg); + } - CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy); + CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy); - ClusterMonitor clusterMonitor = - new ClusterMonitor(cluster.getClusterId(), - cluster.getServiceName(), - deploymentPolicy, policy); - clusterMonitor.setAppId(cluster.getAppId()); + clusterMonitor = new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(), + deploymentPolicy, policy); + clusterMonitor.setAppId(cluster.getAppId()); - for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { + for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { - NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), - partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()); + NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), + partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()); - for (Partition partition : partitionGroup.getPartitions()) { - PartitionContext partitionContext = new PartitionContext(partition); - partitionContext.setServiceName(cluster.getServiceName()); - partitionContext.setProperties(cluster.getProperties()); - partitionContext.setNetworkPartitionId(partitionGroup.getId()); + for (Partition partition : partitionGroup.getPartitions()) { + PartitionContext partitionContext = new PartitionContext(partition); + partitionContext.setServiceName(cluster.getServiceName()); + partitionContext.setProperties(cluster.getProperties()); + partitionContext.setNetworkPartitionId(partitionGroup.getId()); - for (Member member : cluster.getMembers()) { - String memberId = member.getMemberId(); - if (member.getPartitionId().equalsIgnoreCase(partition.getId())) { - MemberContext memberContext = new MemberContext(); - memberContext.setClusterId(member.getClusterId()); - memberContext.setMemberId(memberId); - memberContext.setPartition(partition); - memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties())); + for (Member member : cluster.getMembers()) { + String memberId = member.getMemberId(); + if (member.getPartitionId().equalsIgnoreCase(partition.getId())) { + MemberContext memberContext = new MemberContext(); + memberContext.setClusterId(member.getClusterId()); + memberContext.setMemberId(memberId); + memberContext.setPartition(partition); + memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties())); - if (MemberStatus.Activated.equals(member.getStatus())) { - partitionContext.addActiveMember(memberContext); + if (MemberStatus.Activated.equals(member.getStatus())) { + partitionContext.addActiveMember(memberContext); + //triggering the status checker // networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); // partitionContext.incrementCurrentActiveMemberCount(1); - } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) { - partitionContext.addPendingMember(memberContext); + } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) { + partitionContext.addPendingMember(memberContext); // networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); - } else if (MemberStatus.Suspended.equals(member.getStatus())) { + } else if (MemberStatus.Suspended.equals(member.getStatus())) { // partitionContext.addFaultyMember(memberId); + } + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); + if (log.isInfoEnabled()) { + log.info(String.format("Member stat context has been added: [member] %s", memberId)); + } } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added: [member] %s", memberId)); - } - } + } + if (cluster.hasMembers()) { + //triggering the status checker if cluster has members to decide + // on the current status of the cluster + StatusChecker.getInstance().onMemberStatusChange(clusterId); + } + networkPartitionContext.addPartitionContext(partitionContext); + if (log.isInfoEnabled()) { + log.info(String.format("Partition context has been added: [partition] %s", + partitionContext.getPartitionId())); + } } - networkPartitionContext.addPartitionContext(partitionContext); + + clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); + clusterMonitor.setParent(parentMonitor); + //clusterMonitor.setCurrentStatus(Status.Created); if (log.isInfoEnabled()) { - log.info(String.format("Partition context has been added: [partition] %s", - partitionContext.getPartitionId())); + log.info(String.format("Network partition context has been added: [network partition] %s", + networkPartitionContext.getId())); } } - clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); - //clusterMonitor.setCurrentStatus(Status.Created); - if (log.isInfoEnabled()) { - log.info(String.format("Network partition context has been added: [network partition] %s", - networkPartitionContext.getId())); + if (cluster.getStatus() != clusterMonitor.getStatus()) { + //updating the status, so that it will notify the parent + clusterMonitor.setStatus(cluster.getStatus()); } + } finally { + //release read lock for the service and cluster + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); } // set hasPrimary property diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index bb09811c4f..f08be7f155 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -18,22 +18,19 @@ */ package org.apache.stratos.autoscaler.monitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.messaging.domain.topology.ParentComponent; - import java.util.Map; /** * Abstract class for the monitoring functionality in autoscaler. */ public abstract class Monitor implements EventHandler { + //Id of the monitor, cluster=clusterId, group=group-alias, application=app-alias protected String id; - + //The parent app which this monitor relates to protected String appId; - + //Parent monitor of this monitor, for appMonitor parent will be none. protected ParentComponentMonitor parent; - - //GroupMonitor map, key=GroupAlias and value=GroupMonitor + //monitors map, key=GroupAlias/clusterId and value=GroupMonitor/AbstractClusterMonitor protected Map aliasToMonitorsMap; public String getId() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 1168883874..3cd2d9f19a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.messaging.domain.topology.ParentComponent; -import org.apache.stratos.messaging.domain.topology.Status; import java.util.HashMap; import java.util.List; @@ -44,13 +43,8 @@ public abstract class ParentComponentMonitor extends Monitor { //id of the monitor, it can be alias or the id protected String id; - - //AbstractMonitor map, key=clusterId and value=AbstractMonitors - //protected Map clusterIdToClusterMonitorsMap; //The monitors dependency tree with all the startable/killable dependencies protected DependencyTree dependencyTree; - //status of the monitor whether it is running/in_maintainable/terminated - protected Status status; //Application id of this particular monitor protected String appId; @@ -58,7 +52,6 @@ public ParentComponentMonitor(ParentComponent component) throws DependencyBuilde aliasToMonitorsMap = new HashMap(); //clusterIdToClusterMonitorsMap = new HashMap(); this.id = component.getUniqueIdentifier(); - this.status = component.getStatus(); //Building the dependency for this monitor within the immediate children dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } @@ -118,10 +111,6 @@ private boolean startDependency(List applicationContexts) } - public Status getStatus() { - return status; - } - public String getId() { return this.id; } @@ -171,7 +160,7 @@ public MonitorAdder(ParentComponentMonitor parent, ApplicationContext context, S public void run() { Monitor monitor = null; int retries = 5; - boolean success = false; + boolean success; do { try { Thread.sleep(5000); @@ -183,10 +172,7 @@ public void run() { + context.getId()); } try { - monitor = ApplicationMonitorFactory.getMonitor(context, appId); - monitor.setParent(parent); - //TODO start the status checker - + monitor = ApplicationMonitorFactory.getMonitor(parent, context, appId); } catch (DependencyBuilderException e) { String msg = "Monitor creation failed for: " + context.getId(); log.warn(msg, e); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 92bf6fa558..5df336769e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -40,10 +40,13 @@ */ public class ApplicationMonitor extends ParentComponentMonitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); + //status of the monitor whether it is running/in_maintainable/terminated + protected Status status; public ApplicationMonitor(Application application) throws DependencyBuilderException, - TopologyInConsistentException { + TopologyInConsistentException { super(application); + //setting the appId for the application this.appId = application.getUniqueIdentifier(); //starting the first set of dependencies from its children startDependency(); @@ -107,6 +110,7 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { } */ + /** * Find the group monitor by traversing recursively in the hierarchical monitors. * @@ -183,18 +187,18 @@ protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); ApplicationContext context = this.dependencyTree. findApplicationContextWithId(id); - if(context.getStatusLifeCycle().isEmpty()) { + if (context.getStatusLifeCycle().isEmpty()) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("started a child: " + startDep + " by the group/cluster: " + id); } //updating the life cycle and current status context.setCurrentStatus(statusEvent.getStatus()); context.addStatusToLIfeCycle(statusEvent.getStatus()); - if(!startDep) { + if (!startDep) { //Checking in the children whether all are active, // since no dependency found to be started. StatusChecker.getInstance().onChildStatusChange(id, this.appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index c76f02be07..9f83578b85 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -24,8 +24,8 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.EventHandler; -import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Group; @@ -40,35 +40,24 @@ */ public class GroupMonitor extends ParentComponentMonitor implements EventHandler { private static final Log log = LogFactory.getLog(GroupMonitor.class); - - //Parent monitor of this monitor - private ParentComponentMonitor parent; + //status of the monitor whether it is running/in_maintainable/terminated + private Status status; /** * Constructor of GroupMonitor + * * @param group Takes the group from the Topology - * @throws DependencyBuilderException throws when couldn't build the Topology + * @throws DependencyBuilderException throws when couldn't build the Topology * @throws TopologyInConsistentException throws when topology is inconsistent */ public GroupMonitor(Group group, String appId) throws DependencyBuilderException, - TopologyInConsistentException { + TopologyInConsistentException { super(group); this.appId = appId; + this.setStatus(group.getStatus()); startDependency(); } - /** - * Will set the status of the monitor based on Topology Group status/child status like scaling - * @param status - */ - public void setStatus(Status status) { - log.info(String.format("[Monitor] %s is notifying the parent" + - "on its state change from %s to %s", id, this.status, status)); - this.status = status; - //notifying the parent - MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); - } - @Override public void onEvent(MonitorStatusEvent statusEvent) { monitor(statusEvent); @@ -81,8 +70,8 @@ protected void monitor(MonitorStatusEvent statusEvent) { ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination //TODO if statusEvent is for active, then start the next one if any available - if(!isParent(id)) { - if(status1 == Status.Activated) { + if (!isParent(id)) { + if (status1 == Status.Activated) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); @@ -102,7 +91,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription log.error(e); } - } else if(status1 == Status.In_Maintenance) { + } else if (status1 == Status.In_Active) { //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and //TODO check whether dependent in_active. Then kill c1. @@ -112,8 +101,8 @@ protected void monitor(MonitorStatusEvent statusEvent) { terminationList = this.dependencyTree.getTerminationDependencies(id); //check whether all the children are in_active state - for(ApplicationContext terminationContext : terminationList) { - //terminationContext + for (ApplicationContext terminationContext : terminationList) { + //terminationContext } /*if(terminationList != null && !terminationList.isEmpty()) { @@ -135,23 +124,16 @@ protected void monitor(MonitorStatusEvent statusEvent) { if(canTerminate) { // }*/ - } else { - //TODO get dependents - List dependents = this.dependencyTree.getTerminationDependencies(id); - } - - - - - - } else if(status1 == Status.Created) { - //the dependent goes to be created state, so terminate the dependents + } else { + //TODO get dependents + List dependents = this.dependencyTree.getTerminationDependencies(id); } - } - - + } else if (status1 == Status.Created) { + //the dependent goes to be created state, so terminate the dependents + } + } public ParentComponentMonitor getParent() { return parent; @@ -170,15 +152,27 @@ public void setAppId(String appId) { } private boolean isParent(String id) { - if(this.parent.getId().equals(id)) { + if (this.parent.getId().equals(id)) { return true; } else { return false; } } + public Status getStatus() { + return status; + } - - - + /** + * Will set the status of the monitor based on Topology Group status/child status like scaling + * + * @param status + */ + public void setStatus(Status status) { + log.info(String.format("[Monitor] %s is notifying the parent" + + "on its state change from %s to %s", id, this.status, status)); + this.status = status; + //notifying the parent + MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 04ed325efd..c76df01fa7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -51,11 +51,14 @@ public static StatusChecker getInstance() { /** * Calculating whether the cluster has all min instances as active and send the * ClusterActivatedEvent. + * * @param clusterId id of the cluster */ public void onMemberStatusChange(String clusterId) { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); boolean clusterActive = clusterActive(monitor); + log.info("Status checker running for [cluster] " + clusterId + + " the status [clusterActive] " + clusterActive); // if active then notify upper layer if (clusterActive) { //send event to cluster status topic @@ -104,7 +107,7 @@ public void onMemberFaultEvent(final String clusterId, final String appId, final } else { boolean clusterActive = clusterActive(monitor); - if(clusterActive) { + if (clusterActive) { //TODO evaluate life cycle //send clusterActive event to cluster status topic } @@ -127,7 +130,6 @@ private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionCont } /** - * * @param idOfChild * @param groupId * @param appId @@ -140,6 +142,7 @@ public void onChildStatusChange(final String idOfChild, final String groupId, /** * This will calculate whether the children of an application are active or not. If active, then * it will send the ApplicationActivatedEvent. + * * @param idOfChild * @param appId */ @@ -192,10 +195,9 @@ public void run() { } - - /** * This will use to calculate whether all children of a particular component is active by travesing Top + * * @param appId * @param id * @param groups @@ -211,8 +213,8 @@ private boolean updateChildStatus(String appId, String id, Map gr boolean childFound = false; boolean clusterFound = false; - for(ClusterDataHolder clusterDataHolder : clusterData.values()) { - if(clusterDataHolder.getClusterId().equals(id)) { + for (ClusterDataHolder clusterDataHolder : clusterData.values()) { + if (clusterDataHolder.getClusterId().equals(id)) { clusterFound = true; } } @@ -220,29 +222,29 @@ private boolean updateChildStatus(String appId, String id, Map gr if (clusterFound || groups.containsKey(id)) { childFound = true; if (!clusterData.isEmpty() && !groups.isEmpty()) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("group active found: " + clusterFound); } clustersActive = getClusterStatus(clusterData); groupsActive = getGroupStatus(groups); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Active cluster" + clustersActive + " and group: " + groupActive); } groupActive = clustersActive && groupsActive; } else if (!groups.isEmpty()) { groupsActive = getGroupStatus(groups); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.info("group active found: " + clusterFound); } groupActive = groupsActive; } else if (!clusterData.isEmpty()) { clustersActive = getClusterStatus(clusterData); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Active cluster" + clustersActive + " and group: " + groupActive); } groupActive = clustersActive; } else { - log.warn("Clusters/groups not found in this [component] "+ appId); + log.warn("Clusters/groups not found in this [component] " + appId); } //send the activation event if (parent instanceof Application && groupActive) { From 3c2d3e7222f72646dfced66d75d372800ab0aabc Mon Sep 17 00:00:00 2001 From: reka Date: Sat, 18 Oct 2014 22:44:16 +0530 Subject: [PATCH 202/436] updating the status --- .../stratos/cloud/controller/topology/TopologyBuilder.java | 2 +- .../cloud/controller/topology/TopologyEventPublisher.java | 2 +- .../org/apache/stratos/messaging/domain/topology/Status.java | 5 +++-- .../topology/ClusterMaintenanceModeMessageProcessor.java | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 5a90264f1a..6645529056 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -209,7 +209,7 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { try { TopologyManager.acquireWriteLock(); Cluster cluster = service.getCluster(ctxt.getClusterId()); - cluster.setStatus(Status.In_Maintenance); + cluster.setStatus(Status.In_Active); TopologyManager.updateTopology(topology); } finally { TopologyManager.releaseWriteLock(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index a6d83507dc..2cb1eeb6c7 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -124,7 +124,7 @@ public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymen public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) { ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = new ClusterMaintenanceModeEvent(ctxt.getCartridgeType(), ctxt.getClusterId()); - clusterMaintenanceModeEvent.setStatus(Status.In_Maintenance); + clusterMaintenanceModeEvent.setStatus(Status.In_Active); if(log.isInfoEnabled()) { log.info(String.format("Publishing cluster maintenance mode event: [service] %s [cluster] %s", clusterMaintenanceModeEvent.getServiceName(), clusterMaintenanceModeEvent.getClusterId())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java index 7ba27fc4d4..2bd094531a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -24,8 +24,9 @@ public enum Status { Created(1), Running(2), Activated(3), - In_Maintenance(4), - Removed(5); + In_Active(4), + Terminating(4), + Terminated(5); private int code; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 57d7c4548e..4dc573eb29 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -110,7 +110,7 @@ private boolean doProcess (ClusterMaintenanceModeEvent event,Topology topology) } } else { // Apply changes to the topology - cluster.setStatus(Status.In_Maintenance); + cluster.setStatus(Status.In_Active); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as maintenance mode: %s", cluster.toString())); From 8efef751e88bebe62a9bf00c03f9db9b55ee5032 Mon Sep 17 00:00:00 2001 From: reka Date: Sat, 18 Oct 2014 23:05:38 +0530 Subject: [PATCH 203/436] adding cluster in active processors to topolgy and application status topic --- .../status/ClusterInActivateEvent.java | 50 +++++++ .../status/GroupInActivateEvent.java | 44 ++++++ .../topology/ClusterInActivateEvent.java | 56 ++++++++ .../event/topology/GroupInActivateEvent.java | 43 ++++++ .../ClusterInActivateEventListener.java | 24 ++++ .../status/GroupInActivateEventListener.java | 27 ++++ .../ClusterInActivateEventListener.java | 27 ++++ .../GroupInActivateEventListener.java | 27 ++++ ...atusClusterInActivateMessageProcessor.java | 59 ++++++++ ...StatusGroupInActivateMessageProcessor.java | 62 ++++++++ .../topology/ClusterInActivateProcessor.java | 135 ++++++++++++++++++ .../topology/GroupInActivateProcessor.java | 109 ++++++++++++++ 12 files changed, 663 insertions(+) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java new file mode 100644 index 0000000000..e2a588785b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class ClusterInActivateEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterInActivateEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java new file mode 100644 index 0000000000..c7c8d5816d --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class GroupInActivateEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public GroupInActivateEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId() { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java new file mode 100644 index 0000000000..36ea4362fd --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java @@ -0,0 +1,56 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Cluster activated event will be sent by Autoscaler + */ +public class ClusterInActivateEvent extends Event { + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterInActivateEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + + "]"; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java new file mode 100644 index 0000000000..dd7007b6e9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent to Topology upon group activation + */ +public class GroupInActivateEvent extends Event { + private String appId; + private String groupId; + + public GroupInActivateEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java new file mode 100644 index 0000000000..2ae73351f2 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterInActivateEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java new file mode 100644 index 0000000000..ecc4f04fb9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/22/14. + */ +public abstract class GroupInActivateEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java new file mode 100644 index 0000000000..03a4768a88 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/17/14. + */ +public abstract class ClusterInActivateEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java new file mode 100644 index 0000000000..93a5a60d89 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered by the groups activation processor after processing the event + */ +public abstract class GroupInActivateEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java new file mode 100644 index 0000000000..4e2fe7c750 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class ApplicationStatusClusterInActivateMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ApplicationStatusClusterInActivateMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (ClusterInActivateEvent.class.getName().equals(type)) { + // Parse complete message and build event + ClusterInActivateEvent event = (ClusterInActivateEvent) Util. + jsonToObject(message, ClusterInActivateEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received ClusterInActivateEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java new file mode 100644 index 0000000000..099b1850ff --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.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.messaging.message.processor.application.status; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupInActivateEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ApplicationStatusGroupInActivateMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusGroupInActivateMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (GroupInActivateEvent.class.getName().equals(type)) { + // Parse complete message and build event + GroupInActivateEvent event = + (GroupInActivateEvent) Util.jsonToObject(message, GroupInActivateEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received GroupInActivateEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group in activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java new file mode 100644 index 0000000000..81560551fe --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java @@ -0,0 +1,135 @@ +/* + * 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.messaging.message.processor.topology; + +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.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the cluster activated event + */ +public class ClusterInActivateProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterInActivateProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + + if (ClusterInActivateEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + return false; + } + + // Parse complete message and build event + ClusterInActivateEvent event = (ClusterInActivateEvent) Util. + jsonToObject(message, ClusterInActivateEvent.class); + + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ClusterInActivateEvent event,Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + // Apply changes to the topology + //TODO + // cluster.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster updated as activated : %s", + cluster.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java new file mode 100644 index 0000000000..36ca2595b5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -0,0 +1,109 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; +import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the Group activation events + */ +public class GroupInActivateProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(GroupInActivateProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (GroupActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + GroupInActivateEvent event = (GroupInActivateEvent) Util. + jsonToObject(message, GroupInActivateEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (GroupInActivateEvent event,Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroupRecursively(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + //TODO + // group.setStatus(Status.Activated); + if (log.isInfoEnabled()) { + log.info(String.format("Group updated as activated : %s", + group.getUniqueIdentifier())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} From 4ec1d6fe18760917ecc2b2b6f3633bb7b6cea76d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 16 Oct 2014 18:06:03 +0530 Subject: [PATCH 204/436] initial state life cycle changes --- .../InstanceStatusEventMessageDelegator.java | 48 +++++++++++--- .../controller/topology/TopologyBuilder.java | 15 +++-- .../conf/LoadBalancerConfiguration.java | 8 ++- .../messaging/domain/topology/Member.java | 15 +++-- .../domain/topology/MemberStatus.java | 59 ++++++++++++++--- .../InvalidLifecycleTransitionException.java | 47 ++++++++++++++ .../topology/lifecycle/LifeCycleState.java | 28 ++++++++ .../lifecycle/LifeCycleStateManager.java | 64 +++++++++++++++++++ .../InstanceSpawnedMessageProcessor.java | 2 +- .../MemberActivatedMessageProcessor.java | 7 +- .../MemberMaintenanceModeProcessor.java | 7 +- ...MemberReadyToShutdownMessageProcessor.java | 7 +- .../MemberStartedMessageProcessor.java | 7 +- .../MemberSuspendedMessageProcessor.java | 7 +- 14 files changed, 284 insertions(+), 37 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleState.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java index f019a15fa8..fd89723cb7 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -48,27 +49,56 @@ public void run() { if (InstanceStartedEvent.class.getName().equals(type)) { // retrieve the actual message String json = message.getText(); - TopologyBuilder.handleMemberStarted((InstanceStartedEvent) Util. - jsonToObject(json, InstanceStartedEvent.class)); + try { + TopologyBuilder.handleMemberStarted((InstanceStartedEvent) Util. + jsonToObject(json, InstanceStartedEvent.class)); + + } catch (InvalidLifecycleTransitionException e) { + //TODO: handle properly + log.error(e); + } + } else if (InstanceActivatedEvent.class.getName().equals(type)) { // retrieve the actual message String json = message.getText(); - TopologyBuilder.handleMemberActivated((InstanceActivatedEvent) Util. - jsonToObject(json, InstanceActivatedEvent.class)); + try { + TopologyBuilder.handleMemberActivated((InstanceActivatedEvent) Util. + jsonToObject(json, InstanceActivatedEvent.class)); + + } catch (InvalidLifecycleTransitionException e) { + //TODO: handle properly + log.error(e); + } + } else if (InstanceReadyToShutdownEvent.class.getName().equals(type)) { //retrieve the actual message String json = message.getText(); - TopologyBuilder.handleMemberReadyToShutdown((InstanceReadyToShutdownEvent) Util. - jsonToObject(json, InstanceReadyToShutdownEvent.class)); + try { + TopologyBuilder.handleMemberReadyToShutdown((InstanceReadyToShutdownEvent) Util. + jsonToObject(json, InstanceReadyToShutdownEvent.class)); + + } catch (InvalidLifecycleTransitionException e) { + //TODO: handle properly + log.error(e); + } + } else if (InstanceMaintenanceModeEvent.class.getName().equals(type)) { //retrieve the actual message String json = message.getText(); - TopologyBuilder.handleMemberMaintenance((InstanceMaintenanceModeEvent) Util. - jsonToObject(json, InstanceMaintenanceModeEvent.class)); + try { + TopologyBuilder.handleMemberMaintenance((InstanceMaintenanceModeEvent) Util. + jsonToObject(json, InstanceMaintenanceModeEvent.class)); + + } catch (InvalidLifecycleTransitionException e) { + //TODO: handle properly + log.error(e); + } + } else { log.warn("Event message received is not InstanceStartedEvent or InstanceActivatedEvent"); } - } catch (Exception e) { + + } catch (Exception e) { String error = "Failed to retrieve the instance status event message"; log.error(error, e); // Commenting throwing the error. Otherwise thread will not execute if an exception is thrown. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 6645529056..906323b22d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -29,6 +29,7 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; @@ -239,7 +240,7 @@ public static void handleMemberSpawned(String serviceName, TopologyManager.acquireWriteLock(); Member member = new Member(serviceName, clusterId, networkPartitionId, partitionId, memberId); - member.setStatus(MemberStatus.Created); + //member.setStatus(MemberStatus.Created); member.setMemberIp(privateIp); member.setLbClusterId(lbClusterId); member.setMemberPublicIp(publicIp); @@ -255,7 +256,7 @@ public static void handleMemberSpawned(String serviceName, publicIp, privateIp, context); } - public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) { + public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) throws InvalidLifecycleTransitionException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceStartedEvent.getServiceName()); if (service == null) { @@ -301,6 +302,7 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent try { TopologyManager.acquireWriteLock(); + // try update lifecycle state member.setStatus(MemberStatus.Starting); log.info("member started event adding status started"); @@ -320,7 +322,7 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent null); } - public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) { + public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) throws InvalidLifecycleTransitionException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceActivatedEvent.getServiceName()); if (service == null) { @@ -369,6 +371,7 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId()); try { TopologyManager.acquireWriteLock(); + // try update lifecycle state member.setStatus(MemberStatus.Activated); log.info("member started event adding status activated"); Cartridge cartridge = FasterLookUpDataHolder.getInstance(). @@ -404,7 +407,7 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate } public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent instanceReadyToShutdownEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + throws InvalidMemberException, InvalidCartridgeTypeException, InvalidLifecycleTransitionException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceReadyToShutdownEvent.getServiceName()); //update the status of the member @@ -476,7 +479,7 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst } public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + throws InvalidMemberException, InvalidCartridgeTypeException, InvalidLifecycleTransitionException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceMaintenanceModeEvent.getServiceName()); //update the status of the member @@ -531,6 +534,7 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance instanceMaintenanceModeEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); + // try update lifecycle state member.setStatus(MemberStatus.In_Maintenance); log.info("member maintenance mode event adding status started"); @@ -822,5 +826,4 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app //publishing data TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); } - } diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java index ed8aa0553c..4fff70ae13 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java @@ -32,6 +32,7 @@ import org.apache.stratos.load.balancer.context.LoadBalancerContextUtil; import org.apache.stratos.load.balancer.exception.InvalidConfigurationException; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.io.File; @@ -488,7 +489,12 @@ private LoadBalancerConfiguration transform(Node loadBalancerNode) { Port port = new Port(portNode.getName(), Integer.valueOf(value), Integer.valueOf(proxy)); member.addPort(port); } - member.setStatus(MemberStatus.Activated); + try { + member.setStatus(MemberStatus.Activated); + + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + } cluster.addMember(member); } // Add cluster to service diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index 4a3bf17d12..4ea198cc86 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -19,6 +19,8 @@ package org.apache.stratos.messaging.domain.topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; import javax.xml.bind.annotation.XmlRootElement; @@ -43,11 +45,12 @@ public class Member implements Serializable { @XmlJavaTypeAdapter(MapAdapter.class) private final Map portMap; private String memberPublicIp; - private MemberStatus status; + //private MemberStatus status; private String memberIp; @XmlJavaTypeAdapter(MapAdapter.class) private Properties properties; private String lbClusterId; + private LifeCycleStateManager memberStateManager; public Member(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId) { this.serviceName = serviceName; @@ -56,6 +59,7 @@ public Member(String serviceName, String clusterId, String networkPartitionId, S this.partitionId = partitionId; this.memberId = memberId; this.portMap = new HashMap(); + this.memberStateManager = new LifeCycleStateManager(MemberStatus.Created); } public String getServiceName() { @@ -71,15 +75,15 @@ public String getMemberId() { } public MemberStatus getStatus() { - return status; + return memberStateManager.getCurrentState(); } - public void setStatus(MemberStatus status) { - this.status = status; + public void setStatus(MemberStatus status) throws InvalidLifecycleTransitionException { + this.memberStateManager.changeState(status); } public boolean isActive() { - return (this.status == MemberStatus.Activated); + return (this.memberStateManager.getCurrentState() == MemberStatus.Activated); } public Collection getPorts() { @@ -150,6 +154,5 @@ public String getMemberPublicIp() { public void setMemberPublicIp(String memberPublicIp) { this.memberPublicIp = memberPublicIp; } - } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java index 508e65b8c1..6d23c4b037 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java @@ -19,21 +19,62 @@ package org.apache.stratos.messaging.domain.topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; + import javax.xml.bind.annotation.XmlRootElement; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * Represents status of a member during its lifecycle. */ @XmlRootElement -public enum MemberStatus { - Created(1), - Starting(2), - Activated(3), - In_Maintenance(4), - ReadyToShutDown(5), - Terminated(6), - Suspended(0), - ShuttingDown(0); +public enum MemberStatus implements LifeCycleState { + + Created(1) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.Starting)); + } + }, + Starting(2) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.Activated)); + } + }, + Activated(3) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.Suspended, + MemberStatus.In_Maintenance)); + } + }, + In_Maintenance(4) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.ReadyToShutDown)); + } + }, + ReadyToShutDown(5) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.Terminated)); + } + }, + Suspended(0) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(MemberStatus.Terminated)); + } + }, + Terminated(6) { + @Override + public Set getNextStates() { + return null; + } + }; private int code; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java new file mode 100644 index 0000000000..279e70d074 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.messaging.domain.topology.lifecycle; + +public class InvalidLifecycleTransitionException extends Exception { + + private String message; + + public InvalidLifecycleTransitionException() { + super(); + } + + public InvalidLifecycleTransitionException(String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public InvalidLifecycleTransitionException(String message) { + super(message); + this.message = message; + } + + public InvalidLifecycleTransitionException(Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleState.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleState.java new file mode 100644 index 0000000000..90d45fd2f0 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleState.java @@ -0,0 +1,28 @@ +/* + * 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.messaging.domain.topology.lifecycle; + +import java.io.Serializable; +import java.util.Set; + +public interface LifeCycleState extends Serializable { + + public Set getNextStates(); +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java new file mode 100644 index 0000000000..ee0d6e5ff3 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.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.messaging.domain.topology.lifecycle; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.topology.TopologyEvent; + +import java.io.Serializable; +import java.util.Stack; + +public class LifeCycleStateManager implements Serializable { + + private static Log log = LogFactory.getLog(LifeCycleStateManager.class); + + private Stack stateStack; + + public LifeCycleStateManager(T initialState) { + stateStack = new Stack(); + stateStack.push(initialState); + } + + public void changeState (T nextState) throws InvalidLifecycleTransitionException { + + if(getCurrentState().getNextStates().contains(nextState)) { + // do the transition + stateStack.push(nextState); + //if (log.isDebugEnabled()) { + log.info("Life Cycle State successfully updated from " + getCurrentState() + " to " + nextState); + //} + } else { + // invalid state transition + String errorMsg = "Attempted transition from " + getCurrentState() + " to " + nextState + + " is invalid"; + log.error(errorMsg); + throw new InvalidLifecycleTransitionException(errorMsg); + } + } + + public Stack getStateStack () { + return stateStack; + } + + public T getCurrentState () { + return stateStack.peek(); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java index 3135ba5608..7d7b5938c1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java @@ -131,7 +131,7 @@ private boolean doProcess (InstanceSpawnedEvent event,Topology topology){ // Apply changes to the topology Member member = new Member(event.getServiceName(), event.getClusterId(), event.getNetworkPartitionId(), event.getPartitionId(), event.getMemberId()); - member.setStatus(MemberStatus.Created); + //member.setStatus(MemberStatus.Created); member.setMemberPublicIp(event.getMemberPublicIp()); member.setMemberIp(event.getMemberIp()); member.setLbClusterId(event.getLbClusterId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java index c3f884495f..dc98c9e3fb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -59,6 +60,10 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + return false; + } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -73,7 +78,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberActivatedEvent event,Topology topology) { + private boolean doProcess (MemberActivatedEvent event,Topology topology) throws InvalidLifecycleTransitionException { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java index 2a080fe370..9408e466a5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -56,6 +57,10 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + return false; + } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -70,7 +75,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) { + private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) throws InvalidLifecycleTransitionException { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java index 8f9f149c21..83bb94f1b5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -55,6 +56,10 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + return false; + } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -69,7 +74,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) { + private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) throws InvalidLifecycleTransitionException { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java index 649a5b2367..b55ea26949 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberStartedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -59,6 +60,10 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + return false; + } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -73,7 +78,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberStartedEvent event,Topology topology) { + private boolean doProcess (MemberStartedEvent event,Topology topology) throws InvalidLifecycleTransitionException { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java index b3421040dc..56cc055e88 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -59,6 +60,10 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); + } catch (InvalidLifecycleTransitionException e) { + log.error(e); + return false; + } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -73,7 +78,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberSuspendedEvent event,Topology topology) { + private boolean doProcess (MemberSuspendedEvent event,Topology topology) throws InvalidLifecycleTransitionException { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { From 17d68aba871352cf94ecbb0d843bfbb587478516 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 17 Oct 2014 17:36:56 +0530 Subject: [PATCH 205/436] life cycle status machine contd. --- .../AutoscalerTopologyEventReceiver.java | 20 ++++++---- .../monitor/cluster/ClusterMonitor.java | 4 +- .../monitor/cluster/LbClusterMonitor.java | 4 +- .../status/checker/StatusChecker.java | 2 +- .../InstanceStatusEventMessageDelegator.java | 31 ++------------ .../controller/topology/TopologyBuilder.java | 35 +++++++++++----- .../conf/LoadBalancerConfiguration.java | 8 +--- .../messaging/domain/topology/Cluster.java | 27 ++++++++++--- .../domain/topology/ClusterStatus.java | 40 +++++++++++++++---- ... => LifeCycleStateTransitionBehavior.java} | 28 ++++--------- .../messaging/domain/topology/Member.java | 23 ++++++++--- .../lifecycle/LifeCycleStateManager.java | 33 ++++++++------- .../topology/ClusterActivatedProcessor.java | 10 ++--- ...lusterMaintenanceModeMessageProcessor.java | 5 ++- .../MemberActivatedMessageProcessor.java | 10 ++--- .../MemberMaintenanceModeProcessor.java | 10 ++--- ...MemberReadyToShutdownMessageProcessor.java | 10 ++--- .../MemberStartedMessageProcessor.java | 10 ++--- .../MemberSuspendedMessageProcessor.java | 10 ++--- 19 files changed, 174 insertions(+), 146 deletions(-) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/{lifecycle/InvalidLifecycleTransitionException.java => LifeCycleStateTransitionBehavior.java} (54%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 1e209377f7..b342a81ebc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -306,7 +306,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(Status.In_Active); + monitor.setStatus(Status.In_Maintenance); } else if (AutoscalerContext.getInstance(). lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). @@ -589,19 +589,25 @@ protected synchronized void startApplicationMonitor(String applicationId) { th = new Thread( new ApplicationMonitorAdder(applicationId)); } - // if (th != null) { - th.start(); + + if (th != null) { + th.start(); // try { // th.join(); // } catch (InterruptedException ignore) { - // } - if (log.isDebugEnabled()) { - log.debug(String + if (log.isDebugEnabled()) { + log.debug(String .format("Application monitor thread has been started successfully: " + "[application] %s ", applicationId)); + } + } else { + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread already exists: " + + "[application] %s ", applicationId)); + } } - // } } private class ApplicationMonitorAdder implements Runnable { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index b9e99481e9..c681a0f362 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -84,12 +84,12 @@ public void run() { log.debug("Cluster monitor is running.. " + this.toString()); } try { - if (!ClusterStatus.In_Maintenance.equals(status)) { + if (!ClusterStatus.Inactive.equals(status)) { monitor(); } else { if (log.isDebugEnabled()) { log.debug("Cluster monitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + ClusterStatus.Inactive + " mode......"); } } } catch (Exception e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index e627503a1a..d3a2371875 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -63,12 +63,12 @@ public void run() { log.debug("Cluster monitor is running.. " + this.toString()); } try { - if( !ClusterStatus.In_Maintenance.equals(status)) { + if( !ClusterStatus.Inactive.equals(status)) { monitor(); } else { if (log.isDebugEnabled()) { log.debug("LB Cluster monitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + ClusterStatus.Inactive + " mode......"); } } } catch (Exception e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index c76df01fa7..ff45af1002 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -283,7 +283,7 @@ private boolean getClusterStatus(Map clusterData) { for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); if (service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). - getStatus() == Status.Activated) { + getStatus() == ClusterStatus.Active) { clusterActiveStatus = true; } else { clusterActiveStatus = false; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java index fd89723cb7..dd279eded3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -49,51 +48,27 @@ public void run() { if (InstanceStartedEvent.class.getName().equals(type)) { // retrieve the actual message String json = message.getText(); - try { TopologyBuilder.handleMemberStarted((InstanceStartedEvent) Util. jsonToObject(json, InstanceStartedEvent.class)); - } catch (InvalidLifecycleTransitionException e) { - //TODO: handle properly - log.error(e); - } - } else if (InstanceActivatedEvent.class.getName().equals(type)) { // retrieve the actual message String json = message.getText(); - try { - TopologyBuilder.handleMemberActivated((InstanceActivatedEvent) Util. + TopologyBuilder.handleMemberActivated((InstanceActivatedEvent) Util. jsonToObject(json, InstanceActivatedEvent.class)); - } catch (InvalidLifecycleTransitionException e) { - //TODO: handle properly - log.error(e); - } - } else if (InstanceReadyToShutdownEvent.class.getName().equals(type)) { //retrieve the actual message String json = message.getText(); - try { - TopologyBuilder.handleMemberReadyToShutdown((InstanceReadyToShutdownEvent) Util. + TopologyBuilder.handleMemberReadyToShutdown((InstanceReadyToShutdownEvent) Util. jsonToObject(json, InstanceReadyToShutdownEvent.class)); - } catch (InvalidLifecycleTransitionException e) { - //TODO: handle properly - log.error(e); - } - } else if (InstanceMaintenanceModeEvent.class.getName().equals(type)) { //retrieve the actual message String json = message.getText(); - try { - TopologyBuilder.handleMemberMaintenance((InstanceMaintenanceModeEvent) Util. + TopologyBuilder.handleMemberMaintenance((InstanceMaintenanceModeEvent) Util. jsonToObject(json, InstanceMaintenanceModeEvent.class)); - } catch (InvalidLifecycleTransitionException e) { - //TODO: handle properly - log.error(e); - } - } else { log.warn("Event message received is not InstanceStartedEvent or InstanceActivatedEvent"); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 906323b22d..9f74524e2e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -29,7 +29,6 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; @@ -151,7 +150,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { } cluster.setProperties(props); cluster.setLbCluster(isLb); - cluster.setStatus(Status.Created); + //cluster.setStatus(Status.Created); service.addCluster(cluster); } TopologyManager.updateTopology(topology); @@ -210,7 +209,11 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { try { TopologyManager.acquireWriteLock(); Cluster cluster = service.getCluster(ctxt.getClusterId()); - cluster.setStatus(Status.In_Active); + if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); + } + cluster.setStatus(ClusterStatus.Inactive); + //cluster.setStatus(Status.In_Maintenance); TopologyManager.updateTopology(topology); } finally { TopologyManager.releaseWriteLock(); @@ -256,7 +259,7 @@ public static void handleMemberSpawned(String serviceName, publicIp, privateIp, context); } - public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) throws InvalidLifecycleTransitionException { + public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceStartedEvent.getServiceName()); if (service == null) { @@ -303,6 +306,9 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent try { TopologyManager.acquireWriteLock(); // try update lifecycle state + if (!member.isStateTransitionValid(MemberStatus.Starting)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Starting); + } member.setStatus(MemberStatus.Starting); log.info("member started event adding status started"); @@ -322,7 +328,7 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent null); } - public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) throws InvalidLifecycleTransitionException { + public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceActivatedEvent.getServiceName()); if (service == null) { @@ -372,6 +378,9 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate try { TopologyManager.acquireWriteLock(); // try update lifecycle state + if (!member.isStateTransitionValid(MemberStatus.Activated)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Activated); + } member.setStatus(MemberStatus.Activated); log.info("member started event adding status activated"); Cartridge cartridge = FasterLookUpDataHolder.getInstance(). @@ -407,7 +416,7 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate } public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent instanceReadyToShutdownEvent) - throws InvalidMemberException, InvalidCartridgeTypeException, InvalidLifecycleTransitionException { + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceReadyToShutdownEvent.getServiceName()); //update the status of the member @@ -459,6 +468,10 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst instanceReadyToShutdownEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); + + if (!member.isStateTransitionValid(MemberStatus.ReadyToShutDown)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.ReadyToShutDown); + } member.setStatus(MemberStatus.ReadyToShutDown); log.info("Member Ready to shut down event adding status started"); @@ -479,7 +492,7 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst } public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) - throws InvalidMemberException, InvalidCartridgeTypeException, InvalidLifecycleTransitionException { + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceMaintenanceModeEvent.getServiceName()); //update the status of the member @@ -535,6 +548,9 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance try { TopologyManager.acquireWriteLock(); // try update lifecycle state + if (!member.isStateTransitionValid(MemberStatus.In_Maintenance)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.In_Maintenance); + } member.setStatus(MemberStatus.In_Maintenance); log.info("member maintenance mode event adding status started"); @@ -630,7 +646,7 @@ public static synchronized void handleApplicationDeployed(Application applicatio Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); - cluster.setStatus(Status.Created); + //cluster.setStatus(Status.Created); cluster.addHostName(applicationClusterContext.getHostName()); cluster.setTenantRange(applicationClusterContext.getTenantRange()); clusters.add(cluster); @@ -756,7 +772,8 @@ public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActi clusterActivatedEvent.getClusterId()); try { TopologyManager.acquireWriteLock(); - cluster.setStatus(Status.Activated); + //cluster.setStatus(Status.Activated); + cluster.setStatus(ClusterStatus.Active); log.info("Cluster activated adding status started"); TopologyManager.updateTopology(topology); diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java index 4fff70ae13..ed8aa0553c 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/conf/LoadBalancerConfiguration.java @@ -32,7 +32,6 @@ import org.apache.stratos.load.balancer.context.LoadBalancerContextUtil; import org.apache.stratos.load.balancer.exception.InvalidConfigurationException; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.io.File; @@ -489,12 +488,7 @@ private LoadBalancerConfiguration transform(Node loadBalancerNode) { Port port = new Port(portNode.getName(), Integer.valueOf(value), Integer.valueOf(proxy)); member.addPort(port); } - try { - member.setStatus(MemberStatus.Activated); - - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - } + member.setStatus(MemberStatus.Activated); cluster.addMember(member); } // Add cluster to service diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 578089ab73..31b7bf1443 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.domain.topology; import org.apache.commons.lang3.StringUtils; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.Util; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; @@ -33,7 +34,7 @@ * Key: serviceName, clusterId */ @XmlRootElement -public class Cluster implements Serializable { +public class Cluster implements Serializable, LifeCycleStateTransitionBehavior { private static final long serialVersionUID = -361960242360176077L; @@ -49,13 +50,14 @@ public class Cluster implements Serializable { @XmlJavaTypeAdapter(MapAdapter.class) private Map memberMap; - private Status status; + //private Status status; private String appId; private String loadBalanceAlgorithmName; @XmlJavaTypeAdapter(MapAdapter.class) private Properties properties; + private LifeCycleStateManager clusterStateManager; public Cluster(String serviceName, String clusterId, String deploymentPolicyName, String autoscalePolicyName, String appId) { @@ -66,6 +68,7 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.hostNames = new ArrayList(); this.memberMap = new HashMap(); this.appId = appId; + this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created); } public String getServiceName() { @@ -207,12 +210,24 @@ public Collection findPartitionIds() { return partitionIds.keySet(); } - public Status getStatus() { - return status; + @Override + public boolean isStateTransitionValid(ClusterStatus newState) { + return clusterStateManager.isStateTransitionValid(newState); + } + + @Override + public Stack getTransitionedStates() { + return clusterStateManager.getStateStack(); + } + + public ClusterStatus getStatus() { + //return status; + return clusterStateManager.getCurrentState(); } - public void setStatus(Status status) { - this.status = status; + public void setStatus(ClusterStatus newStatus) { + clusterStateManager.changeState(newStatus); + //this.status = newStatus; } public boolean equals(Object other) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java index 9556c4d528..a9f8afea6d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -18,13 +18,38 @@ */ package org.apache.stratos.messaging.domain.topology; -public enum ClusterStatus { - Created(1), - In_Maintenance(2), - terminating(3), - Removed(4), - Running(5), - Active(6); + +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public enum ClusterStatus implements LifeCycleState { + Created(0) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ClusterStatus.Active)); + } + }, + Active(1) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ClusterStatus.Inactive)); + } + }, + Inactive(3) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ClusterStatus.Active, ClusterStatus.Terminated)); + } + }, + Terminated(4) { + @Override + public Set getNextStates() { + return null; + } + }; private int code; @@ -35,5 +60,4 @@ private ClusterStatus(int code) { public int getCode() { return code; } - } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/LifeCycleStateTransitionBehavior.java similarity index 54% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/LifeCycleStateTransitionBehavior.java index 279e70d074..2199b9a476 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/InvalidLifecycleTransitionException.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/LifeCycleStateTransitionBehavior.java @@ -17,31 +17,19 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology.lifecycle; +package org.apache.stratos.messaging.domain.topology; -public class InvalidLifecycleTransitionException extends Exception { +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; - private String message; +import java.util.Stack; - public InvalidLifecycleTransitionException() { - super(); - } +public interface LifeCycleStateTransitionBehavior { - public InvalidLifecycleTransitionException(String message, Throwable cause) { - super(message, cause); - this.message = message; - } + public boolean isStateTransitionValid(T newState); - public InvalidLifecycleTransitionException(String message) { - super(message); - this.message = message; - } + public Stack getTransitionedStates (); - public InvalidLifecycleTransitionException(Throwable cause) { - super(cause); - } + public T getStatus(); - public String getMessage() { - return message; - } + public void setStatus(T newState); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index 4ea198cc86..f0cde248e5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.domain.topology; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; @@ -33,7 +33,7 @@ * Key: serviceName, clusterId, memberId */ @XmlRootElement -public class Member implements Serializable { +public class Member implements Serializable, LifeCycleStateTransitionBehavior { private static final long serialVersionUID = 4179661867903664661L; private final String serviceName; @@ -74,16 +74,27 @@ public String getMemberId() { return memberId; } + @Override + public boolean isStateTransitionValid(MemberStatus newState) { + return memberStateManager.isStateTransitionValid(newState); + } + + @Override public MemberStatus getStatus() { return memberStateManager.getCurrentState(); } - public void setStatus(MemberStatus status) throws InvalidLifecycleTransitionException { - this.memberStateManager.changeState(status); + public Stack getTransitionedStates () { + return memberStateManager.getStateStack(); + } + + @Override + public void setStatus(MemberStatus newState) { + memberStateManager.changeState(newState); } - public boolean isActive() { - return (this.memberStateManager.getCurrentState() == MemberStatus.Activated); + public boolean isActive () { + return memberStateManager.getCurrentState().equals(MemberStatus.Activated); } public Collection getPorts() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index ee0d6e5ff3..8131b1d23c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -35,23 +35,24 @@ public class LifeCycleStateManager implements Serializ public LifeCycleStateManager(T initialState) { stateStack = new Stack(); stateStack.push(initialState); + //if (log.isDebugEnabled()) { + log.info("Life Cycle State Manager created, initial state: " + initialState.toString()); + //} } - public void changeState (T nextState) throws InvalidLifecycleTransitionException { + public boolean isPreConditionsValid (T nextState, S topologyEvent) { + // TODO: implement + return true; + } + + public boolean isStateTransitionValid (T nextState) { - if(getCurrentState().getNextStates().contains(nextState)) { - // do the transition - stateStack.push(nextState); - //if (log.isDebugEnabled()) { - log.info("Life Cycle State successfully updated from " + getCurrentState() + " to " + nextState); - //} - } else { - // invalid state transition - String errorMsg = "Attempted transition from " + getCurrentState() + " to " + nextState - + " is invalid"; - log.error(errorMsg); - throw new InvalidLifecycleTransitionException(errorMsg); - } + return stateStack.peek().getNextStates().contains(nextState); + } + + public void changeState (T nextState) { + + stateStack.push(nextState); } public Stack getStateStack () { @@ -61,4 +62,8 @@ public Stack getStateStack () { public T getCurrentState () { return stateStack.peek(); } + + public T getPreviousState () { + return stateStack.get(1); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index cb8eb5f9fe..69fc3e7ece 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -20,10 +20,7 @@ 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.domain.topology.Status; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; @@ -118,7 +115,10 @@ private boolean doProcess (ClusterActivatedEvent event,Topology topology) { } } else { // Apply changes to the topology - cluster.setStatus(Status.Activated); + if (!cluster.isStateTransitionValid(ClusterStatus.Active)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); + } + cluster.setStatus(ClusterStatus.Active); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as activated : %s", cluster.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 4dc573eb29..35966e8abc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -110,7 +110,10 @@ private boolean doProcess (ClusterMaintenanceModeEvent event,Topology topology) } } else { // Apply changes to the topology - cluster.setStatus(Status.In_Active); + if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); + } + cluster.setStatus(ClusterStatus.Inactive); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as maintenance mode: %s", cluster.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java index dc98c9e3fb..db9c85cc30 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberActivatedMessageProcessor.java @@ -25,7 +25,6 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -60,10 +59,6 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - return false; - } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -78,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberActivatedEvent event,Topology topology) throws InvalidLifecycleTransitionException { + private boolean doProcess (MemberActivatedEvent event,Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -165,6 +160,9 @@ private boolean doProcess (MemberActivatedEvent event,Topology topology) throws // Apply changes to the topology member.addPorts(event.getPorts()); member.setMemberIp(event.getMemberIp()); + if (!member.isStateTransitionValid(MemberStatus.Activated)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Activated); + } member.setStatus(MemberStatus.Activated); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java index 9408e466a5..2810b190ca 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberMaintenanceModeProcessor.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -57,10 +56,6 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - return false; - } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -75,7 +70,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) throws InvalidLifecycleTransitionException { + private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -148,6 +143,9 @@ private boolean doProcess (MemberMaintenanceModeEvent event,Topology topology) t } else { // Apply changes to the topology + if (!member.isStateTransitionValid(MemberStatus.In_Maintenance)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.In_Maintenance); + } member.setStatus(MemberStatus.In_Maintenance); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java index 83bb94f1b5..2ede9dab03 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberReadyToShutdownMessageProcessor.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -56,10 +55,6 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - return false; - } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -74,7 +69,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) throws InvalidLifecycleTransitionException { + private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -147,6 +142,9 @@ private boolean doProcess (MemberReadyToShutdownEvent event,Topology topology) t } else { // Apply changes to the topology + if (!member.isStateTransitionValid(MemberStatus.ReadyToShutDown)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.ReadyToShutDown); + } member.setStatus(MemberStatus.ReadyToShutDown); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java index b55ea26949..2e4b1716bf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberStartedMessageProcessor.java @@ -25,7 +25,6 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberStartedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -60,10 +59,6 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - return false; - } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -78,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberStartedEvent event,Topology topology) throws InvalidLifecycleTransitionException { + private boolean doProcess (MemberStartedEvent event,Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -150,6 +145,9 @@ private boolean doProcess (MemberStartedEvent event,Topology topology) throws In } else { // Apply changes to the topology + if (!member.isStateTransitionValid(MemberStatus.Starting)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Starting); + } member.setStatus(MemberStatus.Starting); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java index 56cc055e88..e57903ffb2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/MemberSuspendedMessageProcessor.java @@ -25,7 +25,6 @@ import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.domain.topology.lifecycle.InvalidLifecycleTransitionException; import org.apache.stratos.messaging.event.topology.MemberSuspendedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; @@ -60,10 +59,6 @@ public boolean process(String type, String message, Object object) { try { return doProcess(event, topology); - } catch (InvalidLifecycleTransitionException e) { - log.error(e); - return false; - } finally { TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); } @@ -78,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (MemberSuspendedEvent event,Topology topology) throws InvalidLifecycleTransitionException { + private boolean doProcess (MemberSuspendedEvent event,Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -150,6 +145,9 @@ private boolean doProcess (MemberSuspendedEvent event,Topology topology) throws } else { // Apply changes to the topology + if (!member.isStateTransitionValid(MemberStatus.Suspended)) { + log.error("Invalid State Transition from " + member.getStatus() + " to " + MemberStatus.Suspended); + } member.setStatus(MemberStatus.Suspended); if (log.isInfoEnabled()) { From cd66b40a74510f57bda3e9486451f948806cc320 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 19 Oct 2014 08:41:02 +0530 Subject: [PATCH 206/436] changes for Life Cycle State Manager contd. --- .../monitor/ApplicationMonitorFactory.java | 8 +-- .../monitor/group/GroupMonitor.java | 3 +- .../status/checker/StatusChecker.java | 2 +- .../controller/topology/TopologyBuilder.java | 9 ++- .../domain/topology/Application.java | 27 ++++++- .../domain/topology/ApplicationStatus.java | 71 +++++++++++++++++++ .../messaging/domain/topology/Cluster.java | 12 +++- .../domain/topology/ClusterStatus.java | 24 +++++-- .../messaging/domain/topology/Group.java | 30 +++++++- .../domain/topology/GroupStatus.java | 70 ++++++++++++++++++ .../messaging/domain/topology/Member.java | 3 +- .../domain/topology/MemberStatus.java | 14 ++-- .../domain/topology/ParentComponent.java | 12 ++-- .../lifecycle/LifeCycleStateManager.java | 43 +++++++++-- .../domain/topology/util/GroupStatus.java | 40 ----------- .../ApplicationActivatedMessageProcessor.java | 2 +- .../topology/ClusterActivatedProcessor.java | 2 + ...lusterMaintenanceModeMessageProcessor.java | 2 + .../topology/GroupActivatedProcessor.java | 5 +- 19 files changed, 301 insertions(+), 78 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 86e0931ab4..361e89af1f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -106,10 +106,10 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Stri groupMonitor = new GroupMonitor(group, appId); groupMonitor.setAppId(appId); groupMonitor.setParent(parentMonitor); - if (group.getStatus() != groupMonitor.getStatus()) { + if (group.getTempStatus() != groupMonitor.getStatus()) { //updating the status, if the group is not in created state when creating group Monitor //so that groupMonitor will notify the parent (useful when restarting stratos) - groupMonitor.setStatus(group.getStatus()); + groupMonitor.setStatus(group.getTempStatus()); } } finally { TopologyManager.releaseReadLockForApplication(appId); @@ -290,9 +290,9 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni } } - if (cluster.getStatus() != clusterMonitor.getStatus()) { + if (cluster.getTempStatus() != clusterMonitor.getStatus()) { //updating the status, so that it will notify the parent - clusterMonitor.setStatus(cluster.getStatus()); + clusterMonitor.setStatus(cluster.getTempStatus()); } } finally { //release read lock for the service and cluster diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 9f83578b85..9e3662266b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -54,7 +54,7 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException TopologyInConsistentException { super(group); this.appId = appId; - this.setStatus(group.getStatus()); + this.setStatus(group.getTempStatus()); startDependency(); } @@ -92,6 +92,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { log.error(e); } } else if (status1 == Status.In_Active) { + //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and //TODO check whether dependent in_active. Then kill c1. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index ff45af1002..c59313cfc2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -267,7 +267,7 @@ private boolean updateChildStatus(String appId, String id, Map gr private boolean getGroupStatus(Map groups) { boolean groupActiveStatus = false; for (Group group : groups.values()) { - if (group.getStatus() == Status.Activated) { + if (group.getTempStatus() == Status.Activated) { groupActiveStatus = true; } else { groupActiveStatus = false; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 9f74524e2e..b9fb5814a6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -213,6 +213,8 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); } cluster.setStatus(ClusterStatus.Inactive); + // temporary; should be removed + cluster.setTempStatus(Status.In_Active); //cluster.setStatus(Status.In_Maintenance); TopologyManager.updateTopology(topology); } finally { @@ -774,6 +776,9 @@ public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActi TopologyManager.acquireWriteLock(); //cluster.setStatus(Status.Activated); cluster.setStatus(ClusterStatus.Active); + // temporary; should be removed + cluster.setTempStatus(Status.Activated); + log.info("Cluster activated adding status started"); TopologyManager.updateTopology(topology); @@ -807,7 +812,7 @@ public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedE groupActivatedEvent.getGroupId()); try { TopologyManager.acquireWriteLock(); - group.setStatus(Status.Activated); + group.setTempStatus(Status.Activated); log.info("Group activated adding status started"); TopologyManager.updateTopology(topology); @@ -833,7 +838,7 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app applicationActivatedEvent.getAppId()); try { TopologyManager.acquireWriteLock(); - application.setStatus(Status.Activated); + application.setTempStatus(Status.Activated); log.info("Application activated adding status started for Topology"); TopologyManager.updateTopology(topology); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index c30d5b712a..ecca8df8c1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -20,6 +20,7 @@ package org.apache.stratos.messaging.domain.topology; import org.apache.commons.lang3.RandomStringUtils; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import java.util.*; @@ -27,7 +28,7 @@ * Represents an Application in the Topology */ -public class Application extends ParentComponent { +public class Application extends ParentComponent implements LifeCycleStateTransitionBehavior { private static final long serialVersionUID = -5092959597171649688L; // Unique id for the Application, defined in Application Definition @@ -40,11 +41,15 @@ public class Application extends ParentComponent { private String tenantDomain; // tenant admin user private String tenantAdminUserName; + // Life cycle state manager + protected LifeCycleStateManager applicationStateManager; public Application (String id) { super(); this.id = id; this.key = RandomStringUtils.randomAlphanumeric(16); + this.applicationStateManager = + new LifeCycleStateManager(ApplicationStatus.Created); } public String getUniqueIdentifier() { @@ -79,6 +84,26 @@ public void setTenantAdminUserName(String tenantAdminUserName) { this.tenantAdminUserName = tenantAdminUserName; } + @Override + public boolean isStateTransitionValid(ApplicationStatus newState) { + return this.applicationStateManager.isStateTransitionValid(newState); + } + + @Override + public Stack getTransitionedStates() { + return this.applicationStateManager.getStateStack(); + } + + @Override + public ApplicationStatus getStatus() { + return this.applicationStateManager.getCurrentState(); + } + + @Override + public void setStatus(ApplicationStatus newState) { + this.applicationStateManager.changeState(newState); + } + public boolean equals(Object other) { if(other == null || !(other instanceof Application)) { return false; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java new file mode 100644 index 0000000000..6ca8e27a67 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java @@ -0,0 +1,71 @@ +/* + * 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.messaging.domain.topology; + +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public enum ApplicationStatus implements LifeCycleState { + + Created (0) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ApplicationStatus.Active, + ApplicationStatus.Terminating)); + } + }, + Active (1) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ApplicationStatus.Inactive)); + } + }, + Inactive (2) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ApplicationStatus.Terminating)); + } + }, + Terminating (3) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ApplicationStatus.Terminated)); + } + }, + Terminated (4) { + @Override + public Set getNextStates() { + return null; + } + }; + + private int code; + + private ApplicationStatus (int code) { + this.code = code; + } + + public int getCode() { + return code; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 31b7bf1443..3325561e2c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -50,7 +50,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior memberMap; - //private Status status; + private Status tempStatus; private String appId; @@ -69,6 +69,8 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.memberMap = new HashMap(); this.appId = appId; this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created); + // temporary; should be removed + this.tempStatus = Status.Created; } public String getServiceName() { @@ -250,5 +252,13 @@ public int hashCode () { public String getAppId() { return appId; } + + public Status getTempStatus () { + return tempStatus; + } + + public void setTempStatus (Status tempStatus) { + this.tempStatus = tempStatus; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java index a9f8afea6d..8ff59573eb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -26,25 +26,41 @@ import java.util.Set; public enum ClusterStatus implements LifeCycleState { + Created(0) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Active)); + return new HashSet(Arrays.asList(ClusterStatus.Active, + ClusterStatus.Terminating)); } }, Active(1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Inactive)); + return new HashSet(Arrays.asList(ClusterStatus.Inactive, + ClusterStatus.Patching, ClusterStatus.Terminating)); + } + }, + Patching (2) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ClusterStatus.Active)); } }, Inactive(3) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Active, ClusterStatus.Terminated)); + return new HashSet(Arrays.asList(ClusterStatus.Active, + ClusterStatus.Terminating)); + } + }, + Terminating(4) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(ClusterStatus.Terminated)); } }, - Terminated(4) { + Terminated(5) { @Override public Set getNextStates() { return null; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 9b5a29ee3f..0b64f67e33 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.domain.topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; + +import java.util.Stack; + /** * Represents a Group/nested Group in an Application/Group */ -public class Group extends ParentComponent { +public class Group extends ParentComponent implements LifeCycleStateTransitionBehavior { private static final long serialVersionUID = 8347096598203655846L; // Name of the Group, specified in Group Definition @@ -34,11 +38,14 @@ public class Group extends ParentComponent { private String deploymentPolicy; // Group level autoscaling policy private String autoscalingPolicy; + // Life cycle state manager + protected LifeCycleStateManager groupStateManager; public Group (String name, String alias) { super(); this.name = name; this.alias = alias; + this.groupStateManager = new LifeCycleStateManager(GroupStatus.Created); } public String getUniqueIdentifier() { @@ -65,6 +72,26 @@ public void setAutoscalingPolicy(String autoscalingPolicy) { this.autoscalingPolicy = autoscalingPolicy; } + @Override + public boolean isStateTransitionValid(GroupStatus newState) { + return groupStateManager.isStateTransitionValid(newState); + } + + @Override + public Stack getTransitionedStates() { + return groupStateManager.getStateStack(); + } + + @Override + public GroupStatus getStatus() { + return groupStateManager.getCurrentState(); + } + + @Override + public void setStatus(GroupStatus newState) { + this.groupStateManager.changeState(newState); + } + public boolean equals(Object other) { if(other == null || !(other instanceof Group)) { return false; @@ -81,5 +108,4 @@ public boolean equals(Object other) { public int hashCode () { return name.hashCode() + alias.hashCode(); } - } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java new file mode 100644 index 0000000000..55a77310e6 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.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.messaging.domain.topology; + +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +public enum GroupStatus implements LifeCycleState { + + Created(0) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(GroupStatus.Active, GroupStatus.Terminating)); + } + }, + Active(1) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(GroupStatus.Inactive, GroupStatus.Terminating)); + } + }, + Inactive(2) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(GroupStatus.Terminating)); + } + }, + Terminating(3) { + @Override + public Set getNextStates() { + return new HashSet(Arrays.asList(GroupStatus.Terminated)); + } + }, + Terminated(4) { + @Override + public Set getNextStates() { + return null; + } + }; + + private int code; + + private GroupStatus(int code) { + this.code = code; + } + + public int getCode() { + return code; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index f0cde248e5..1d80b169ce 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -19,7 +19,6 @@ package org.apache.stratos.messaging.domain.topology; -import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; @@ -90,7 +89,7 @@ public Stack getTransitionedStates () { @Override public void setStatus(MemberStatus newState) { - memberStateManager.changeState(newState); + this.memberStateManager.changeState(newState); } public boolean isActive () { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java index 6d23c4b037..a35766cd7b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java @@ -32,38 +32,38 @@ @XmlRootElement public enum MemberStatus implements LifeCycleState { - Created(1) { + Created(0) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.Starting)); } }, - Starting(2) { + Starting(1) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.Activated)); } }, - Activated(3) { + Activated(2) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.Suspended, - MemberStatus.In_Maintenance)); + MemberStatus.In_Maintenance, MemberStatus.Starting)); } }, - In_Maintenance(4) { + In_Maintenance(3) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.ReadyToShutDown)); } }, - ReadyToShutDown(5) { + ReadyToShutDown(4) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.Terminated)); } }, - Suspended(0) { + Suspended(5) { @Override public Set getNextStates() { return new HashSet(Arrays.asList(MemberStatus.Terminated)); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java index 7ce813e20f..dc5dd20f3e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java @@ -36,10 +36,10 @@ public abstract class ParentComponent implements Serializable { // Cluster Id map, key = subscription alias for the cartridge type private Map aliasToClusterDataMap; // Application status - private Status status; + private Status tempStatus; public ParentComponent () { - this.status = Status.Created; + this.tempStatus = Status.Created; aliasToGroupMap = new HashMap(); aliasToClusterDataMap = new HashMap(); } @@ -212,11 +212,11 @@ private void getClusterData (Set clusterData, Collection implements Serializ private Stack stateStack; public LifeCycleStateManager(T initialState) { + stateStack = new Stack(); stateStack.push(initialState); - //if (log.isDebugEnabled()) { - log.info("Life Cycle State Manager created, initial state: " + initialState.toString()); - //} + log.info("Life Cycle State Manager created, initial state: " + initialState.toString()); } + /** + * checks if any conditions that should be met for the state transfer is valid + * + * @param nextState possible next state for the topology element + * @param topologyEvent relevant ToplogyEvent + * @param subclass of Topology event + * @return + */ public boolean isPreConditionsValid (T nextState, S topologyEvent) { // TODO: implement return true; } + /** + * Checks if the state transition is valid + * + * @param nextState possible next state for the topology element + * @return true if transitioning for nextState from current state is valid, else false + */ public boolean isStateTransitionValid (T nextState) { - return stateStack.peek().getNextStates().contains(nextState); } + /** + * Changes the current state to nextState + * + * @param nextState + */ public void changeState (T nextState) { - stateStack.push(nextState); + log.info("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " + + getCurrentState() + " ]"); } + /** + * Get all the states this element has gone through + * + * @return Stack of states + */ public Stack getStateStack () { return stateStack; } + /** + * Get the current state + * + * @return the current state + */ public T getCurrentState () { return stateStack.peek(); } + /** + * Retrieves the previous state + * + * @return previous state + */ public T getPreviousState () { return stateStack.get(1); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.java deleted file mode 100644 index e00d4faabd..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/GroupStatus.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.messaging.domain.topology.util; - -public enum GroupStatus { - - Created(1), - In_Maintenance(2), - terminating(3), - Removed(4), - Running(5), - Active(6); - - private int code; - - private GroupStatus(int code) { - this.code = code; - } - - public int getCode() { - return code; - } - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index d32cecff5f..9bcf47d66a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -88,7 +88,7 @@ private boolean doProcess (ApplicationActivatedEvent event, Topology topology) { return false; } else { // Apply changes to the topology - application.setStatus(Status.Activated); + application.setTempStatus(Status.Activated); if (log.isInfoEnabled()) { log.info(String.format("Application updated as activated : %s", application.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index 69fc3e7ece..1a6ffc750d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -119,6 +119,8 @@ private boolean doProcess (ClusterActivatedEvent event,Topology topology) { log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); } cluster.setStatus(ClusterStatus.Active); + // temporary; should be removed + cluster.setTempStatus(Status.Activated); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as activated : %s", cluster.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java index 35966e8abc..096c9a3a4a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java @@ -114,6 +114,8 @@ private boolean doProcess (ClusterMaintenanceModeEvent event,Topology topology) log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); } cluster.setStatus(ClusterStatus.Inactive); + // temporary; should be removed + cluster.setTempStatus(Status.In_Active); if (log.isInfoEnabled()) { log.info(String.format("Cluster updated as maintenance mode: %s", cluster.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index 5c8de02ded..1ed6b2759c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -90,7 +90,10 @@ private boolean doProcess (GroupActivatedEvent event,Topology topology) { } } else { // Apply changes to the topology - group.setStatus(Status.Activated); + if (!group.isStateTransitionValid(GroupStatus.Active)) { + log.error("Invalid State Transition from " + application.getTempStatus() + " to " + GroupStatus.Active); + } + group.setTempStatus(Status.Activated); if (log.isInfoEnabled()) { log.info(String.format("Group updated as activated : %s", group.getUniqueIdentifier())); From ae4f94efb27a17ffa196128730772fc6febdbf82 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 19 Oct 2014 10:03:19 +0530 Subject: [PATCH 207/436] fixing a build break in AutoscalerTopologyEventReceiver --- .../receiver/topology/AutoscalerTopologyEventReceiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index b342a81ebc..ed250b5b03 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -306,7 +306,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(Status.In_Maintenance); + monitor.setStatus(Status.In_Active); } else if (AutoscalerContext.getInstance(). lbMonitorExist((cluster.getClusterId()))) { AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). From 6d8ea4132625ef015299a544b4963a41109c3562 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 20 Oct 2014 09:57:21 +0530 Subject: [PATCH 208/436] adding in_active events support --- .../grouping/dependency/DependencyTree.java | 3 +- .../grouping/topic/StatusEventPublisher.java | 49 ++++++++++++ .../AutoscalerTopologyEventReceiver.java | 48 +++++++++++- .../stratos/autoscaler/monitor/Monitor.java | 12 +-- .../monitor/ParentComponentMonitor.java | 24 +++--- .../application/ApplicationMonitor.java | 11 ++- .../events/ApplicationStatusEvent.java | 8 +- .../monitor/events/ClusterStatusEvent.java | 10 ++- .../monitor/events/GroupStatusEvent.java | 12 ++- .../monitor/events/MonitorStatusEvent.java | 14 +--- .../monitor/group/GroupMonitor.java | 74 +++++++++++++++++-- .../status/checker/StatusChecker.java | 26 ++++++- .../domain/topology/ComponentStatus.java | 26 +++++++ .../messaging/domain/topology/Status.java | 2 +- 14 files changed, 270 insertions(+), 49 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 156f3a50be..e4f214eb3a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -92,7 +92,8 @@ public ApplicationContext findApplicationContextWithId(String id) { */ private ApplicationContext findApplicationContextWithId(String id, List contexts) { for (ApplicationContext context : contexts) { - if (context.getId().equals(id) && context.getCurrentStatus() == null) { + //TODO check for the status + if (context.getId().equals(id)) { return context; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index efd5eea7ad..f8a2322f2f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -6,6 +6,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; import org.apache.stratos.messaging.util.Constants; /** @@ -14,6 +15,19 @@ public class StatusEventPublisher { private static final Log log = LogFactory.getLog(StatusEventPublisher.class); + public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Cluster activated event for [application]: " + appId + + " [cluster]: " + clusterId); + } + + //TODO cluster + ClusterCreatedEvent clusterActivatedEvent = new ClusterCreatedEvent(appId, serviceName, null); + + publishEvent(clusterActivatedEvent); + } + public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { @@ -26,6 +40,18 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S publishEvent(clusterActivatedEvent); } + public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Cluster in-activate event for [application]: " + appId + + " [cluster]: " + clusterId); + } + + /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterActivatedEvent);*/ + } + public static void sendClusterInMaintenanceEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { @@ -39,6 +65,17 @@ public static void sendClusterInMaintenanceEvent(String appId, String serviceNam publishEvent(clusterInMaintenanceEvent); } + public static void sendGroupCreatedEvent(String appId, String groupId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Group activated event for [application]: " + appId + + " [group]: " + groupId); + } + +/* + publishEvent(groupActivatedEvent);*/ + } + public static void sendGroupActivatedEvent(String appId, String groupId) { if (log.isInfoEnabled()) { @@ -51,6 +88,18 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { publishEvent(groupActivatedEvent); } + public static void sendGroupInActivateEvent(String appId, String groupId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Group in-activate event for [application]: " + appId + + " [group]: " + groupId); + } + + /*GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId); + + publishEvent(groupActivatedEvent);*/ + } + public static void sendApplicationActivatedEvent(String appId) { if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 1e209377f7..29e5c50cf3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; @@ -160,6 +161,26 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + + ClusterInActivateEvent clusterInActivateEvent = (ClusterInActivateEvent) event; + String appId = clusterInActivateEvent.getAppId(); + String clusterId = clusterInActivateEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(Status.In_Active); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { @Override protected void onEvent(Event event) { @@ -181,6 +202,27 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new GroupInActivateEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupInActivateEvent] Received: " + event.getClass()); + + GroupInActivateEvent groupInActivateEvent = (GroupInActivateEvent) event; + String appId = groupInActivateEvent.getAppId(); + String groupId = groupInActivateEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(Status.In_Active); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); + } + }); + topologyEventReceiver.addEventListener(new ApplicationActivatedEventListener() { @Override protected void onEvent(Event event) { @@ -209,14 +251,14 @@ protected void onEvent(Event event) { try { //TODO remove monitors as well as any starting or pending threads - /*ApplicationMonitor monitor = AutoscalerContext.getInstance(). + ApplicationMonitor monitor = AutoscalerContext.getInstance(). getAppMonitor(applicationRemovedEvent.getApplicationId()); if (monitor != null) { List clusters = monitor. findClustersOfApplication(applicationRemovedEvent.getApplicationId()); for (String clusterId : clusters) { //stopping the cluster monitor and remove it from the AS - AutoscalerContext.getInstance().getMonitor(clusterId).setDestroyed(true); + ((ClusterMonitor)AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true); AutoscalerContext.getInstance().removeMonitor(clusterId); } //removing the application monitor @@ -225,7 +267,7 @@ protected void onEvent(Event event) { } else { log.warn("Application Monitor cannot be found for the removed [application] " + applicationRemovedEvent.getApplicationId()); - }*/ + } } finally { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index f08be7f155..a0f1d986a6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -31,7 +31,9 @@ public abstract class Monitor implements EventHandler { //Parent monitor of this monitor, for appMonitor parent will be none. protected ParentComponentMonitor parent; //monitors map, key=GroupAlias/clusterId and value=GroupMonitor/AbstractClusterMonitor - protected Map aliasToMonitorsMap; + protected Map aliasToActiveMonitorsMap; + //monitors map, stopped monitors + protected Map aliasToInActiveMonitorsMap; public String getId() { return id; @@ -50,12 +52,12 @@ public void setAppId(String appId) { this.appId = appId; } - public Map getAliasToMonitorsMap() { - return aliasToMonitorsMap; + public Map getAliasToActiveMonitorsMap() { + return aliasToActiveMonitorsMap; } - public void setAliasToMonitorsMap(Map aliasToMonitorsMap) { - this.aliasToMonitorsMap = aliasToMonitorsMap; + public void setAliasToActiveMonitorsMap(Map aliasToActiveMonitorsMap) { + this.aliasToActiveMonitorsMap = aliasToActiveMonitorsMap; } public ParentComponentMonitor getParent() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 3cd2d9f19a..08f23769f9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -49,7 +49,7 @@ public abstract class ParentComponentMonitor extends Monitor { protected String appId; public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException { - aliasToMonitorsMap = new HashMap(); + aliasToActiveMonitorsMap = new HashMap(); //clusterIdToClusterMonitorsMap = new HashMap(); this.id = component.getUniqueIdentifier(); //Building the dependency for this monitor within the immediate children @@ -103,8 +103,12 @@ private boolean startDependency(List applicationContexts) if (log.isDebugEnabled()) { log.debug("Dependency check for the Group " + context.getId() + " started"); } - startMonitor(this, context); - //context.setCurrentStatus(Status.Created); + if(!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { + //to avoid if it is already started + startMonitor(this, context); + } else if(this.aliasToInActiveMonitorsMap.containsKey(context.getId())) { + //need to trigger the cluster monitor + } } return true; @@ -129,7 +133,7 @@ public void setAppId(String appId) { protected synchronized void startMonitor(ParentComponentMonitor parent, ApplicationContext context) { Thread th = null; - if (!this.aliasToMonitorsMap.containsKey(context.getId())) { + if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { th = new Thread( new MonitorAdder(parent, context, this.appId)); if (log.isDebugEnabled()) { @@ -205,7 +209,7 @@ public void run() { } AutoscalerContext.getInstance().addMonitor(monitor); - aliasToMonitorsMap.put(context.getId(), monitor); + aliasToActiveMonitorsMap.put(context.getId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Monitor has been added successfully for: %s", context.getId())); @@ -217,7 +221,7 @@ public void run() { /*protected synchronized void startGroupMonitor(ParentComponentMonitor parent, GroupContext groupContext) { Thread th = null; //String groupId = group.getUniqueIdentifier(); - if (!this.aliasToMonitorsMap.containsKey(groupId)) { + if (!this.aliasToActiveMonitorsMap.containsKey(groupId)) { if (log.isDebugEnabled()) { log.debug(String .format("Group monitor Adder has been added: [group] %s ", @@ -259,7 +263,7 @@ public void run() { /*protected synchronized void startClusterMonitor(ParentComponentMonitor parent, ApplicationContext clusterContext) { Thread th = null; - if (!this.aliasToMonitorsMap.containsKey(clusterContext.getId())) { + if (!this.aliasToActiveMonitorsMap.containsKey(clusterContext.getId())) { th = new Thread( new ClusterMonitorAdder(parent, clusterContext)); if (log.isDebugEnabled()) { @@ -357,7 +361,7 @@ public void run() { th.start(); AutoscalerContext.getInstance().addMonitor(monitor); - aliasToMonitorsMap.put(cluster.getClusterId(), monitor); + aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); @@ -421,7 +425,7 @@ public void run() { throw new RuntimeException(msg); } - aliasToMonitorsMap.put(groupId, monitor); + aliasToActiveMonitorsMap.put(groupId, monitor); //parent.addObserver(monitor); if (log.isInfoEnabled()) { @@ -473,7 +477,7 @@ public void run() { Thread th = new Thread(monitor); th.start(); AutoscalerContext.getInstance().addLbMonitor(monitor); - aliasToMonitorsMap.put(cluster.getClusterId(), monitor); + aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", cluster.getClusterId())); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 5df336769e..ce1ffb6533 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ComponentStatus; import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; @@ -78,7 +79,7 @@ public List findClustersOfApplication(String appId) { */ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { /*return findClusterMonitor(clusterId, clusterIdToClusterMonitorsMap.values(), - aliasToMonitorsMap.values());*/ + aliasToActiveMonitorsMap.values());*/ return null; } @@ -118,7 +119,7 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { * @return the found GroupMonitor */ public Monitor findGroupMonitorWithId(String groupId) { - return findGroupMonitor(groupId, aliasToMonitorsMap.values()); + return findGroupMonitor(groupId, aliasToActiveMonitorsMap.values()); } @@ -137,8 +138,8 @@ private Monitor findGroupMonitor(String id, Collection monitors) { return monitor; } else { // check if this Group has nested sub Groups. If so, traverse them as well - if (monitor.getAliasToMonitorsMap() != null) { - return findGroupMonitor(id, monitor.getAliasToMonitorsMap().values()); + if (monitor.getAliasToActiveMonitorsMap() != null) { + return findGroupMonitor(id, monitor.getAliasToActiveMonitorsMap().values()); } } } @@ -196,8 +197,6 @@ protected void monitor(MonitorStatusEvent statusEvent) { } //updating the life cycle and current status - context.setCurrentStatus(statusEvent.getStatus()); - context.addStatusToLIfeCycle(statusEvent.getStatus()); if (!startDep) { //Checking in the children whether all are active, // since no dependency found to be started. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java index 783cc7a560..657719a49d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java @@ -25,12 +25,18 @@ */ public class ApplicationStatusEvent extends MonitorStatusEvent { + private Status status; + public ApplicationStatusEvent(Status status, String id) { - super(status, id); + super(id); + this.status = status; } public Status getStatus() { return this.status; } + public void setStatus(Status status) { + this.status = status; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java index d05208fb15..7e3fabc056 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java @@ -25,12 +25,18 @@ */ public class ClusterStatusEvent extends MonitorStatusEvent { + private Status status; + public ClusterStatusEvent(Status status, String id) { - super(status, id); + super(id); + this.status = status; } public Status getStatus() { - return super.getStatus(); + return this.status; } + public void setStatus(Status status) { + this.status = status; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java index aa31d73388..bb937103b2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java @@ -24,8 +24,18 @@ * This will use to notify observers upon a group activation events received in Topology. */ public class GroupStatusEvent extends MonitorStatusEvent { + private Status status; public GroupStatusEvent(Status status, String id) { - super(status, id); + super(id); + this.status = status; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java index 336bd7a2ef..180b1cc197 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java @@ -18,21 +18,19 @@ */ package org.apache.stratos.autoscaler.monitor.events; +import org.apache.stratos.messaging.domain.topology.ComponentStatus; import org.apache.stratos.messaging.domain.topology.Status; /** * Monitor Status Event */ public abstract class MonitorStatusEvent { - protected Status status; protected String id; - public MonitorStatusEvent(Status status, String id) { - this.setStatus(status); + public MonitorStatusEvent(String id) { this.setId(id); } - public String getId() { return id; } @@ -41,11 +39,5 @@ public void setId(String id) { this.id = id; } - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } + public abstract ComponentStatus getStatus(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 9f83578b85..a06ab149d0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.ComponentStatus; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.Status; @@ -66,7 +67,7 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); - Status status1 = statusEvent.getStatus(); + ComponentStatus status1 = statusEvent.getStatus(); ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination //TODO if statusEvent is for active, then start the next one if any available @@ -92,7 +93,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { log.error(e); } } else if (status1 == Status.In_Active) { - //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and + //TODO if C1 depends on C2, then if C2 is in_active, then by getting kill depend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and //TODO check whether dependent in_active. Then kill c1. //evaluate termination behavior and take action based on that. @@ -100,11 +101,31 @@ protected void monitor(MonitorStatusEvent statusEvent) { List terminationList = new ArrayList(); terminationList = this.dependencyTree.getTerminationDependencies(id); - //check whether all the children are in_active state - for (ApplicationContext terminationContext : terminationList) { - //terminationContext + if(terminationList != null) { + //Move to in_active monitors list + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + boolean allInActive = false; + //check whether all the children are in_active state + for (ApplicationContext terminationContext : terminationList) { + //Check for whether all dependent are in_active + if(this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { + allInActive = true; + } else { + allInActive = false; + } + } + + if(allInActive) { + //Then kill-all of each termination dependents and get a lock for CM + //if start order then can kill only the first one, rest of them will get killed based on created event of first one. + } } + + + + + /*if(terminationList != null && !terminationList.isEmpty()) { for(ApplicationContext context1 : terminationList) { if(context1 instanceof ClusterContext) { @@ -124,9 +145,50 @@ protected void monitor(MonitorStatusEvent statusEvent) { if(canTerminate) { // }*/ - } else { + } else if(status1 == Status.Created) { //TODO get dependents List dependents = this.dependencyTree.getTerminationDependencies(id); + // if no dependencies then start the cluster monitor. if all are in created, then start them in the order. + if(dependents != null) { + boolean allCreated = false; + //check whether all the children are in_active state + for (ApplicationContext terminationContext : dependents) { + //Check for whether all dependent are in_active + if(this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { + allCreated = true; + } else { + allCreated = false; + } + } + + String firstChildToBeStarted = null; + + if(allCreated) { + //start the CM according to startup order and releasing the lock for it + try { + //if life cycle is empty, need to start the monitor + boolean startDep = startDependency(firstChildToBeStarted); + if (log.isDebugEnabled()) { + log.debug("started a child: " + startDep + " by the group/cluster: " + firstChildToBeStarted); + + } + //updating the life cycle and current status + if (startDep) { + context.setCurrentStatus(Status.Created); + context.addStatusToLIfeCycle(Status.Created); + } else { + StatusChecker.getInstance().onChildStatusChange(id, firstChildToBeStarted, this.appId); + } + + } catch (TopologyInConsistentException e) { + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error(e); + } + } else { + //kill other dependents cluster + + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index c76df01fa7..32523d071a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -70,8 +70,15 @@ public void onMemberStatusChange(String clusterId) { public void onMemberTermination(String clusterId) { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //TODO get Topology status - // if cluster not having any members and if the cluster was in_active then send created Events - // if cluster was in terminating, then send terminated event. + boolean clusterMonitorHasMembers; + clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); + if(clusterMonitorHasMembers) { + //monitor.pause(); + // if cluster not having any members and if the cluster was in_active then send created Events + StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(), + monitor.getClusterId()); + } + // TODO if cluster was in terminating, then send terminated event. } private boolean clusterActive(AbstractClusterMonitor monitor) { @@ -93,6 +100,20 @@ private boolean clusterActive(AbstractClusterMonitor monitor) { return clusterActive; } + private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { + boolean hasMember = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { + //minimum check per partition + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + if (partitionContext.getNonTerminatedMemberCount() > 0) { + hasMember = true; + return hasMember; + } + } + } + return hasMember; + } + /** * @param clusterId * @param appId @@ -104,6 +125,7 @@ public void onMemberFaultEvent(final String clusterId, final String appId, final if (clusterInActive) { //TODO evaluate life cycle //send cluster In-Active event to cluster status topic + StatusEventPublisher.sendGroupInActivateEvent(appId, monitor.getParent().getId()); } else { boolean clusterActive = clusterActive(monitor); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java new file mode 100644 index 0000000000..1b8993c318 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.domain.topology; + +/** + * Created by reka on 10/18/14. + */ +public interface ComponentStatus { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java index 2bd094531a..dd6f9225e6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.domain.topology; -public enum Status { +public enum Status implements ComponentStatus { Created(1), Running(2), From b81a69b24c289b1aec73971dd7415b80c022cd92 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 20 Oct 2014 11:10:00 +0530 Subject: [PATCH 209/436] updating the status of applicatio, group and cluster with their own status --- .../context/ApplicationContext.java | 16 +++---- .../AutoscalerTopologyEventReceiver.java | 33 +++++-------- .../monitor/AbstractClusterMonitor.java | 11 ++--- .../monitor/ApplicationMonitorFactory.java | 11 +++-- .../monitor/MonitorStatusEventBuilder.java | 9 ++-- .../application/ApplicationMonitor.java | 7 ++- .../monitor/cluster/ClusterMonitor.java | 2 +- .../events/ApplicationStatusEvent.java | 10 ++-- .../monitor/events/ClusterStatusEvent.java | 9 ++-- .../monitor/events/GroupStatusEvent.java | 10 ++-- .../monitor/events/MonitorStatusEvent.java | 5 +- .../monitor/group/GroupMonitor.java | 47 +++++++++---------- .../autoscaler/util/AutoscalerUtil.java | 16 +------ .../domain/topology/ComponentStatus.java | 26 ---------- .../messaging/domain/topology/Status.java | 2 +- 15 files changed, 82 insertions(+), 132 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java index 5b98264cde..e496f4017a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.autoscaler.grouping.dependency.context; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; import java.util.ArrayList; import java.util.List; @@ -34,15 +34,15 @@ public abstract class ApplicationContext { protected boolean started; protected boolean terminated; - private Status status; + private ClusterStatus status; - private Stack statusLifeCycle; + private Stack statusLifeCycle; protected boolean killDependent; public ApplicationContext(String id, boolean killDependent) { applicationContextList = new ArrayList(); - statusLifeCycle = new Stack(); + statusLifeCycle = new Stack(); this.killDependent = killDependent; this.id = id; } @@ -60,7 +60,7 @@ public void addApplicationContext(ApplicationContext applicationContext) { } - public void addStatusToLIfeCycle(Status status) { + public void addStatusToLIfeCycle(ClusterStatus status) { this.statusLifeCycle.push(status); } @@ -72,15 +72,15 @@ public void setId(String id) { this.id = id; } - public Status getCurrentStatus() { + public ClusterStatus getCurrentStatus() { return status; } - public void setCurrentStatus(Status status) { + public void setCurrentStatus(ClusterStatus status) { this.status = status; } - public List getStatusLifeCycle() { + public List getStatusLifeCycle() { return statusLifeCycle; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 1d83e27228..6cb186e104 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -35,10 +35,7 @@ import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.listener.topology.*; @@ -154,7 +151,7 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(Status.Activated); + clusterMonitor.setStatus(ClusterStatus.Active); //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); @@ -174,7 +171,7 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(Status.In_Active); + clusterMonitor.setStatus(ClusterStatus.Inactive); //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); @@ -195,7 +192,7 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(Status.Activated); + monitor.setStatus(GroupStatus.Active); //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); @@ -216,7 +213,7 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(Status.In_Active); + monitor.setStatus(GroupStatus.Inactive); //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); @@ -233,7 +230,7 @@ protected void onEvent(Event event) { String appId = applicationActivatedEvent.getAppId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - appMonitor.setStatus(Status.Activated); + appMonitor.setStatus(ApplicationStatus.Active); } }); @@ -258,7 +255,7 @@ protected void onEvent(Event event) { findClustersOfApplication(applicationRemovedEvent.getApplicationId()); for (String clusterId : clusters) { //stopping the cluster monitor and remove it from the AS - ((ClusterMonitor)AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true); + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true); AutoscalerContext.getInstance().removeMonitor(clusterId); } //removing the application monitor @@ -348,11 +345,7 @@ protected void onEvent(Event event) { AbstractClusterMonitor monitor; if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(Status.In_Active); - } else if (AutoscalerContext.getInstance(). - lbMonitorExist((cluster.getClusterId()))) { - AutoscalerContext.getInstance().getLBMonitor(clusterMaitenanceEvent.getClusterId()). - setStatus(clusterMaitenanceEvent.getStatus()); + monitor.setStatus(ClusterStatus.Inactive); } else { log.error("cluster monitor not exists for the cluster: " + cluster.toString()); } @@ -634,14 +627,14 @@ protected synchronized void startApplicationMonitor(String applicationId) { if (th != null) { th.start(); - // try { - // th.join(); - // } catch (InterruptedException ignore) { + // try { + // th.join(); + // } catch (InterruptedException ignore) { if (log.isDebugEnabled()) { log.debug(String - .format("Application monitor thread has been started successfully: " + - "[application] %s ", applicationId)); + .format("Application monitor thread has been started successfully: " + + "[application] %s ", applicationId)); } } else { if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index e470d7feff..487e8be84b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -28,10 +28,7 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Member; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; @@ -65,7 +62,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected String serviceId; protected String appId; - protected Status status; + protected ClusterStatus status; protected ParentComponentMonitor parent; @@ -235,11 +232,11 @@ public int getMonitorInterval() { return monitorInterval; } - public Status getStatus() { + public ClusterStatus getStatus() { return status; } - public void setStatus(Status status) { + public void setStatus(ClusterStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", clusterId, this.status, status)); this.status = status; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 361e89af1f..bfc7bbb5bc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -106,11 +106,12 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Stri groupMonitor = new GroupMonitor(group, appId); groupMonitor.setAppId(appId); groupMonitor.setParent(parentMonitor); - if (group.getTempStatus() != groupMonitor.getStatus()) { + //TODO + /*if (group.getTempStatus() != groupMonitor.getStatus()) { //updating the status, if the group is not in created state when creating group Monitor //so that groupMonitor will notify the parent (useful when restarting stratos) groupMonitor.setStatus(group.getTempStatus()); - } + }*/ } finally { TopologyManager.releaseReadLockForApplication(appId); @@ -289,11 +290,11 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni networkPartitionContext.getId())); } } - - if (cluster.getTempStatus() != clusterMonitor.getStatus()) { + //TODO + /*if (cluster.getTempStatus() != clusterMonitor.getStatus()) { //updating the status, so that it will notify the parent clusterMonitor.setStatus(cluster.getTempStatus()); - } + }*/ } finally { //release read lock for the service and cluster TopologyManager.releaseReadLockForCluster(serviceName, clusterId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index d8bc6d9d3d..a27e0564b2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -24,6 +24,9 @@ import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.Status; /** @@ -32,17 +35,17 @@ public class MonitorStatusEventBuilder { private static final Log log = LogFactory.getLog(MonitorStatusEventBuilder.class); - public static void handleClusterStatusEvent(ParentComponentMonitor parent, Status status, String clusterId) { + public static void handleClusterStatusEvent(ParentComponentMonitor parent, ClusterStatus status, String clusterId) { ClusterStatusEvent clusterStatusEvent = new ClusterStatusEvent(status, clusterId); notifyParent(parent, clusterStatusEvent); } - public static void handleGroupStatusEvent(ParentComponentMonitor parent, Status status, String groupId) { + public static void handleGroupStatusEvent(ParentComponentMonitor parent, GroupStatus status, String groupId) { GroupStatusEvent groupStatusEvent = new GroupStatusEvent(status, groupId); notifyParent(parent, groupStatusEvent); } - public static void handleApplicationStatusEvent(ParentComponentMonitor parent, Status status, String appId) { + public static void handleApplicationStatusEvent(ParentComponentMonitor parent, ApplicationStatus status, String appId) { ApplicationStatusEvent applicationStatusEvent = new ApplicationStatusEvent(status, appId); notifyParent(parent, applicationStatusEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index ce1ffb6533..c3c7459658 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -29,8 +29,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ComponentStatus; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import java.util.ArrayList; import java.util.Collection; @@ -42,7 +41,7 @@ public class ApplicationMonitor extends ParentComponentMonitor { private static final Log log = LogFactory.getLog(ApplicationMonitor.class); //status of the monitor whether it is running/in_maintainable/terminated - protected Status status; + protected ApplicationStatus status; public ApplicationMonitor(Application application) throws DependencyBuilderException, TopologyInConsistentException { @@ -151,7 +150,7 @@ private Monitor findGroupMonitor(String id, Collection monitors) { * * @param status the status */ - public void setStatus(Status status) { + public void setStatus(ApplicationStatus status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); this.status = status; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index c681a0f362..6043b5cdf2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -65,7 +65,7 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); } networkPartitionCtxts = new ConcurrentHashMap(); - status = Status.Created; + status = ClusterStatus.Created; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java index 657719a49d..d92de77c9b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java @@ -18,25 +18,25 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; /** * This will use to notify observers upon a application activation events received in Topology. */ public class ApplicationStatusEvent extends MonitorStatusEvent { - private Status status; + private ApplicationStatus status; - public ApplicationStatusEvent(Status status, String id) { + public ApplicationStatusEvent(ApplicationStatus status, String id) { super(id); this.status = status; } - public Status getStatus() { + public ApplicationStatus getStatus() { return this.status; } - public void setStatus(Status status) { + public void setStatus(ApplicationStatus status) { this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java index 7e3fabc056..de8f0d551a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.events; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Status; /** @@ -25,18 +26,18 @@ */ public class ClusterStatusEvent extends MonitorStatusEvent { - private Status status; + private ClusterStatus status; - public ClusterStatusEvent(Status status, String id) { + public ClusterStatusEvent(ClusterStatus status, String id) { super(id); this.status = status; } - public Status getStatus() { + public ClusterStatus getStatus() { return this.status; } - public void setStatus(Status status) { + public void setStatus(ClusterStatus status) { this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java index bb937103b2..7956914818 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java @@ -18,24 +18,24 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.GroupStatus; /** * This will use to notify observers upon a group activation events received in Topology. */ public class GroupStatusEvent extends MonitorStatusEvent { - private Status status; + private GroupStatus status; - public GroupStatusEvent(Status status, String id) { + public GroupStatusEvent(GroupStatus status, String id) { super(id); this.status = status; } - public Status getStatus() { + public GroupStatus getStatus() { return status; } - public void setStatus(Status status) { + public void setStatus(GroupStatus status) { this.status = status; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java index 180b1cc197..d4af749343 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java @@ -18,8 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import org.apache.stratos.messaging.domain.topology.ComponentStatus; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; /** * Monitor Status Event @@ -39,5 +38,5 @@ public void setId(String id) { this.id = id; } - public abstract ComponentStatus getStatus(); + public abstract LifeCycleState getStatus(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index aafedea014..20dd003ad4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -28,9 +28,10 @@ import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.ComponentStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.Status; +import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import java.util.ArrayList; import java.util.List; @@ -42,7 +43,7 @@ public class GroupMonitor extends ParentComponentMonitor implements EventHandler { private static final Log log = LogFactory.getLog(GroupMonitor.class); //status of the monitor whether it is running/in_maintainable/terminated - private Status status; + private GroupStatus status; /** * Constructor of GroupMonitor @@ -55,7 +56,7 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException TopologyInConsistentException { super(group); this.appId = appId; - this.setStatus(group.getTempStatus()); + //TODO this.setStatus(group.getTempStatus()); startDependency(); } @@ -67,12 +68,12 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); - ComponentStatus status1 = statusEvent.getStatus(); + LifeCycleState status1 = statusEvent.getStatus(); ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination //TODO if statusEvent is for active, then start the next one if any available if (!isParent(id)) { - if (status1 == Status.Activated) { + if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { try { //if life cycle is empty, need to start the monitor boolean startDep = startDependency(statusEvent.getId()); @@ -81,10 +82,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { } //updating the life cycle and current status - if (startDep) { - context.setCurrentStatus(Status.Created); - context.addStatusToLIfeCycle(Status.Created); - } else { + if (!startDep) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); } @@ -92,7 +90,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription log.error(e); } - } else if (status1 == Status.In_Active) { + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and @@ -102,21 +100,21 @@ protected void monitor(MonitorStatusEvent statusEvent) { List terminationList = new ArrayList(); terminationList = this.dependencyTree.getTerminationDependencies(id); - if(terminationList != null) { + if (terminationList != null) { //Move to in_active monitors list this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); boolean allInActive = false; //check whether all the children are in_active state for (ApplicationContext terminationContext : terminationList) { //Check for whether all dependent are in_active - if(this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { + if (this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { allInActive = true; } else { allInActive = false; } } - if(allInActive) { + if (allInActive) { //Then kill-all of each termination dependents and get a lock for CM //if start order then can kill only the first one, rest of them will get killed based on created event of first one. } @@ -146,16 +144,16 @@ protected void monitor(MonitorStatusEvent statusEvent) { if(canTerminate) { // }*/ - } else if(status1 == Status.Created) { + } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { //TODO get dependents List dependents = this.dependencyTree.getTerminationDependencies(id); // if no dependencies then start the cluster monitor. if all are in created, then start them in the order. - if(dependents != null) { + if (dependents != null) { boolean allCreated = false; //check whether all the children are in_active state for (ApplicationContext terminationContext : dependents) { //Check for whether all dependent are in_active - if(this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { + if (this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { allCreated = true; } else { allCreated = false; @@ -164,7 +162,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { String firstChildToBeStarted = null; - if(allCreated) { + if (allCreated) { //start the CM according to startup order and releasing the lock for it try { //if life cycle is empty, need to start the monitor @@ -174,10 +172,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { } //updating the life cycle and current status - if (startDep) { - context.setCurrentStatus(Status.Created); - context.addStatusToLIfeCycle(Status.Created); - } else { + if (!startDep) { StatusChecker.getInstance().onChildStatusChange(id, firstChildToBeStarted, this.appId); } @@ -187,13 +182,13 @@ protected void monitor(MonitorStatusEvent statusEvent) { } } else { //kill other dependents cluster - + } } } - } else if (status1 == Status.Created) { + } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { //the dependent goes to be created state, so terminate the dependents } } @@ -222,7 +217,7 @@ private boolean isParent(String id) { } } - public Status getStatus() { + public GroupStatus getStatus() { return status; } @@ -231,7 +226,7 @@ public Status getStatus() { * * @param status */ - public void setStatus(Status status) { + public void setStatus(GroupStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); this.status = status; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 050a388ccd..59dda9f24a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -26,15 +26,9 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.partition.PartitionManager; @@ -45,7 +39,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import javax.xml.namespace.QName; @@ -62,12 +55,7 @@ private AutoscalerUtil() { } - - - - - - public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { + /*public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { // FIXME fix the following code to correctly update // AutoscalerContext context = AutoscalerContext.getInstance(); if (null == cluster) { @@ -180,7 +168,7 @@ public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws Polic log.info("LB Cluster monitor created: "+clusterMonitor.toString()); return clusterMonitor; - } + }*/ //TODO moving it into factory class diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.java deleted file mode 100644 index 1b8993c318..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ComponentStatus.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.messaging.domain.topology; - -/** - * Created by reka on 10/18/14. - */ -public interface ComponentStatus { - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java index dd6f9225e6..2bd094531a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.domain.topology; -public enum Status implements ComponentStatus { +public enum Status { Created(1), Running(2), From d6962c906daf43b37c965e3adf8ad5dfd34c33f0 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 16 Oct 2014 21:48:20 +0530 Subject: [PATCH 210/436] null check for authheader setter --- .../stratos/metadata/client/rest/DefaultRestClient.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index e6279d7549..160ca15cae 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -22,6 +22,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.http.HttpResponse; @@ -94,6 +95,9 @@ public HttpResponse doPost(String resourcePath, Object payload) throws RestClien } private void setAuthHeader(HttpRequestBase post) { + if(StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){ + return; + } String identity = username + ":" + password; String encoding = new String(Base64.encodeBase64(identity.getBytes())); post.setHeader("Authorization", "Basic " + encoding); From ca43f8d476df23f7b876e3017bb69c97b5e0197b Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 17 Oct 2014 18:24:44 +0530 Subject: [PATCH 211/436] getApplicationInfo --- .../rest/endpoint/bean/ApplicationBean.java | 18 +++++++ .../stratos/rest/endpoint/bean/GroupBean.java | 35 +++++++++++++ .../rest/endpoint/services/ServiceUtils.java | 51 +++++++++++++++++-- .../rest/endpoint/services/StratosAdmin.java | 10 ++++ 4 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java create mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java new file mode 100644 index 0000000000..024664b74d --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java @@ -0,0 +1,18 @@ +package org.apache.stratos.rest.endpoint.bean; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by udara on 10/17/14. + */ +public class ApplicationBean { + public List groups = null; + public String id; + public ApplicationBean(){ + this.groups = new ArrayList(); + } + public void addGroup(GroupBean groupBean) { + this.groups.add(groupBean); + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java new file mode 100644 index 0000000000..77736bdc30 --- /dev/null +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java @@ -0,0 +1,35 @@ +/* + * 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.rest.endpoint.bean; + +import java.util.ArrayList; +import java.util.List; + +public class GroupBean { + List subGroups = null; + public String alias; + + public GroupBean(){ + this.subGroups = new ArrayList(); + } + + public void addGroup(GroupBean groupBean){ + subGroups.add(groupBean); + } +} diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 515a21af47..e29fb4cbd0 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -51,12 +51,12 @@ 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.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.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.rest.endpoint.bean.ApplicationBean; import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; +import org.apache.stratos.rest.endpoint.bean.GroupBean; import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; @@ -1578,4 +1578,49 @@ static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) t log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName); } + + public static Object getApplicationInfo(String applicationId, ConfigurationContext configContext) { + + TopologyManager.acquireReadLock(); + Application application = TopologyManager.getTopology().getApplication(applicationId); + ApplicationBean applicationBean = applicationToBean(application); + + Map topLevelClusterDataMap = application.getClusterDataMap(); + for(Map.Entry entry : topLevelClusterDataMap.entrySet()){ + String alias = entry.getKey(); + ClusterDataHolder clusterDataHolder = entry.getValue(); + String clusterId = clusterDataHolder.getClusterId(); + Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterDataHolder.getServiceType()).getCluster(clusterId); + } + + Collection groups = application.getGroups(); + for(Group group : groups){ + GroupBean groupBean = toGroupBean(group); + setSubGroups(group, groupBean); + applicationBean.addGroup(groupBean); + } + TopologyManager.releaseReadLock(); + return null; + } + + private static void setSubGroups(Group group, GroupBean groupBean) { + Collection subgroups = group.getGroups(); + for(Group subGroup : subgroups){ + GroupBean subGroupBean = toGroupBean(subGroup); + setSubGroups(subGroup, subGroupBean); + groupBean.addGroup(subGroupBean); + } + } + + private static GroupBean toGroupBean(Group group) { + GroupBean groupBean = new GroupBean(); + groupBean.alias = group.getUniqueIdentifier(); + return groupBean; + } + + private static ApplicationBean applicationToBean(Application application) { + ApplicationBean applicationBean = new ApplicationBean(); + applicationBean.id = application.getUniqueIdentifier(); + return applicationBean; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index d8e5a40e42..668f9d60a9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -449,6 +449,16 @@ public Response getSubscriptionsOfApplication(@PathParam("application_id") Strin return Response.ok().entity(subscriptions).build(); } + + @GET + @Path("/application/{appId}") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response getApplicationInfo(@PathParam("appId") String applicationId) throws RestAPIException { + Object application = ServiceUtils.getApplicationInfo(applicationId, getConfigContext()); + return Response.status(Response.Status.NOT_FOUND).build(); + } + @GET @Path("/cartridge/list") @Produces("application/json") From 6804f41ae45cf3d59a8216543cbecb8e14fb7aeb Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 20 Oct 2014 17:43:39 +0530 Subject: [PATCH 212/436] getapplicationinfo rest api --- .../monitor/group/GroupMonitor.java | 1 - .../rest/endpoint/bean/ApplicationBean.java | 6 ++++ .../stratos/rest/endpoint/bean/GroupBean.java | 31 +++++++++++++++++-- .../rest/endpoint/bean/topology/Cluster.java | 2 +- .../rest/endpoint/services/ServiceUtils.java | 24 +++++++++++++- .../rest/endpoint/services/StratosAdmin.java | 6 +++- 6 files changed, 63 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 20dd003ad4..5129e34f55 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -91,7 +91,6 @@ protected void monitor(MonitorStatusEvent statusEvent) { log.error(e); } } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { - //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and //TODO need to send in_active for c1. When C1 in_active receives, get dependent and //TODO check whether dependent in_active. Then kill c1. diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java index 024664b74d..dbcbe9ccae 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java @@ -1,16 +1,22 @@ package org.apache.stratos.rest.endpoint.bean; +import org.apache.stratos.rest.endpoint.bean.topology.Cluster; + +import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; /** * Created by udara on 10/17/14. */ +@XmlRootElement(name="applications") public class ApplicationBean { public List groups = null; + public List clusters = null; public String id; public ApplicationBean(){ this.groups = new ArrayList(); + this.clusters = new ArrayList(); } public void addGroup(GroupBean groupBean) { this.groups.add(groupBean); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java index 77736bdc30..b79265ce1a 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java @@ -18,18 +18,43 @@ */ package org.apache.stratos.rest.endpoint.bean; +import org.apache.stratos.rest.endpoint.bean.topology.Cluster; + +import javax.xml.bind.annotation.XmlRootElement; import java.util.ArrayList; import java.util.List; +@XmlRootElement(name="groups") public class GroupBean { - List subGroups = null; + private List subGroups = null; + private List clusters = null; public String alias; public GroupBean(){ - this.subGroups = new ArrayList(); + this.setClusters(new ArrayList()); + this.setSubGroups(new ArrayList()); } public void addGroup(GroupBean groupBean){ - subGroups.add(groupBean); + getSubGroups().add(groupBean); + } + public void addCluster(Cluster cluster){ + getClusters().add(cluster); + } + + public List getSubGroups() { + return subGroups; + } + + public void setSubGroups(List subGroups) { + this.subGroups = subGroups; + } + + public List getClusters() { + return clusters; + } + + public void setClusters(List clusters) { + this.clusters = clusters; } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java index 6b8af54d2f..f2e5d730d1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/topology/Cluster.java @@ -21,7 +21,7 @@ import javax.xml.bind.annotation.XmlRootElement; import java.util.List; -@XmlRootElement +@XmlRootElement(name="clusters") public class Cluster { @Override diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index e29fb4cbd0..ff357b6549 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -52,6 +52,8 @@ import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.manager.utils.CartridgeConstants; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import org.apache.stratos.rest.endpoint.bean.ApplicationBean; @@ -66,6 +68,7 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; +import org.apache.stratos.rest.endpoint.bean.topology.*; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; @@ -1591,6 +1594,7 @@ public static Object getApplicationInfo(String applicationId, ConfigurationConte ClusterDataHolder clusterDataHolder = entry.getValue(); String clusterId = clusterDataHolder.getClusterId(); Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterDataHolder.getServiceType()).getCluster(clusterId); + applicationBean.clusters.add(toClusterBean(topLevelCluster)); } Collection groups = application.getGroups(); @@ -1600,18 +1604,30 @@ public static Object getApplicationInfo(String applicationId, ConfigurationConte applicationBean.addGroup(groupBean); } TopologyManager.releaseReadLock(); - return null; + return applicationBean; } private static void setSubGroups(Group group, GroupBean groupBean) { Collection subgroups = group.getGroups(); + addClustersToGroupBean(group, groupBean); for(Group subGroup : subgroups){ GroupBean subGroupBean = toGroupBean(subGroup); + setSubGroups(subGroup, subGroupBean); groupBean.addGroup(subGroupBean); } } + private static void addClustersToGroupBean(Group group, GroupBean groupBean) { + Map clustersDatamap = group.getClusterDataMap(); + for(Map.Entry x : clustersDatamap.entrySet()){ + String alias = x.getKey(); + ClusterDataHolder clusterHolder = x.getValue(); + Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterHolder.getServiceType()).getCluster(clusterHolder.getClusterId()); + groupBean.addCluster(toClusterBean(topLevelCluster)); + } + } + private static GroupBean toGroupBean(Group group) { GroupBean groupBean = new GroupBean(); groupBean.alias = group.getUniqueIdentifier(); @@ -1623,4 +1639,10 @@ private static ApplicationBean applicationToBean(Application application) { applicationBean.id = application.getUniqueIdentifier(); return applicationBean; } + + private static org.apache.stratos.rest.endpoint.bean.topology.Cluster toClusterBean(Cluster cluster){ + org.apache.stratos.rest.endpoint.bean.topology.Cluster clusterBean = new org.apache.stratos.rest.endpoint.bean.topology.Cluster(); + clusterBean.serviceName=cluster.getServiceName(); + return clusterBean; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 668f9d60a9..fe4a696673 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -456,7 +456,11 @@ public Response getSubscriptionsOfApplication(@PathParam("application_id") Strin @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getApplicationInfo(@PathParam("appId") String applicationId) throws RestAPIException { Object application = ServiceUtils.getApplicationInfo(applicationId, getConfigContext()); - return Response.status(Response.Status.NOT_FOUND).build(); + if(application == null) { + return Response.status(Response.Status.NOT_FOUND).build(); + }else{ + return Response.ok().entity(application).build(); + } } @GET From e75aaa3ec47670902958f5568bb43e3e35f13c18 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 20 Oct 2014 17:47:01 +0530 Subject: [PATCH 213/436] application status events, processors and listners --- .../grouping/topic/StatusEventPublisher.java | 10 ++ .../ApplicationStatusTopicReceiver.java | 39 +++++- .../controller/topology/TopologyBuilder.java | 121 +++++++++++++++++- .../topology/TopologyEventPublisher.java | 30 ++++- .../status/ApplicationCreatedEvent.java | 38 ++++++ .../status/ApplicationInactivatedEvent.java | 38 ++++++ .../status/ApplicationTerminatedEvent.java | 38 ++++++ .../status/ApplicationTerminatingEvent.java | 38 ++++++ .../topology/ApplicationInactivatedEvent.java | 34 +++++ .../topology/ApplicationTerminatedEvent.java | 34 +++++ .../topology/ApplicationTerminatingEvent.java | 34 +++++ .../ApplicationCreatedEventListener.java | 27 ++++ .../ApplicationInActivatedEventListener.java | 27 ++++ .../ApplicationTerminatedEventListener.java | 27 ++++ .../ApplicationTerminatingEventListener.java | 27 ++++ ...ationStatusAppCreatedMessageProcessor.java | 65 ++++++++++ ...nStatusAppInActivatedMessageProcessor.java | 65 ++++++++++ ...onStatusAppTerminatedMessageProcessor.java | 65 ++++++++++ ...nStatusAppTerminatingMessageProcessor.java | 65 ++++++++++ ...pplicationStatusMessageProcessorChain.java | 27 +++- 20 files changed, 835 insertions(+), 14 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index f8a2322f2f..4867b9ce51 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -111,6 +111,16 @@ public static void sendApplicationActivatedEvent(String appId) { publishEvent(applicationActivatedEvent); } + public static void sendApplicationInactivatedEvent(String appId){ + if (log.isInfoEnabled()) { + log.info("Publishing Application Inactivated event for [application]: " + appId); + } + + ApplicationInactivatedEvent applicationInActivatedEvent = new ApplicationInactivatedEvent(appId); + + publishEvent(applicationInActivatedEvent); + } + public static void sendGroupInMaintenanceEvent(String appId, String groupId) { if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 7cce18f676..cfcea8a7ff 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -22,10 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; -import org.apache.stratos.messaging.listener.application.status.ApplicationActivatedEventListener; +import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.listener.application.status.*; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; @@ -93,6 +91,39 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new ApplicationInActivatedEventListener() { + + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event); + + } + }); + + statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event); + + } + }); + + statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event); + + } + }); + + statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event); + + } + }); + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index b9fb5814a6..b54b203579 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -30,9 +30,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; -import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -668,8 +666,8 @@ public static synchronized void handleApplicationDeployed(Application applicatio TopologyManager.updateTopology(topology); log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully"); - - TopologyEventPublisher.sendApplicationCreatedEvent(application ,clusters); + org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters); + TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); } finally { TopologyManager.releaseWriteLock(); @@ -838,7 +836,7 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app applicationActivatedEvent.getAppId()); try { TopologyManager.acquireWriteLock(); - application.setTempStatus(Status.Activated); + application.setStatus(ApplicationStatus.Active); log.info("Application activated adding status started for Topology"); TopologyManager.updateTopology(topology); @@ -848,4 +846,115 @@ public static void handleApplicationActivatedEvent(ApplicationActivatedEvent app //publishing data TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); } + + public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent applicationActivatedEvent = + new org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent( + event.getAppId()); + try { + TopologyManager.acquireWriteLock(); + application.setStatus(ApplicationStatus.Inactive); + log.info("Application inactivated adding status started for Topology"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent); + } + + public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + List clusters = new ArrayList(); + Set allClusters = application.getClusterDataRecursively(); + + for(ClusterDataHolder clusterDataHolder : allClusters){ + String clusterId = clusterDataHolder.getClusterId(); + String serviceName = clusterDataHolder.getServiceType(); + clusters.add(TopologyManager.getTopology().getService(serviceName).getCluster(clusterId)); + } + org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationActivatedEvent = + new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent( + application, clusters); + try { + TopologyManager.acquireWriteLock(); + application.setStatus(ApplicationStatus.Created); + log.info("Application created adding status started for Topology"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent); + } + + public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent applicationTerminatingEvent = + new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent( + event.getAppId()); + try { + TopologyManager.acquireWriteLock(); + application.setStatus(ApplicationStatus.Terminating); + log.info("Application terminating adding status started for Topology"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendApplicationTerminatingEvent(applicationTerminatingEvent); + } + + public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent = + new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent( + event.getAppId()); + try { + TopologyManager.acquireWriteLock(); + application.setStatus(ApplicationStatus.Terminated); + log.info("Application terminated adding status started for Topology"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent); + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 2cb1eeb6c7..b3f60b9145 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -91,13 +91,13 @@ public static void sendClusterCreatedEvent(String serviceName, String clusterId, } - public static void sendApplicationCreatedEvent (Application application, List clusters) { + public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) { if(log.isInfoEnabled()) { - log.info("Publishing Application created event: " + application.toString()); + log.info("Publishing Application created event: " + applicationCreatedEvent.toString()); } - publishEvent(new ApplicationCreatedEvent(application, clusters)); + publishEvent(applicationCreatedEvent); } public static void sendApplicationRemovedEvent(String applicationId, Set clusterData, @@ -270,4 +270,28 @@ public static void publishEvent(Event event) { EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); eventPublisher.publish(event); } + + public static void sendApplicationInactivatedEvent(ApplicationInactivatedEvent applicationActivatedEvent1) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application in activated event: [appId] %s", + applicationActivatedEvent1.getAppId())); + } + publishEvent(applicationActivatedEvent1); + } + + public static void sendApplicationTerminatingEvent(ApplicationTerminatingEvent applicationTerminatingEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application terminating event: [appId] %s", + applicationTerminatingEvent.getAppId())); + } + publishEvent(applicationTerminatingEvent); + } + + public static void sendApplicationTerminatedEvent(ApplicationTerminatedEvent applicationTerminatedEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing application terminated event: [appId] %s", + applicationTerminatedEvent.getAppId())); + } + publishEvent(applicationTerminatedEvent); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java new file mode 100644 index 0000000000..f353067995 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java @@ -0,0 +1,38 @@ +/* + * 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.messaging.event.application.status; + +import java.io.Serializable; + +/** + * This event will be fired upon the application activated is detected. + */ +public class ApplicationCreatedEvent extends StatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String appId; + + public ApplicationCreatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java new file mode 100644 index 0000000000..ab0587c7d4 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java @@ -0,0 +1,38 @@ +/* + * 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.messaging.event.application.status; + +import java.io.Serializable; + +/** + * This event will be fired upon the application activated is detected. + */ +public class ApplicationInactivatedEvent extends StatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String appId; + + public ApplicationInactivatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java new file mode 100644 index 0000000000..16167e929a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java @@ -0,0 +1,38 @@ +/* + * 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.messaging.event.application.status; + +import java.io.Serializable; + +/** + * This event will be fired upon the application activated is detected. + */ +public class ApplicationTerminatedEvent extends StatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String appId; + + public ApplicationTerminatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java new file mode 100644 index 0000000000..bac610a784 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java @@ -0,0 +1,38 @@ +/* + * 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.messaging.event.application.status; + +import java.io.Serializable; + +/** + * This event will be fired upon the application activated is detected. + */ +public class ApplicationTerminatingEvent extends StatusEvent implements Serializable { + private static final long serialVersionUID = 2625412714611885089L; + + private String appId; + + public ApplicationTerminatingEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java new file mode 100644 index 0000000000..5d5bbfb69e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java @@ -0,0 +1,34 @@ +/* + * 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.messaging.event.topology; + +/** + * This event will be sent to Topology upon activation of application + */ +public class ApplicationInactivatedEvent extends TopologyEvent { + private String appId; + + public ApplicationInactivatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java new file mode 100644 index 0000000000..6c6ca7180b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -0,0 +1,34 @@ +/* + * 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.messaging.event.topology; + +/** + * This event will be sent to Topology upon activation of application + */ +public class ApplicationTerminatedEvent extends TopologyEvent { + private String appId; + + public ApplicationTerminatedEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java new file mode 100644 index 0000000000..98ef80016b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java @@ -0,0 +1,34 @@ +/* + * 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.messaging.event.topology; + +/** + * This event will be sent to Topology upon activation of application + */ +public class ApplicationTerminatingEvent extends TopologyEvent { + private String appId; + + public ApplicationTerminatingEvent(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java new file mode 100644 index 0000000000..cbeffa8c68 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will get triggered upon the application created event. + */ +public abstract class ApplicationCreatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java new file mode 100644 index 0000000000..378738e359 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will get triggered upon the application In activated event. + */ +public abstract class ApplicationInActivatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java new file mode 100644 index 0000000000..aacde3bb5a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will get triggered upon the application terminated event. + */ +public abstract class ApplicationTerminatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java new file mode 100644 index 0000000000..b35984b2dc --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will get triggered upon the application terminating event. + */ +public abstract class ApplicationTerminatingEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java new file mode 100644 index 0000000000..33f0a751d5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java @@ -0,0 +1,65 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by reka on 9/25/14. + */ +public class ApplicationStatusAppCreatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusAppCreatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + + } + + @Override + public boolean process(String type, String message, Object object) { + if (ApplicationCreatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ApplicationCreatedEvent event = + (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received ApplicationCreated Event in application status topic: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java new file mode 100644 index 0000000000..a4b4e3fcd5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java @@ -0,0 +1,65 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by reka on 9/25/14. + */ +public class ApplicationStatusAppInActivatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusAppInActivatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + + } + + @Override + public boolean process(String type, String message, Object object) { + if (ApplicationInactivatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ApplicationInactivatedEvent event = + (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java new file mode 100644 index 0000000000..74f082fb6c --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java @@ -0,0 +1,65 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by reka on 9/25/14. + */ +public class ApplicationStatusAppTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusAppTerminatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + + } + + @Override + public boolean process(String type, String message, Object object) { + if (ApplicationTerminatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ApplicationTerminatedEvent event = + (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java new file mode 100644 index 0000000000..2acbe58eb6 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java @@ -0,0 +1,65 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by reka on 9/25/14. + */ +public class ApplicationStatusAppTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusAppTerminatingMessageProcessor.class); + + + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + + } + + @Override + public boolean process(String type, String message, Object object) { + if (ApplicationTerminatingEvent.class.getName().equals(type)) { + // Parse complete message and build event + ApplicationTerminatingEvent event = + (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group activated message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index 809789bf3a..93f9558e07 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationActivatedEventListener; +import org.apache.stratos.messaging.listener.application.status.*; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; @@ -36,6 +36,10 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; + private ApplicationStatusAppCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; + private ApplicationStatusAppInActivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; + private ApplicationStatusAppTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; + private ApplicationStatusAppTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; public void initialize() { // Add instance notifier event processors @@ -46,6 +50,19 @@ public void initialize() { appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor(); add(appActivatedMessageProcessor); + applicationStatusAppCreatedMessageProcessor = new ApplicationStatusAppCreatedMessageProcessor(); + this.add(applicationStatusAppCreatedMessageProcessor); + + applicationStatusAppInActivatedMessageProcessor = new ApplicationStatusAppInActivatedMessageProcessor(); + this.add(applicationStatusAppInActivatedMessageProcessor); + + applicationStatusAppTerminatedMessageProcessor = new ApplicationStatusAppTerminatedMessageProcessor(); + this.add(applicationStatusAppTerminatedMessageProcessor); + + applicationStatusAppTerminatingMessageProcessor = new ApplicationStatusAppTerminatingMessageProcessor(); + this.add(applicationStatusAppTerminatingMessageProcessor); + + if (log.isDebugEnabled()) { log.debug("Instance notifier message processor chain initialized"); } @@ -58,6 +75,14 @@ public void addEventListener(EventListener eventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationInActivatedEventListener){ + applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationCreatedEventListener){ + applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationTerminatingEventListener){ + applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationTerminatedEventListener){ + applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); } else { throw new RuntimeException("Unknown event listener"); } From 5dae422f1c8e8006a07e32676782a999d545632b Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 20 Oct 2014 18:01:50 +0530 Subject: [PATCH 214/436] fixing formatin changes --- .../status/ApplicationCreatedEvent.java | 2 +- .../status/ApplicationInactivatedEvent.java | 2 +- .../status/ApplicationTerminatedEvent.java | 2 +- .../status/ApplicationTerminatingEvent.java | 2 +- .../event/topology/ApplicationCreatedEvent.java | 2 +- .../topology/ApplicationInactivatedEvent.java | 2 +- .../event/topology/ApplicationRemovedEvent.java | 16 ++++++++-------- .../topology/ApplicationTerminatedEvent.java | 2 +- .../topology/ApplicationTerminatingEvent.java | 2 +- .../ApplicationInActivatedEventListener.java | 2 +- ...licationStatusAppCreatedMessageProcessor.java | 4 +--- ...tionStatusAppInActivatedMessageProcessor.java | 4 +--- ...ationStatusAppTerminatedMessageProcessor.java | 4 +--- ...tionStatusAppTerminatingMessageProcessor.java | 4 +--- 14 files changed, 21 insertions(+), 29 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java index f353067995..b2f02e5b41 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationCreatedEvent.java @@ -21,7 +21,7 @@ import java.io.Serializable; /** - * This event will be fired upon the application activated is detected. + * This event will be fired upon the application created is detected. */ public class ApplicationCreatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java index ab0587c7d4..c082981e91 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationInactivatedEvent.java @@ -21,7 +21,7 @@ import java.io.Serializable; /** - * This event will be fired upon the application activated is detected. + * This event will be fired upon the application inactivated is detected. */ public class ApplicationInactivatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java index 16167e929a..27f7041070 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java @@ -21,7 +21,7 @@ import java.io.Serializable; /** - * This event will be fired upon the application activated is detected. + * This event will be fired upon the application terminated is detected. */ public class ApplicationTerminatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java index bac610a784..9d3f966ce3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java @@ -21,7 +21,7 @@ import java.io.Serializable; /** - * This event will be fired upon the application activated is detected. + * This event will be fired upon the application terminating is detected. */ public class ApplicationTerminatingEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index 23f115fd6e..90067d4409 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -30,7 +30,7 @@ public class ApplicationCreatedEvent extends TopologyEvent { private List clusterList; - public ApplicationCreatedEvent (Application application, List clusters) { + public ApplicationCreatedEvent(Application application, List clusters) { this.application = application; this.setClusterList(clusters); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java index 5d5bbfb69e..a2c287d2cc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; /** - * This event will be sent to Topology upon activation of application + * This event will be sent to Topology upon inactivation of application */ public class ApplicationInactivatedEvent extends TopologyEvent { private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java index 8b0f2cb171..67eff8ba7e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java @@ -27,17 +27,17 @@ public class ApplicationRemovedEvent extends TopologyEvent { /** - * - */ - private static final long serialVersionUID = -5499420725533165623L; - private String applicationId; + * + */ + private static final long serialVersionUID = -5499420725533165623L; + private String applicationId; private Set clusterData; private String tenantDomain; private int tenantId; - public ApplicationRemovedEvent (String applicationId, Set clusterData, - int tenantId, String tenantDomain) { + public ApplicationRemovedEvent(String applicationId, Set clusterData, + int tenantId, String tenantDomain) { this.applicationId = applicationId; this.clusterData = clusterData; this.tenantId = tenantId; @@ -47,11 +47,11 @@ public ApplicationRemovedEvent (String applicationId, Set clu public String getApplicationId() { return applicationId; } - + public int getTenantId() { return tenantId; } - + public String getTenantDomain() { return tenantDomain; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java index 6c6ca7180b..493ddfa20c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; /** - * This event will be sent to Topology upon activation of application + * This event will be sent to Topology upon termination of application */ public class ApplicationTerminatedEvent extends TopologyEvent { private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java index 98ef80016b..f5887c3c1c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; /** - * This event will be sent to Topology upon activation of application + * This event will be sent to Topology upon terminating of application */ public class ApplicationTerminatingEvent extends TopologyEvent { private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java index 378738e359..eecf941774 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java @@ -21,7 +21,7 @@ import org.apache.stratos.messaging.listener.EventListener; /** - * This listener will get triggered upon the application In activated event. + * This listener will get triggered upon the application inactivated event. */ public abstract class ApplicationInActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java index 33f0a751d5..66448ac5e7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java @@ -24,15 +24,13 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -/** - * Created by reka on 9/25/14. - */ public class ApplicationStatusAppCreatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationStatusAppCreatedMessageProcessor.class); private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java index a4b4e3fcd5..20e0e129c0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java @@ -24,15 +24,13 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -/** - * Created by reka on 9/25/14. - */ public class ApplicationStatusAppInActivatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationStatusAppInActivatedMessageProcessor.class); private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java index 74f082fb6c..ad5565a513 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java @@ -24,15 +24,13 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -/** - * Created by reka on 9/25/14. - */ public class ApplicationStatusAppTerminatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationStatusAppTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java index 2acbe58eb6..2ace24b680 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java @@ -24,15 +24,13 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -/** - * Created by reka on 9/25/14. - */ public class ApplicationStatusAppTerminatingMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationStatusAppTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; From ad31e2a16cd24069c6b17e4fb977089eaeecc37a Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 20 Oct 2014 18:12:16 +0530 Subject: [PATCH 215/436] making appId final in events --- .../messaging/event/topology/ApplicationActivatedEvent.java | 2 +- .../messaging/event/topology/ApplicationCreatedEvent.java | 2 +- .../messaging/event/topology/ApplicationInactivatedEvent.java | 2 +- .../messaging/event/topology/ApplicationRemovedEvent.java | 2 +- .../messaging/event/topology/ApplicationTerminatedEvent.java | 2 +- .../messaging/event/topology/ApplicationTerminatingEvent.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java index 64417c7ecc..2d825f74af 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationActivatedEvent.java @@ -22,7 +22,7 @@ * This event will be sent to Topology upon activation of application */ public class ApplicationActivatedEvent extends TopologyEvent { - private String appId; + private final String appId; public ApplicationActivatedEvent(String appId) { this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index 90067d4409..425dd47288 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -26,7 +26,7 @@ public class ApplicationCreatedEvent extends TopologyEvent { - private Application application; + private final Application application; private List clusterList; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java index a2c287d2cc..d81dc555f8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationInactivatedEvent.java @@ -22,7 +22,7 @@ * This event will be sent to Topology upon inactivation of application */ public class ApplicationInactivatedEvent extends TopologyEvent { - private String appId; + private final String appId; public ApplicationInactivatedEvent(String appId) { this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java index 67eff8ba7e..3d5b9a40fd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java @@ -30,7 +30,7 @@ public class ApplicationRemovedEvent extends TopologyEvent { * */ private static final long serialVersionUID = -5499420725533165623L; - private String applicationId; + private final String applicationId; private Set clusterData; private String tenantDomain; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java index 493ddfa20c..441b9025d8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -22,7 +22,7 @@ * This event will be sent to Topology upon termination of application */ public class ApplicationTerminatedEvent extends TopologyEvent { - private String appId; + private final String appId; public ApplicationTerminatedEvent(String appId) { this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java index f5887c3c1c..e1fbc026a9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java @@ -22,7 +22,7 @@ * This event will be sent to Topology upon terminating of application */ public class ApplicationTerminatingEvent extends TopologyEvent { - private String appId; + private final String appId; public ApplicationTerminatingEvent(String appId) { this.appId = appId; From 297864957c2bc7369a7edefc84ddf2513205f101 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 20 Oct 2014 19:09:46 +0530 Subject: [PATCH 216/436] adding a debug log to print all states transitioned --- .../domain/topology/lifecycle/LifeCycleStateManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index edb4cb101a..c52d7a2396 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -59,6 +59,15 @@ public boolean isPreConditionsValid (T nextState, S to * @return true if transitioning for nextState from current state is valid, else false */ public boolean isStateTransitionValid (T nextState) { + if (log.isDebugEnabled()) { + // print all transitions till now + StringBuilder stateTransitions = new StringBuilder("Transitioned States: [ START --> "); + for (int i = 0 ; i < stateStack.size() ; i++) { + stateTransitions.append(stateStack.get(i) + " --> "); + } + stateTransitions.append(" END ]"); + log.debug(stateTransitions); + } return stateStack.peek().getNextStates().contains(nextState); } From 6e723749f4ece9a680a85f864587be757f597e94 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 21 Oct 2014 10:12:37 +0530 Subject: [PATCH 217/436] adding support for in_active status changes in monitor --- .../grouping/dependency/DependencyTree.java | 19 +++ .../grouping/topic/StatusEventPublisher.java | 12 +- .../AutoscalerTopologyEventReceiver.java | 20 +++- .../monitor/AbstractClusterMonitor.java | 13 ++ .../autoscaler/monitor/EventHandler.java | 16 +++ .../stratos/autoscaler/monitor/Monitor.java | 10 ++ .../monitor/ParentComponentMonitor.java | 4 +- .../application/ApplicationMonitor.java | 12 ++ .../events/GroupTerminateAllEvent.java | 29 +++++ .../monitor/events/MonitorEvent.java | 31 +++++ .../monitor/events/MonitorScalingEvent.java | 30 +++++ .../monitor/events/MonitorStatusEvent.java | 5 +- .../events/MonitorTerminateAllEvent.java | 29 +++++ .../monitor/group/GroupMonitor.java | 82 ++++++++----- .../status/checker/StatusChecker.java | 113 +++++++++++++----- 15 files changed, 357 insertions(+), 68 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupTerminateAllEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorScalingEvent.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorTerminateAllEvent.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index e4f214eb3a..642a40ad41 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -104,6 +104,25 @@ private ApplicationContext findApplicationContextWithId(String id, List contexts) { + for (ApplicationContext context : contexts) { + //TODO check for the status + if (context.getId().equals(id)) { + return parent; + } + } + //if not found in the top level search recursively + for (ApplicationContext context : this.applicationContextList) { + return findParentContextWithId(context, id, context.getApplicationContextList()); + } + return null; + } /** * Getting the next start able dependencies upon the activate event * received for a group/cluster which is part of this tree. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 4867b9ce51..abc03df59c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -6,7 +6,13 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; import org.apache.stratos.messaging.util.Constants; /** @@ -95,9 +101,9 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { " [group]: " + groupId); } - /*GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId); + GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); - publishEvent(groupActivatedEvent);*/ + publishEvent(groupInActivateEvent); } public static void sendApplicationActivatedEvent(String appId) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 6cb186e104..c5095e3c4f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -141,7 +141,6 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterActivatedEvent] Received: " + event.getClass()); ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; @@ -158,6 +157,25 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + + ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; + String clusterId = clusterCreatedEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(ClusterStatus.Created); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 487e8be84b..3e630fabfe 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -23,7 +23,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; @@ -258,4 +260,15 @@ public void setParent(ParentComponentMonitor parent) { public void onEvent(MonitorStatusEvent statusEvent) { } + + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { + + } + } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java index b1ba90f227..e4eb816d25 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java @@ -18,7 +18,9 @@ */ package org.apache.stratos.autoscaler.monitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; /** * Event Handler to notify the observer/to receive notification @@ -30,4 +32,18 @@ public interface EventHandler { * @param statusEvent */ public abstract void onEvent(MonitorStatusEvent statusEvent); + + /** + * Triggered when termination decision is made. + * + * @param terminateAllEvent + */ + public abstract void onEvent(MonitorTerminateAllEvent terminateAllEvent); + + /** + * Triggered when scaling decision is made. + * + * @param scalingEvent + */ + public abstract void onEvent(MonitorScalingEvent scalingEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index a0f1d986a6..3276c47ee6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -35,6 +35,8 @@ public abstract class Monitor implements EventHandler { //monitors map, stopped monitors protected Map aliasToInActiveMonitorsMap; + protected boolean killChildren; + public String getId() { return id; } @@ -67,4 +69,12 @@ public ParentComponentMonitor getParent() { public void setParent(ParentComponentMonitor parent) { this.parent = parent; } + + public boolean hasMonitors() { + boolean hasMonitor = false; + if(this.aliasToActiveMonitorsMap != null ) { + hasMonitor = true; + } + return hasMonitor; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 08f23769f9..994897697c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -42,11 +42,11 @@ public abstract class ParentComponentMonitor extends Monitor { private static final Log log = LogFactory.getLog(ParentComponentMonitor.class); //id of the monitor, it can be alias or the id - protected String id; + //protected String id; //The monitors dependency tree with all the startable/killable dependencies protected DependencyTree dependencyTree; //Application id of this particular monitor - protected String appId; + //protected String appId; public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException { aliasToActiveMonitorsMap = new HashMap(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index c3c7459658..3e8057084b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -26,7 +26,9 @@ import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.ApplicationStatus; @@ -161,6 +163,16 @@ public void onEvent(MonitorStatusEvent statusEvent) { monitor(statusEvent); } + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { + + } + @Override protected void monitor(MonitorStatusEvent statusEvent) { /*ApplicationContext context = this.dependencyTree. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupTerminateAllEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupTerminateAllEvent.java new file mode 100644 index 0000000000..0fdf9e3db9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupTerminateAllEvent.java @@ -0,0 +1,29 @@ +/* + * 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.autoscaler.monitor.events; + +/** + * This will handle the termination of all groups/clusters of a group. + */ +public class GroupTerminateAllEvent extends MonitorTerminateAllEvent { + + public GroupTerminateAllEvent(String id) { + super(id); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java new file mode 100644 index 0000000000..a733a0eed4 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java @@ -0,0 +1,31 @@ +/* + * 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.autoscaler.monitor.events; + +/** + * Created by reka on 10/20/14. + */ +public abstract class MonitorEvent { + protected String id; + + public MonitorEvent(String id) { + this.id = id; + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorScalingEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorScalingEvent.java new file mode 100644 index 0000000000..ce7b311b3f --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorScalingEvent.java @@ -0,0 +1,30 @@ +/* + * 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.autoscaler.monitor.events; + +/** + * This is to handle scaling of the monitors + */ +public abstract class MonitorScalingEvent extends MonitorEvent { + + public MonitorScalingEvent(String id) { + super(id); + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java index d4af749343..7d2f480667 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStatusEvent.java @@ -23,11 +23,10 @@ /** * Monitor Status Event */ -public abstract class MonitorStatusEvent { - protected String id; +public abstract class MonitorStatusEvent extends MonitorEvent { public MonitorStatusEvent(String id) { - this.setId(id); + super(id); } public String getId() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorTerminateAllEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorTerminateAllEvent.java new file mode 100644 index 0000000000..86efc7edd9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorTerminateAllEvent.java @@ -0,0 +1,29 @@ +/* + * 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.autoscaler.monitor.events; + +/** + * This will be used to terminate all the instances of the cluster/group. + */ +public class MonitorTerminateAllEvent extends MonitorEvent { + + public MonitorTerminateAllEvent(String id) { + super(id); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 5129e34f55..54c37e97a5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -23,10 +23,11 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.monitor.EventHandler; -import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; -import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; +import org.apache.stratos.autoscaler.monitor.*; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Group; @@ -65,6 +66,16 @@ public void onEvent(MonitorStatusEvent statusEvent) { monitor(statusEvent); } + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { + + } + @Override protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); @@ -96,53 +107,66 @@ protected void monitor(MonitorStatusEvent statusEvent) { //TODO check whether dependent in_active. Then kill c1. //evaluate termination behavior and take action based on that. - List terminationList = new ArrayList(); + List terminationList; + Monitor monitor; terminationList = this.dependencyTree.getTerminationDependencies(id); + //Temporarily move the group/cluster to inactive list + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); if (terminationList != null) { //Move to in_active monitors list - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); boolean allInActive = false; //check whether all the children are in_active state for (ApplicationContext terminationContext : terminationList) { //Check for whether all dependent are in_active if (this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { - allInActive = true; + monitor = this.aliasToInActiveMonitorsMap. + get(terminationContext.getId()); + //start to kill it + monitor.onEvent(new MonitorTerminateAllEvent(terminationContext.getId())); + } else { - allInActive = false; + monitor = this.aliasToActiveMonitorsMap. + get(terminationContext.getId()); + if(monitor.hasMonitors()) { + //it is a group + StatusEventPublisher.sendGroupInActivateEvent(this.appId, terminationContext.getId()); + } else { + StatusEventPublisher.sendClusterInActivateEvent(this.appId, + ((AbstractClusterMonitor)monitor).getServiceId(), terminationContext.getId()); + + } + } } if (allInActive) { //Then kill-all of each termination dependents and get a lock for CM - //if start order then can kill only the first one, rest of them will get killed based on created event of first one. + //if start order then can kill only the first one, + // rest of them will get killed based on created event of first one. } - } - + } else { + //find any other immediate dependent which is in_active/created state + ApplicationContext context1 = this.dependencyTree.findParentContextWithId(id); + if(context1 != null) { + if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + monitor = this.aliasToInActiveMonitorsMap.get(id); + //killall + monitor.onEvent(new MonitorTerminateAllEvent(id)); + } else { + monitor = this.aliasToActiveMonitorsMap.get(context1.getId()); + } + } else { + //Independent monitor + } + } + //To update the status of the Group + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - /*if(terminationList != null && !terminationList.isEmpty()) { - for(ApplicationContext context1 : terminationList) { - if(context1 instanceof ClusterContext) { - AbstractClusterMonitor monitor = this.clusterIdToClusterMonitorsMap. - get(context1.getId()); - //Whether life cycle change to Created - if(monitor.getStatus() == Status.Created) { - canTerminate = true; - } else { - //TODO sending group in_active event to dependent cluster/group - StatusEventPublisher.sendGroupActivatedEvent(this.appId, this.id); - //not all dependent clusters are in created state. - canTerminate = false; - } - } - } - if(canTerminate) { - // - }*/ } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { //TODO get dependents List dependents = this.dependencyTree.getTerminationDependencies(id); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index f8d1601cfc..de6f261c19 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -125,7 +125,7 @@ public void onMemberFaultEvent(final String clusterId, final String appId, final if (clusterInActive) { //TODO evaluate life cycle //send cluster In-Active event to cluster status topic - StatusEventPublisher.sendGroupInActivateEvent(appId, monitor.getParent().getId()); + StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId); } else { boolean clusterActive = clusterActive(monitor); @@ -230,8 +230,8 @@ public void run() { private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { boolean groupActive = false; - boolean clustersActive; - boolean groupsActive; + ClusterStatus clustersActive; + GroupStatus groupsActive; boolean childFound = false; boolean clusterFound = false; @@ -243,41 +243,71 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("cluster found: " + clusterFound); if (clusterFound || groups.containsKey(id)) { childFound = true; - if (!clusterData.isEmpty() && !groups.isEmpty()) { + /*if (!clusterData.isEmpty() && !groups.isEmpty()) { if (log.isDebugEnabled()) { log.debug("group active found: " + clusterFound); } - clustersActive = getClusterStatus(clusterData); - groupsActive = getGroupStatus(groups); + if (log.isDebugEnabled()) { log.debug("Active cluster" + clustersActive + " and group: " + groupActive); } - groupActive = clustersActive && groupsActive; + groupActive = clustersActive == ClusterStatus.Active && groupsActive == GroupStatus.Active; } else if (!groups.isEmpty()) { groupsActive = getGroupStatus(groups); if (log.isDebugEnabled()) { log.info("group active found: " + clusterFound); } - groupActive = groupsActive; + groupActive = groupsActive == GroupStatus.Active; } else if (!clusterData.isEmpty()) { clustersActive = getClusterStatus(clusterData); if (log.isDebugEnabled()) { log.debug("Active cluster" + clustersActive + " and group: " + groupActive); } - groupActive = clustersActive; + groupActive = clustersActive == ClusterStatus.Active; + } */ + + clustersActive = getClusterStatus(clusterData); + groupsActive = getGroupStatus(groups); + + if (groupsActive == null && clustersActive == ClusterStatus.Active || + clustersActive == null && groupsActive == GroupStatus.Active || + groupsActive == GroupStatus.Active && clustersActive == ClusterStatus.Active) { + //send activation event + if (parent instanceof Application) { + //send application activated event + log.info("sending app activate found: " + appId); + StatusEventPublisher.sendApplicationActivatedEvent(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group activate found: " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groupsActive == null && clustersActive == ClusterStatus.Inactive || + clustersActive == null && groupsActive == GroupStatus.Inactive || + groupsActive == GroupStatus.Inactive && clustersActive == ClusterStatus.Inactive) { + //send the in activation event + if (parent instanceof Application) { + //send application activated event + log.info("sending app in-active found: " + appId); + StatusEventPublisher.sendApplicationInActivatedEvent(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group in-active found: " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groupsActive == null && clustersActive == ClusterStatus.Terminating || + clustersActive == null && groupsActive == GroupStatus.Terminating || + groupsActive == GroupStatus.Terminating && clustersActive == ClusterStatus.Terminating) { + //send the terminating event + } else if (groupsActive == null && clustersActive == ClusterStatus.Terminated || + clustersActive == null && groupsActive == GroupStatus.Terminated || + groupsActive == GroupStatus.Terminated && clustersActive == ClusterStatus.Terminated) { + //send the terminated event } else { log.warn("Clusters/groups not found in this [component] " + appId); } - //send the activation event - if (parent instanceof Application && groupActive) { - //send application activated event - log.info("sending app activate found: " + appId); - StatusEventPublisher.sendApplicationActivatedEvent(appId); - } else if (parent instanceof Group && groupActive) { - //send activation to the parent - log.info("sending group activate found: " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); - } + + return childFound; } else { log.warn("There is no child found in the [group/cluster] " + id + " found in the " + @@ -286,33 +316,56 @@ private boolean updateChildStatus(String appId, String id, Map gr return childFound; } - private boolean getGroupStatus(Map groups) { + private GroupStatus getGroupStatus(Map groups) { boolean groupActiveStatus = false; + GroupStatus status = null; + for (Group group : groups.values()) { - if (group.getTempStatus() == Status.Activated) { + /*if (group.getTempStatus() == Status.Activated) { groupActiveStatus = true; } else { groupActiveStatus = false; break; + }*/ + + if (group.getStatus() == GroupStatus.Active) { + status = GroupStatus.Active; + } else if(group.getStatus() == GroupStatus.Inactive){ + status = GroupStatus.Inactive; + break; + } else if(group.getStatus() == GroupStatus.Created) { + status = GroupStatus.Created; + } else if(group.getStatus() == GroupStatus.Terminating) { + status = GroupStatus.Terminating; + break; + } else if(group.getStatus() == GroupStatus.Terminated) { + status = GroupStatus.Terminated; } } - return groupActiveStatus; + return status; } - private boolean getClusterStatus(Map clusterData) { - boolean clusterActiveStatus = false; + private ClusterStatus getClusterStatus(Map clusterData) { + ClusterStatus status = null; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); - if (service.getCluster(clusterDataHolderEntry.getValue().getClusterId()). - getStatus() == ClusterStatus.Active) { - clusterActiveStatus = true; - } else { - clusterActiveStatus = false; + Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); + if (cluster.getStatus() == ClusterStatus.Active) { + status = ClusterStatus.Active; + } else if(cluster.getStatus() == ClusterStatus.Inactive){ + status = ClusterStatus.Inactive; + break; + } else if(cluster.getStatus() == ClusterStatus.Created) { + status = ClusterStatus.Created; + } else if(cluster.getStatus() == ClusterStatus.Terminating) { + status = ClusterStatus.Terminating; break; + } else if(cluster.getStatus() == ClusterStatus.Terminated) { + status = ClusterStatus.Terminated; } } - return clusterActiveStatus; + return status; } private static class Holder { From 06e1e9ffb25cc0e538a4009aa8318af614b845f3 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 21 Oct 2014 10:13:11 +0530 Subject: [PATCH 218/436] updating the cluster created event --- .../event/topology/ClusterCreatedEvent.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java index 5d51ab8ffb..70452ab6c4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java @@ -28,35 +28,31 @@ public class ClusterCreatedEvent extends TopologyEvent implements Serializable { private static final long serialVersionUID = 2080623816272047762L; - private final String serviceName; + private final String appId; + private final String serviceName; private final String clusterId; - private Cluster cluster; - public ClusterCreatedEvent(String serviceName, String clusterId, Cluster cluster) { + public ClusterCreatedEvent(String appId, String serviceName, String clusterId) { + this.appId = appId; this.serviceName = serviceName; this.clusterId = clusterId; - this.cluster = cluster; } - public Cluster getCluster() { - return cluster; - } - - public void setCluster(Cluster cluster) { - this.cluster = cluster; - } - public String getServiceName() { return serviceName; } @Override public String toString() { - return "ClusterCreatedEvent [serviceName=" + serviceName + ", cluster=" + cluster + "]"; + return "ClusterCreatedEvent [serviceName=" + serviceName + ", application=" + appId + "]"; } public String getClusterId() { return clusterId; } + + public String getAppId() { + return appId; + } } From 9b31646b176601edf8f78c3bac89597103cbb347 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 21 Oct 2014 10:21:52 +0530 Subject: [PATCH 219/436] a print utility method for LifeCycleStateManager --- .../lifecycle/LifeCycleStateManager.java | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index c52d7a2396..0f627a8a08 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -59,15 +59,7 @@ public boolean isPreConditionsValid (T nextState, S to * @return true if transitioning for nextState from current state is valid, else false */ public boolean isStateTransitionValid (T nextState) { - if (log.isDebugEnabled()) { - // print all transitions till now - StringBuilder stateTransitions = new StringBuilder("Transitioned States: [ START --> "); - for (int i = 0 ; i < stateStack.size() ; i++) { - stateTransitions.append(stateStack.get(i) + " --> "); - } - stateTransitions.append(" END ]"); - log.debug(stateTransitions); - } + return stateStack.peek().getNextStates().contains(nextState); } @@ -77,7 +69,11 @@ public boolean isStateTransitionValid (T nextState) { * @param nextState */ public void changeState (T nextState) { + stateStack.push(nextState); + if (log.isDebugEnabled()) { + printStateTransitions(stateStack); + } log.info("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " + getCurrentState() + " ]"); } @@ -108,4 +104,18 @@ public T getCurrentState () { public T getPreviousState () { return stateStack.get(1); } + + /** + * Print utility to print transitioned states + */ + private static void printStateTransitions (Stack stateStack) { + + // print all transitions till now + StringBuilder stateTransitions = new StringBuilder("Transitioned States: [ START --> "); + for (int i = 0 ; i < stateStack.size() ; i++) { + stateTransitions.append(stateStack.get(i) + " --> "); + } + stateTransitions.append(" END ]"); + log.debug(stateTransitions); + } } From 50e9e69b2c893ae8f2c989f5ea674de4bd1353e1 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 21 Oct 2014 15:45:10 +0530 Subject: [PATCH 220/436] adding recovery support for the monitors --- .../grouping/dependency/DependencyTree.java | 14 ++ .../grouping/topic/StatusEventPublisher.java | 48 +++++ .../monitor/AbstractClusterMonitor.java | 10 +- .../monitor/ApplicationMonitorFactory.java | 41 ++-- .../stratos/autoscaler/monitor/Monitor.java | 14 +- .../monitor/ParentComponentMonitor.java | 2 - .../application/ApplicationMonitor.java | 9 +- .../monitor/cluster/ClusterMonitor.java | 11 +- .../monitor/events/MonitorStartAllEvent.java | 28 +++ .../monitor/group/GroupMonitor.java | 177 +++++++++--------- .../status/checker/StatusChecker.java | 2 +- .../ClusterCreatedMessageProcessor.java | 8 +- 12 files changed, 244 insertions(+), 120 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStartAllEvent.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 642a40ad41..6dbbce3548 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -108,6 +108,20 @@ public ApplicationContext findParentContextWithId(String id) { return findParentContextWithId(null, id, this.applicationContextList); } + public List findAllParentContextWithId(String id) { + List applicationContexts = new ArrayList(); + return findAllParent(applicationContexts, id); + } + + private List findAllParent(List parentContexts, String id) { + ApplicationContext context = findParentContextWithId(null, id, this.applicationContextList); + if(context != null) { + parentContexts.add(context); + findAllParent(parentContexts, context.getId()); + } + return parentContexts; + } + private ApplicationContext findParentContextWithId(ApplicationContext parent, String id, List contexts) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index abc03df59c..2ffff81ddf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -58,6 +58,30 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, publishEvent(clusterActivatedEvent);*/ } + public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Cluster in-activate event for [application]: " + appId + + " [cluster]: " + clusterId); + } + + /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterActivatedEvent);*/ + } + + public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Cluster in-activate event for [application]: " + appId + + " [cluster]: " + clusterId); + } + + /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterActivatedEvent);*/ + } + public static void sendClusterInMaintenanceEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { @@ -106,6 +130,30 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { publishEvent(groupInActivateEvent); } + public static void sendGroupTerminatingEvent(String appId, String groupId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Group terminating event for [application]: " + appId + + " [group]: " + groupId); + } + + GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); + + publishEvent(groupInActivateEvent); + } + + public static void sendGroupTerminatedEvent(String appId, String groupId) { + + if (log.isInfoEnabled()) { + log.info("Publishing Group terminated event for [application]: " + appId + + " [group]: " + groupId); + } + + GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); + + publishEvent(groupInActivateEvent); + } + public static void sendApplicationActivatedEvent(String appId) { if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 3e630fabfe..beee67ad42 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -242,8 +242,14 @@ public void setStatus(ClusterStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", clusterId, this.status, status)); this.status = status; - //notifying the parent monitor about the state change - MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + /** + * notifying the parent monitor about the state change + * If the cluster in_active and if it is a in_dependent cluster, + * then won't send the notification to parent. + */ + if(status == ClusterStatus.Inactive && !this.hasDependent) { + MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index bfc7bbb5bc..6d8f2a300f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -73,7 +73,7 @@ public static Monitor getMonitor(ParentComponentMonitor parentMonitor, Applicati Monitor monitor; if (context instanceof GroupContext) { - monitor = getGroupMonitor(parentMonitor, context.getId(), appId); + monitor = getGroupMonitor(parentMonitor, context, appId); } else if (context instanceof ClusterContext) { monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId); //Start the thread @@ -89,29 +89,36 @@ public static Monitor getMonitor(ParentComponentMonitor parentMonitor, Applicati * This will create the GroupMonitor based on given groupId by going thr Topology * * @param parentMonitor parent of the monitor - * @param groupId groupId of the group + * @param context groupId of the group * @param appId appId of the relevant application * @return Group monitor * @throws DependencyBuilderException throws while building dependency for app monitor * @throws TopologyInConsistentException throws while traversing thr topology */ - public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, String groupId, String appId) + public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId) throws DependencyBuilderException, TopologyInConsistentException { GroupMonitor groupMonitor; TopologyManager.acquireReadLockForApplication(appId); try { - Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(groupId); + Group group = TopologyManager.getTopology().getApplication(appId).getGroupRecursively(context.getId()); groupMonitor = new GroupMonitor(group, appId); groupMonitor.setAppId(appId); - groupMonitor.setParent(parentMonitor); - //TODO - /*if (group.getTempStatus() != groupMonitor.getStatus()) { - //updating the status, if the group is not in created state when creating group Monitor - //so that groupMonitor will notify the parent (useful when restarting stratos) - groupMonitor.setStatus(group.getTempStatus()); - }*/ + if(parentMonitor != null) { + groupMonitor.setParent(parentMonitor); + if(!parentMonitor.isHasDependent() && !context.hasChild()) { + groupMonitor.setHasDependent(true); + } + //TODO make sure when it is async + + if (group.getStatus() != groupMonitor.getStatus()) { + //updating the status, if the group is not in created state when creating group Monitor + //so that groupMonitor will notify the parent (useful when restarting stratos) + groupMonitor.setStatus(group.getStatus()); + } + } + } finally { TopologyManager.releaseReadLockForApplication(appId); @@ -284,17 +291,21 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); clusterMonitor.setParent(parentMonitor); + if(!parentMonitor.isHasDependent() && !context.hasChild()) { + clusterMonitor.setHasDependent(true); + } //clusterMonitor.setCurrentStatus(Status.Created); if (log.isInfoEnabled()) { log.info(String.format("Network partition context has been added: [network partition] %s", networkPartitionContext.getId())); } } - //TODO - /*if (cluster.getTempStatus() != clusterMonitor.getStatus()) { + //TODO to make sure when group monitor is async + //if cluster is not in created state then notify the parent monitor + if (cluster.getStatus() != clusterMonitor.getStatus()) { //updating the status, so that it will notify the parent - clusterMonitor.setStatus(cluster.getTempStatus()); - }*/ + clusterMonitor.setStatus(cluster.getStatus()); + } } finally { //release read lock for the service and cluster TopologyManager.releaseReadLockForCluster(serviceName, clusterId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 3276c47ee6..b670077632 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -34,8 +34,11 @@ public abstract class Monitor implements EventHandler { protected Map aliasToActiveMonitorsMap; //monitors map, stopped monitors protected Map aliasToInActiveMonitorsMap; + //flag will get set to true in MonitorTerminateAllEvent when termination of + // this monitor decided by its parent + protected boolean terminateChildren = false; - protected boolean killChildren; + protected boolean hasDependent; public String getId() { return id; @@ -45,7 +48,6 @@ public void setId(String id) { this.id = id; } - public String getAppId() { return appId; } @@ -77,4 +79,12 @@ public boolean hasMonitors() { } return hasMonitor; } + + public boolean isHasDependent() { + return hasDependent; + } + + public void setHasDependent(boolean hasDependent) { + this.hasDependent = hasDependent; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 994897697c..0d64e3e447 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -106,8 +106,6 @@ private boolean startDependency(List applicationContexts) if(!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { //to avoid if it is already started startMonitor(this, context); - } else if(this.aliasToInActiveMonitorsMap.containsKey(context.getId())) { - //need to trigger the cluster monitor } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 3e8057084b..7befc2b4e2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -50,6 +50,7 @@ public ApplicationMonitor(Application application) throws DependencyBuilderExcep super(application); //setting the appId for the application this.appId = application.getUniqueIdentifier(); + this.status = application.getStatus(); //starting the first set of dependencies from its children startDependency(); @@ -120,8 +121,12 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { * @return the found GroupMonitor */ public Monitor findGroupMonitorWithId(String groupId) { - return findGroupMonitor(groupId, aliasToActiveMonitorsMap.values()); - + Monitor monitor; + monitor = findGroupMonitor(groupId, aliasToActiveMonitorsMap.values()); + if(monitor == null) { + monitor = findGroupMonitor(groupId, aliasToInActiveMonitorsMap.values()); + } + return monitor; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 6043b5cdf2..a129d182d2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -71,20 +71,13 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo @Override public void run() { - - /*try { - // TODO make this configurable(**Remove this as LB will be a seperate monitor), - // this is the delay the min check of normal cluster monitor to wait until LB monitor is added - Thread.sleep(60000); - } catch (InterruptedException ignore) { - }*/ - //this.status = Status.Running; while (!isDestroyed()) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } try { - if (!ClusterStatus.Inactive.equals(status)) { + if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || + (this.status == ClusterStatus.Inactive && !hasDependent)) { monitor(); } else { if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStartAllEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStartAllEvent.java new file mode 100644 index 0000000000..21f83ece91 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorStartAllEvent.java @@ -0,0 +1,28 @@ +/* + * 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.autoscaler.monitor.events; + +/** + * This will use to start the child monitors + */ +public class MonitorStartAllEvent extends MonitorEvent { + public MonitorStartAllEvent(String id) { + super(id); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 54c37e97a5..f278fb685a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -57,7 +57,7 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException TopologyInConsistentException { super(group); this.appId = appId; - //TODO this.setStatus(group.getTempStatus()); + this.setStatus(group.getStatus()); startDependency(); } @@ -68,6 +68,7 @@ public void onEvent(MonitorStatusEvent statusEvent) { @Override public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + this.terminateChildren = true; } @@ -82,30 +83,27 @@ protected void monitor(MonitorStatusEvent statusEvent) { LifeCycleState status1 = statusEvent.getStatus(); ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination - //TODO if statusEvent is for active, then start the next one if any available if (!isParent(id)) { if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { try { - //if life cycle is empty, need to start the monitor + //if the activated monitor is in in_active map move it to active map + if(this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id)); + } boolean startDep = startDependency(statusEvent.getId()); if (log.isDebugEnabled()) { log.debug("started a child: " + startDep + " by the group/cluster: " + id); } - //updating the life cycle and current status if (!startDep) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); } - } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription log.error(e); } + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { - //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and - //TODO need to send in_active for c1. When C1 in_active receives, get dependent and - //TODO check whether dependent in_active. Then kill c1. - //evaluate termination behavior and take action based on that. List terminationList; Monitor monitor; @@ -114,105 +112,116 @@ protected void monitor(MonitorStatusEvent statusEvent) { this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); if (terminationList != null) { - //Move to in_active monitors list - boolean allInActive = false; - //check whether all the children are in_active state + //Checking the termination dependents status for (ApplicationContext terminationContext : terminationList) { - //Check for whether all dependent are in_active - if (this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { - monitor = this.aliasToInActiveMonitorsMap. - get(terminationContext.getId()); - //start to kill it - monitor.onEvent(new MonitorTerminateAllEvent(terminationContext.getId())); - + //Check whether dependent is in_active, then start to kill it + monitor = this.aliasToActiveMonitorsMap. + get(terminationContext.getId()); + //start to kill it + if(monitor.hasMonitors()) { + //it is a group + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); } else { - monitor = this.aliasToActiveMonitorsMap. - get(terminationContext.getId()); - if(monitor.hasMonitors()) { - //it is a group - StatusEventPublisher.sendGroupInActivateEvent(this.appId, terminationContext.getId()); - } else { - StatusEventPublisher.sendClusterInActivateEvent(this.appId, - ((AbstractClusterMonitor)monitor).getServiceId(), terminationContext.getId()); - - } + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor)monitor).getServiceId(), terminationContext.getId()); } } - - if (allInActive) { - //Then kill-all of each termination dependents and get a lock for CM - //if start order then can kill only the first one, - // rest of them will get killed based on created event of first one. - } } else { - //find any other immediate dependent which is in_active/created state - ApplicationContext context1 = this.dependencyTree.findParentContextWithId(id); - if(context1 != null) { - if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - monitor = this.aliasToInActiveMonitorsMap.get(id); - //killall - monitor.onEvent(new MonitorTerminateAllEvent(id)); + log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" + + " where child is identified as a independent"); + /*//find any other immediate dependent which is in_active/created state + ApplicationContext context1 = this.dependencyTree.findParentContextWithId(id); + if(context1 != null) { + if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + monitor = this.aliasToInActiveMonitorsMap.get(id); + //killall + monitor.onEvent(new MonitorTerminateAllEvent(id)); - } else { - monitor = this.aliasToActiveMonitorsMap.get(context1.getId()); - } } else { - //Independent monitor + log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" + + " where child is identified as a independent"); } - + }*/ } - - //To update the status of the Group StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { - //TODO get dependents - List dependents = this.dependencyTree.getTerminationDependencies(id); - // if no dependencies then start the cluster monitor. if all are in created, then start them in the order. - if (dependents != null) { - boolean allCreated = false; - //check whether all the children are in_active state - for (ApplicationContext terminationContext : dependents) { - //Check for whether all dependent are in_active - if (this.aliasToInActiveMonitorsMap.containsKey(terminationContext.getId())) { - allCreated = true; - } else { - allCreated = false; - } - } + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { + //Check whether hasDependent true + if(!this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + } - String firstChildToBeStarted = null; + Monitor monitor = this.aliasToInActiveMonitorsMap.get(id); + for(Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { + if(monitor.hasMonitors()) { + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor)monitor1).getServiceId(), monitor.getId()); + } + } + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { + //Check whether all dependent goes Terminated and then start them in parallel. + this.aliasToInActiveMonitorsMap.remove(id); + if(this.status != GroupStatus.Terminating) { + List terminationList; + boolean allDependentTerminated = true; + terminationList = this.dependencyTree.getTerminationDependencies(id); + if(terminationList != null) { + for(ApplicationContext context1 : terminationList) { + if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + allDependentTerminated = false; + } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); + allDependentTerminated = false; + } else { + allDependentTerminated = true; + } + } - if (allCreated) { - //start the CM according to startup order and releasing the lock for it - try { - //if life cycle is empty, need to start the monitor - boolean startDep = startDependency(firstChildToBeStarted); - if (log.isDebugEnabled()) { - log.debug("started a child: " + startDep + " by the group/cluster: " + firstChildToBeStarted); + if(allDependentTerminated) { + } + } else { + List parentContexts = this.dependencyTree.findAllParentContextWithId(id); + boolean canStart = false; + if(parentContexts != null) { + for(ApplicationContext context1 : parentContexts) { + if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + canStart = false; + } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + if(canStart) { + log.warn("Found the Dependent [monitor] " + context1.getId() + + " in the active list wrong state"); + } + } else { + log.info("[Parent Monitor] " + context1.getId() + + " has already been terminated"); + canStart = true; + } } - //updating the life cycle and current status - if (!startDep) { - StatusChecker.getInstance().onChildStatusChange(id, firstChildToBeStarted, this.appId); + + if(canStart) { + //start the monitor } - } catch (TopologyInConsistentException e) { - //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription - log.error(e); + } else { + //Start the monitor } - } else { - //kill other dependents cluster } + } else { + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + log.info("Executing the un-subscription request for the [monitor] " + id); } } - - - } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { - //the dependent goes to be created state, so terminate the dependents } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index de6f261c19..b89637842a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -289,7 +289,7 @@ private boolean updateChildStatus(String appId, String id, Map gr if (parent instanceof Application) { //send application activated event log.info("sending app in-active found: " + appId); - StatusEventPublisher.sendApplicationInActivatedEvent(appId); + StatusEventPublisher.sendApplicationInactivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group in-active found: " + parent.getUniqueIdentifier()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index 71df7ce871..bcb7ea4ec6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -21,6 +21,7 @@ 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.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; @@ -96,7 +97,7 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { } // Validate event properties - Cluster cluster = event.getCluster(); + /*Cluster cluster = event.getCluster(); if(cluster == null) { String msg = "Cluster object of cluster created event is null."; log.error(msg); @@ -104,7 +105,7 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { } if (cluster.getHostNames().isEmpty()) { throw new RuntimeException("Host name/s not found in cluster created event"); - } + }*/ // Validate event against the existing topology Service service = topology.getService(event.getServiceName()); if (service == null) { @@ -122,7 +123,8 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { } else { // Apply changes to the topology - service.addCluster(cluster); + Cluster cluster = service.getCluster(event.getClusterId()); + cluster.setStatus(ClusterStatus.Created); if (log.isInfoEnabled()) { log.info(String.format("Cluster created: %s", cluster.toString())); From 4a3a94255c9013e52fbf3e5e9c1519074c2cb6c2 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 21 Oct 2014 17:27:59 +0530 Subject: [PATCH 221/436] updating the monitors with termination, inactive and terminated events --- .../monitor/ParentComponentMonitor.java | 126 ++++++++++++++ .../application/ApplicationMonitor.java | 91 +++------- .../monitor/group/GroupMonitor.java | 156 ++---------------- .../status/checker/StatusChecker.java | 144 ++++++++-------- 4 files changed, 240 insertions(+), 277 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 0d64e3e447..74a421b2e3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -28,8 +28,13 @@ import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import java.util.HashMap; import java.util.List; @@ -64,6 +69,127 @@ public ParentComponentMonitor(ParentComponent component) throws DependencyBuilde protected abstract void monitor(MonitorStatusEvent statusEvent); + protected void onChildActivatedEvent(MonitorStatusEvent statusEvent) { + try { + //if the activated monitor is in in_active map move it to active map + if (this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id)); + } + boolean startDep = startDependency(statusEvent.getId()); + if (log.isDebugEnabled()) { + log.debug("started a child: " + startDep + " by the group/cluster: " + id); + + } + if (!startDep) { + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } + } catch (TopologyInConsistentException e) { + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error(e); + } + + } + + protected void onChildTerminatingEvent() { + //Check whether hasDependent true + if (!this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + } + + Monitor monitor = this.aliasToInActiveMonitorsMap.get(id); + for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { + if (monitor.hasMonitors()) { + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId()); + } + } + } + + protected void onChildInActiveEvent() { + List terminationList; + Monitor monitor; + terminationList = this.dependencyTree.getTerminationDependencies(id); + //Temporarily move the group/cluster to inactive list + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + + if (terminationList != null) { + //Checking the termination dependents status + for (ApplicationContext terminationContext : terminationList) { + //Check whether dependent is in_active, then start to kill it + monitor = this.aliasToActiveMonitorsMap. + get(terminationContext.getId()); + //start to kill it + if (monitor.hasMonitors()) { + //it is a group + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); + + } + } + } else { + log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" + + " where child is identified as a independent"); + } + } + + protected void onChildTerminatedEvent() { + List terminationList; + boolean allDependentTerminated = true; + terminationList = this.dependencyTree.getTerminationDependencies(id); + if (terminationList != null) { + for (ApplicationContext context1 : terminationList) { + if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + allDependentTerminated = false; + } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); + allDependentTerminated = false; + } else { + allDependentTerminated = true; + } + } + + if (allDependentTerminated) { + + } + } else { + List parentContexts = this.dependencyTree.findAllParentContextWithId(id); + boolean canStart = false; + if (parentContexts != null) { + for (ApplicationContext context1 : parentContexts) { + if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + canStart = false; + } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + if (canStart) { + log.warn("Found the Dependent [monitor] " + context1.getId() + + " in the active list wrong state"); + } + } else { + log.info("[Parent Monitor] " + context1.getId() + + " has already been terminated"); + canStart = true; + } + } + + if (canStart) { + //start the monitor + } + + } else { + //Start the monitor + } + + } + } + + /** * This will start the parallel dependencies at once from the top level. * it will get invoked when the monitor starts up only. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 7befc2b4e2..c587115e18 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -32,6 +32,9 @@ import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import java.util.ArrayList; import java.util.Collection; @@ -86,33 +89,6 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { } - /** - * utility method to recursively search for cluster monitors in the App monitor - * - * @param clusterId cluster id of the monitor to be searched - * @param clusterMonitors cluster monitors found in the app Monitor - * @param groupMonitors group monitors found in the app monitor - * @return the found cluster monitor - */ - /*private AbstractClusterMonitor findClusterMonitor(String clusterId, - Collection clusterMonitors, - Collection groupMonitors) { - for (AbstractClusterMonitor monitor : clusterMonitors) { - // check if alias is equal, if so, return - if (monitor.equals(clusterId)) { - return monitor; - } - } - - for (Monitor groupMonitor : groupMonitors) { - return findClusterMonitor(clusterId, - groupMonitor.getClusterIdToClusterMonitorsMap().values(), - groupMonitor.getAliasToGroupMonitorsMap().values()); - } - return null; - - } -*/ /** * Find the group monitor by traversing recursively in the hierarchical monitors. @@ -180,52 +156,27 @@ public void onEvent(MonitorScalingEvent scalingEvent) { @Override protected void monitor(MonitorStatusEvent statusEvent) { - /*ApplicationContext context = this.dependencyTree. - findApplicationContextWithId(statusEvent.getId()); - //TODO remove activated - if(context.getStatusLifeCycle().isEmpty() || context.getStatus() == Status.Activated) { - try { - //if life cycle is empty, need to start the monitor - boolean dependencyStarted = startDependency(statusEvent.getId()); - if(!dependencyStarted) { - //Have to check whether all other dependencies started - - } - //updating the life cycle - context.addStatusToLIfeCycle(statusEvent.getStatus()); - } catch (TopologyInConsistentException e) { - //TODO revert the siblings - log.error(e); - } - } else { - //TODO act based on life cycle events - }*/ - String id = statusEvent.getId(); - ApplicationContext context = this.dependencyTree. - findApplicationContextWithId(id); - if (context.getStatusLifeCycle().isEmpty()) { - try { - //if life cycle is empty, need to start the monitor - boolean startDep = startDependency(statusEvent.getId()); - if (log.isDebugEnabled()) { - log.debug("started a child: " + startDep + " by the group/cluster: " + id); - - } - //updating the life cycle and current status - if (!startDep) { - //Checking in the children whether all are active, - // since no dependency found to be started. - StatusChecker.getInstance().onChildStatusChange(id, this.appId); - } - } catch (TopologyInConsistentException e) { - //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription - log.error(e); + LifeCycleState status1 = statusEvent.getStatus(); + //Events coming from parent are In_Active(in faulty detection), Scaling events, termination + if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { + onChildActivatedEvent(statusEvent); + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { + onChildInActiveEvent(); + //TODO update the status of the Application as in_active when child becomes in_active + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { + onChildTerminatingEvent(); + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { + //Check whether all dependent goes Terminated and then start them in parallel. + this.aliasToInActiveMonitorsMap.remove(id); + if (this.status != ApplicationStatus.Terminating) { + onChildTerminatedEvent(); + } else { + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + log.info("Executing the un-subscription request for the [monitor] " + id); } - } else { - //TODO act based on life cycle events } - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index f278fb685a..1b01ed0b99 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -34,7 +34,6 @@ import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; -import java.util.ArrayList; import java.util.List; /** @@ -81,148 +80,27 @@ public void onEvent(MonitorScalingEvent scalingEvent) { protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); LifeCycleState status1 = statusEvent.getStatus(); - ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination - if (!isParent(id)) { - if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { - try { - //if the activated monitor is in in_active map move it to active map - if(this.aliasToInActiveMonitorsMap.containsKey(id)) { - this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id)); - } - boolean startDep = startDependency(statusEvent.getId()); - if (log.isDebugEnabled()) { - log.debug("started a child: " + startDep + " by the group/cluster: " + id); - - } - if (!startDep) { - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - } - } catch (TopologyInConsistentException e) { - //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription - log.error(e); - } - - } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { - - List terminationList; - Monitor monitor; - terminationList = this.dependencyTree.getTerminationDependencies(id); - //Temporarily move the group/cluster to inactive list - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); - - if (terminationList != null) { - //Checking the termination dependents status - for (ApplicationContext terminationContext : terminationList) { - //Check whether dependent is in_active, then start to kill it - monitor = this.aliasToActiveMonitorsMap. - get(terminationContext.getId()); - //start to kill it - if(monitor.hasMonitors()) { - //it is a group - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); - } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor)monitor).getServiceId(), terminationContext.getId()); - - } - } - } else { - log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" - + " where child is identified as a independent"); - /*//find any other immediate dependent which is in_active/created state - ApplicationContext context1 = this.dependencyTree.findParentContextWithId(id); - if(context1 != null) { - if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - monitor = this.aliasToInActiveMonitorsMap.get(id); - //killall - monitor.onEvent(new MonitorTerminateAllEvent(id)); - - } else { - log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" - + " where child is identified as a independent"); - } - }*/ - } - //To update the status of the Group + if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { + onChildActivatedEvent(statusEvent); + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { + onChildInActiveEvent(); + //To update the status of the Group + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { + onChildTerminatingEvent(); + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { + //Check whether all dependent goes Terminated and then start them in parallel. + this.aliasToInActiveMonitorsMap.remove(id); + if (this.status != GroupStatus.Terminating) { + onChildTerminatedEvent(); + } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - - } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - //Check whether hasDependent true - if(!this.aliasToInActiveMonitorsMap.containsKey(id)) { - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); - } - - Monitor monitor = this.aliasToInActiveMonitorsMap.get(id); - for(Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { - if(monitor.hasMonitors()) { - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); - } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor)monitor1).getServiceId(), monitor.getId()); - } - } - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { - //Check whether all dependent goes Terminated and then start them in parallel. - this.aliasToInActiveMonitorsMap.remove(id); - if(this.status != GroupStatus.Terminating) { - List terminationList; - boolean allDependentTerminated = true; - terminationList = this.dependencyTree.getTerminationDependencies(id); - if(terminationList != null) { - for(ApplicationContext context1 : terminationList) { - if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [Parent Monitor] " + context1.getId() - + " to be terminated"); - allDependentTerminated = false; - } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { - log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); - allDependentTerminated = false; - } else { - allDependentTerminated = true; - } - } - - if(allDependentTerminated) { - - } - } else { - List parentContexts = this.dependencyTree.findAllParentContextWithId(id); - boolean canStart = false; - if(parentContexts != null) { - for(ApplicationContext context1 : parentContexts) { - if(this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [Parent Monitor] " + context1.getId() - + " to be terminated"); - canStart = false; - } else if(this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { - if(canStart) { - log.warn("Found the Dependent [monitor] " + context1.getId() - + " in the active list wrong state"); - } - } else { - log.info("[Parent Monitor] " + context1.getId() - + " has already been terminated"); - canStart = true; - } - } - - if(canStart) { - //start the monitor - } - - } else { - //Start the monitor - } - - } - } else { - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - log.info("Executing the un-subscription request for the [monitor] " + id); - } + log.info("Executing the un-subscription request for the [monitor] " + id); } } + } public ParentComponentMonitor getParent() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index b89637842a..34388b8196 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -75,6 +75,7 @@ public void onMemberTermination(String clusterId) { if(clusterMonitorHasMembers) { //monitor.pause(); // if cluster not having any members and if the cluster was in_active then send created Events + //TODO StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(), monitor.getClusterId()); } @@ -161,47 +162,21 @@ public void onChildStatusChange(final String idOfChild, final String groupId, updateChild(idOfChild, groupId, appId); } - /** - * This will calculate whether the children of an application are active or not. If active, then - * it will send the ApplicationActivatedEvent. - * - * @param idOfChild - * @param appId - */ - public void onChildStatusChange(final String idOfChild, final String appId) { - updateChild(idOfChild, appId); - } - private void updateChild(final String idOfChild, final String groupId, final String appId) { Runnable group = new Runnable() { public void run() { try { - //TODO getting lock TopologyManager.acquireReadLockForApplication(appId); - ParentComponent component1 = TopologyManager.getTopology(). - getApplication(appId).getGroupRecursively(groupId); - Map clusterIds = component1.getClusterDataMap(); - Map groups = component1.getAliasToGroupMap(); - updateChildStatus(appId, idOfChild, groups, clusterIds, component1); - } finally { - TopologyManager.releaseReadLockForApplication(appId); - - } - - } - }; - Thread groupThread = new Thread(group); - groupThread.start(); - } - - private void updateChild(final String idOfChild, final String appId) { - Runnable group = new Runnable() { - public void run() { - try { - //TODO getting lock - TopologyManager.acquireReadLockForApplication(appId); - ParentComponent component = TopologyManager.getTopology(). - getApplication(appId); + ParentComponent component; + if(groupId.equals(appId)) { + //it is an application + component = TopologyManager.getTopology(). + getApplication(appId); + } else { + //it is a group + component = TopologyManager.getTopology(). + getApplication(appId).getGroupRecursively(groupId); + } Map clusterIds = component.getClusterDataMap(); Map groups = component.getAliasToGroupMap(); updateChildStatus(appId, idOfChild, groups, clusterIds, component); @@ -216,7 +191,6 @@ public void run() { groupThread.start(); } - /** * This will use to calculate whether all children of a particular component is active by travesing Top * @@ -230,8 +204,8 @@ public void run() { private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { boolean groupActive = false; - ClusterStatus clustersActive; - GroupStatus groupsActive; + ClusterStatus clusterStatus; + GroupStatus groupStatus; boolean childFound = false; boolean clusterFound = false; @@ -266,43 +240,48 @@ private boolean updateChildStatus(String appId, String id, Map gr groupActive = clustersActive == ClusterStatus.Active; } */ - clustersActive = getClusterStatus(clusterData); - groupsActive = getGroupStatus(groups); + clusterStatus = getClusterStatus(clusterData); + groupStatus = getGroupStatus(groups); - if (groupsActive == null && clustersActive == ClusterStatus.Active || - clustersActive == null && groupsActive == GroupStatus.Active || - groupsActive == GroupStatus.Active && clustersActive == ClusterStatus.Active) { + if (groups.isEmpty() && clusterStatus == ClusterStatus.Active || + clusterData.isEmpty() && groupStatus == GroupStatus.Active || + groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) { //send activation event if (parent instanceof Application) { //send application activated event - log.info("sending app activate found: " + appId); + log.info("sending app activate: " + appId); StatusEventPublisher.sendApplicationActivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent - log.info("sending group activate found: " + parent.getUniqueIdentifier()); + log.info("sending group activate: " + parent.getUniqueIdentifier()); StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); } - } else if (groupsActive == null && clustersActive == ClusterStatus.Inactive || - clustersActive == null && groupsActive == GroupStatus.Inactive || - groupsActive == GroupStatus.Inactive && clustersActive == ClusterStatus.Inactive) { + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || + clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || + groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { //send the in activation event if (parent instanceof Application) { //send application activated event - log.info("sending app in-active found: " + appId); + log.info("sending app in-active : " + appId); StatusEventPublisher.sendApplicationInactivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent - log.info("sending group in-active found: " + parent.getUniqueIdentifier()); + log.info("sending group in-active: " + parent.getUniqueIdentifier()); StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); } - } else if (groupsActive == null && clustersActive == ClusterStatus.Terminating || - clustersActive == null && groupsActive == GroupStatus.Terminating || - groupsActive == GroupStatus.Terminating && clustersActive == ClusterStatus.Terminating) { - //send the terminating event - } else if (groupsActive == null && clustersActive == ClusterStatus.Terminated || - clustersActive == null && groupsActive == GroupStatus.Terminated || - groupsActive == GroupStatus.Terminated && clustersActive == ClusterStatus.Terminated) { + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || + clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || + groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { //send the terminated event + if (parent instanceof Application) { + //send application activated event + log.info("sending app terminated: " + appId); + //StatusEventPublisher.sendApp(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group terminated : " + parent.getUniqueIdentifier()); + //StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); + } } else { log.warn("Clusters/groups not found in this [component] " + appId); } @@ -319,6 +298,8 @@ private boolean updateChildStatus(String appId, String id, Map gr private GroupStatus getGroupStatus(Map groups) { boolean groupActiveStatus = false; GroupStatus status = null; + boolean groupActive = false; + boolean groupTerminated = false; for (Group group : groups.values()) { /*if (group.getTempStatus() == Status.Activated) { @@ -329,42 +310,69 @@ private GroupStatus getGroupStatus(Map groups) { }*/ if (group.getStatus() == GroupStatus.Active) { - status = GroupStatus.Active; + groupActive = true; + groupTerminated = false; } else if(group.getStatus() == GroupStatus.Inactive){ status = GroupStatus.Inactive; break; + } else if(group.getStatus() == GroupStatus.Terminated) { + groupActive = false; + groupTerminated = true; } else if(group.getStatus() == GroupStatus.Created) { + groupActive = false; + groupTerminated = false; status = GroupStatus.Created; } else if(group.getStatus() == GroupStatus.Terminating) { + groupActive = false; + groupTerminated = false; status = GroupStatus.Terminating; - break; - } else if(group.getStatus() == GroupStatus.Terminated) { - status = GroupStatus.Terminated; + } } + + if(groupActive) { + status = GroupStatus.Active; + } else if(groupTerminated) { + status = GroupStatus.Terminated; + } return status; } private ClusterStatus getClusterStatus(Map clusterData) { ClusterStatus status = null; + boolean clusterActive = false; + boolean clusterTerminated = false; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); if (cluster.getStatus() == ClusterStatus.Active) { - status = ClusterStatus.Active; + clusterActive = true; + clusterTerminated = false; } else if(cluster.getStatus() == ClusterStatus.Inactive){ status = ClusterStatus.Inactive; + clusterActive = false; + clusterTerminated = false; break; - } else if(cluster.getStatus() == ClusterStatus.Created) { - status = ClusterStatus.Created; + } else if(cluster.getStatus() == ClusterStatus.Terminated) { + clusterActive = false; + clusterTerminated = true; } else if(cluster.getStatus() == ClusterStatus.Terminating) { status = ClusterStatus.Terminating; - break; - } else if(cluster.getStatus() == ClusterStatus.Terminated) { - status = ClusterStatus.Terminated; + clusterActive = false; + clusterTerminated = false; + } else if(cluster.getStatus() == ClusterStatus.Created) { + status = ClusterStatus.Created; + clusterActive = false; + clusterTerminated = false; } } + + if(clusterActive) { + status = ClusterStatus.Active; + } else if(clusterTerminated) { + status = ClusterStatus.Terminated; + } return status; } From 77676a680ce3a270f267af367e4652db0a259416 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 21 Oct 2014 17:54:38 +0530 Subject: [PATCH 222/436] removing the common Status for Topology and using the correct status for the application, Group and cluster --- .../grouping/dependency/DependencyTree.java | 22 +- .../AutoscalerTopologyEventReceiver.java | 35 - .../monitor/MonitorStatusEventBuilder.java | 3 +- .../monitor/cluster/ClusterMonitor.java | 1 - .../monitor/cluster/LbClusterMonitor.java | 9 +- .../monitor/events/ClusterStatusEvent.java | 1 - .../termination-change.patch | 596 ++++++++++++++++++ .../impl/CloudControllerServiceImpl.java | 4 +- .../controller/topology/TopologyBuilder.java | 15 +- .../topology/TopologyEventPublisher.java | 18 +- .../messaging/domain/topology/Cluster.java | 57 +- .../domain/topology/ParentComponent.java | 10 - .../messaging/domain/topology/Status.java | 40 -- .../topology/ClusterMaintenanceModeEvent.java | 58 -- .../ClusterMaintenanceModeEventListener.java | 25 - .../ApplicationActivatedMessageProcessor.java | 6 +- .../topology/ClusterActivatedProcessor.java | 11 +- .../topology/ClusterInActivateProcessor.java | 19 +- ...lusterMaintenanceModeMessageProcessor.java | 129 ---- .../topology/GroupActivatedProcessor.java | 4 +- .../topology/GroupInActivateProcessor.java | 5 +- .../TopologyMessageProcessorChain.java | 6 - 22 files changed, 665 insertions(+), 409 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/termination-change.patch delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterMaintenanceModeEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterMaintenanceModeEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterMaintenanceModeMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 6dbbce3548..61648b31de 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; import java.util.List; @@ -34,8 +33,6 @@ public class DependencyTree { private List applicationContextList; - private Status status; - private boolean started; private boolean terminated; @@ -115,11 +112,11 @@ public List findAllParentContextWithId(String id) { private List findAllParent(List parentContexts, String id) { ApplicationContext context = findParentContextWithId(null, id, this.applicationContextList); - if(context != null) { + if (context != null) { parentContexts.add(context); findAllParent(parentContexts, context.getId()); } - return parentContexts; + return parentContexts; } @@ -137,6 +134,7 @@ private ApplicationContext findParentContextWithId(ApplicationContext parent, St } return null; } + /** * Getting the next start able dependencies upon the activate event * received for a group/cluster which is part of this tree. @@ -175,9 +173,9 @@ public List getTerminationDependencies(String id) { if (this.killDependent) { //finding the ApplicationContext of the given id //finding all the children of the found application context - findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), - allChildrenOfAppContext); - return allChildrenOfAppContext; + findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), + allChildrenOfAppContext); + return allChildrenOfAppContext; } else if (this.killAll) { //killall will be killed by the monitor from it's list. findAllChildrenOfAppContext(this.applicationContextList, @@ -236,14 +234,6 @@ public void setTerminated(boolean terminated) { this.terminated = terminated; } - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - public boolean isKillDependent() { return killDependent; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index c5095e3c4f..c650a3db6f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -344,41 +344,6 @@ protected void onEvent(Event event) { }); - - topologyEventReceiver.addEventListener(new ClusterMaintenanceModeEventListener() { - @Override - protected void onEvent(Event event) { - - ClusterMaintenanceModeEvent clusterMaitenanceEvent = null; - - try { - log.info("Event received: " + event); - clusterMaitenanceEvent = (ClusterMaintenanceModeEvent) event; - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(clusterMaitenanceEvent.getServiceName(), - clusterMaitenanceEvent.getClusterId()); - - Service service = TopologyManager.getTopology().getService(clusterMaitenanceEvent.getServiceName()); - Cluster cluster = service.getCluster(clusterMaitenanceEvent.getClusterId()); - AbstractClusterMonitor monitor; - if (AutoscalerContext.getInstance().monitorExist((cluster.getClusterId()))) { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterMaitenanceEvent.getClusterId()); - monitor.setStatus(ClusterStatus.Inactive); - } else { - log.error("cluster monitor not exists for the cluster: " + cluster.toString()); - } - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(clusterMaitenanceEvent.getServiceName(), - clusterMaitenanceEvent.getClusterId()); - } - } - - }); - - topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index a27e0564b2..fcb0f06364 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -27,7 +27,6 @@ import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.GroupStatus; -import org.apache.stratos.messaging.domain.topology.Status; /** * This will build the necessary monitor status events to be sent to the parent/child monitor @@ -51,7 +50,7 @@ public static void handleApplicationStatusEvent(ParentComponentMonitor parent, A } private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEvent statusEvent) { - parent.onEvent(statusEvent); + parent.onEvent(statusEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index a129d182d2..5fabab4311 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -31,7 +31,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Status; import java.util.ArrayList; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index d3a2371875..895f0182dc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -27,7 +27,6 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Status; import java.util.concurrent.ConcurrentHashMap; @@ -39,7 +38,6 @@ public class LbClusterMonitor extends AbstractClusterMonitor { private static final Log log = LogFactory.getLog(LbClusterMonitor.class); - private Status status; public LbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { @@ -63,12 +61,12 @@ public void run() { log.debug("Cluster monitor is running.. " + this.toString()); } try { - if( !ClusterStatus.Inactive.equals(status)) { + if (!ClusterStatus.Inactive.equals(status)) { monitor(); } else { if (log.isDebugEnabled()) { log.debug("LB Cluster monitor is suspended as the cluster is in " + - ClusterStatus.Inactive + " mode......"); + ClusterStatus.Inactive + " mode......"); } } } catch (Exception e) { @@ -92,7 +90,7 @@ private void monitor() { if (partitionContext != null) { minCheckKnowledgeSession.setGlobal("clusterId", clusterId); minCheckKnowledgeSession.setGlobal("isPrimary", false); - + if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); @@ -117,5 +115,4 @@ public String toString() { } - } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java index de8f0d551a..58c59baa4c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ClusterStatusEvent.java @@ -19,7 +19,6 @@ package org.apache.stratos.autoscaler.monitor.events; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Status; /** * This will use to notify observers upon a cluster activation events received in Topology. diff --git a/components/org.apache.stratos.autoscaler/termination-change.patch b/components/org.apache.stratos.autoscaler/termination-change.patch new file mode 100644 index 0000000000..8573805954 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/termination-change.patch @@ -0,0 +1,596 @@ +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +index d3dded3..156f3a5 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +@@ -46,6 +46,10 @@ public class DependencyTree { + + private boolean killDependent; + ++ private boolean startupOder; ++ ++ private boolean reverseStartupOrder; ++ + private String id; + + public DependencyTree(String id) { +@@ -88,7 +92,7 @@ public class DependencyTree { + */ + private ApplicationContext findApplicationContextWithId(String id, List contexts) { + for (ApplicationContext context : contexts) { +- if (context.getId().equals(id)) { ++ if (context.getId().equals(id) && context.getCurrentStatus() == null) { + return context; + } + } +@@ -130,23 +134,23 @@ public class DependencyTree { + * @param id the alias/id of group/cluster in which terminated event received + * @return all the kill able children dependencies + */ +- public List getKillDependencies(String id) { ++ public List getTerminationDependencies(String id) { + List allChildrenOfAppContext = new ArrayList(); ++ ApplicationContext applicationContext = findApplicationContextWithId(id); + +- if (killDependent) { ++ if (this.killDependent) { + //finding the ApplicationContext of the given id +- ApplicationContext applicationContext = findApplicationContextWithId(id); + //finding all the children of the found application context +- findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), +- allChildrenOfAppContext); +- return allChildrenOfAppContext; +- } else if (killAll) { ++ findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), ++ allChildrenOfAppContext); ++ return allChildrenOfAppContext; ++ } else if (this.killAll) { + //killall will be killed by the monitor from it's list. + findAllChildrenOfAppContext(this.applicationContextList, + allChildrenOfAppContext); + + } +- //return empty for the kill-none case ++ //return empty for the kill-none case, what ever returns here will be killed in + return allChildrenOfAppContext; + } + +@@ -221,4 +225,20 @@ public class DependencyTree { + public void setId(String id) { + this.id = id; + } ++ ++ public boolean isStartupOder() { ++ return startupOder; ++ } ++ ++ public void setStartupOder(boolean startupOder) { ++ this.startupOder = startupOder; ++ } ++ ++ public boolean isReverseStartupOrder() { ++ return reverseStartupOrder; ++ } ++ ++ public void setReverseStartupOrder(boolean reverseStartupOrder) { ++ this.reverseStartupOrder = reverseStartupOrder; ++ } + } +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +index f923bb0..5b98264 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +@@ -22,6 +22,7 @@ import org.apache.stratos.messaging.domain.topology.Status; + + import java.util.ArrayList; + import java.util.List; ++import java.util.Stack; + + /** + * This is to keep track of the +@@ -35,13 +36,13 @@ public abstract class ApplicationContext { + + private Status status; + +- private List statusLifeCycle; ++ private Stack statusLifeCycle; + + protected boolean killDependent; + + public ApplicationContext(String id, boolean killDependent) { + applicationContextList = new ArrayList(); +- statusLifeCycle = new ArrayList(); ++ statusLifeCycle = new Stack(); + this.killDependent = killDependent; + this.id = id; + } +@@ -60,7 +61,7 @@ public abstract class ApplicationContext { + } + + public void addStatusToLIfeCycle(Status status) { +- this.statusLifeCycle.add(status); ++ this.statusLifeCycle.push(status); + } + + public String getId() { +@@ -71,11 +72,11 @@ public abstract class ApplicationContext { + this.id = id; + } + +- public Status getStatus() { ++ public Status getCurrentStatus() { + return status; + } + +- public void setStatus(Status status) { ++ public void setCurrentStatus(Status status) { + this.status = status; + } + +@@ -83,7 +84,15 @@ public abstract class ApplicationContext { + return statusLifeCycle; + } + +- public void setStatusLifeCycle(List statusLifeCycle) { +- this.statusLifeCycle = statusLifeCycle; ++ public boolean hasChild() { ++ boolean hasChild; ++ if(this.applicationContextList.isEmpty()) { ++ hasChild = false; ++ } else { ++ hasChild = true; ++ } ++ return hasChild; + } ++ ++ + } +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +index 801af0e..c19c2a0 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +@@ -430,6 +430,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { + String memberId = memberTerminatedEvent.getMemberId(); + partitionContext.removeMemberStatsContext(memberId); + ++ + if (partitionContext.removeTerminationPendingMember(memberId)) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is removed from termination pending " + +@@ -452,6 +453,9 @@ public class AutoscalerTopologyEventReceiver implements Runnable { + log.info(String.format("Member stat context has been removed " + + " successfully: [member] %s", memberId)); + } ++ //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated ++ StatusChecker.getInstance().onMemberTermination(clusterId); ++ + // partitionContext.decrementCurrentActiveMemberCount(1); + + +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +index 4f501d2..aeb0e28 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +@@ -120,6 +120,7 @@ public abstract class Monitor implements EventHandler { + } + if (context instanceof GroupContext) { + startGroupMonitor(this, context.getId()); ++ //context.setCurrentStatus(Status.Created); + } else if (context instanceof ClusterContext) { + String clusterId = context.getId(); + String serviceName = null; +@@ -144,6 +145,7 @@ public abstract class Monitor implements EventHandler { + log.debug("Dependency check starting the [cluster]" + clusterId); + } + startClusterMonitor(this, cluster); ++ //context.setCurrentStatus(Status.Created); + } else { + String msg = "[Cluster] " + clusterId + " cannot be found in the " + + "Topology for [service] " + serviceName; +@@ -372,9 +374,10 @@ public abstract class Monitor implements EventHandler { + try { + if (log.isDebugEnabled()) { + log.debug("Group monitor is going to be started for [group] " +- + groupId); ++ + groupId ); + } + monitor = AutoscalerUtil.getGroupMonitor(groupId, appId); ++ //setting the parent monitor + monitor.setParent(parent); + //setting the status of cluster monitor w.r.t Topology cluster + //if(group.getStatus() != Status.Created && +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +index 5b6598a..5eab977 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +@@ -29,7 +29,6 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; + import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; + import org.apache.stratos.autoscaler.status.checker.StatusChecker; + import org.apache.stratos.messaging.domain.topology.Application; +-import org.apache.stratos.messaging.domain.topology.ParentComponent; + import org.apache.stratos.messaging.domain.topology.Status; + + import java.util.ArrayList; +@@ -63,7 +62,7 @@ public class ApplicationMonitor extends Monitor { + for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) { + clusters.add(monitor.getClusterId()); + } +- //TODO rest ++ //TODO restart + return clusters; + + } +@@ -261,7 +260,7 @@ public class ApplicationMonitor extends Monitor { + + } + //updating the life cycle and current status +- context.setStatus(statusEvent.getStatus()); ++ context.setCurrentStatus(statusEvent.getStatus()); + context.addStatusToLIfeCycle(statusEvent.getStatus()); + if(!startDep) { + //Checking in the children whether all are active, +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +index 0bdad16..0aa89fa 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +@@ -23,16 +23,21 @@ import org.apache.commons.logging.LogFactory; + import org.apache.stratos.autoscaler.exception.DependencyBuilderException; + import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; + import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; ++import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; ++import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; ++import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; ++import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; + import org.apache.stratos.autoscaler.monitor.EventHandler; + import org.apache.stratos.autoscaler.monitor.Monitor; + import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; +-import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; +-import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; + import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; + import org.apache.stratos.autoscaler.status.checker.StatusChecker; ++import org.apache.stratos.messaging.domain.topology.Application; + import org.apache.stratos.messaging.domain.topology.Group; + import org.apache.stratos.messaging.domain.topology.Status; +-import org.apache.stratos.messaging.event.application.status.StatusEvent; ++ ++import java.util.ArrayList; ++import java.util.List; + + /** + * This is GroupMonitor to monitor the group which consists of +@@ -43,9 +48,6 @@ public class GroupMonitor extends Monitor implements EventHandler { + + //Parent monitor of this monitor + private Monitor parent; +- //Application id of this particular monitor +- protected String appId; +- + + /** + * Constructor of GroupMonitor +@@ -53,7 +55,7 @@ public class GroupMonitor extends Monitor implements EventHandler { + * @throws DependencyBuilderException throws when couldn't build the Topology + * @throws TopologyInConsistentException throws when topology is inconsistent + */ +- public GroupMonitor(Group group) throws DependencyBuilderException, ++ public GroupMonitor(Group group, String appId) throws DependencyBuilderException, + TopologyInConsistentException { + super(group); + startDependency(); +@@ -79,32 +81,86 @@ public class GroupMonitor extends Monitor implements EventHandler { + @Override + protected void monitor(MonitorStatusEvent statusEvent) { + String id = statusEvent.getId(); +- ApplicationContext context = this.dependencyTree. +- findApplicationContextWithId(id); +- if(context.getStatusLifeCycle().isEmpty()) { +- try { +- //if life cycle is empty, need to start the monitor +- boolean startDep = startDependency(statusEvent.getId()); +- if(log.isDebugEnabled()) { +- log.debug("started a child: " + startDep + " by the group/cluster: " + id); ++ Status status1 = statusEvent.getStatus(); ++ ApplicationContext context = this.dependencyTree.findApplicationContextWithId(id); ++ //Events coming from parent are In_Active(in faulty detection), Scaling events, termination ++ //TODO if statusEvent is for active, then start the next one if any available ++ if(!isParent(id)) { ++ if(status1 == Status.Activated) { ++ try { ++ //if life cycle is empty, need to start the monitor ++ boolean startDep = startDependency(statusEvent.getId()); ++ if (log.isDebugEnabled()) { ++ log.debug("started a child: " + startDep + " by the group/cluster: " + id); + ++ } ++ //updating the life cycle and current status ++ if (startDep) { ++ context.setCurrentStatus(Status.Created); ++ context.addStatusToLIfeCycle(Status.Created); ++ } else { ++ StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); ++ } ++ ++ } catch (TopologyInConsistentException e) { ++ //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription ++ log.error(e); + } +- //updating the life cycle and current status +- context.setStatus(statusEvent.getStatus()); +- context.addStatusToLIfeCycle(statusEvent.getStatus()); +- if(!startDep) { +- //Checking in the children whether all are active, +- // since no dependency found to be started. +- StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); ++ } else if(status1 == Status.In_Active) { ++ //TODO if C1 depends on C2, then if C2 is in_active, then by getting killdepend as C1 and ++ //TODO need to send in_active for c1. When C1 in_active receives, get dependent and ++ //TODO check whether dependent in_active. Then kill c1. ++ //evaluate termination behavior and take action based on that. ++ ++ List terminationList = new ArrayList(); ++ terminationList = this.dependencyTree.getTerminationDependencies(id); ++ ++ //check whether all the children are in_active state ++ for(ApplicationContext terminationContext : terminationList) { ++ terminationContext ++ } ++ ++ /*if(terminationList != null && !terminationList.isEmpty()) { ++ for(ApplicationContext context1 : terminationList) { ++ if(context1 instanceof ClusterContext) { ++ AbstractClusterMonitor monitor = this.clusterIdToClusterMonitorsMap. ++ get(context1.getId()); ++ //Whether life cycle change to Created ++ if(monitor.getStatus() == Status.Created) { ++ canTerminate = true; ++ } else { ++ //TODO sending group in_active event to dependent cluster/group ++ StatusEventPublisher.sendGroupActivatedEvent(this.appId, this.id); ++ //not all dependent clusters are in created state. ++ canTerminate = false; ++ } ++ } ++ } ++ if(canTerminate) { ++ // ++ }*/ ++ } else { ++ //TODO get dependents ++ List dependents = this.dependencyTree.getTerminationDependencies(id); + } +- } catch (TopologyInConsistentException e) { +- //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription +- log.error(e); ++ ++ ++ ++ ++ ++ } else if(status1 == Status.Created) { ++ //the dependent goes to be created state, so terminate the dependents + } + } else { +- //TODO act based on life cycle events ++ //If it is coming from parent, then can be unsubscribe/scaling/terminate ++ // request upon other siblings's status changes ++ ++ ++ + } + ++ ++ + } + + public Monitor getParent() { +@@ -123,4 +179,16 @@ public class GroupMonitor extends Monitor implements EventHandler { + this.appId = appId; + } + ++ private boolean isParent(String id) { ++ if(this.parent.getId().equals(id)) { ++ return true; ++ } else { ++ return false; ++ } ++ } ++ ++ ++ ++ ++ + } +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +index ee04fff..e298df3 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +@@ -64,6 +64,13 @@ public class StatusChecker { + } + } + ++ public void onMemberTermination(String clusterId) { ++ ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); ++ //TODO get Topology status ++ // if cluster not having any members and if the cluster was in_active then send created Events ++ // if cluster was in terminating, then send terminated event. ++ } ++ + private boolean clusterActive(AbstractClusterMonitor monitor) { + boolean clusterActive = false; + for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { +@@ -84,6 +91,42 @@ public class StatusChecker { + } + + /** ++ * @param clusterId ++ * @param appId ++ * @param partitionContext is to decide in which partition has less members while others have active members ++ */ ++ public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { ++ ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); ++ boolean clusterInActive = getClusterInActive(monitor, partitionContext); ++ if (clusterInActive) { ++ //TODO evaluate life cycle ++ //send cluster In-Active event to cluster status topic ++ ++ } else { ++ boolean clusterActive = clusterActive(monitor); ++ if(clusterActive) { ++ //TODO evaluate life cycle ++ //send clusterActive event to cluster status topic ++ } ++ } ++ } ++ ++ private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) { ++ boolean clusterInActive = false; ++ for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { ++ for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { ++ if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && ++ partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { ++ clusterInActive = true; ++ return clusterInActive; ++ } ++ } ++ ++ } ++ return clusterInActive; ++ } ++ ++ /** + * + * @param idOfChild + * @param groupId +@@ -149,47 +192,7 @@ public class StatusChecker { + } + + +- /** +- * @param clusterId +- * @param appId +- * @param partitionContext is to decide in which partition has less members while others have active members +- */ +- public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { +- Runnable memberFault = new Runnable() { +- public void run() { +- ClusterMonitor monitor = AutoscalerContext.getInstance().getMonitor(clusterId); +- boolean clusterActive = false; +- boolean clusterInMaintenance = false; +- for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { +- for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { +- if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && +- partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { +- clusterInMaintenance = true; +- } else { +- log.info(String.format("Hence the [partition] %s, in [networkpartition], " + +- "%s has exceeded the [minimum], %d with current active " + +- "[members], %d the [cluster], %s is still in active mode." +- , partition.getPartitionId(), partition.getNetworkPartitionId(), +- partition.getMinimumMemberCount(), partition.getActiveMemberCount(), clusterId)); +- } +- if (partitionContext.getMinimumMemberCount() >= partitionContext.getActiveMemberCount()) { +- clusterActive = true; +- } +- clusterActive = false; +- } +- +- } +- // if in maintenance then notify upper layer +- if (clusterActive && clusterInMaintenance) { +- //send clusterInmaintenance event to cluster status topic +- +- } + +- } +- }; +- Thread faultHandlingThread = new Thread(memberFault); +- faultHandlingThread.start(); +- } + + /** + * This will use to calculate whether all children of a particular component is active by travesing Top +diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +index cb03158..77af14c 100644 +--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java ++++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +@@ -163,7 +163,7 @@ public class AutoscalerUtil { + } + + clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); +- //clusterMonitor.setStatus(Status.Created); ++ //clusterMonitor.setCurrentStatus(Status.Created); + if(log.isInfoEnabled()){ + log.info(String.format("Network partition context has been added: [network partition] %s", + networkPartitionContext.getId())); +diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +index 7ba27fc..2bd0945 100644 +--- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java ++++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Status.java +@@ -24,8 +24,9 @@ public enum Status { + Created(1), + Running(2), + Activated(3), +- In_Maintenance(4), +- Removed(5); ++ In_Active(4), ++ Terminating(4), ++ Terminated(5); + + private int code; + +diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json +index 942ef8b..0043e2e 100755 +--- a/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json ++++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/group2.json +@@ -4,12 +4,15 @@ + "group1" + ], + "cartridges": [ +- "tomcat" ++ "tomcat","tomcat1" + ], + "dependencies": { + "startupOrders": [ + "group.group1,cartridge.tomcat" + ], +- "killBehaviour": "kill-dependents" +- } ++ "termination": { ++ "terminationBehaviour": "kill-dependents", ++ "terminationOrder" : "startupOrder/reverseStartupOrder" ++ } ++ } + } +diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json +index b234c49..95c61b4 100644 +--- a/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json ++++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/m2_single_subsciption_app.json +@@ -13,7 +13,12 @@ + "type": "tomcat", + "alias": "mygroup2tomcat" + +- } ++ }, ++ { ++ "type": "tomcat1", ++ "alias": "mygroup2tomcat1" ++ } ++ + ], + "subGroups": [ + { +@@ -88,6 +93,15 @@ + "alias": "mygroup1tomcat1", + "deploymentPolicy": "deployment_policy_1", + "autoscalingPolicy": "autoscale_policy_1" ++ }, ++ { ++ "alias": "mygroup2tomcat1", ++ "deploymentPolicy": "deployment_policy_1", ++ "autoscalingPolicy": "autoscale_policy_1", ++ "repoURL": "www.mygit.com/php.git", ++ "privateRepo": "true", ++ "repoUsername": "admin", ++ "repoPassword": "xxxx" + } + + ] diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 68ccc5e64f..ce09d15612 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1212,7 +1212,7 @@ public CartridgeInfo getCartridgeInfo(String cartridgeType) @Override public void unregisterService(String clusterId) throws UnregisteredClusterException { final String clusterId_ = clusterId; - TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); + /*TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); Runnable terminateInTimeout = new Runnable() { @Override @@ -1309,7 +1309,7 @@ private void deleteVolumes(ClusterContext ctxt) { } }; new Thread(terminateInTimeout).start(); - new Thread(unregister).start(); + new Thread(unregister).start();*/ } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index b54b203579..81c228c3b6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -114,7 +114,7 @@ public static void handleServiceRemoved(List cartridgeList) { } public static void handleClusterCreated(Registrant registrant, boolean isLb) { - Topology topology = TopologyManager.getTopology(); + /*Topology topology = TopologyManager.getTopology(); Service service; try { TopologyManager.acquireWriteLock(); @@ -156,7 +156,7 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { } finally { TopologyManager.releaseWriteLock(); - } + }*/ } public static void handleClusterRemoved(ClusterContext ctxt) { @@ -187,7 +187,7 @@ public static void handleClusterRemoved(ClusterContext ctxt) { TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy); } - public static void handleClusterMaintenanceMode(ClusterContext ctxt) { + /*public static void handleClusterMaintenanceMode(ClusterContext ctxt) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(ctxt.getCartridgeType()); @@ -211,15 +211,12 @@ public static void handleClusterMaintenanceMode(ClusterContext ctxt) { log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); } cluster.setStatus(ClusterStatus.Inactive); - // temporary; should be removed - cluster.setTempStatus(Status.In_Active); - //cluster.setStatus(Status.In_Maintenance); TopologyManager.updateTopology(topology); } finally { TopologyManager.releaseWriteLock(); } TopologyEventPublisher.sendClusterMaintenanceModeEvent(ctxt); - } + }*/ public static void handleMemberSpawned(String serviceName, @@ -774,8 +771,6 @@ public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActi TopologyManager.acquireWriteLock(); //cluster.setStatus(Status.Activated); cluster.setStatus(ClusterStatus.Active); - // temporary; should be removed - cluster.setTempStatus(Status.Activated); log.info("Cluster activated adding status started"); @@ -810,7 +805,7 @@ public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedE groupActivatedEvent.getGroupId()); try { TopologyManager.acquireWriteLock(); - group.setTempStatus(Status.Activated); + group.setStatus(GroupStatus.Active); log.info("Group activated adding status started"); TopologyManager.updateTopology(topology); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index b3f60b9145..2786605759 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -81,11 +81,11 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } } - public static void sendClusterCreatedEvent(String serviceName, String clusterId, Cluster cluster) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(serviceName, clusterId, cluster); + public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { + ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId); if(log.isInfoEnabled()) { - log.info("Publishing cluster created event: " +cluster.toString()); + log.info("Publishing cluster created event: " +clusterId); } publishEvent(clusterCreatedEvent); @@ -121,18 +121,6 @@ public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymen } - public static void sendClusterMaintenanceModeEvent(ClusterContext ctxt) { - - ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = new ClusterMaintenanceModeEvent(ctxt.getCartridgeType(), ctxt.getClusterId()); - clusterMaintenanceModeEvent.setStatus(Status.In_Active); - if(log.isInfoEnabled()) { - log.info(String.format("Publishing cluster maintenance mode event: [service] %s [cluster] %s", - clusterMaintenanceModeEvent.getServiceName(), clusterMaintenanceModeEvent.getClusterId())); - } - publishEvent(clusterMaintenanceModeEvent); - - } - public static void sendInstanceSpawnedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, String lbClusterId, String publicIp, String privateIp, MemberContext context) { InstanceSpawnedEvent instanceSpawnedEvent = new InstanceSpawnedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 3325561e2c..06d408ca1c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -36,9 +36,9 @@ @XmlRootElement public class Cluster implements Serializable, LifeCycleStateTransitionBehavior { - private static final long serialVersionUID = -361960242360176077L; - - private final String serviceName; + private static final long serialVersionUID = -361960242360176077L; + + private final String serviceName; private final String clusterId; private final String autoscalePolicyName; private final String deploymentPolicyName; @@ -50,7 +50,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior memberMap; - private Status tempStatus; + private ClusterStatus status; private String appId; @@ -70,7 +70,7 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.appId = appId; this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created); // temporary; should be removed - this.tempStatus = Status.Created; + this.status = ClusterStatus.Created; } public String getServiceName() { @@ -103,11 +103,10 @@ public Collection getMembers() { } public boolean hasMembers() { - return memberMap.isEmpty(); + return memberMap.isEmpty(); } - public void addMember(Member member) { memberMap.put(member.getMemberId(), member); } @@ -136,9 +135,9 @@ public String getAutoscalePolicyName() { return autoscalePolicyName; } - public String getDeploymentPolicyName() { - return deploymentPolicyName; - } + public String getDeploymentPolicyName() { + return deploymentPolicyName; + } public String getLoadBalanceAlgorithmName() { return loadBalanceAlgorithmName; @@ -155,7 +154,7 @@ public boolean isLbCluster() { public void setLbCluster(boolean isLbCluster) { this.isLbCluster = isLbCluster; } - + @Override public String toString() { return "Cluster [serviceName=" + serviceName + ", clusterId=" + clusterId + @@ -171,24 +170,22 @@ public String toString() { * @return */ public boolean tenantIdInRange(int tenantId) { - if(StringUtils.isBlank(getTenantRange())) { + if (StringUtils.isBlank(getTenantRange())) { return false; } - if("*".equals(getTenantRange())) { + if ("*".equals(getTenantRange())) { return true; - } - else { + } else { String[] array = getTenantRange().split("-"); int tenantStart = Integer.parseInt(array[0]); - if(tenantStart <= tenantId) { + if (tenantStart <= tenantId) { String tenantEndStr = array[1]; - if("*".equals(tenantEndStr)) { + if ("*".equals(tenantEndStr)) { return true; - } - else { + } else { int tenantEnd = Integer.parseInt(tenantEndStr); - if(tenantId <= tenantEnd) { + if (tenantId <= tenantEnd) { return true; } } @@ -204,8 +201,8 @@ public boolean tenantIdInRange(int tenantId) { */ public Collection findPartitionIds() { Map partitionIds = new HashMap(); - for(Member member : getMembers()) { - if((StringUtils.isNotBlank(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) { + for (Member member : getMembers()) { + if ((StringUtils.isNotBlank(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) { partitionIds.put(member.getPartitionId(), true); } } @@ -233,19 +230,19 @@ public void setStatus(ClusterStatus newStatus) { } public boolean equals(Object other) { - if(other == null || !(other instanceof Cluster)) { + if (other == null || !(other instanceof Cluster)) { return false; } - if(this == other) { + if (this == other) { return true; } - Cluster that = (Cluster)other; + Cluster that = (Cluster) other; return this.clusterId.equals(that.clusterId); } - public int hashCode () { + public int hashCode() { return clusterId.hashCode(); } @@ -253,12 +250,12 @@ public String getAppId() { return appId; } - public Status getTempStatus () { - return tempStatus; + public ClusterStatus getTempStatus() { + return status; } - public void setTempStatus (Status tempStatus) { - this.tempStatus = tempStatus; + public void setTempStatus(ClusterStatus status) { + this.status = status; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java index dc5dd20f3e..86000e9748 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java @@ -36,10 +36,8 @@ public abstract class ParentComponent implements Serializable { // Cluster Id map, key = subscription alias for the cartridge type private Map aliasToClusterDataMap; // Application status - private Status tempStatus; public ParentComponent () { - this.tempStatus = Status.Created; aliasToGroupMap = new HashMap(); aliasToClusterDataMap = new HashMap(); } @@ -211,12 +209,4 @@ private void getClusterData (Set clusterData, Collection Date: Tue, 21 Oct 2014 16:21:42 +0530 Subject: [PATCH 223/436] initial changes for application undeploying --- .../AutoscalerTopologyEventReceiver.java | 41 ++++++ .../impl/CloudControllerServiceImpl.java | 2 +- .../controller/topology/TopologyBuilder.java | 118 +++++++++++---- .../topology/TopologyEventPublisher.java | 10 +- .../topology/ApplicationUndeployedEvent.java | 43 ++++++ .../ApplicationUndeployedEventListener.java | 26 ++++ ...ApplicationUndeployedMessageProcessor.java | 138 ++++++++++++++++++ .../ClusterCreatedMessageProcessor.java | 1 + .../TopologyMessageProcessorChain.java | 6 + 9 files changed, 353 insertions(+), 32 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index c650a3db6f..cd56579dac 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -252,6 +252,47 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); + + ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; + TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + + try { + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationUndeployedEvent.getApplicationId()); + + // update the status as Terminating + appMonitor.setStatus(ApplicationStatus.Terminating); + + if (appMonitor != null) { + List clusters = appMonitor. + findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); + + for (String clusterId : clusters) { + //stopping the cluster monitor and remove it from the AS + ClusterMonitor clusterMonitor = + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); + clusterMonitor.setDestroyed(true); + clusterMonitor.setStatus(ClusterStatus.Terminating); + AutoscalerContext.getInstance().removeMonitor(clusterId); + } + + } else { + log.warn("Application Monitor cannot be found for the removed [application] " + + applicationUndeployedEvent.getApplicationId()); + } + + } finally { + TopologyManager. + releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + } + } + }); + topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index ce09d15612..3ccaccd329 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1459,7 +1459,7 @@ public void unDeployApplicationDefinition(String applicationId, int tenantId, St TopologyBuilder.handleApplicationUndeployed(dataHolder, applicationId, tenantId, tenantDomain); - persist(); + //persist(); } private List restoreConfigCompositeApplication () { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 81c228c3b6..d8bf3196d5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -674,52 +674,110 @@ public static synchronized void handleApplicationDeployed(Application applicatio public static synchronized void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder, String applicationId, int tenantId, String tenantDomain) { - Topology topology = TopologyManager.getTopology(); + Set clusterData; + + // update the Application and Cluster Statuses as 'Terminating' + TopologyManager.acquireWriteLock(); try { - TopologyManager.acquireWriteLock(); + + Topology topology = TopologyManager.getTopology(); if (!topology.applicationExists(applicationId)) { log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); + return; + } - } else { - Application application = topology.getApplication(applicationId); - Set clusterData = application.getClusterDataRecursively(); - // remove clusters - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - // remove Cluster - service.removeCluster(clusterDataHolder.getClusterId()); - - if (log.isDebugEnabled()) { - log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); + Application application = topology.getApplication(applicationId); + // check and update application status to 'Terminating' + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully + application.setStatus(ApplicationStatus.Terminating); + log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); + + // update all the Clusters' statuses to 'Terminating' + clusterData = application.getClusterDataRecursively(); + for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = topology.getService(clusterDataHolder.getServiceType()); + if (service != null) { + Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); + if (aCluster != null) { + // validate state transition + if (aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid state transfer from " + aCluster.getStatus() + " to " + + ClusterStatus.Terminating + " successfully"); } + // for now anyway update the status forcefully + aCluster.setStatus(ClusterStatus.Terminating); + log.info("Cluster " + clusterDataHolder.getClusterId() + "'s status updated to " + + ClusterStatus.Terminating + " successfully"); + } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); + log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + + " in Topology"); } - // remove runtime data - dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); - if(log.isDebugEnabled()) { - log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); - } + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); } - - // remove application - topology.removeApplication(applicationId); - TopologyManager.updateTopology(topology); - - log.info("Removed application [ " + applicationId + " ] from Topology"); - - TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain); } } finally { TopologyManager.releaseWriteLock(); } + + TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); + + +// Topology topology = TopologyManager.getTopology(); +// +// try { +// TopologyManager.acquireWriteLock(); +// +// if (!topology.applicationExists(applicationId)) { +// log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); +// //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); +// +// } else { +// Application application = topology.getApplication(applicationId); +// Set clusterData = application.getClusterDataRecursively(); +// // remove clusters +// for (ClusterDataHolder clusterDataHolder : clusterData) { +// Service service = topology.getService(clusterDataHolder.getServiceType()); +// if (service != null) { +// // remove Cluster +// service.removeCluster(clusterDataHolder.getClusterId()); +// +// if (log.isDebugEnabled()) { +// log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); +// } +// } else { +// log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + +// " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); +// } +// +// // remove runtime data +// dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); +// if(log.isDebugEnabled()) { +// log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); +// } +// } +// +// // remove application +// topology.removeApplication(applicationId); +// TopologyManager.updateTopology(topology); +// +// log.info("Removed application [ " + applicationId + " ] from Topology"); +// +// TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain); +// } +// +// } finally { +// TopologyManager.releaseWriteLock(); +// } } public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 2786605759..93523a4ae0 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -88,7 +88,6 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str log.info("Publishing cluster created event: " +clusterId); } publishEvent(clusterCreatedEvent); - } public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) { @@ -100,6 +99,15 @@ public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicat publishEvent(applicationCreatedEvent); } + public static void sendApplicationUndeployedEvent (String applicationId, Set clusterData) { + + if (log.isInfoEnabled()) { + log.info("Publishing Application undeployed event for Application: " + applicationId); + } + + publishEvent(new ApplicationUndeployedEvent(applicationId, clusterData)); + } + public static void sendApplicationRemovedEvent(String applicationId, Set clusterData, int tenantId, String tenantDomain) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java new file mode 100644 index 0000000000..ae56bb6196 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; + +import java.util.Set; + +public class ApplicationUndeployedEvent extends TopologyEvent { + + private String applicationId; + private Set clusterData; + + public ApplicationUndeployedEvent (String applicationId, Set clusterData) { + this.applicationId = applicationId; + this.clusterData = clusterData; + } + + public String getApplicationId() { + return applicationId; + } + + public Set getClusterData() { + return clusterData; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java new file mode 100644 index 0000000000..b28a40dd0e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ApplicationUndeployedEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java new file mode 100644 index 0000000000..3f397c0b46 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java @@ -0,0 +1,138 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +import java.util.Set; + +public class ApplicationUndeployedMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + + if (ApplicationUndeployedEvent.class.getName().equals(type)) { + if (!topology.isInitialized()) { + return false; + } + + ApplicationUndeployedEvent event = (ApplicationUndeployedEvent) + Util.jsonToObject(message, ApplicationUndeployedEvent.class); + if (event == null) { + log.error("Unable to convert the JSON message to ApplicationUndeployedEvent"); + return false; + } + + // get write lock for the application and relevant Clusters + TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId()); + Set clusterDataHolders = event.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.acquireWriteLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } + + try { + return doProcess(event, topology); + + } finally { + // remove locks + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.releaseWriteLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } + TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format + ("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) { + + // update the application status to Terminating + Application application = topology.getApplication(event.getApplicationId()); + // check and update application status to 'Terminating' + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully + application.setStatus(ApplicationStatus.Terminating); + log.info("Application " + event.getApplicationId() + "'s status updated to " + ApplicationStatus.Terminating); + + // update all the Clusters' statuses to 'Terminating' + Set clusterData = application.getClusterDataRecursively(); + // update the Cluster statuses to Terminating + for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = topology.getService(clusterDataHolder.getServiceType()); + if (service != null) { + Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); + if (aCluster != null) { + // validate state transition + if (aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid state transfer from " + aCluster.getStatus() + " to " + + ClusterStatus.Terminating + " successfully"); + } + // for now anyway update the status forcefully + aCluster.setStatus(ClusterStatus.Terminating); + log.info("Cluster " + clusterDataHolder.getClusterId() + "'s status updated to " + + ClusterStatus.Terminating + " successfully"); + + } else { + log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + + " in Topology"); + } + + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); + } + } + + return true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index bcb7ea4ec6..613c5df42d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -98,6 +98,7 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { // Validate event properties /*Cluster cluster = event.getCluster(); + if(cluster == null) { String msg = "Cluster object of cluster created event is null."; log.error(msg); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index e6535f1b49..6a58d179ab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -48,6 +48,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private GroupActivatedProcessor groupActivatedProcessor; //private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; + private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; @@ -98,6 +99,9 @@ public void initialize() { applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); add(applicationCreatedMessageProcessor); + applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor(); + add(applicationUndeployedMessageProcessor); + applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor(); add(applicationRemovedMessageProcessor); @@ -140,6 +144,8 @@ public void addEventListener(EventListener eventListener) { groupActivatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationCreatedEventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationUndeployedEventListener) { + applicationUndeployedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationRemovedEventListener) { applicationRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { From ea8ee9b3e8ed611b8c1fd992a3f98682ea370e8e Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 21 Oct 2014 18:18:55 +0530 Subject: [PATCH 224/436] calling terminate all rule from AS --- .../topology/AutoscalerTopologyEventReceiver.java | 10 +++++----- .../autoscaler/monitor/AbstractClusterMonitor.java | 4 ++++ .../autoscaler/monitor/cluster/ClusterMonitor.java | 13 +++++++++++++ .../monitor/cluster/LbClusterMonitor.java | 6 ++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index cd56579dac..44059edd23 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -265,10 +265,10 @@ protected void onEvent(Event event) { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). getAppMonitor(applicationUndeployedEvent.getApplicationId()); - // update the status as Terminating - appMonitor.setStatus(ApplicationStatus.Terminating); - if (appMonitor != null) { + // update the status as Terminating + appMonitor.setStatus(ApplicationStatus.Terminating); + List clusters = appMonitor. findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); @@ -278,11 +278,11 @@ protected void onEvent(Event event) { ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); clusterMonitor.setDestroyed(true); clusterMonitor.setStatus(ClusterStatus.Terminating); - AutoscalerContext.getInstance().removeMonitor(clusterId); + clusterMonitor.terminateAllMembers(); } } else { - log.warn("Application Monitor cannot be found for the removed [application] " + log.warn("Application Monitor cannot be found for the undeployed [application] " + applicationUndeployedEvent.getApplicationId()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index beee67ad42..ccca072ea2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -54,10 +54,12 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected FactHandle minCheckFactHandle; protected FactHandle scaleCheckFactHandle; protected FactHandle terminateDependencyFactHandle; + protected FactHandle terminateAllFactHandle; protected StatefulKnowledgeSession minCheckKnowledgeSession; protected StatefulKnowledgeSession scaleCheckKnowledgeSession; protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; + protected StatefulKnowledgeSession terminateAllKnowledgeSession; protected boolean isDestroyed; protected String clusterId; @@ -124,6 +126,8 @@ public void destroy() { } } + public abstract void terminateAllMembers (); + public boolean isDestroyed() { return isDestroyed; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 5fabab4311..65e6882693 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -57,6 +57,7 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); this.terminateDependencyKnowledgeSession = autoscalerRuleEvaluator.getTerminateDependencyStatefulSession(); + this.terminateAllKnowledgeSession = autoscalerRuleEvaluator.getTerminateAllStatefulSession(); this.deploymentPolicy = deploymentPolicy; this.autoscalePolicy = autoscalePolicy; @@ -96,6 +97,18 @@ public void run() { } + @Override + public void terminateAllMembers() { + + for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { + //if (log.isDebugEnabled()) { + log.info("Starting to terminate all members in Network Partition " + networkPartitionContext.getId()); + // } + terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll + (terminateAllKnowledgeSession, terminateAllFactHandle, networkPartitionContext); + } + } + private boolean isPrimaryMember(MemberContext memberContext) { Properties props = memberContext.getProperties(); if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index 895f0182dc..cc21205cdb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -47,6 +47,7 @@ public LbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy dep this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); + this.terminateAllKnowledgeSession = autoscalerRuleEvaluator.getTerminateAllStatefulSession(); this.deploymentPolicy = deploymentPolicy; this.deploymentPolicy = deploymentPolicy; @@ -79,6 +80,11 @@ public void run() { } } + @Override + public void terminateAllMembers() { + //To change body of implemented methods use File | Settings | File Templates. + } + private void monitor() { // TODO make this concurrent for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { From 684d71f72d8150be5da1bc1e8805266fabe0fa05 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 21 Oct 2014 19:50:04 +0530 Subject: [PATCH 225/436] completing the initial flow for application undeployment --- .../grouping/topic/StatusEventPublisher.java | 15 ++ .../status/checker/StatusChecker.java | 1 + .../controller/topology/TopologyBuilder.java | 140 ++++++++++-------- .../domain/topology/ApplicationStatus.java | 6 +- .../messaging/domain/topology/Cluster.java | 18 +-- .../status/ApplicationTerminatedEvent.java | 11 +- 6 files changed, 115 insertions(+), 76 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 2ffff81ddf..668161af43 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -4,10 +4,12 @@ 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.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; @@ -15,6 +17,8 @@ import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; import org.apache.stratos.messaging.util.Constants; +import java.util.Set; + /** * This will publish application related events to application status topic. */ @@ -188,6 +192,17 @@ public static void sendGroupInMaintenanceEvent(String appId, String groupId) { publishEvent(groupMaintenanceModeEvent); } + public static void sendApplicationTerminatingEvent (String appId) { + // TODO: implement + } + + public static void sendApplicationTerminatedEvent (String appId, Set clusterData) { + + ApplicationTerminatedEvent applicationTerminatedEvent = + new ApplicationTerminatedEvent(appId, clusterData); + publishEvent(applicationTerminatedEvent); + } + public static void publishEvent(Event event) { //publishing events to application status topic EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.APPLICATION_STATUS_TOPIC); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 34388b8196..9b39c5a037 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -276,6 +276,7 @@ private boolean updateChildStatus(String appId, String id, Map gr if (parent instanceof Application) { //send application activated event log.info("sending app terminated: " + appId); + StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); //StatusEventPublisher.sendApp(appId); } else if (parent instanceof Group) { //send activation to the parent diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index d8bf3196d5..68c96d47b7 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -26,6 +26,7 @@ import org.apache.stratos.cloud.controller.pojo.Cartridge; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; +import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; @@ -39,6 +40,7 @@ import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.util.Constants; +import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; import java.util.Properties; @@ -730,54 +732,6 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold } TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); - - -// Topology topology = TopologyManager.getTopology(); -// -// try { -// TopologyManager.acquireWriteLock(); -// -// if (!topology.applicationExists(applicationId)) { -// log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); -// //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); -// -// } else { -// Application application = topology.getApplication(applicationId); -// Set clusterData = application.getClusterDataRecursively(); -// // remove clusters -// for (ClusterDataHolder clusterDataHolder : clusterData) { -// Service service = topology.getService(clusterDataHolder.getServiceType()); -// if (service != null) { -// // remove Cluster -// service.removeCluster(clusterDataHolder.getClusterId()); -// -// if (log.isDebugEnabled()) { -// log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); -// } -// } else { -// log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + -// " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); -// } -// -// // remove runtime data -// dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); -// if(log.isDebugEnabled()) { -// log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); -// } -// } -// -// // remove application -// topology.removeApplication(applicationId); -// TopologyManager.updateTopology(topology); -// -// log.info("Removed application [ " + applicationId + " ] from Topology"); -// -// TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain); -// } -// -// } finally { -// TopologyManager.releaseWriteLock(); -// } } public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { @@ -986,28 +940,86 @@ public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent } public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } +// Topology topology = TopologyManager.getTopology(); +// Application application = topology.getApplication(event.getAppId()); +// //update the status of the Group +// if (application == null) { +// log.warn(String.format("Application %s does not exist", +// event.getAppId())); +// return; +// } +// +// org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent = +// new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent( +// event.getAppId()); +// try { +// TopologyManager.acquireWriteLock(); +// application.setStatus(ApplicationStatus.Terminated); +// log.info("Application terminated adding status started for Topology"); +// +// TopologyManager.updateTopology(topology); +// } finally { +// TopologyManager.releaseWriteLock(); +// } +// //publishing data +// TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent); + + + Topology topology = TopologyManager.getTopology(); - org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent = - new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent( - event.getAppId()); try { TopologyManager.acquireWriteLock(); - application.setStatus(ApplicationStatus.Terminated); - log.info("Application terminated adding status started for Topology"); - TopologyManager.updateTopology(topology); + if (!topology.applicationExists(event.getAppId())) { + log.warn("Application with id [ " + event.getAppId() + " ] doesn't exist in Topology"); + //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); + + } else { + Application application = topology.getApplication(event.getAppId()); + int tenantId = application.getTenantId(); + String tenantDomain = application.getTenantDomain(); + Set clusterData = application.getClusterDataRecursively(); + // remove clusters + for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = topology.getService(clusterDataHolder.getServiceType()); + if (service != null) { + // remove Cluster + service.removeCluster(clusterDataHolder.getClusterId()); + + if (log.isDebugEnabled()) { + log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); + } + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); + } + + // remove runtime data + FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); + dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); + if(log.isDebugEnabled()) { + log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); + } + + try { + RegistryManager.getInstance().persist(dataHolder); + } catch (RegistryException e) { + log.error("Unable to persist data in Registry", e); + } + } + + // remove application + topology.removeApplication(event.getAppId()); + TopologyManager.updateTopology(topology); + + log.info("Removed application [ " + event.getAppId() + " ] from Topology"); + + TopologyEventPublisher.sendApplicationRemovedEvent(event.getAppId(), + clusterData, tenantId, tenantDomain); + } + } finally { TopologyManager.releaseWriteLock(); } - //publishing data - TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java index 6ca8e27a67..cda6196317 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java @@ -37,13 +37,15 @@ public Set getNextStates() { Active (1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Inactive)); + return new HashSet(Arrays.asList(ApplicationStatus.Terminating, + ApplicationStatus.Inactive)); } }, Inactive (2) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Terminating)); + return new HashSet(Arrays.asList(ApplicationStatus.Active, + ApplicationStatus.Terminating)); } }, Terminating (3) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 06d408ca1c..e99090341d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -50,7 +50,7 @@ public class Cluster implements Serializable, LifeCycleStateTransitionBehavior memberMap; - private ClusterStatus status; + //private ClusterStatus status; private String appId; @@ -70,7 +70,7 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.appId = appId; this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created); // temporary; should be removed - this.status = ClusterStatus.Created; + //this.status = ClusterStatus.Created; } public String getServiceName() { @@ -250,12 +250,12 @@ public String getAppId() { return appId; } - public ClusterStatus getTempStatus() { - return status; - } - - public void setTempStatus(ClusterStatus status) { - this.status = status; - } +// public ClusterStatus getTempStatus() { +// return status; +// } +// +// public void setTempStatus(ClusterStatus status) { +// this.status = status; +// } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java index 27f7041070..5151501322 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatedEvent.java @@ -18,7 +18,10 @@ */ package org.apache.stratos.messaging.event.application.status; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; + import java.io.Serializable; +import java.util.Set; /** * This event will be fired upon the application terminated is detected. @@ -27,12 +30,18 @@ public class ApplicationTerminatedEvent extends StatusEvent implements Serializa private static final long serialVersionUID = 2625412714611885089L; private String appId; + private Set clusterData; - public ApplicationTerminatedEvent(String appId) { + public ApplicationTerminatedEvent(String appId, Set clusterData) { this.appId = appId; + this.clusterData = clusterData; } public String getAppId() { return appId; } + + public Set getClusterData() { + return clusterData; + } } From c91ef96cbed87022a2729d7311d901402d5c40a4 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Tue, 21 Oct 2014 16:10:46 -0700 Subject: [PATCH 226/436] code cleanup , renaming classes, methods for more consistency --- .../CompositeApplicationManager.java | 4 +- ...nition.java => ApplicationDefinition.java} | 2 +- .../DefaultCompositeApplicationParser.java | 14 +- .../DataInsertionAndRetrievalManager.java | 2 +- .../stratos/manager/utils/Serializer.java | 2 +- .../bean/util/converter/PojoConverter.java | 4 +- .../rest/endpoint/services/ServiceUtils.java | 140 +----------------- .../rest/endpoint/services/StratosAdmin.java | 6 +- 8 files changed, 21 insertions(+), 153 deletions(-) rename components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/{CompositeAppDefinition.java => ApplicationDefinition.java} (98%) diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java index 9dce3037aa..649db842c1 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java @@ -4,7 +4,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.parser.CompositeApplicationParser; import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser; import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; @@ -28,7 +28,7 @@ public CompositeApplicationManager () { cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); } - public void deployCompositeApplication (CompositeAppDefinition compositeAppDefinition, int tenantId, String tenantDomain, + public void deployCompositeApplication (ApplicationDefinition compositeAppDefinition, int tenantId, String tenantDomain, String tenantAdminUsername) throws CompositeApplicationException, CompositeApplicationDefinitionException, PersistenceManagerException { diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java similarity index 98% rename from components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java rename to components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java index 353d7db12b..fb201f88a8 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/CompositeAppDefinition.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/ApplicationDefinition.java @@ -23,7 +23,7 @@ import java.util.List; @XmlRootElement -public class CompositeAppDefinition { +public class ApplicationDefinition { private String applicationId; diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 3b54bedd2f..9a49e2c20e 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.manager.client.CloudControllerServiceClient; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; @@ -55,10 +55,10 @@ public DefaultCompositeApplicationParser () { @Override public CompositeAppContext parse(Object obj) throws CompositeApplicationDefinitionException { - CompositeAppDefinition compositeAppDefinition = null; + ApplicationDefinition compositeAppDefinition = null; - if (obj instanceof CompositeAppDefinition) { - compositeAppDefinition = (CompositeAppDefinition) obj; + if (obj instanceof ApplicationDefinition) { + compositeAppDefinition = (ApplicationDefinition) obj; } if (compositeAppDefinition == null) { @@ -102,7 +102,7 @@ public CompositeAppContext parse(Object obj) throws CompositeApplicationDefiniti return buildCompositeAppStructure (compositeAppDefinition, definedGroups, subscribablesInfo); } - private Map getDefinedGroups (CompositeAppDefinition compositeAppDefinition) throws + private Map getDefinedGroups (ApplicationDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException { // map [group alias -> Group Definition] @@ -146,7 +146,7 @@ private Map getDefinedGroups (CompositeAppDefinition co return definedGroups; } - private Map getSubscribableInformation (CompositeAppDefinition compositeAppDefinition) throws + private Map getSubscribableInformation (ApplicationDefinition compositeAppDefinition) throws CompositeApplicationDefinitionException { // map [cartridge alias -> Subscribable Information] @@ -189,7 +189,7 @@ private boolean isGroupDeployed (String serviceGroupName) throws CompositeApplic } - private CompositeAppContext buildCompositeAppStructure (CompositeAppDefinition compositeAppDefinition, + private CompositeAppContext buildCompositeAppStructure (ApplicationDefinition compositeAppDefinition, Map definedGroups, Map subscribableInformation) throws CompositeApplicationDefinitionException { 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 index e4fb669206..c404978433 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +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; 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 index a9fc6fe306..248abdf308 100644 --- 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 @@ -19,7 +19,7 @@ package org.apache.stratos.manager.utils; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +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; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 3524bf4ae2..d4002ea1e2 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -23,7 +23,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.cloud.controller.stub.pojo.application.*; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; @@ -677,7 +677,7 @@ public static List convertToServiceDefinitionBeans (Colle private static Log log = LogFactory.getLog(PojoConverter.class); - public static ApplicationContext convertApplicationBeanToApplicationContext (CompositeAppDefinition compositeAppDefinition) { + public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) { ApplicationContext applicationContext = new ApplicationContext(); applicationContext.setApplicationId(compositeAppDefinition.getApplicationId()); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index ff357b6549..d0b256f51d 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -34,7 +34,7 @@ import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.composite.application.CompositeApplicationManager; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager; import org.apache.stratos.manager.dto.Cartridge; @@ -129,148 +129,16 @@ static void deployCartridge(CartridgeDefinitionBean cartridgeDefinitionBean, Con } } - // Grouping - /* - static StratosAdminResponse deployApplication(CompositeApplicationDefinitionBean applicationDefinitionBean, ConfigurationContext ctxt, - String userName, String tenantDomain) throws RestAPIException { - - log.info("Starting to deploy a application " + applicationDefinitionBean); - - if (log.isDebugEnabled()) { - log.debug("application data id:" + applicationDefinitionBean.applicationId + " /alias: " + - applicationDefinitionBean.alias); - if (applicationDefinitionBean.components != null) { - log.debug("application config groups size " + applicationDefinitionBean.components.size()); - for (ComponentDefinition cfg : applicationDefinitionBean.components) { - log.debug("listing application config groups " + cfg.alias + " /sub " + - cfg.subscribables + " /dep " + cfg.dependencies); - if (cfg.dependencies != null) { - log.debug("listing application group dependencies: kill: " + - cfg.dependencies.kill_behavior + " / startup: " + - cfg.dependencies.startup_order); - if (cfg.dependencies.startup_order != null) { - for (ConfigDependencies.Pair pair : cfg.dependencies.startup_order) { - log.debug("listing dependencies pairs : " + pair.getKey() + " / " + pair.getValue()); - } - } - } - } - } else { - log.debug("no config group in application"); - } - - } - - // convert to json - String applicationId = applicationDefinitionBean.applicationId; - - if (log.isDebugEnabled()) { - log.debug("publishing application created event " + applicationId); - } - - // convert to domain object - move to ojoConverted - ConfigCompositeApplication app = PojoConverter.convertToCompositeApplication(applicationDefinitionBean); - if (log.isDebugEnabled()) { - log.debug("converted application to CompositeApplication " + app); - } - CompositeApplicationManager manager = new CompositeApplicationManager(); - - - try { - manager.deployCompositeApplication(app); - } catch (ADCException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = e.getMessage(); - log.error(message, e); - throw new RestAPIException(message, e); - } - - log.info("l [type] " + applicationDefinitionBean); - // deploy to cloud controller - CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); - - - if (log.isDebugEnabled()) { - log.debug("deployeing composite app in cloud controller"); - } - - ServiceUtils.deployApplicationDefinition(applicationDefinitionBean, ctxt, userName, tenantDomain); - - if (log.isDebugEnabled()) { - log.debug("done deployeing composite app in cloud controller"); - } - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deployed application definition w" + applicationDefinitionBean); - return stratosAdminResponse; - } */ - /* - static StratosAdminResponse deployApplicationDefinition (CompositeApplicationDefinitionBean compositeApplicationDefinition, ConfigurationContext ctxt, - String userName, String tenantDomain) throws RestAPIException { - - log.info("Starting to deploy composite application definition "+ compositeApplicationDefinition); - - CompositeApplicationDefinition appConfig = PojoConverter.convertToCompositeApplicationForCC(compositeApplicationDefinition); - - CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient(); - - if (cloudControllerServiceClient != null) { - // call CC - try { - cloudControllerServiceClient.deployApplicationDefinition(appConfig); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - log.error(e.getMessage(), e); - throw new RestAPIException(e.getMessage(), e); - } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - //String message = e.getFaultMessage().getInvalidCompositeApplicationDefinitionException().getMessage(); - String message = "CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException"; - log.error(message, e); - throw new RestAPIException(message, e); - } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - String message = e.getFaultMessage().getInvalidIaasProviderException().getMessage(); - log.error(message, e); - throw new RestAPIException(message, e); - } - - log.info("Successfully deployed composite application to Cloud Controller"); - - } - - StratosAdminResponse stratosAdminResponse = new StratosAdminResponse(); - stratosAdminResponse.setMessage("Successfully deployed composite application to cloud controller"); - return stratosAdminResponse; - } -*/ - static void deployCompositeApplicationDefintion (CompositeAppDefinition compositeAppDefinition, ConfigurationContext ctxt, + static void deployApplicationDefinition (ApplicationDefinition appDefinition, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { -// -// int tenantId = ApplicationManagementUtil.getTenantId(ctxt); -// -// try { -// compositeApplicationManager.deployCompositeApplication(compositeAppDefinition, tenantId, tenantDomain, userName); -// -// } catch (CompositeApplicationDefinitionException e) { -// throw new RestAPIException(e); -// } catch (PersistenceManagerException e) { -// throw new RestAPIException(e); -// } catch (CompositeApplicationException e) { -// throw new RestAPIException(e); -// } // check if an application with same id already exists // check if application with same appId / tenant already exists CartridgeSubscriptionManager subscriptionMgr = new CartridgeSubscriptionManager(); int tenantId = ApplicationManagementUtil.getTenantId(ctxt); - String appId = compositeAppDefinition.getApplicationId(); + String appId = appDefinition.getApplicationId(); try { if (subscriptionMgr.getApplicationSubscription(appId, tenantId) != null) { @@ -281,7 +149,7 @@ static void deployCompositeApplicationDefintion (CompositeAppDefinition composit throw new RestAPIException(e1); } - ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(compositeAppDefinition); + ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition); applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index fe4a696673..1a28e0d742 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -25,7 +25,7 @@ import org.apache.stratos.common.exception.StratosException; import org.apache.stratos.common.util.ClaimsMgtUtil; import org.apache.stratos.common.util.CommonUtil; -import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; +import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; import org.apache.stratos.manager.exception.DomainMappingExistsException; @@ -143,9 +143,9 @@ public StratosAdminResponse deployApplicationDefinition(CompositeApplicationDefi @AuthorizationAction("/permission/protected/manage/monitor/tenants") @SuperTenantService(true) // Grouping - public Response deployApplicationDefinition(CompositeAppDefinition applicationDefinitionBean) + public Response deployApplicationDefinition(ApplicationDefinition applicationDefinitionBean) throws RestAPIException { - ServiceUtils.deployCompositeApplicationDefintion(applicationDefinitionBean, getConfigContext(), + ServiceUtils.deployApplicationDefinition(applicationDefinitionBean, getConfigContext(), getUsername(), getTenantDomain()); URI url = uriInfo.getAbsolutePathBuilder().path(applicationDefinitionBean.getApplicationId()).build(); From 4904878df788dee015775caf53f6564ddf985df6 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 11:47:52 +0530 Subject: [PATCH 227/436] adding support to start instances on top of termination --- .../grouping/dependency/DependencyTree.java | 22 ++++ .../context/ApplicationContext.java | 9 +- .../monitor/ParentComponentMonitor.java | 117 ++++++++++-------- .../application/ApplicationMonitor.java | 14 ++- .../monitor/group/GroupMonitor.java | 22 ++-- 5 files changed, 119 insertions(+), 65 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 61648b31de..48ba7b7b2e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.messaging.domain.topology.Application; import java.util.ArrayList; import java.util.List; @@ -159,6 +160,27 @@ public List getStarAbleDependencies() { return this.applicationContextList; } + public List getStarAbleDependenciesByTermination() { + //Breadth First search over the graph to find out which level has the terminated contexts + return traverseGraphByLevel(this.applicationContextList); + } + + + private List traverseGraphByLevel(List contexts) { + for(ApplicationContext context : contexts) { + if(context.isTerminated()) { + return contexts; + } + } + + for(ApplicationContext context : contexts) { + return traverseGraphByLevel(context.getApplicationContextList()); + } + return null; + } + + + /** * When one group/cluster terminates/in_maintenance, need to consider about other * dependencies diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java index e496f4017a..45e165525f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -32,7 +32,7 @@ public abstract class ApplicationContext { private String id; protected boolean started; - protected boolean terminated; + private boolean terminated; private ClusterStatus status; @@ -95,4 +95,11 @@ public boolean hasChild() { } + public boolean isTerminated() { + return terminated; + } + + public void setTerminated(boolean terminated) { + this.terminated = terminated; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 74a421b2e3..5bfb5423dc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -31,10 +31,7 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; -import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import java.util.HashMap; import java.util.List; @@ -69,19 +66,19 @@ public ParentComponentMonitor(ParentComponent component) throws DependencyBuilde protected abstract void monitor(MonitorStatusEvent statusEvent); - protected void onChildActivatedEvent(MonitorStatusEvent statusEvent) { + protected void onChildActivatedEvent(String idOfEvent) { try { //if the activated monitor is in in_active map move it to active map - if (this.aliasToInActiveMonitorsMap.containsKey(id)) { - this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(id)); + if (this.aliasToInActiveMonitorsMap.containsKey(idOfEvent)) { + this.aliasToActiveMonitorsMap.put(id, this.aliasToInActiveMonitorsMap.remove(idOfEvent)); } - boolean startDep = startDependency(statusEvent.getId()); + boolean startDep = startDependency(idOfEvent); if (log.isDebugEnabled()) { - log.debug("started a child: " + startDep + " by the group/cluster: " + id); + log.debug("started a child: " + startDep + " by the group/cluster: " + idOfEvent); } if (!startDep) { - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); } } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription @@ -90,13 +87,13 @@ protected void onChildActivatedEvent(MonitorStatusEvent statusEvent) { } - protected void onChildTerminatingEvent() { + protected void onChildTerminatingEvent(String idOfEvent) { //Check whether hasDependent true - if (!this.aliasToInActiveMonitorsMap.containsKey(id)) { - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + if (!this.aliasToInActiveMonitorsMap.containsKey(idOfEvent)) { + this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(idOfEvent)); } - Monitor monitor = this.aliasToInActiveMonitorsMap.get(id); + Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent); for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { if (monitor.hasMonitors()) { StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); @@ -107,12 +104,12 @@ protected void onChildTerminatingEvent() { } } - protected void onChildInActiveEvent() { + protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; - terminationList = this.dependencyTree.getTerminationDependencies(id); + terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); //Temporarily move the group/cluster to inactive list - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(id)); + this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); if (terminationList != null) { //Checking the termination dependents status @@ -131,20 +128,25 @@ protected void onChildInActiveEvent() { } } } else { - log.warn("Wrong inActive event received from [Child] " + id + " to the [parent]" + log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" + " where child is identified as a independent"); } } - protected void onChildTerminatedEvent() { + protected void onChildTerminatedEvent(String idOfEvent) { List terminationList; boolean allDependentTerminated = true; - terminationList = this.dependencyTree.getTerminationDependencies(id); + + ApplicationContext context = this.dependencyTree.findApplicationContextWithId(idOfEvent); + context.setTerminated(true); + + terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); + /** + * Make sure that all the dependents have been terminated properly to start the recovery + */ if (terminationList != null) { for (ApplicationContext context1 : terminationList) { if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [Parent Monitor] " + context1.getId() - + " to be terminated"); allDependentTerminated = false; } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); @@ -153,40 +155,44 @@ protected void onChildTerminatedEvent() { allDependentTerminated = true; } } + } - if (allDependentTerminated) { - - } - } else { - List parentContexts = this.dependencyTree.findAllParentContextWithId(id); - boolean canStart = false; - if (parentContexts != null) { - for (ApplicationContext context1 : parentContexts) { - if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [Parent Monitor] " + context1.getId() - + " to be terminated"); - canStart = false; - } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { - if (canStart) { - log.warn("Found the Dependent [monitor] " + context1.getId() - + " in the active list wrong state"); - } - } else { - log.info("[Parent Monitor] " + context1.getId() - + " has already been terminated"); - canStart = true; + List parentContexts = this.dependencyTree.findAllParentContextWithId(idOfEvent); + boolean canStart = false; + if (parentContexts != null) { + for (ApplicationContext context1 : parentContexts) { + if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + canStart = false; + } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + if (canStart) { + log.warn("Found the Dependent [monitor] " + context1.getId() + + " in the active list wrong state"); } + } else { + log.info("[Parent Monitor] " + context1.getId() + + " has already been terminated"); + canStart = true; } + } + } - if (canStart) { - //start the monitor - } + if((terminationList != null && allDependentTerminated || terminationList == null) && + (parentContexts != null && canStart || parentContexts == null)) { + //Find the non existent monitor by traversing dependency tree - } else { - //Start the monitor + try { + this.startDependency(); + } catch (TopologyInConsistentException e) { + e.printStackTrace(); } - + } else { + log.info("Waiting for the dependent of [monitor] " + idOfEvent + + " to be terminated"); } + + } @@ -202,6 +208,19 @@ public void startDependency() throws TopologyInConsistentException { } + /** + * This will start the parallel dependencies at once from the top level + * by traversing to find the terminated dependencies. + * it will get invoked when start a child monitor on termination of a sub tree + */ + public void startDependencyOnTermination() throws TopologyInConsistentException { + //start the first dependency which went to terminated + List applicationContexts = this.dependencyTree. + getStarAbleDependenciesByTermination(); + startDependency(applicationContexts); + + } + /** * This will get invoked based on the activation event of its one of the child * @@ -229,7 +248,7 @@ private boolean startDependency(List applicationContexts) if (log.isDebugEnabled()) { log.debug("Dependency check for the Group " + context.getId() + " started"); } - if(!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { + if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) { //to avoid if it is already started startMonitor(this, context); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index c587115e18..b7db30bb72 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -160,18 +160,22 @@ protected void monitor(MonitorStatusEvent statusEvent) { LifeCycleState status1 = statusEvent.getStatus(); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { - onChildActivatedEvent(statusEvent); + onChildActivatedEvent(id); + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { - onChildInActiveEvent(); + onChildInActiveEvent(id); //TODO update the status of the Application as in_active when child becomes in_active + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - onChildTerminatingEvent(); + onChildTerminatingEvent(id); StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != ApplicationStatus.Terminating) { - onChildTerminatedEvent(); + if (this.status != ApplicationStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() && + !this.aliasToActiveMonitorsMap.isEmpty()) { + onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 1b01ed0b99..14c53cdb30 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -22,9 +22,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.*; +import org.apache.stratos.autoscaler.monitor.EventHandler; +import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; @@ -34,8 +34,6 @@ import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; -import java.util.List; - /** * This is GroupMonitor to monitor the group which consists of * groups and clusters @@ -82,19 +80,23 @@ protected void monitor(MonitorStatusEvent statusEvent) { LifeCycleState status1 = statusEvent.getStatus(); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination if (status1 == ClusterStatus.Active || status1 == GroupStatus.Active) { - onChildActivatedEvent(statusEvent); + onChildActivatedEvent(id); + } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { - onChildInActiveEvent(); + onChildInActiveEvent(id); //To update the status of the Group StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - onChildTerminatingEvent(); + onChildTerminatingEvent(id); StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != GroupStatus.Terminating) { - onChildTerminatedEvent(); + if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() && + !this.aliasToActiveMonitorsMap.isEmpty()) { + onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); From fd6b7ab9b2f6031dab1c888fc7e0c5a8ff6f7a2f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 11:53:06 +0530 Subject: [PATCH 228/436] changing life cycle states to allow transitions to self --- .../controller/topology/TopologyBuilder.java | 8 ++++---- .../domain/topology/ApplicationStatus.java | 15 ++++++++------- .../domain/topology/ClusterStatus.java | 15 ++++++++------- .../messaging/domain/topology/GroupStatus.java | 13 ++++++++----- .../messaging/domain/topology/MemberStatus.java | 17 ++++++++++------- .../lifecycle/LifeCycleStateManager.java | 2 +- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 68c96d47b7..c3286c5f22 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -707,14 +707,14 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); if (aCluster != null) { // validate state transition - if (aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating + " successfully"); + + ClusterStatus.Terminating); } // for now anyway update the status forcefully aCluster.setStatus(ClusterStatus.Terminating); log.info("Cluster " + clusterDataHolder.getClusterId() + "'s status updated to " - + ClusterStatus.Terminating + " successfully"); + + ClusterStatus.Terminating); } else { log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + @@ -723,7 +723,7 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold } else { log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); + " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java index cda6196317..2173f86442 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java @@ -30,34 +30,35 @@ public enum ApplicationStatus implements LifeCycleState { Created (0) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Active, - ApplicationStatus.Terminating)); + return new HashSet(Arrays.asList(ApplicationStatus.Created, + ApplicationStatus.Active, ApplicationStatus.Terminating)); } }, Active (1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Terminating, - ApplicationStatus.Inactive)); + return new HashSet(Arrays.asList(ApplicationStatus.Active, + ApplicationStatus.Terminating, ApplicationStatus.Inactive)); } }, Inactive (2) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Active, + return new HashSet(Arrays.asList(ApplicationStatus.Inactive, ApplicationStatus.Active, ApplicationStatus.Terminating)); } }, Terminating (3) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ApplicationStatus.Terminated)); + return new HashSet(Arrays.asList(ApplicationStatus.Terminating, + ApplicationStatus.Terminated)); } }, Terminated (4) { @Override public Set getNextStates() { - return null; + return new HashSet(Arrays.asList(ApplicationStatus.Terminated)); } }; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java index 8ff59573eb..afc0b30b97 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -30,40 +30,41 @@ public enum ClusterStatus implements LifeCycleState { Created(0) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Active, - ClusterStatus.Terminating)); + return new HashSet(Arrays.asList(ClusterStatus.Created, + ClusterStatus.Active, ClusterStatus.Terminating)); } }, Active(1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Inactive, + return new HashSet(Arrays.asList(ClusterStatus.Active, ClusterStatus.Inactive, ClusterStatus.Patching, ClusterStatus.Terminating)); } }, Patching (2) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Active)); + return new HashSet(Arrays.asList(ClusterStatus.Patching, ClusterStatus.Active)); } }, Inactive(3) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Active, + return new HashSet(Arrays.asList(ClusterStatus.Inactive, ClusterStatus.Active, ClusterStatus.Terminating)); } }, Terminating(4) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(ClusterStatus.Terminated)); + return new HashSet(Arrays.asList(ClusterStatus.Terminating, + ClusterStatus.Terminated)); } }, Terminated(5) { @Override public Set getNextStates() { - return null; + return new HashSet(Arrays.asList(ClusterStatus.Terminated)); } }; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java index 55a77310e6..42873be35c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java @@ -29,31 +29,34 @@ public enum GroupStatus implements LifeCycleState { Created(0) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(GroupStatus.Active, GroupStatus.Terminating)); + return new HashSet(Arrays.asList(GroupStatus.Created, + GroupStatus.Active, GroupStatus.Terminating)); } }, Active(1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(GroupStatus.Inactive, GroupStatus.Terminating)); + return new HashSet(Arrays.asList(GroupStatus.Active, + GroupStatus.Inactive, GroupStatus.Terminating)); } }, Inactive(2) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(GroupStatus.Terminating)); + return new HashSet(Arrays.asList(GroupStatus.Inactive, GroupStatus.Terminating)); } }, Terminating(3) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(GroupStatus.Terminated)); + return new HashSet(Arrays.asList(GroupStatus.Terminating, + GroupStatus.Terminated)); } }, Terminated(4) { @Override public Set getNextStates() { - return null; + return new HashSet(Arrays.asList(GroupStatus.Terminated)); } }; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java index a35766cd7b..624d134b97 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/MemberStatus.java @@ -35,44 +35,47 @@ public enum MemberStatus implements LifeCycleState { Created(0) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.Starting)); + return new HashSet(Arrays.asList(MemberStatus.Created, MemberStatus.Starting)); } }, Starting(1) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.Activated)); + return new HashSet(Arrays.asList(MemberStatus.Starting, MemberStatus.Activated)); } }, Activated(2) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.Suspended, + return new HashSet(Arrays.asList(MemberStatus.Activated, MemberStatus.Suspended, MemberStatus.In_Maintenance, MemberStatus.Starting)); } }, In_Maintenance(3) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.ReadyToShutDown)); + return new HashSet(Arrays.asList(MemberStatus.In_Maintenance, + MemberStatus.ReadyToShutDown)); } }, ReadyToShutDown(4) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.Terminated)); + return new HashSet(Arrays.asList(MemberStatus.ReadyToShutDown, + MemberStatus.Terminated)); } }, Suspended(5) { @Override public Set getNextStates() { - return new HashSet(Arrays.asList(MemberStatus.Terminated)); + return new HashSet(Arrays.asList(MemberStatus.Suspended, + MemberStatus.Terminated)); } }, Terminated(6) { @Override public Set getNextStates() { - return null; + return new HashSet(Arrays.asList(MemberStatus.Terminated)); } }; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index 0f627a8a08..bbe81a66af 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -36,7 +36,7 @@ public LifeCycleStateManager(T initialState) { stateStack = new Stack(); stateStack.push(initialState); - log.info("Life Cycle State Manager created, initial state: " + initialState.toString()); + log.info("Life Cycle State Manager started, initial state: " + initialState.toString()); } /** From b92a27d35011acaed7e1b8732e9103c570642ac1 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 12:18:29 +0530 Subject: [PATCH 229/436] fixing a bug in printing state changes --- .../domain/topology/lifecycle/LifeCycleStateManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index bbe81a66af..b1b01902dd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -102,7 +102,7 @@ public T getCurrentState () { * @return previous state */ public T getPreviousState () { - return stateStack.get(1); + return stateStack.get(stateStack.size() - 2); } /** From 1763feac9dbfd7877f288af423661417c5c3fca9 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 22 Oct 2014 13:50:19 +0530 Subject: [PATCH 230/436] adding message processors for topology --- ...pplicationInactivatedMessageProcessor.java | 103 ++++++++++++++++++ ...ApplicationTerminatedMessageProcessor.java | 103 ++++++++++++++++++ .../TopologyMessageProcessorChain.java | 25 ++++- ...pplicationTerminatingMessageProcessor.java | 102 +++++++++++++++++ 4 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java new file mode 100644 index 0000000000..986e04ea1b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java @@ -0,0 +1,103 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ +public class ApplicationInactivatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationInactivatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (ApplicationInactivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. + jsonToObject(message, ApplicationInactivatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + application.setStatus(ApplicationStatus.Terminated); + if (log.isInfoEnabled()) { + log.info(String.format("Application updated as inactivated : %s", + application.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java new file mode 100644 index 0000000000..3c9d753ac0 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -0,0 +1,103 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ +public class ApplicationTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationTerminatedMessageProcessor.class); + + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (ApplicationInactivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. + jsonToObject(message, ApplicationInactivatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + application.setStatus(ApplicationStatus.Terminating); + if (log.isInfoEnabled()) { + log.info(String.format("Application updated as terminating : %s", + application.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index db9e8b1831..b0cefbbf0e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,8 +22,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationInActivatedEventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatedEventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; +import org.apache.stratos.messaging.message.processor.topology.updater.ApplicationTerminatingMessageProcessor; /** * Defines default topology message processor chain. @@ -51,6 +55,9 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; + private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor; + private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor; + private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor; public void initialize() { // Add topology event processors @@ -108,6 +115,15 @@ public void initialize() { applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); add(applicationActivatedMessageProcessor); + applicationInactivatedMessageProcessor = new ApplicationInactivatedMessageProcessor(); + add(applicationInactivatedMessageProcessor); + + applicationTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor(); + add(applicationTerminatedMessageProcessor); + + applicationTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor(); + add(applicationTerminatingMessageProcessor); + if (log.isDebugEnabled()) { log.debug("Topology message processor chain initialized X1"); } @@ -150,7 +166,14 @@ public void addEventListener(EventListener eventListener) { applicationRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { applicationActivatedMessageProcessor.addEventListener(eventListener); - } else { + } else if (eventListener instanceof ApplicationInActivatedEventListener){ + applicationInactivatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationTerminatedEventListener){ + applicationTerminatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ApplicationTerminatingEventListener){ + applicationTerminatingMessageProcessor.addEventListener(eventListener); + } + else { throw new RuntimeException("Unknown event listener"); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java new file mode 100644 index 0000000000..fba6b53c82 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java @@ -0,0 +1,102 @@ +/* + * 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.messaging.message.processor.topology.updater; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ +public class ApplicationTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationTerminatingMessageProcessor.class); + + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (ApplicationInactivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. + jsonToObject(message, ApplicationInactivatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + application.setStatus(ApplicationStatus.Inactive); + if (log.isInfoEnabled()) { + log.info(String.format("Application updated as activated : %s", + application.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } +} From dda0db8b3e4c430a4b06b5165ca1a1462bfa83dd Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 22 Oct 2014 13:52:13 +0530 Subject: [PATCH 231/436] add more details to getapplicationinfo --- .../rest/endpoint/bean/ApplicationBean.java | 30 +++++++- .../stratos/rest/endpoint/bean/GroupBean.java | 28 ++++++- .../bean/util/converter/PojoConverter.java | 34 ++++++++- .../rest/endpoint/services/ServiceUtils.java | 75 +++++++++---------- .../rest/endpoint/services/StratosAdmin.java | 3 +- 5 files changed, 124 insertions(+), 46 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java index dbcbe9ccae..eb90f3b5a6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java @@ -11,9 +11,13 @@ */ @XmlRootElement(name="applications") public class ApplicationBean { + private String id; + private String tenantDomain; + private String tenantAdminUsername; public List groups = null; public List clusters = null; - public String id; + + public ApplicationBean(){ this.groups = new ArrayList(); this.clusters = new ArrayList(); @@ -21,4 +25,28 @@ public ApplicationBean(){ public void addGroup(GroupBean groupBean) { this.groups.add(groupBean); } + + public void setId(String id) { + this.id = id; + } + + public void setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + } + + public void setTenantAdminUsername(String tenantAdminUsername) { + this.tenantAdminUsername = tenantAdminUsername; + } + + public String getId() { + return id; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getTenantAdminUsername() { + return tenantAdminUsername; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java index b79265ce1a..b86da10e40 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/GroupBean.java @@ -28,7 +28,9 @@ public class GroupBean { private List subGroups = null; private List clusters = null; - public String alias; + private String alias; + private String deploymentPolicy; + private String autoScalingPolicy; public GroupBean(){ this.setClusters(new ArrayList()); @@ -57,4 +59,28 @@ public List getClusters() { public void setClusters(List clusters) { this.clusters = clusters; } + + public void setAlias(String alias) { + this.alias = alias; + } + + public void setDeploymentPolicy(String deploymentPolicy) { + this.deploymentPolicy = deploymentPolicy; + } + + public void setAutoScalingPolicy(String autoScalingPolicy) { + this.autoScalingPolicy = autoScalingPolicy; + } + + public String getAlias() { + return alias; + } + + public String getDeploymentPolicy() { + return deploymentPolicy; + } + + public String getAutoScalingPolicy() { + return autoScalingPolicy; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 3524bf4ae2..5970415534 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -19,8 +19,9 @@ package org.apache.stratos.rest.endpoint.bean.util.converter; -import org.apache.commons.logging.LogFactory; import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.cloud.controller.stub.pojo.application.*; import org.apache.stratos.manager.composite.application.beans.CompositeAppDefinition; @@ -30,9 +31,12 @@ import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; -import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.subscription.SubscriptionDomain; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.rest.endpoint.bean.ApplicationBean; +import org.apache.stratos.rest.endpoint.bean.GroupBean; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.PartitionGroup; import org.apache.stratos.rest.endpoint.bean.autoscaler.policy.autoscale.*; @@ -40,7 +44,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.*; import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.topology.Member; -import org.apache.commons.logging.Log; import java.util.ArrayList; import java.util.Arrays; @@ -788,6 +791,31 @@ private static SubscribableContext getSubscribableContextFromSubscribableDefinit subscribableContext.setType(subscribableDefinition.getType()); return subscribableContext; } + + public static ApplicationBean applicationToBean(Application application) { + + if(application == null){ + return null; + } + + ApplicationBean applicationBean = new ApplicationBean(); + applicationBean.setId(application.getUniqueIdentifier()); + applicationBean.setTenantDomain(application.getTenantDomain()); + applicationBean.setTenantAdminUsername(application.getTenantAdminUserName()); + return applicationBean; + } + + public static GroupBean toGroupBean(Group group) { + if(group == null){ + return null; + } + + GroupBean groupBean = new GroupBean(); + groupBean.setAlias(group.getUniqueIdentifier()); + groupBean.setDeploymentPolicy(group.getDeploymentPolicy()); + groupBean.setAutoScalingPolicy(group.getAutoscalingPolicy()); + return groupBean; + } /* public static ConfigCompositeApplication convertToCompositeApplication(CompositeApplicationDefinitionBean appBean) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index ff357b6549..8c0ea6deda 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -52,8 +52,6 @@ import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.manager.utils.CartridgeConstants; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import org.apache.stratos.rest.endpoint.bean.ApplicationBean; @@ -68,7 +66,6 @@ import org.apache.stratos.rest.endpoint.bean.cartridge.definition.ServiceDefinitionBean; import org.apache.stratos.rest.endpoint.bean.repositoryNotificationInfoBean.Payload; import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; -import org.apache.stratos.rest.endpoint.bean.topology.*; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; @@ -1582,28 +1579,43 @@ static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) t log.info("Successfully undeployed the Service Group Definition with name " + serviceGroupDefinitionName); } - public static Object getApplicationInfo(String applicationId, ConfigurationContext configContext) { + public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext configContext) { + ApplicationBean applicationBean = null; + try{ + TopologyManager.acquireReadLockForApplication(applicationId); + Application application = TopologyManager.getTopology().getApplication(applicationId); + if(application == null){ + return null; + } + applicationBean = PojoConverter.applicationToBean(application); - TopologyManager.acquireReadLock(); - Application application = TopologyManager.getTopology().getApplication(applicationId); - ApplicationBean applicationBean = applicationToBean(application); + Map topLevelClusterDataMap = application.getClusterDataMap(); + for(Map.Entry entry : topLevelClusterDataMap.entrySet()){ + ClusterDataHolder clusterDataHolder = entry.getValue(); + String clusterId = clusterDataHolder.getClusterId(); + String serviceType = clusterDataHolder.getServiceType(); + TopologyManager.acquireReadLockForCluster(serviceType, clusterId); + Cluster topLevelCluster; - Map topLevelClusterDataMap = application.getClusterDataMap(); - for(Map.Entry entry : topLevelClusterDataMap.entrySet()){ - String alias = entry.getKey(); - ClusterDataHolder clusterDataHolder = entry.getValue(); - String clusterId = clusterDataHolder.getClusterId(); - Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterDataHolder.getServiceType()).getCluster(clusterId); - applicationBean.clusters.add(toClusterBean(topLevelCluster)); - } + try { + topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId); + }finally { + TopologyManager.releaseReadLockForCluster(serviceType, clusterId); + } + applicationBean.clusters.add(PojoConverter.populateClusterPojos(topLevelCluster)); + } - Collection groups = application.getGroups(); - for(Group group : groups){ - GroupBean groupBean = toGroupBean(group); - setSubGroups(group, groupBean); - applicationBean.addGroup(groupBean); + Collection groups = application.getGroups(); + for(Group group : groups){ + GroupBean groupBean = PojoConverter.toGroupBean(group); + setSubGroups(group, groupBean); + applicationBean.addGroup(groupBean); + } + }finally { + TopologyManager.releaseReadLockForApplication(applicationId); } - TopologyManager.releaseReadLock(); + + return applicationBean; } @@ -1611,7 +1623,7 @@ private static void setSubGroups(Group group, GroupBean groupBean) { Collection subgroups = group.getGroups(); addClustersToGroupBean(group, groupBean); for(Group subGroup : subgroups){ - GroupBean subGroupBean = toGroupBean(subGroup); + GroupBean subGroupBean = PojoConverter.toGroupBean(subGroup); setSubGroups(subGroup, subGroupBean); groupBean.addGroup(subGroupBean); @@ -1624,25 +1636,8 @@ private static void addClustersToGroupBean(Group group, GroupBean groupBean) { String alias = x.getKey(); ClusterDataHolder clusterHolder = x.getValue(); Cluster topLevelCluster = TopologyManager.getTopology().getService(clusterHolder.getServiceType()).getCluster(clusterHolder.getClusterId()); - groupBean.addCluster(toClusterBean(topLevelCluster)); + groupBean.addCluster(PojoConverter.populateClusterPojos(topLevelCluster)); } } - private static GroupBean toGroupBean(Group group) { - GroupBean groupBean = new GroupBean(); - groupBean.alias = group.getUniqueIdentifier(); - return groupBean; - } - - private static ApplicationBean applicationToBean(Application application) { - ApplicationBean applicationBean = new ApplicationBean(); - applicationBean.id = application.getUniqueIdentifier(); - return applicationBean; - } - - private static org.apache.stratos.rest.endpoint.bean.topology.Cluster toClusterBean(Cluster cluster){ - org.apache.stratos.rest.endpoint.bean.topology.Cluster clusterBean = new org.apache.stratos.rest.endpoint.bean.topology.Cluster(); - clusterBean.serviceName=cluster.getServiceName(); - return clusterBean; - } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index fe4a696673..45cae8bbf1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -37,6 +37,7 @@ import org.apache.stratos.rest.endpoint.Utils; import org.apache.stratos.rest.endpoint.annotation.AuthorizationAction; import org.apache.stratos.rest.endpoint.annotation.SuperTenantService; +import org.apache.stratos.rest.endpoint.bean.ApplicationBean; import org.apache.stratos.rest.endpoint.bean.CartridgeInfoBean; import org.apache.stratos.rest.endpoint.bean.StratosAdminResponse; import org.apache.stratos.rest.endpoint.bean.SubscriptionDomainRequest; @@ -455,7 +456,7 @@ public Response getSubscriptionsOfApplication(@PathParam("application_id") Strin @Consumes("application/json") @AuthorizationAction("/permission/protected/manage/monitor/tenants") public Response getApplicationInfo(@PathParam("appId") String applicationId) throws RestAPIException { - Object application = ServiceUtils.getApplicationInfo(applicationId, getConfigContext()); + ApplicationBean application = ServiceUtils.getApplicationInfo(applicationId, getConfigContext()); if(application == null) { return Response.status(Response.Status.NOT_FOUND).build(); }else{ From 4eb3e860cfb4b6748bacefd234e87b35a9ebfb4e Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 14:04:06 +0530 Subject: [PATCH 232/436] fixing monitor startup issue --- .../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 1 + .../stratos/autoscaler/monitor/cluster/ClusterMonitor.java | 2 +- .../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index ccca072ea2..d2b206fca4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -77,6 +77,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable public AbstractClusterMonitor() { readConfigurations(); + status = ClusterStatus.Created; } private void readConfigurations() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 65e6882693..114d8aae10 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -65,7 +65,7 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); } networkPartitionCtxts = new ConcurrentHashMap(); - status = ClusterStatus.Created; + //status = ClusterStatus.Created; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 14c53cdb30..161d9b4a4a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -54,7 +54,7 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException TopologyInConsistentException { super(group); this.appId = appId; - this.setStatus(group.getStatus()); + this.status = group.getStatus(); startDependency(); } From 069b61a843e6806bef97c7e74718b8551dd5fe89 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 14:12:33 +0530 Subject: [PATCH 233/436] correcting wrong states in the Application* processors --- .../topology/ApplicationActivatedMessageProcessor.java | 4 ++++ .../topology/ApplicationInactivatedMessageProcessor.java | 6 +++++- .../topology/ApplicationTerminatedMessageProcessor.java | 6 +++++- .../ApplicationTerminatingMessageProcessor.java | 9 +++++++-- .../topology/TopologyMessageProcessorChain.java | 1 - 5 files changed, 21 insertions(+), 5 deletions(-) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/{updater => }/ApplicationTerminatingMessageProcessor.java (88%) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index 8626fca517..ed360be69d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -88,6 +88,10 @@ private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { return false; } else { // Apply changes to the topology + if (!application.isStateTransitionValid(ApplicationStatus.Active)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Active + " ]"); + } application.setStatus(ApplicationStatus.Active); if (log.isInfoEnabled()) { log.info(String.format("Application updated as activated : %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java index 986e04ea1b..a2bdb6098a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java @@ -88,7 +88,11 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) return false; } else { // Apply changes to the topology - application.setStatus(ApplicationStatus.Terminated); + if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Inactive + " ]"); + } + application.setStatus(ApplicationStatus.Inactive); if (log.isInfoEnabled()) { log.info(String.format("Application updated as inactivated : %s", application.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java index 3c9d753ac0..b08e6f9942 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -88,7 +88,11 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) return false; } else { // Apply changes to the topology - application.setStatus(ApplicationStatus.Terminating); + if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Terminated + " ]"); + } + application.setStatus(ApplicationStatus.Terminated); if (log.isInfoEnabled()) { log.info(String.format("Application updated as terminating : %s", application.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java similarity index 88% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java index fba6b53c82..2c1ed00566 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology.updater; +package org.apache.stratos.messaging.message.processor.topology; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -87,7 +88,11 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) return false; } else { // Apply changes to the topology - application.setStatus(ApplicationStatus.Inactive); + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Terminating + " ]"); + } + application.setStatus(ApplicationStatus.Terminating); if (log.isInfoEnabled()) { log.info(String.format("Application updated as activated : %s", application.toString())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 206b7db645..8a549161ce 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -27,7 +27,6 @@ import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; -import org.apache.stratos.messaging.message.processor.topology.updater.ApplicationTerminatingMessageProcessor; /** * Defines default topology message processor chain. From 4b0ef9864f394919a902ad60ab93e685a1cab1f8 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 14:18:58 +0530 Subject: [PATCH 234/436] adding cluster and group in_active processor to processor chain --- ...pplicationStatusMessageProcessorChain.java | 14 +++++++++++ .../topology/GroupInActivateProcessor.java | 5 ++-- .../TopologyMessageProcessorChain.java | 23 +++++++++++++++---- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index 93f9558e07..3c32de829f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -34,7 +34,9 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private static final Log log = LogFactory.getLog(ApplicationStatusMessageProcessorChain.class); private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; + private ApplicationStatusClusterInActivateMessageProcessor clusterInActivateMessageProcessor; private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; + private ApplicationStatusGroupInActivateMessageProcessor groupInActivateMessageProcessor; private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; private ApplicationStatusAppCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; private ApplicationStatusAppInActivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; @@ -45,8 +47,16 @@ public void initialize() { // Add instance notifier event processors clusterActivatedMessageProcessor = new ApplicationStatusClusterActivatedMessageProcessor(); add(clusterActivatedMessageProcessor); + + clusterInActivateMessageProcessor = new ApplicationStatusClusterInActivateMessageProcessor(); + add(clusterInActivateMessageProcessor); + groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); + + groupInActivateMessageProcessor = new ApplicationStatusGroupInActivateMessageProcessor(); + add(groupInActivateMessageProcessor); + appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor(); add(appActivatedMessageProcessor); @@ -71,8 +81,12 @@ public void initialize() { public void addEventListener(EventListener eventListener) { if (eventListener instanceof ClusterActivatedEventListener) { clusterActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterInActivateEventListener) { + clusterInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupInActivateEventListener) { + groupInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ApplicationInActivatedEventListener){ diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java index 571fc74c24..ed8488c06a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; @@ -92,9 +93,7 @@ private boolean doProcess(GroupInActivateEvent event, Topology topology) { event.getGroupId())); } } else { - // Apply changes to the topology - //TODO - // group.setStatus(Status.Activated); + group.setStatus(GroupStatus.Inactive); if (log.isInfoEnabled()) { log.info(String.format("Group updated as activated : %s", group.getUniqueIdentifier())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 8a549161ce..77e4b015c2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,10 +22,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationInActivatedEventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatedEventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatingEventListener; +import org.apache.stratos.messaging.listener.application.status.*; import org.apache.stratos.messaging.listener.topology.*; +import org.apache.stratos.messaging.listener.topology.ApplicationActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.ApplicationCreatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; +import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupInActivateEventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; /** @@ -40,6 +44,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor; private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor; private ClusterActivatedProcessor clusterActivatedProcessor; + private ClusterInActivateProcessor clusterInActivateProcessor; private ClusterRemovedMessageProcessor clusterRemovedMessageProcessor; private InstanceSpawnedMessageProcessor instanceSpawnedMessageProcessor; private MemberStartedMessageProcessor memberStartedMessageProcessor; @@ -49,7 +54,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; private GroupActivatedProcessor groupActivatedProcessor; - //private CompositeApplicationRemovedMessageProcessor compositeApplicationRemovedMessageProcessor; + private GroupInActivateProcessor groupInActivateProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor; private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; @@ -75,6 +80,9 @@ public void initialize() { clusterActivatedProcessor = new ClusterActivatedProcessor(); add(clusterActivatedProcessor); + clusterInActivateProcessor = new ClusterInActivateProcessor(); + add(clusterInActivateProcessor); + clusterRemovedMessageProcessor = new ClusterRemovedMessageProcessor(); add(clusterRemovedMessageProcessor); @@ -102,6 +110,9 @@ public void initialize() { groupActivatedProcessor = new GroupActivatedProcessor(); add(groupActivatedProcessor); + groupInActivateProcessor = new GroupInActivateProcessor(); + add(groupInActivateProcessor); + applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); add(applicationCreatedMessageProcessor); @@ -135,6 +146,8 @@ public void addEventListener(EventListener eventListener) { clusterCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterActivatedEventListener) { clusterActivatedProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterInActivateEventListener) { + clusterInActivateProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterRemovedEventListener) { clusterRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof InstanceSpawnedEventListener) { @@ -157,6 +170,8 @@ public void addEventListener(EventListener eventListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupInActivateEventListener) { + groupInActivateProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationCreatedEventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationUndeployedEventListener) { From 473f25b2c3e8c4c9a621db69e96b987dddd3aabb Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 14:39:21 +0530 Subject: [PATCH 235/436] fixig an NPE while adding cluster monitor --- .../stratos/autoscaler/status/checker/StatusChecker.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 9b39c5a037..1366bf8572 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -56,7 +56,11 @@ public static StatusChecker getInstance() { */ public void onMemberStatusChange(String clusterId) { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterActive = clusterActive(monitor); + boolean clusterActive = false; + if(monitor != null) { + clusterActive = clusterActive(monitor); + + } log.info("Status checker running for [cluster] " + clusterId + " the status [clusterActive] " + clusterActive); // if active then notify upper layer From b9f7ea275a2e14cbb19c000c3bde49f02bf526fe Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 15:12:57 +0530 Subject: [PATCH 236/436] correcting the log and notifying listeners --- .../topology/ApplicationUndeployedMessageProcessor.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java index 3f397c0b46..8915e4f21a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java @@ -31,7 +31,7 @@ public class ApplicationUndeployedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); + private static final Log log = LogFactory.getLog(ApplicationUndeployedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -113,9 +113,9 @@ private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); if (aCluster != null) { // validate state transition - if (aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating + " successfully"); + + ClusterStatus.Terminating); } // for now anyway update the status forcefully aCluster.setStatus(ClusterStatus.Terminating); @@ -133,6 +133,7 @@ private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) } } + notifyEventListeners(event); return true; } } From 2720204e5d23673623a4ccdfda86375ddecd3be8 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 15:20:30 +0530 Subject: [PATCH 237/436] adding tomcat1 artifacts --- .../samples/ec2/tomcat1.json | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat1.json diff --git a/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat1.json b/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat1.json new file mode 100755 index 0000000000..0984fb9fa8 --- /dev/null +++ b/tools/automation-sripts/grouping-automation-script/samples/ec2/tomcat1.json @@ -0,0 +1,33 @@ +{ + "type": "tomcat1", + "provider": "apache", + "host": "isuruh.lk", + "displayName": "tomcat1", + "description": "tomcat1 Cartridge", + "version": "7", + "multiTenant": "false", + "portMapping": [ + { + "protocol": "http", + "port": "80", + "proxyPort": "8280" + } + ], + "deployment": { + }, + "iaasProvider": [ + { + "type": "ec2", + "imageId": "ap-southeast-1/ami-3c0f5d6e", + "maxInstanceLimit": "2", + "property": [ + ] + } + ], + "loadBalancer": { + "property": { + "name": "no.load.balancer", + "value": "true" + } + }, +} From fa17eee7335daf4a7d65ab7ec0f4328df05a2ebe Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 15:21:36 +0530 Subject: [PATCH 238/436] fixing cluster monitor issue --- .../monitor/ApplicationMonitorFactory.java | 14 ++++++++------ .../autoscaler/monitor/ParentComponentMonitor.java | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 6d8f2a300f..fc22388078 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.MemberStatsContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; @@ -277,11 +278,6 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni } } - if (cluster.hasMembers()) { - //triggering the status checker if cluster has members to decide - // on the current status of the cluster - StatusChecker.getInstance().onMemberStatusChange(clusterId); - } networkPartitionContext.addPartitionContext(partitionContext); if (log.isInfoEnabled()) { log.info(String.format("Partition context has been added: [partition] %s", @@ -294,7 +290,7 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni if(!parentMonitor.isHasDependent() && !context.hasChild()) { clusterMonitor.setHasDependent(true); } - //clusterMonitor.setCurrentStatus(Status.Created); + AutoscalerContext.getInstance().addMonitor(clusterMonitor); if (log.isInfoEnabled()) { log.info(String.format("Network partition context has been added: [network partition] %s", networkPartitionContext.getId())); @@ -306,6 +302,12 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni //updating the status, so that it will notify the parent clusterMonitor.setStatus(cluster.getStatus()); } + + if (!cluster.hasMembers()) { + //triggering the status checker if cluster has members to decide + // on the current status of the cluster + StatusChecker.getInstance().onMemberStatusChange(clusterId); + } } finally { //release read lock for the service and cluster TopologyManager.releaseReadLockForCluster(serviceName, clusterId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 5bfb5423dc..7e748095b0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -350,8 +350,6 @@ public void run() { //TODO parent.notify(); throw new RuntimeException(msg); } - - AutoscalerContext.getInstance().addMonitor(monitor); aliasToActiveMonitorsMap.put(context.getId(), monitor); if (log.isInfoEnabled()) { log.info(String.format("Monitor has been added successfully for: %s", From d390ab5979e99c434c696abe37fe409b7cf24480 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 15:41:27 +0530 Subject: [PATCH 239/436] adding id for cluster monitor --- .../stratos/autoscaler/monitor/cluster/ClusterMonitor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 114d8aae10..8396f552c0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -51,6 +51,7 @@ public class ClusterMonitor extends AbstractClusterMonitor { public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, AutoscalePolicy autoscalePolicy) { this.clusterId = clusterId; + this.id = clusterId; this.serviceId = serviceId; this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); From 76a91ea2100672333e97ddb273e3375b110d7708 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 22 Oct 2014 16:47:18 +0530 Subject: [PATCH 240/436] fixing issue while creating hierarchical monitors --- .../autoscaler/monitor/AbstractClusterMonitor.java | 13 ++----------- .../monitor/ApplicationMonitorFactory.java | 1 - .../apache/stratos/autoscaler/monitor/Monitor.java | 1 + .../autoscaler/monitor/ParentComponentMonitor.java | 1 + 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index d2b206fca4..8ff4cac832 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -68,7 +68,7 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected ClusterStatus status; - protected ParentComponentMonitor parent; + //protected ParentComponentMonitor parent; protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; @@ -252,21 +252,12 @@ public void setStatus(ClusterStatus status) { * If the cluster in_active and if it is a in_dependent cluster, * then won't send the notification to parent. */ - if(status == ClusterStatus.Inactive && !this.hasDependent) { + if(!(status == ClusterStatus.Inactive && !this.hasDependent)) { MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); } } - public ParentComponentMonitor getParent() { - return parent; - } - - public void setParent(ParentComponentMonitor parent) { - this.parent = parent; - this.appId = parent.getAppId(); - } - @Override public void onEvent(MonitorStatusEvent statusEvent) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index fc22388078..92b3eb883a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -236,7 +236,6 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni clusterMonitor = new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(), deploymentPolicy, policy); - clusterMonitor.setAppId(cluster.getAppId()); for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index b670077632..1ac0893a8a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -70,6 +70,7 @@ public ParentComponentMonitor getParent() { public void setParent(ParentComponentMonitor parent) { this.parent = parent; + this.appId = parent.getAppId(); } public boolean hasMonitors() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 7e748095b0..f2965faae4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -52,6 +52,7 @@ public abstract class ParentComponentMonitor extends Monitor { public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException { aliasToActiveMonitorsMap = new HashMap(); + aliasToInActiveMonitorsMap = new HashMap(); //clusterIdToClusterMonitorsMap = new HashMap(); this.id = component.getUniqueIdentifier(); //Building the dependency for this monitor within the immediate children From d5d98d4efff9d5f36f1c2d6d45ff2a671da2a012 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 16:54:48 +0530 Subject: [PATCH 241/436] implementing findClustersOfApplication in ApplicationMonitor --- .../application/ApplicationMonitor.java | 32 +++++++++++-------- .../lifecycle/LifeCycleStateManager.java | 4 +-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index b7db30bb72..deb0950922 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -30,15 +30,11 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; +import java.util.*; /** * ApplicationMonitor is to control the child monitors @@ -67,13 +63,23 @@ public ApplicationMonitor(Application application) throws DependencyBuilderExcep */ public List findClustersOfApplication(String appId) { List clusters = new ArrayList(); - //considering only one level - /*for (AbstractClusterMonitor monitor : this.clusterIdToClusterMonitorsMap.values()) { - clusters.add(monitor.getClusterId()); - }*/ - //TODO restart and read from Topology - return clusters; + Set clusterData; + + TopologyManager.acquireReadLockForApplication(appId); + try { + clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively(); + + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + if (clusterData != null) { + for (ClusterDataHolder clusterDataHolder : clusterData) { + clusters.add(clusterDataHolder.getClusterId()); + } + } + + return clusters; } /** diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index b1b01902dd..9151bb10aa 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -73,9 +73,9 @@ public void changeState (T nextState) { stateStack.push(nextState); if (log.isDebugEnabled()) { printStateTransitions(stateStack); +// log.debug("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " + +// getCurrentState() + " ]"); } - log.info("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " + - getCurrentState() + " ]"); } /** From 6435221ff9e836f6dd2ab115ae1e3545da2de0fc Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 17:25:39 +0530 Subject: [PATCH 242/436] adding a null check and disposing terminateALlKnowledgeSession in AbstractClusterMonitor --- .../topology/AutoscalerTopologyEventReceiver.java | 10 +++++++--- .../autoscaler/monitor/AbstractClusterMonitor.java | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 44059edd23..2f31d1b299 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -276,9 +276,13 @@ protected void onEvent(Event event) { //stopping the cluster monitor and remove it from the AS ClusterMonitor clusterMonitor = ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); - clusterMonitor.setDestroyed(true); - clusterMonitor.setStatus(ClusterStatus.Terminating); - clusterMonitor.terminateAllMembers(); + if (clusterMonitor != null) { + clusterMonitor.setDestroyed(true); + clusterMonitor.setStatus(ClusterStatus.Terminating); + clusterMonitor.terminateAllMembers(); + } else { + log.warn("No Cluster Monitor found for cluster id " + clusterId); + } } } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 8ff4cac832..3993683f12 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -120,6 +120,7 @@ public String getPartitionOfMember(String memberId) { public void destroy() { minCheckKnowledgeSession.dispose(); scaleCheckKnowledgeSession.dispose(); + terminateAllKnowledgeSession.dispose(); terminateDependencyKnowledgeSession.dispose(); setDestroyed(true); if (log.isDebugEnabled()) { From 85503988938a305d681189c671799b19d0947ad6 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 22 Oct 2014 17:40:32 +0530 Subject: [PATCH 243/436] adding a null check in ParentComponentMonitor#onChildTerminatingEvent --- .../monitor/ParentComponentMonitor.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index f2965faae4..14ce2817cc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -95,13 +95,17 @@ protected void onChildTerminatingEvent(String idOfEvent) { } Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent); - for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { - if (monitor.hasMonitors()) { - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); - } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId()); + if (monitor != null) { + for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { + if (monitor.hasMonitors()) { + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId()); + } } + } else { + log.warn("Active Monitor not found for the id " + idOfEvent); } } From 773a01eaa519e77fa01e3eebd1d616e905105953 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Wed, 22 Oct 2014 17:44:43 +0530 Subject: [PATCH 244/436] groupTerminating and groupTerminated events, listenrs and prcessors --- .../AutoscalerTopologyEventReceiver.java | 49 +++++++- .../ApplicationStatusTopicReceiver.java | 20 ++++ .../controller/topology/TopologyBuilder.java | 80 ++++++++++++- .../topology/TopologyEventPublisher.java | 21 +++- .../status/GroupInInactivateEvent.java | 44 +++++++ .../status/GroupInTerminatedEvent.java | 44 +++++++ .../status/GroupInTerminatingEvent.java | 44 +++++++ .../event/topology/GroupInactivatedEvent.java | 43 +++++++ .../event/topology/GroupTerminatedEvent.java | 43 +++++++ .../event/topology/GroupTerminatingEvent.java | 43 +++++++ .../GroupInTerminatedEventListener.java | 27 +++++ .../GroupInTerminatingEventListener.java | 27 +++++ .../GroupTerminatedEventListener.java | 27 +++++ .../GroupTerminatingEventListener.java | 27 +++++ ...StatusGroupTerminatedMessageProcessor.java | 61 ++++++++++ ...tatusGroupTerminatingMessageProcessor.java | 61 ++++++++++ ...pplicationStatusMessageProcessorChain.java | 15 ++- .../topology/GroupTerminatedProcessor.java | 110 ++++++++++++++++++ .../topology/GroupTerminatingProcessor.java | 110 ++++++++++++++++++ .../TopologyMessageProcessorChain.java | 22 ++-- 20 files changed, 900 insertions(+), 18 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatingEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 2f31d1b299..7ae7df09a2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -35,9 +35,14 @@ import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.application.status.GroupInTerminatingEvent; import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.messaging.listener.application.status.GroupInTerminatingEventListener; 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; @@ -238,6 +243,48 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new GroupTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupTerminatedEven] Received: " + event.getClass()); + + GroupTerminatingEvent groupTerminatingEvent = (GroupTerminatingEvent) event; + String appId = groupTerminatingEvent.getAppId(); + String groupId = groupTerminatingEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(GroupStatus.Terminating); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); + } + }); + + topologyEventReceiver.addEventListener(new GroupTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupTerminatedEven] Received: " + event.getClass()); + + GroupTerminatedEvent groupTerminatedEvent = (GroupTerminatedEvent) event; + String appId = groupTerminatedEvent.getAppId(); + String groupId = groupTerminatedEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(GroupStatus.Terminated); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); + } + }); + topologyEventReceiver.addEventListener(new ApplicationActivatedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index cfcea8a7ff..bfd01675ae 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -23,9 +23,13 @@ import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; +import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.listener.application.status.*; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupTerminatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupTerminatingEventListener; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; public class ApplicationStatusTopicReceiver implements Runnable { @@ -82,6 +86,22 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupTerminatedEvent((GroupInTerminatedEvent) event); + + } + }); + + statusEventReceiver.addEventListener(new GroupTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupTerminatingEvent((GroupInTerminatingEvent) event); + + } + }); + statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() { @Override diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index c3286c5f22..cee40f3147 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -32,14 +32,18 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; -import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; -import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; -import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; -import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.messaging.event.topology.*; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; @@ -1022,4 +1026,72 @@ public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent e TopologyManager.releaseWriteLock(); } } + + public static void handleGroupTerminatedEvent(GroupInTerminatedEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + Group group = application.getGroupRecursively(event.getGroupId()); + if (group == null) { + log.warn(String.format("Group %s does not exist", + event.getGroupId())); + return; + } + + org.apache.stratos.messaging.event.topology.GroupTerminatedEvent groupTerminatedTopologyEvent = + new org.apache.stratos.messaging.event.topology.GroupTerminatedEvent( + event.getAppId(), + event.getGroupId()); + try { + TopologyManager.acquireWriteLock(); + group.setStatus(GroupStatus.Terminated); + log.info("Group activated adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent); + } + + public static void handleGroupTerminatingEvent(GroupInTerminatingEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + Group group = application.getGroupRecursively(event.getGroupId()); + if (group == null) { + log.warn(String.format("Group %s does not exist", + event.getGroupId())); + return; + } + + org.apache.stratos.messaging.event.topology.GroupTerminatingEvent groupTerminatingTopologyEvent = + new org.apache.stratos.messaging.event.topology.GroupTerminatingEvent( + event.getAppId(), + event.getGroupId()); + try { + TopologyManager.acquireWriteLock(); + group.setStatus(GroupStatus.Terminating); + log.info("Group activated adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 93523a4ae0..f6b247b151 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -26,11 +26,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; 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.ConfigCompositeApplication; -import org.apache.stratos.messaging.domain.topology.Port; -import org.apache.stratos.messaging.domain.topology.ServiceType; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; @@ -290,4 +285,20 @@ public static void sendApplicationTerminatedEvent(ApplicationTerminatedEvent app } publishEvent(applicationTerminatedEvent); } + + public static void sendGroupTerminatedEvent(GroupTerminatedEvent groupTerminatedTopologyEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing group terminated event: [appId] %s", + groupTerminatedTopologyEvent.getAppId())); + } + publishEvent(groupTerminatedTopologyEvent); + } + + public static void sendGroupTerminatingEvent(GroupTerminatingEvent groupTerminatingTopologyEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing group terminating event: [appId] %s", + groupTerminatingTopologyEvent.getAppId())); + } + publishEvent(groupTerminatingTopologyEvent); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java new file mode 100644 index 0000000000..6aeada77e0 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class GroupInInactivateEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public GroupInInactivateEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId() { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java new file mode 100644 index 0000000000..16cc0c73c7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class GroupInTerminatedEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public GroupInTerminatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId() { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java new file mode 100644 index 0000000000..6eaf5c36aa --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class GroupInTerminatingEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public GroupInTerminatingEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId() { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java new file mode 100644 index 0000000000..176f7090a4 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent to Topology upon group activation + */ +public class GroupInactivatedEvent extends Event { + private String appId; + private String groupId; + + public GroupInactivatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatedEvent.java new file mode 100644 index 0000000000..667343cecd --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatedEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent to Topology upon group activation + */ +public class GroupTerminatedEvent extends Event { + private String appId; + private String groupId; + + public GroupTerminatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatingEvent.java new file mode 100644 index 0000000000..31e0cc598f --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupTerminatingEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent to Topology upon group activation + */ +public class GroupTerminatingEvent extends Event { + private String appId; + private String groupId; + + public GroupTerminatingEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java new file mode 100644 index 0000000000..8cb331ce55 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/22/14. + */ +public abstract class GroupInTerminatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java new file mode 100644 index 0000000000..20c8b68479 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by reka on 9/22/14. + */ +public abstract class GroupInTerminatingEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java new file mode 100644 index 0000000000..af409e786f --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered by the groups activation processor after processing the event + */ +public abstract class GroupTerminatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java new file mode 100644 index 0000000000..ab4042fb2d --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered by the groups activation processor after processing the event + */ +public abstract class GroupTerminatingEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java new file mode 100644 index 0000000000..93dd750ad3 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java @@ -0,0 +1,61 @@ +/* + * 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.messaging.message.processor.application.status; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.GroupInTerminatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ApplicationStatusGroupTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusGroupTerminatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (GroupInTerminatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + GroupInTerminatedEvent event = + (GroupInTerminatedEvent) Util.jsonToObject(message, GroupInTerminatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received GroupTerminatingEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group in GroupTerminatingEvent message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java new file mode 100644 index 0000000000..493bd6c0f5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java @@ -0,0 +1,61 @@ +/* + * 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.messaging.message.processor.application.status; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class ApplicationStatusGroupTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(ApplicationStatusGroupTerminatingMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (GroupTerminatingEvent.class.getName().equals(type)) { + // Parse complete message and build event + GroupTerminatingEvent event = + (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received GroupTerminatingEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group in GroupTerminatingEvent message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index 3c32de829f..d5dccbbc1d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -43,6 +43,9 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private ApplicationStatusAppTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; private ApplicationStatusAppTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; + private ApplicationStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor; + private ApplicationStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor; + public void initialize() { // Add instance notifier event processors clusterActivatedMessageProcessor = new ApplicationStatusClusterActivatedMessageProcessor(); @@ -72,6 +75,11 @@ public void initialize() { applicationStatusAppTerminatingMessageProcessor = new ApplicationStatusAppTerminatingMessageProcessor(); this.add(applicationStatusAppTerminatingMessageProcessor); + groupTerminatedMessageProcessor = new ApplicationStatusGroupTerminatedMessageProcessor(); + this.add(groupTerminatedMessageProcessor); + + groupTerminatingMessageProcessor = new ApplicationStatusGroupTerminatingMessageProcessor(); + this.add(groupTerminatingMessageProcessor); if (log.isDebugEnabled()) { log.debug("Instance notifier message processor chain initialized"); @@ -97,7 +105,12 @@ public void addEventListener(EventListener eventListener) { applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ApplicationTerminatedEventListener){ applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); - } else { + } else if (eventListener instanceof GroupInTerminatingEventListener){ + groupTerminatingMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupInTerminatedEventListener){ + groupTerminatedMessageProcessor.addEventListener(eventListener); + } else + { throw new RuntimeException("Unknown event listener"); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java new file mode 100644 index 0000000000..6196776ae7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java @@ -0,0 +1,110 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the Group activation events + */ +public class GroupTerminatedProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(GroupTerminatedProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (GroupTerminatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + GroupTerminatedEvent event = (GroupTerminatedEvent) Util. + jsonToObject(message, GroupTerminatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (GroupTerminatedEvent event,Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroupRecursively(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + if (!group.isStateTransitionValid(GroupStatus.Terminating)) { + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + } + group.setStatus(GroupStatus.Terminated); + if (log.isInfoEnabled()) { + log.info(String.format("Group updated as activated : %s", + group.getUniqueIdentifier())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java new file mode 100644 index 0000000000..afec0f2c70 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java @@ -0,0 +1,110 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the Group activation events + */ +public class GroupTerminatingProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(GroupTerminatingProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (GroupTerminatingEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + GroupTerminatingEvent event = (GroupTerminatingEvent) Util. + jsonToObject(message, GroupTerminatingEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (GroupTerminatingEvent event,Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroupRecursively(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + if (!group.isStateTransitionValid(GroupStatus.Active)) { + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + } + group.setStatus(GroupStatus.Terminating); + if (log.isInfoEnabled()) { + log.info(String.format("Group updated as Terminating : %s", + group.getUniqueIdentifier())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 77e4b015c2..1fb3961a57 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,14 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.application.status.*; +import org.apache.stratos.messaging.listener.application.status.ApplicationInActivatedEventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatedEventListener; +import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.*; -import org.apache.stratos.messaging.listener.topology.ApplicationActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.ApplicationCreatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; -import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupInActivateEventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; /** @@ -62,6 +58,8 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor; private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor; private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor; + private GroupTerminatingProcessor groupTerminatingProcessor; + private GroupTerminatedProcessor groupTerminatedProcessor; public void initialize() { // Add topology event processors @@ -113,6 +111,12 @@ public void initialize() { groupInActivateProcessor = new GroupInActivateProcessor(); add(groupInActivateProcessor); + groupTerminatingProcessor = new GroupTerminatingProcessor(); + add(groupTerminatingProcessor); + + groupTerminatedProcessor = new GroupTerminatedProcessor(); + add(groupTerminatedProcessor); + applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); add(applicationCreatedMessageProcessor); @@ -172,6 +176,10 @@ public void addEventListener(EventListener eventListener) { groupActivatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupInActivateEventListener) { groupInActivateProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupTerminatedEventListener){ + groupTerminatedProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupTerminatingEventListener){ + groupTerminatingProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationCreatedEventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationUndeployedEventListener) { From 9beae45922537a1d672d97ab8fad40f1bd1ab04a Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Wed, 22 Oct 2014 16:07:54 -0700 Subject: [PATCH 245/436] more cleanup, removing unused grouping POC code ... --- .../impl/CloudControllerServiceImpl.java | 65 +--- .../runtime/FasterLookUpDataHolder.java | 20 -- .../controller/topology/TopologyBuilder.java | 22 -- .../topology/TopologyEventPublisher.java | 21 -- .../client/CloudControllerServiceClient.java | 8 +- .../CompositeApplicationManager.java | 312 ----------------- .../application/utils/ApplicationUtils.java | 82 ----- .../DataInsertionAndRetrievalManager.java | 1 - .../stratos/manager/utils/Serializer.java | 1 - .../topology/ConfigCompositeApplication.java | 2 +- .../bean/util/converter/PojoConverter.java | 124 ------- .../rest/endpoint/services/ServiceUtils.java | 4 - .../rest/endpoint/services/StratosAdmin.java | 36 -- .../resources/CloudControllerService.wsdl | 313 +++++------------- 14 files changed, 91 insertions(+), 920 deletions(-) delete mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 3ccaccd329..2fbf89ab2b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -95,7 +95,6 @@ private void acquireData() { currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); currentData.setCartridges(serializedObj.getCartridges()); - currentData.setConfigCompositeApplication(serializedObj.getConfigCompositeApplication()); currentData.setServiceGroups(serializedObj.getServiceGroups()); if(log.isDebugEnabled()) { @@ -115,50 +114,9 @@ private void acquireData() { } } - // restore compostie application - List apps = restoreConfigCompositeApplication(); - if (apps == null) { - this.dataHolder.setConfigCompositeApplication(new ArrayList()); - - } - } - - - public void deployCompositeApplicationDefinition(CompositeApplicationDefinition compositeApplicationDefinition) throws InvalidCompositeApplicationDefinitionException, - InvalidIaasProviderException { - - String alias = compositeApplicationDefinition.getAlias(); - if(log.isDebugEnabled()){ - log.debug("composite application alias : " + alias); - } - - ConfigCompositeApplication messConfigApp = null;//TopologyBuilder.convertCompositeApplication(compositeApplicationDefinition); - String key = "compositeApplicationAlias"; //app.getAlias() - - - List data = new ArrayList(); - data.add(messConfigApp); - dataHolder.setConfigCompositeApplication(data); - - // persist - persist(); - - if(log.isDebugEnabled()){ - log.debug("deploying composite application in cloud controller: " + compositeApplicationDefinition); - } - - TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); + } - public void unDeployCompositeApplicationDefinition(String appAlias) throws InvalidCompositeApplicationDefinitionException, - InvalidIaasProviderException { - if(log.isDebugEnabled()){ - log.debug("undeploying composite application in cloud controller, removing all composite apps "); - dataHolder.removeAllConfigCompositeApplications(); - persist(); - TopologyBuilder.handleCompositeApplicationRemoved(appAlias); - } - } public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, InvalidIaasProviderException { @@ -1462,26 +1420,5 @@ public void unDeployApplicationDefinition(String applicationId, int tenantId, St //persist(); } - private List restoreConfigCompositeApplication () { - List apps = this.dataHolder.getConfigCompositeApplication(); - if (apps == null) { - if (log.isDebugEnabled()) { - log.debug("composite applications for cloud controller is null while restoring "); - } - return apps; - } - if (log.isDebugEnabled()) { - log.debug("trying to restore composite applications for cloud controller " + apps.size()); - } - for (ConfigCompositeApplication messConfigApp : apps) { - if (log.isDebugEnabled()) { - log.debug(" restoring composite application for cloud controller " + messConfigApp.getAlias()); - } - TopologyBuilder.handleCompositeApplicationCreated(messConfigApp); - } - - return apps; - } - } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java index e9e550a1f2..973e924a36 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/runtime/FasterLookUpDataHolder.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.registry.RegistryManager; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.wso2.carbon.databridge.agent.thrift.AsyncDataPublisher; import java.io.Serializable; @@ -87,8 +86,6 @@ public class FasterLookUpDataHolder implements Serializable{ * List of deployed service groups */ private List serviceGroups; - - private List configCompositeApplication; /** * List of IaaS Providers. @@ -134,8 +131,6 @@ private FasterLookUpDataHolder() { cartridges = new ArrayList(); serviceGroups = new ArrayList(); - configCompositeApplication = new ArrayList(); - } public List getCartridges() { @@ -154,20 +149,6 @@ public List getServiceGroups() { return this.serviceGroups; } - public List getConfigCompositeApplication() { - return configCompositeApplication; - } - - public void setConfigCompositeApplication( - List configCompositeApplication) { - this.configCompositeApplication = configCompositeApplication; - } - - public void removeAllConfigCompositeApplications() { - if (this.configCompositeApplication != null) { - this.configCompositeApplication.removeAll(configCompositeApplication); - } - } public Cartridge getCartridge(String cartridgeType) { for (Cartridge cartridge : cartridges) { @@ -177,7 +158,6 @@ public Cartridge getCartridge(String cartridgeType) { } return null; - } public void addCartridge(Cartridge newCartridges) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index cee40f3147..ac409c7747 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -738,28 +738,6 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); } - public static void handleCompositeApplicationCreated(ConfigCompositeApplication messConfigApp) { - Topology topology = TopologyManager.getTopology(); - - //ConfigCompositeApplication messConfigApp; - try { - - TopologyManager.acquireWriteLock(); - String key = "compositeApplicationAlias"; //app.getAlias() - topology.addConfigCompositeApplication(key, messConfigApp); - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - TopologyEventPublisher.sendConfigApplicationCreatedEventEvent(messConfigApp); - log.info("TopolgyBuilder: sending sendConfigApplicationCreatedEventEvent "); - - } - - public static void handleCompositeApplicationRemoved(String alias) { - log.info("TopolgyBuilder: sending sendConfigApplicationRemovedEventEvent "); - TopologyEventPublisher.sendConfigApplicationRemovedEventEvent(alias); - } public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index f6b247b151..21d82677af 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -228,27 +228,6 @@ public static void sendCompleteTopologyEvent(Topology topology) { publishEvent(completeTopologyEvent); } - // Grouping - public static void sendConfigApplicationCreatedEventEvent(ConfigCompositeApplication configCompositeApplication) { - - CompositeApplicationCreatedEvent compositeApplicationCreatedEvent = new CompositeApplicationCreatedEvent(configCompositeApplication); - - if(log.isDebugEnabled()) { - log.debug(String.format("Publishing compositeApplicationCreatedEvent: " + compositeApplicationCreatedEvent)); - } - publishEvent(compositeApplicationCreatedEvent); - } - - public static void sendConfigApplicationRemovedEventEvent(String alias) { - - CompositeApplicationRemovedEvent compositeApplicationCreatedEvent = new CompositeApplicationRemovedEvent(alias); - - if(log.isDebugEnabled()) { - log.debug(String.format("Publishing compositeApplicationRemovedEvent: " + compositeApplicationCreatedEvent)); - } - publishEvent(compositeApplicationCreatedEvent); - } - public static void sendApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) { if(log.isInfoEnabled()) { log.info(String.format("Publishing application activated event: [appId] %s", 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 efe7de1681..75f48d876a 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 @@ -132,7 +132,7 @@ public boolean register(String clusterId, String cartridgeType, public void deployApplicationDefinition(ApplicationContext applicationContext) - throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, + throws RemoteException, CloudControllerServiceInvalidIaasProviderExceptionException, CloudControllerServiceApplicationDefinitionExceptionException { stub.deployApplicationDefinition(applicationContext); @@ -145,12 +145,6 @@ public void undeployApplicationDefinition (String applicationId, int tenantId, S stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain); } - public void unDeployCompositeApplicationDefinition(String appAlias) throws RemoteException, CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException, CloudControllerServiceInvalidIaasProviderExceptionException { - stub.unDeployCompositeApplicationDefinition(appAlias); - } - - - @SuppressWarnings("unused") private Properties diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java deleted file mode 100644 index 649db842c1..0000000000 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/CompositeApplicationManager.java +++ /dev/null @@ -1,312 +0,0 @@ -package org.apache.stratos.manager.composite.application; - -import java.util.*; - -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.composite.application.parser.CompositeApplicationParser; -import org.apache.stratos.manager.composite.application.parser.DefaultCompositeApplicationParser; -import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; -import org.apache.stratos.manager.composite.application.structure.GroupContext; -import org.apache.stratos.manager.composite.application.structure.SubscribableContext; -import org.apache.stratos.manager.exception.*; -import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; -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.subscription.SubscriptionData; - -//Grouping -public class CompositeApplicationManager { - - private static Log log = LogFactory.getLog(CompositeApplicationManager.class); - - CartridgeSubscriptionManager cartridgeSubscriptionManager; - - public CompositeApplicationManager () { - cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); - } - - public void deployCompositeApplication (ApplicationDefinition compositeAppDefinition, int tenantId, String tenantDomain, - String tenantAdminUsername) throws CompositeApplicationException, CompositeApplicationDefinitionException, - PersistenceManagerException { - - CompositeApplicationParser compositeAppParser = new DefaultCompositeApplicationParser(); - CompositeAppContext compositeAppContext = compositeAppParser.parse(compositeAppDefinition); - - log.info("Composite Application [ Id: " + compositeAppDefinition.getApplicationId() + " , alias: " - + compositeAppDefinition.getAlias() + " ] parsed successfully"); - - // create the CompositeAppSubscription - ApplicationSubscription compositeAppSubscription; - try { - compositeAppSubscription = cartridgeSubscriptionManager.createApplicationSubscription(compositeAppContext.getAppId(), tenantId); - - } catch (ApplicationSubscriptionException e) { - throw new CompositeApplicationDefinitionException(e); - } - - // keep track of all CartridgeSubscriptions, against the alias - Map aliasToCartridgeSubscription = new HashMap(); - - // Keep track of all Group Subscriptions - Map groupAliasToGroupSubscription = new HashMap(); - - // traverse through the Composite App Structure and create Cartridge Subscriptions - if(compositeAppContext.getSubscribableContexts() != null) { - // Subscriptions relevant to top level Subscribables - - for (CartridgeSubscription cartridgeSubscription : getCartridgeSybscriptionsForSubscribables(compositeAppContext.getSubscribableContexts(), - tenantId, tenantDomain, tenantAdminUsername)) { - - // check if a Cartridge Subscription already exists with this alias for this Composite App - if (cartridgeSubscriptionExistsForAlias(aliasToCartridgeSubscription, cartridgeSubscription.getAlias())) { - throw new CompositeApplicationException("Cartridge Subscription with alias [ " + cartridgeSubscription.getAlias() - + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); - } - - aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); - } - // get top level cartridge aliases to add to Composite App Subscription - compositeAppSubscription.addCartridgeSubscriptionAliases(getCartrigdeSubscriptionAliases(compositeAppContext.getSubscribableContexts())); - } - - if (compositeAppContext.getGroupContexts() != null) { - // Subscriptions relevant to Groups - - for (CartridgeSubscription cartridgeSubscription : getCartridgeSubscriptionForGroups(compositeAppContext.getGroupContexts(), tenantId, - tenantDomain, tenantAdminUsername)) { - - // check if a Cartridge Subscription already exists with this alias for this Composite App - if (cartridgeSubscriptionExistsForAlias(aliasToCartridgeSubscription, cartridgeSubscription.getAlias())) { - throw new CompositeApplicationException("Cartridge Subscription with alias [ " + cartridgeSubscription.getAlias() - + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); - } - - aliasToCartridgeSubscription.put(cartridgeSubscription.getAlias(), cartridgeSubscription); - } - - // create Group Subscriptions and collect them - List groupSubscriptions = new LinkedList(); - getGroupSubscriptions(compositeAppContext.getGroupContexts(), tenantId, groupSubscriptions); - for (GroupSubscription groupSubscription : groupSubscriptions) { - - // check if a Group Subscription already exists with this alias for this Composite App - if (groupSubscriptionExistsForAlias(groupAliasToGroupSubscription, groupSubscription.getGroupAlias())) { - throw new CompositeApplicationException("Group Subscription with alias [ " + groupSubscription.getGroupAlias() - + " ] already exists in Composite Application [ " + compositeAppSubscription.getAppId() + " ]"); - } - - groupAliasToGroupSubscription.put(groupSubscription.getGroupAlias(), groupSubscription); - } - - // set top level group aliases to Composite App Subscription - compositeAppSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(compositeAppContext.getGroupContexts())); - } - - // TODO: send the Composite App structure to CC - - // persist - persistSubscriptions(aliasToCartridgeSubscription.values(), groupAliasToGroupSubscription.values(), compositeAppSubscription); - } - - private Set getCartrigdeSubscriptionAliases (Set subscribableContexts) throws CompositeApplicationException { - - Set cartridgeSubscriptionAliases = new HashSet(); - for (SubscribableContext subscribableContext : subscribableContexts) { - cartridgeSubscriptionAliases.add(subscribableContext.getAlias()); - } - - return cartridgeSubscriptionAliases; - } - - private void getGroupSubscriptions(Set groupContexts, int tenantID, List groupSubscriptions) throws CompositeApplicationException { - - for (GroupContext groupContext : groupContexts) { - // create Group Subscriptions for this Group - GroupSubscription groupSubscription; - try { - groupSubscription = cartridgeSubscriptionManager.createGroupSubscription(groupContext.getName(), groupContext.getAlias(), tenantID); - - } catch (GroupSubscriptionException e) { - throw new CompositeApplicationException(e); - } - if (groupContext.getSubscribableContexts() != null) { - groupSubscription.addCartridgeSubscriptionAliases(getCartrigdeSubscriptionAliases(groupContext.getSubscribableContexts())); - } - - // nested Group - if (groupContext.getGroupContexts() != null) { - groupSubscription.addGroupSubscriptionAliases(getGroupSubscriptionAliases(groupContext.getGroupContexts())); - // need to recurse to get other nested groups, if any - getGroupSubscriptions(groupContext.getGroupContexts(), tenantID, groupSubscriptions); - } - - groupSubscriptions.add(groupSubscription); - } - } - - private Set getGroupSubscriptionAliases (Set groupContexts) throws CompositeApplicationException { - - Set topLevelGroupAliases = new HashSet(); - - for (GroupContext topLevelGroupCtxt : groupContexts) { - topLevelGroupAliases.add(topLevelGroupCtxt.getAlias()); - } - - return topLevelGroupAliases; - } - - private Set getCartridgeSubscriptionForGroups (Set groupContexts, - int tenantId, String tenantDomain, - String tenantAdminUsername) - throws CompositeApplicationException { - - Set cartridgeSubscriptions = new HashSet(); - for (GroupContext groupContext : groupContexts) { - // create Subscriptions for the Group's top level Subscribables - if (groupContext.getSubscribableContexts() != null) { - cartridgeSubscriptions.addAll(getCartridgeSybscriptionsForSubscribables(groupContext.getSubscribableContexts(), - tenantId, tenantDomain, tenantAdminUsername)); - } - // create Subscriptions for the nested Group's Subscribables - if (groupContext.getGroupContexts() != null) { - cartridgeSubscriptions.addAll(getCartridgeSubscriptionForGroups(groupContext.getGroupContexts(), tenantId, - tenantDomain, tenantAdminUsername)); - } - } - - return cartridgeSubscriptions; - } - - private Set getCartridgeSybscriptionsForSubscribables (Set subscribableContexts, - int tenantId, String tenantDomain, - String tenantAdminUsername) - throws CompositeApplicationException { - - Set cartridgeSubscriptions = new HashSet(); - - for (SubscribableContext subscribableContext : subscribableContexts) { - cartridgeSubscriptions.add(getCartridgeSubscription(subscribableContext, tenantId, tenantDomain, tenantAdminUsername)); - } - - return cartridgeSubscriptions; - } - - private CartridgeSubscription getCartridgeSubscription (SubscribableContext subscribableContext, int tenantId, String tenantDomain, - String tenantAdminUsername) throws CompositeApplicationException { - - SubscriptionData subscriptionData = new SubscriptionData(); - subscriptionData.setCartridgeType(subscribableContext.getCartridgeType()); - subscriptionData.setCartridgeAlias(subscribableContext.getAlias()); - subscriptionData.setAutoscalingPolicyName(subscribableContext.getAutoscalingPolicy()); - subscriptionData.setDeploymentPolicyName(subscribableContext.getDeploymentPolicy()); - subscriptionData.setTenantId(tenantId); - subscriptionData.setTenantDomain(tenantDomain); - subscriptionData.setTenantAdminUsername(tenantAdminUsername); - - if (subscribableContext.getRepoUrl() != null && !subscribableContext.getRepoUrl().isEmpty()) { - subscriptionData.setRepositoryType("git"); - subscriptionData.setRepositoryURL(subscribableContext.getRepoUrl()); - subscriptionData.setPrivateRepository(subscribableContext.isPrivateRepo()); - subscriptionData.setRepositoryUsername(subscribableContext.getUsername()); - subscriptionData.setRepositoryPassword(subscribableContext.getPassword()); - } - - CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); - try { - return cartridgeSubscriptionManager.createCartridgeSubscription(subscriptionData); - - } catch (ADCException e) { - throw new CompositeApplicationException(e); - } catch (InvalidCartridgeAliasException e) { - throw new CompositeApplicationException(e); - } catch (DuplicateCartridgeAliasException e) { - throw new CompositeApplicationException(e); - } catch (PolicyException e) { - throw new CompositeApplicationException(e); - } catch (UnregisteredCartridgeException e) { - throw new CompositeApplicationException(e); - } catch (RepositoryRequiredException e) { - throw new CompositeApplicationException(e); - } catch (RepositoryCredentialsRequiredException e) { - throw new CompositeApplicationException(e); - } catch (RepositoryTransportException e) { - throw new CompositeApplicationException(e); - } catch (AlreadySubscribedException e) { - throw new CompositeApplicationException(e); - } catch (InvalidRepositoryException e) { - throw new CompositeApplicationException(e); - } - - } - - private boolean cartridgeSubscriptionExistsForAlias (Map aliasToCartridgeSubscription, - String newCartridgeSubscriptionAlias) { - - return aliasToCartridgeSubscription.get(newCartridgeSubscriptionAlias) != null; - } - - - private boolean groupSubscriptionExistsForAlias (Map groupAliasToGroupSubscription, - String newGroupSubscriptionAlias) { - - return groupAliasToGroupSubscription.get(newGroupSubscriptionAlias) != null; - } - - private synchronized void persistSubscriptions(Collection cartridgeSubscriptions, - Collection groupSubscriptions, - ApplicationSubscription compositeAppSubscription) - throws CompositeApplicationException { - - persistCartridgeSubscriptions(cartridgeSubscriptions); - persistGroupSubscriptions(groupSubscriptions); - persistCompositeAppSubscription(compositeAppSubscription); - } - - private void persistCartridgeSubscriptions (Collection cartridgeSubscriptions) throws CompositeApplicationException { - - if (cartridgeSubscriptions == null) { - return; - } - - for (CartridgeSubscription cartridgeSubscription : cartridgeSubscriptions) { - try { - cartridgeSubscriptionManager.persistCartridgeSubscription(cartridgeSubscription); - - } catch (ADCException e) { - throw new CompositeApplicationException(e); - } - } - } - - private void persistGroupSubscriptions (Collection groupSubscriptions) throws CompositeApplicationException { - - if (groupSubscriptions == null) { - return; - } - - for (GroupSubscription groupSubscription : groupSubscriptions) { - try { - cartridgeSubscriptionManager.persistGroupSubscription(groupSubscription); - - } catch (ADCException e) { - throw new CompositeApplicationException(e); - } - } - } - - private void persistCompositeAppSubscription (ApplicationSubscription compositeAppSubscription) throws CompositeApplicationException { - - if (compositeAppSubscription != null) { - try { - cartridgeSubscriptionManager.persistApplicationSubscription(compositeAppSubscription); - - } catch (ADCException e) { - throw new CompositeApplicationException(e); - } - } - } - -} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java index e208562316..4dbf251a0c 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java @@ -11,94 +11,12 @@ import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; import org.apache.stratos.messaging.util.Constants; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; // Grouping public class ApplicationUtils { private static Log log = LogFactory.getLog(ApplicationUtils.class); - - static class ApplicationCreatedEventPublisher implements Runnable { - - private ConfigCompositeApplication configCompositeApplication; - - public ApplicationCreatedEventPublisher(ConfigCompositeApplication configCompositeApplication) { - this.configCompositeApplication = configCompositeApplication; - - } - - @Override - public void run() { - try { - if(log.isInfoEnabled()) { - log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplication.getAlias())); - } - CompositeApplicationCreatedEvent event = new CompositeApplicationCreatedEvent(configCompositeApplication); - EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); - eventPublisher.publish(event); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error(String.format("Could not publish tenant subscribed event: [application-alias] %s ", configCompositeApplication.getAlias()), e); - } - } - - } - - } - - public static void publishApplicationCreatedEvent(ConfigCompositeApplication configCompositeApplication) { - - - Executor exec = new Executor() { - @Override - public void execute(Runnable command) { - command.run(); - } - }; - - exec.execute(new ApplicationCreatedEventPublisher(configCompositeApplication)); - } - - - static class ApplicationRemovedEventPublisher implements Runnable { - - private String configCompositeApplicationAlias; - - public ApplicationRemovedEventPublisher(String configCompositeApplicationAlias) { - this.configCompositeApplicationAlias = configCompositeApplicationAlias; - - } - - @Override - public void run() { - try { - if(log.isInfoEnabled()) { - log.info(String.format("Publishing application createdevent: [application-alias] %s ", configCompositeApplicationAlias)); - } - CompositeApplicationRemovedEvent event = new CompositeApplicationRemovedEvent(configCompositeApplicationAlias); - EventPublisher eventPublisher = EventPublisherPool.getPublisher(Constants.TOPOLOGY_TOPIC); - eventPublisher.publish(event); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error(String.format("Could not publish composite removed event event: [application-alias] %s ", configCompositeApplicationAlias), e); - } - } - - } - - } - - public static void publishApplicationUnDeployEvent(String configApplicationAlias) { - Executor exec = new Executor() { - @Override - public void execute(Runnable command) { - command.run(); - } - }; - - exec.execute(new ApplicationRemovedEventPublisher(configApplicationAlias)); - } public static boolean isAliasValid (String alias) { 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 index c404978433..a386c03fcc 100644 --- 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 @@ -31,7 +31,6 @@ 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.messaging.domain.topology.ConfigCompositeApplication; import java.util.Collection; import java.util.Set; 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 index 248abdf308..c6dadf97e0 100644 --- 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 @@ -26,7 +26,6 @@ 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.messaging.domain.topology.ConfigCompositeApplication; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java index eb0564b3b6..e2c753b544 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ConfigCompositeApplication.java @@ -8,6 +8,7 @@ public class ConfigCompositeApplication implements Serializable { + /* grouping_poc */ private String applicationId; private String alias; private List components; @@ -38,5 +39,4 @@ public void setCartridges(List cartridges) { this.cartridges = cartridges; } - } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index d1d2f4b862..cc3ae4abd6 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -785,12 +785,6 @@ private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List configCartridges = - new ArrayList(); - - for (CartridgeDefinition beanCartridge : appBean.cartridges ) { - org.apache.stratos.messaging.domain.topology.ConfigCartridge configCartridge = - new org.apache.stratos.messaging.domain.topology.ConfigCartridge(); - configCartridge.setAlias(beanCartridge.alias); - configCartridges.add(configCartridge); - } - configApp.setCartridges(configCartridges); - - // converting groups / components - List configGroups = - new ArrayList(); - - for (ComponentDefinition beanGroup : appBean.components ) { - org.apache.stratos.messaging.domain.topology.ConfigGroup configGroup = - new org.apache.stratos.messaging.domain.topology.ConfigGroup(); - configGroup.setAlias(beanGroup.alias); - configGroup.setSubscribables(beanGroup.subscribables); - org.apache.stratos.messaging.domain.topology.ConfigDependencies configDep = - new org.apache.stratos.messaging.domain.topology.ConfigDependencies(); - - - // convert dependencies - configDep.setKill_behavior(beanGroup.dependencies.kill_behavior); - List configPairs = - new ArrayList(); - for (ConfigDependencies.Pair beanPair : beanGroup.dependencies.startup_order) { - configPairs.add(new org.apache.stratos.messaging.domain.topology.ConfigDependencies.Pair(beanPair.getKey(), beanPair.getValue())); - } - configDep.setStartup_order(configPairs); - configGroup.setDependencies(configDep); - - configGroups.add(configGroup); - } - configApp.setComponents(configGroups); - - return configApp; - } - */ - // grouping - /* - public static CompositeApplicationDefinition convertToCompositeApplicationForCC (CompositeApplicationDefinitionBean appBean) { - CompositeApplicationDefinition configApp = new CompositeApplicationDefinition(); - - configApp.setAlias(appBean.alias); - configApp.setApplicationId(appBean.applicationId); - - - - List configCartridges = - new ArrayList(); - - for (CartridgeDefinition beanCartridge : appBean.cartridges ) { - org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge configCartridge = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge(); - configCartridge.setAlias(beanCartridge.alias); - configCartridges.add(configCartridge); - } - org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge [] arrayConfigCartridge = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigCartridge[configCartridges.size()]; - arrayConfigCartridge = configCartridges.toArray(arrayConfigCartridge); - configApp.setCartridges(arrayConfigCartridge); - - // converting groups / components - List configGroups = - new ArrayList(); - - for (ComponentDefinition beanGroup : appBean.components ) { - org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup configGroup = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup(); - configGroup.setAlias(beanGroup.alias); - String [] arraySubscribables = new String[beanGroup.subscribables.size()]; - arraySubscribables = beanGroup.subscribables.toArray(arraySubscribables); - configGroup.setSubscribables(arraySubscribables); - org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencies configDep = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencies(); - - - // convert dependencies - configDep.setKill_behavior(beanGroup.dependencies.kill_behavior); - int i = 0; - org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair[] configPairs = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair[beanGroup.dependencies.startup_order.size()]; - - for (ConfigDependencies.Pair beanPair : beanGroup.dependencies.startup_order) { - //configPairs.add(new org.apache.stratos.messaging.domain.topology.ConfigDependencies.Pair(beanPair.getKey(), beanPair.getValue())); - - org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair pair = new org.apache.stratos.cloud.controller.stub.pojo.ConfigDependencyPair(); - pair.setKey(beanPair.getKey()); - pair.setValue(beanPair.getValue()); - - configPairs[i] = pair; - i++; - } - configDep.setStartup_order(configPairs); - configGroup.setDependencies(configDep); - - configGroups.add(configGroup); - - } - org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup [] configGroupArray = - new org.apache.stratos.cloud.controller.stub.pojo.ConfigGroup[configGroups.size()]; - configGroupArray = configGroups.toArray(configGroupArray); - configApp.setComponents(configGroupArray); - - return configApp; - } - - */ } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 4423586014..1bd2568cfe 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -33,7 +33,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; -import org.apache.stratos.manager.composite.application.CompositeApplicationManager; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager; @@ -86,7 +85,6 @@ public class ServiceUtils { private static CartridgeSubscriptionManager cartridgeSubsciptionManager = new CartridgeSubscriptionManager(); private static ServiceGroupingManager serviceGropingManager = new ServiceGroupingManager(); private static ServiceDeploymentManager serviceDeploymentManager = new ServiceDeploymentManager(); - private static CompositeApplicationManager compositeApplicationManager = new CompositeApplicationManager(); static void deployCartridge(CartridgeDefinitionBean cartridgeDefinitionBean, ConfigurationContext ctxt, String userName, String tenantDomain) throws RestAPIException { @@ -156,8 +154,6 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co } catch (RemoteException e) { throw new RestAPIException(e); - } catch (CloudControllerServiceInvalidCompositeApplicationDefinitionExceptionException e) { - throw new RestAPIException(e); } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { throw new RestAPIException(e); } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 24397979e6..56602ade5e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -183,42 +183,6 @@ public Response unDeployApplicationDefinition(@PathParam("applicationId") String } -// -// @DELETE -// @Path("/application/definition/{applicationAlias}") -// @Produces("application/json") -// @Consumes("application/json") -// @AuthorizationAction("/permission/protected/manage/monitor/tenants") -// @SuperTenantService(true) -// // Grouping -// public Response unDeployApplicationDefinitionX(@PathParam("applicationAlias")String configCompositeApplicationAlias) -// throws RestAPIException { -// -// ServiceUtils.unDeployApplication(configCompositeApplicationAlias, getConfigContext(), getUsername(), -// getTenantDomain()); -// return Response.noContent().build(); -// -// } - - - - /* - * Grouping --- fix API, use this instead of POST to remove application !!!! - - @DELETE - @Path("/cartridge/definition/{cartridgeType}") - @Produces("application/json") - @Consumes("application/json") - @AuthorizationAction("/permission/protected/manage/monitor/tenants") - @SuperTenantService(true) - public StratosAdminResponse unDeployCartridgeDefinition (@PathParam("cartridgeType") String cartridgeType) throws RestAPIException { - - return ServiceUtils.undeployCartridge(cartridgeType); - } - nnnnnn - */ - - @POST @Path("/cartridge/definition/") @Produces("application/json") diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index b3906ac4cb..602de3f606 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,8 +6,8 @@ - - + + @@ -15,9 +15,9 @@ - - - + + + @@ -31,9 +31,9 @@ - + - + @@ -76,11 +76,6 @@ - - - - - @@ -112,22 +107,36 @@ - + + - + + + + + + + + + + + + + + - + - + @@ -143,28 +152,28 @@ - + - + - + - + @@ -178,49 +187,21 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -239,13 +220,6 @@ - - - - - - - @@ -256,14 +230,14 @@ - + - + @@ -312,28 +286,28 @@ - + - + - + - + @@ -347,7 +321,7 @@ - + @@ -373,7 +347,7 @@ - + @@ -394,7 +368,7 @@ - + @@ -415,7 +389,7 @@ - + @@ -434,13 +408,37 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -451,12 +449,12 @@ - - + + - - - + + + @@ -471,16 +469,16 @@ - + - + - + @@ -492,7 +490,7 @@ - + @@ -503,26 +501,14 @@ - + - - - - - - - - - - - - - + @@ -534,7 +520,7 @@ - + @@ -542,11 +528,11 @@ - + - - - + + + @@ -559,54 +545,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -630,7 +572,7 @@ - + @@ -642,8 +584,8 @@ - - + + @@ -742,12 +684,6 @@ - - - - - - @@ -778,9 +714,6 @@ - - - @@ -849,11 +782,6 @@ - - - - - @@ -880,11 +808,6 @@ - - - - - @@ -1047,18 +970,6 @@ - - - - - - - - - - - - @@ -1119,18 +1030,6 @@ - - - - - - - - - - - - @@ -1293,18 +1192,6 @@ - - - - - - - - - - - - @@ -1365,18 +1252,6 @@ - - - - - - - - - - - - @@ -1488,12 +1363,6 @@ - - - - - - @@ -1539,12 +1408,6 @@ - - - - - - From edd105e200337297e1c55caaffd7b803126edb6c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 23 Oct 2014 13:06:59 +0530 Subject: [PATCH 246/436] fixing STRATOS-906 and initial app undeployment --- .../topology/AutoscalerTopologyEventReceiver.java | 2 +- .../monitor/cluster/ClusterMonitor.java | 15 ++++++++++----- .../autoscaler/rule/AutoscalerRuleEvaluator.java | 3 ++- .../autoscaler/rule/RuleTasksDelegator.java | 5 +++++ .../receiver/ApplicationStatusTopicReceiver.java | 10 ++-------- .../ApplicationStatusMessageProcessorChain.java | 2 -- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 7ae7df09a2..bb91b7eaea 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -325,8 +325,8 @@ protected void onEvent(Event event) { ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); if (clusterMonitor != null) { clusterMonitor.setDestroyed(true); - clusterMonitor.setStatus(ClusterStatus.Terminating); clusterMonitor.terminateAllMembers(); + clusterMonitor.setStatus(ClusterStatus.Terminating); } else { log.warn("No Cluster Monitor found for cluster id " + clusterId); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 8396f552c0..38b554cbab 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -102,11 +102,16 @@ public void run() { public void terminateAllMembers() { for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - //if (log.isDebugEnabled()) { - log.info("Starting to terminate all members in Network Partition " + networkPartitionContext.getId()); - // } - terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll - (terminateAllKnowledgeSession, terminateAllFactHandle, networkPartitionContext); + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + //if (log.isDebugEnabled()) { + log.info("Starting to terminate all members in Network Partition [ " + + networkPartitionContext.getId() + " ], Partition [ " + + partitionContext.getPartitionId() + " ]"); + // } + + terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll + (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); + } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java index 133483e131..68511b757d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java @@ -68,6 +68,7 @@ public AutoscalerRuleEvaluator(){ if (log.isDebugEnabled()) { log.debug("Scale check rule is parsed successfully"); } + terminateAllKbase = readKnowledgeBase(TERMINATE_ALL_DRL_FILE_NAME); if (log.isDebugEnabled()) { @@ -172,7 +173,7 @@ public StatefulKnowledgeSession getScaleCheckStatefulSession() { } public StatefulKnowledgeSession getTerminateAllStatefulSession() { StatefulKnowledgeSession ksession; - ksession = scaleCheckKbase.newStatefulKnowledgeSession(); + ksession = terminateAllKbase.newStatefulKnowledgeSession(); ksession.setGlobal("log", RuleLog.getInstance()); return ksession; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java index 57043d9c2a..350a975373 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java @@ -172,6 +172,11 @@ public static String getLbClusterId(String lbRefType, PartitionContext partition } public void delegateTerminate(PartitionContext partitionContext, String memberId) { + + log.info("Starting to terminate Member [ " + memberId + " ], in Partition [ " + + partitionContext.getPartitionId() + " ], NW Partition [ " + + partitionContext.getNetworkPartitionId() + " ]"); + try { //calling SM to send the instance notification event. InstanceNotificationClient.getInstance().sendMemberCleanupEvent(memberId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index bfd01675ae..7c0abfc44a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -23,13 +23,7 @@ import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; -import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.listener.application.status.*; -import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupTerminatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupTerminatingEventListener; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; public class ApplicationStatusTopicReceiver implements Runnable { @@ -86,7 +80,7 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { + statusEventReceiver.addEventListener(new GroupInTerminatedEventListener() { @Override protected void onEvent(Event event) { TopologyBuilder.handleGroupTerminatedEvent((GroupInTerminatedEvent) event); @@ -94,7 +88,7 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new GroupTerminatingEventListener() { + statusEventReceiver.addEventListener(new GroupInTerminatingEventListener() { @Override protected void onEvent(Event event) { TopologyBuilder.handleGroupTerminatingEvent((GroupInTerminatingEvent) event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index d5dccbbc1d..24cb122d5e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -22,8 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.listener.application.status.*; -import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; /** From 54e720ce312a9cd587993e6b9b49e9f4b4b37419 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 23 Oct 2014 13:53:11 +0530 Subject: [PATCH 247/436] rename some events --- .../AutoscalerTopologyEventReceiver.java | 3 +- .../ApplicationStatusTopicReceiver.java | 5 +-- .../status/GroupInInactivateEvent.java | 44 ------------------- ...teEvent.java => GroupInactivateEvent.java} | 4 +- ...java => GroupInactivateEventListener.java} | 2 +- ...java => GroupTerminatedEventListener.java} | 5 +-- ...ava => GroupTerminatingEventListener.java} | 2 +- ...atusGroupInActivatedMessageProcessor.java} | 13 +++--- ...pplicationStatusMessageProcessorChain.java | 12 ++--- 9 files changed, 20 insertions(+), 70 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupInActivateEvent.java => GroupInactivateEvent.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupInActivateEventListener.java => GroupInactivateEventListener.java} (93%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupInTerminatingEventListener.java => GroupTerminatedEventListener.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupInTerminatedEventListener.java => GroupTerminatingEventListener.java} (92%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusGroupInActivateMessageProcessor.java => ApplicationStatusGroupInActivatedMessageProcessor.java} (81%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index bb91b7eaea..9e7c7691ac 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -40,9 +40,8 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.application.status.GroupInTerminatingEvent; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.listener.application.status.GroupInTerminatingEventListener; +import org.apache.stratos.messaging.listener.application.status.GroupTerminatingEventListener; 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; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 7c0abfc44a..3a3be45910 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -37,7 +37,6 @@ public ApplicationStatusTopicReceiver() { addEventListeners(); } - @Override public void run() { //FIXME this activated before autoscaler deployer activated. try { @@ -80,7 +79,7 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new GroupInTerminatedEventListener() { + statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { @Override protected void onEvent(Event event) { TopologyBuilder.handleGroupTerminatedEvent((GroupInTerminatedEvent) event); @@ -88,7 +87,7 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new GroupInTerminatingEventListener() { + statusEventReceiver.addEventListener(new GroupTerminatingEventListener() { @Override protected void onEvent(Event event) { TopologyBuilder.handleGroupTerminatingEvent((GroupInTerminatingEvent) event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java deleted file mode 100644 index 6aeada77e0..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInInactivateEvent.java +++ /dev/null @@ -1,44 +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.messaging.event.application.status; - -/** - * This event is fired by cartridge agent when it has started the server and - * applications are ready to serve the incoming requests. - */ -public class GroupInInactivateEvent extends StatusEvent { - private static final long serialVersionUID = 2625412714611885089L; - - private String groupId; - private String appId; - - public GroupInInactivateEvent(String appId, String groupId) { - this.appId = appId; - this.groupId = groupId; - } - - public String getGroupId() { - return this.groupId; - } - - public String getAppId() { - return appId; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java index c7c8d5816d..e81648032f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInActivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java @@ -23,13 +23,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupInActivateEvent extends StatusEvent { +public class GroupInactivateEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupInActivateEvent(String appId, String groupId) { + public GroupInactivateEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java similarity index 93% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java index ecc4f04fb9..bcca3fdb48 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInActivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java @@ -23,5 +23,5 @@ /** * Created by reka on 9/22/14. */ -public abstract class GroupInActivateEventListener extends EventListener { +public abstract class GroupInactivateEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java similarity index 88% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java index 20c8b68479..6572516de2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/22/14. - */ -public abstract class GroupInTerminatingEventListener extends EventListener { +public abstract class GroupTerminatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java similarity index 92% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java index 8cb331ce55..afb65b827d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java @@ -23,5 +23,5 @@ /** * Created by reka on 9/22/14. */ -public abstract class GroupInTerminatedEventListener extends EventListener { +public abstract class GroupTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java similarity index 81% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java index 099b1850ff..2f7f231682 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivateMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java @@ -21,14 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupInActivateEvent; +import org.apache.stratos.messaging.event.application.status.GroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusGroupInActivateMessageProcessor extends MessageProcessor { +public class ApplicationStatusGroupInActivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusGroupInActivateMessageProcessor.class); + LogFactory.getLog(ApplicationStatusGroupInActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -38,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (GroupInActivateEvent.class.getName().equals(type)) { + if (GroupInactivateEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupInActivateEvent event = - (GroupInActivateEvent) Util.jsonToObject(message, GroupInActivateEvent.class); + GroupInactivateEvent event = + (GroupInactivateEvent) Util.jsonToObject(message, GroupInactivateEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupInActivateEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index 24cb122d5e..e8575cce97 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -34,7 +34,7 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; private ApplicationStatusClusterInActivateMessageProcessor clusterInActivateMessageProcessor; private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; - private ApplicationStatusGroupInActivateMessageProcessor groupInActivateMessageProcessor; + private ApplicationStatusGroupInActivatedMessageProcessor groupInActivateMessageProcessor; private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; private ApplicationStatusAppCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; private ApplicationStatusAppInActivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; @@ -55,7 +55,7 @@ public void initialize() { groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); - groupInActivateMessageProcessor = new ApplicationStatusGroupInActivateMessageProcessor(); + groupInActivateMessageProcessor = new ApplicationStatusGroupInActivatedMessageProcessor(); add(groupInActivateMessageProcessor); appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor(); @@ -91,7 +91,7 @@ public void addEventListener(EventListener eventListener) { clusterInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupInActivateEventListener) { + } else if (eventListener instanceof GroupInactivateEventListener) { groupInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); @@ -103,13 +103,13 @@ public void addEventListener(EventListener eventListener) { applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ApplicationTerminatedEventListener){ applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupInTerminatingEventListener){ + } else if (eventListener instanceof GroupTerminatingEventListener){ groupTerminatingMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupInTerminatedEventListener){ + } else if (eventListener instanceof GroupTerminatedEventListener){ groupTerminatedMessageProcessor.addEventListener(eventListener); } else { - throw new RuntimeException("Unknown event listener"); + throw new RuntimeException("Unknown event listener " + eventListener.toString()); } } } From c6cadf0bfc940595f724208f12c125d310673b92 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 23 Oct 2014 14:26:30 +0530 Subject: [PATCH 248/436] changes related to LifeCycleStateManager, adding an identifier for the ease of logging --- .../controller/topology/TopologyBuilder.java | 2 -- .../domain/topology/Application.java | 2 +- .../messaging/domain/topology/Cluster.java | 2 +- .../messaging/domain/topology/Group.java | 2 +- .../messaging/domain/topology/Member.java | 2 +- .../lifecycle/LifeCycleStateManager.java | 26 +++++++++++++------ .../ApplicationActivatedMessageProcessor.java | 5 +--- ...pplicationInactivatedMessageProcessor.java | 5 +--- ...ApplicationTerminatedMessageProcessor.java | 5 +--- ...pplicationTerminatingMessageProcessor.java | 5 +--- ...ApplicationUndeployedMessageProcessor.java | 3 --- .../topology/ClusterActivatedProcessor.java | 5 +--- .../topology/ClusterInActivateProcessor.java | 5 +--- .../topology/GroupActivatedProcessor.java | 5 +--- .../topology/GroupTerminatedProcessor.java | 5 +--- .../topology/GroupTerminatingProcessor.java | 5 +--- 16 files changed, 31 insertions(+), 53 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index ac409c7747..9b21c558fe 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -717,8 +717,6 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold } // for now anyway update the status forcefully aCluster.setStatus(ClusterStatus.Terminating); - log.info("Cluster " + clusterDataHolder.getClusterId() + "'s status updated to " - + ClusterStatus.Terminating); } else { log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java index ecca8df8c1..0e4438b767 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java @@ -49,7 +49,7 @@ public Application (String id) { this.id = id; this.key = RandomStringUtils.randomAlphanumeric(16); this.applicationStateManager = - new LifeCycleStateManager(ApplicationStatus.Created); + new LifeCycleStateManager(ApplicationStatus.Created, id); } public String getUniqueIdentifier() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index e99090341d..1f69fd65c3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -68,7 +68,7 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.hostNames = new ArrayList(); this.memberMap = new HashMap(); this.appId = appId; - this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created); + this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created, clusterId); // temporary; should be removed //this.status = ClusterStatus.Created; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java index 0b64f67e33..79ce4bcba4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java @@ -45,7 +45,7 @@ public Group (String name, String alias) { super(); this.name = name; this.alias = alias; - this.groupStateManager = new LifeCycleStateManager(GroupStatus.Created); + this.groupStateManager = new LifeCycleStateManager(GroupStatus.Created, alias); } public String getUniqueIdentifier() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index 1d80b169ce..fbab2f6fe8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -58,7 +58,7 @@ public Member(String serviceName, String clusterId, String networkPartitionId, S this.partitionId = partitionId; this.memberId = memberId; this.portMap = new HashMap(); - this.memberStateManager = new LifeCycleStateManager(MemberStatus.Created); + this.memberStateManager = new LifeCycleStateManager(MemberStatus.Created, memberId); } public String getServiceName() { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index 9151bb10aa..f57edf8d32 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -32,11 +32,17 @@ public class LifeCycleStateManager implements Serializ private Stack stateStack; - public LifeCycleStateManager(T initialState) { + // a unique id which points to the relevant topology member + // ex.: member id in a Member + private String identifier; + public LifeCycleStateManager(T initialState, String identifier) { + + this.identifier = identifier; stateStack = new Stack(); stateStack.push(initialState); - log.info("Life Cycle State Manager started, initial state: " + initialState.toString()); + log.info("Life Cycle State Manager started for Topology element [ " + identifier + + " ], initial state: " + initialState.toString()); } /** @@ -45,7 +51,7 @@ public LifeCycleStateManager(T initialState) { * @param nextState possible next state for the topology element * @param topologyEvent relevant ToplogyEvent * @param subclass of Topology event - * @return + * @return true if preconditions are valid and satisfied, else false */ public boolean isPreConditionsValid (T nextState, S topologyEvent) { // TODO: implement @@ -66,15 +72,15 @@ public boolean isStateTransitionValid (T nextState) { /** * Changes the current state to nextState * - * @param nextState + * @param nextState the next state to change */ public void changeState (T nextState) { stateStack.push(nextState); + log.info("Topology element [ " + identifier + " ]'s life Cycle State changed from [ " + + getPreviousState() + " ] to [ " + getCurrentState() + " ]"); if (log.isDebugEnabled()) { printStateTransitions(stateStack); -// log.debug("Life Cycle State changed from [ " + getPreviousState() + " ] to [ " + -// getCurrentState() + " ]"); } } @@ -112,10 +118,14 @@ private static void printStateTransitions (Stack s // print all transitions till now StringBuilder stateTransitions = new StringBuilder("Transitioned States: [ START --> "); - for (int i = 0 ; i < stateStack.size() ; i++) { - stateTransitions.append(stateStack.get(i) + " --> "); + for (T aStateStack : stateStack) { + stateTransitions.append(aStateStack).append(" --> "); } stateTransitions.append(" END ]"); log.debug(stateTransitions); } + + public String getIdentifier() { + return identifier; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index ed360be69d..064fb9c285 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -93,10 +93,7 @@ private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { " ] to [ " + ApplicationStatus.Active + " ]"); } application.setStatus(ApplicationStatus.Active); - if (log.isInfoEnabled()) { - log.info(String.format("Application updated as activated : %s", - application.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java index a2bdb6098a..cda1d73693 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java @@ -93,10 +93,7 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) " ] to [ " + ApplicationStatus.Inactive + " ]"); } application.setStatus(ApplicationStatus.Inactive); - if (log.isInfoEnabled()) { - log.info(String.format("Application updated as inactivated : %s", - application.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java index b08e6f9942..2d22c6c985 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -93,10 +93,7 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) " ] to [ " + ApplicationStatus.Terminated + " ]"); } application.setStatus(ApplicationStatus.Terminated); - if (log.isInfoEnabled()) { - log.info(String.format("Application updated as terminating : %s", - application.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java index 2c1ed00566..cb6e887168 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java @@ -93,10 +93,7 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) " ] to [ " + ApplicationStatus.Terminating + " ]"); } application.setStatus(ApplicationStatus.Terminating); - if (log.isInfoEnabled()) { - log.info(String.format("Application updated as activated : %s", - application.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java index 8915e4f21a..04c69731d1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java @@ -102,7 +102,6 @@ private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) } // for now anyway update the status forcefully application.setStatus(ApplicationStatus.Terminating); - log.info("Application " + event.getApplicationId() + "'s status updated to " + ApplicationStatus.Terminating); // update all the Clusters' statuses to 'Terminating' Set clusterData = application.getClusterDataRecursively(); @@ -119,8 +118,6 @@ private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) } // for now anyway update the status forcefully aCluster.setStatus(ClusterStatus.Terminating); - log.info("Cluster " + clusterDataHolder.getClusterId() + "'s status updated to " - + ClusterStatus.Terminating + " successfully"); } else { log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java index f2f2521bed..899b12f994 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterActivatedProcessor.java @@ -122,10 +122,7 @@ private boolean doProcess(ClusterActivatedEvent event, Topology topology) { log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); } cluster.setStatus(ClusterStatus.Active); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster updated as activated : %s", - cluster.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java index c9499fb472..cfaad73c66 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java @@ -121,10 +121,7 @@ private boolean doProcess(ClusterInActivateEvent event, Topology topology) { log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); } cluster.setStatus(ClusterStatus.Inactive); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster updated as maintenance mode: %s", - cluster.toString())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index d7f2de61dc..aa050ef975 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -94,10 +94,7 @@ private boolean doProcess (GroupActivatedEvent event,Topology topology) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); } group.setStatus(GroupStatus.Active); - if (log.isInfoEnabled()) { - log.info(String.format("Group updated as activated : %s", - group.getUniqueIdentifier())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java index 6196776ae7..5e96709beb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java @@ -97,10 +97,7 @@ private boolean doProcess (GroupTerminatedEvent event,Topology topology) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); } group.setStatus(GroupStatus.Terminated); - if (log.isInfoEnabled()) { - log.info(String.format("Group updated as activated : %s", - group.getUniqueIdentifier())); - } + } // Notify event listeners diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java index afec0f2c70..210279c7b8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java @@ -97,10 +97,7 @@ private boolean doProcess (GroupTerminatingEvent event,Topology topology) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); } group.setStatus(GroupStatus.Terminating); - if (log.isInfoEnabled()) { - log.info(String.format("Group updated as Terminating : %s", - group.getUniqueIdentifier())); - } + } // Notify event listeners From 928969d436972266f4d6b4208bb69ecbe94c3568 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 24 Oct 2014 11:09:14 +0530 Subject: [PATCH 249/436] fixing STRATOS-908 --- .../AutoscalerTopologyEventReceiver.java | 11 ++++---- .../ApplicationInActivateEventListener.java | 27 +++++++++++++++++++ .../ApplicationTerminatedEventListener.java | 27 +++++++++++++++++++ .../ApplicationTerminatingEventListener.java | 27 +++++++++++++++++++ .../TopologyMessageProcessorChain.java | 5 +--- 5 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 9e7c7691ac..93b312327c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -41,7 +41,6 @@ import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.listener.application.status.GroupTerminatingEventListener; 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; @@ -96,6 +95,8 @@ private void addEventListeners() { protected void onEvent(Event event) { if (!topologyInitialized) { + log.info("[CompleteTopologyEvent] Received: " + event.getClass()); + TopologyManager.acquireReadLock(); try { for (Application application : TopologyManager.getTopology().getApplications()) { @@ -165,7 +166,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + log.info("[ClusterCreatedEvent] Received: " + event.getClass()); ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; String clusterId = clusterCreatedEvent.getClusterId(); @@ -184,7 +185,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + log.info("[ClusterInActivateEvent] Received: " + event.getClass()); ClusterInActivateEvent clusterInActivateEvent = (ClusterInActivateEvent) event; String appId = clusterInActivateEvent.getAppId(); @@ -246,7 +247,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[GroupTerminatedEven] Received: " + event.getClass()); + log.info("[GroupTerminatingEvent] Received: " + event.getClass()); GroupTerminatingEvent groupTerminatingEvent = (GroupTerminatingEvent) event; String appId = groupTerminatingEvent.getAppId(); @@ -267,7 +268,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[GroupTerminatedEven] Received: " + event.getClass()); + log.info("[GroupTerminatedEvent] Received: " + event.getClass()); GroupTerminatedEvent groupTerminatedEvent = (GroupTerminatedEvent) event; String appId = groupTerminatedEvent.getAppId(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java new file mode 100644 index 0000000000..d33c0379a7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will be triggered upon the application activated event received. + */ +public abstract class ApplicationInActivateEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java new file mode 100644 index 0000000000..0b6fd597a9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will be triggered upon the application activated event received. + */ +public abstract class ApplicationTerminatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java new file mode 100644 index 0000000000..cc2645439a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This listener will be triggered upon the application activated event received. + */ +public abstract class ApplicationTerminatingEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 1fb3961a57..1e1930c021 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,9 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationInActivatedEventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatedEventListener; -import org.apache.stratos.messaging.listener.application.status.ApplicationTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; @@ -188,7 +185,7 @@ public void addEventListener(EventListener eventListener) { applicationRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { applicationActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationInActivatedEventListener){ + } else if (eventListener instanceof ApplicationInActivateEventListener){ applicationInactivatedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ApplicationTerminatedEventListener){ applicationTerminatedMessageProcessor.addEventListener(eventListener); From 061cc496fc811d9bc0dbb3f4535496cfa366ec94 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 24 Oct 2014 14:33:46 +0530 Subject: [PATCH 250/436] removnig the wrong id and used the correct id --- .../stratos/autoscaler/monitor/ParentComponentMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 14ce2817cc..26eff1d024 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -91,7 +91,7 @@ protected void onChildActivatedEvent(String idOfEvent) { protected void onChildTerminatingEvent(String idOfEvent) { //Check whether hasDependent true if (!this.aliasToInActiveMonitorsMap.containsKey(idOfEvent)) { - this.aliasToInActiveMonitorsMap.put(id, this.aliasToActiveMonitorsMap.remove(idOfEvent)); + this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); } Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent); From c01d963dee00f10c32180a8fc6f7d1c3a8af3afc Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 23 Oct 2014 17:53:13 +0530 Subject: [PATCH 251/436] add acquire topology lock for get app info --- .../org/apache/stratos/rest/endpoint/services/ServiceUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 1bd2568cfe..b7b5695e87 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -1462,6 +1462,7 @@ public static ApplicationBean getApplicationInfo(String applicationId, Configura Cluster topLevelCluster; try { + TopologyManager.acquireReadLockForCluster(serviceType, clusterId); topLevelCluster = TopologyManager.getTopology().getService(serviceType).getCluster(clusterId); }finally { TopologyManager.releaseReadLockForCluster(serviceType, clusterId); From 4b1d3a656d7f21eed1c15f247b7fc2c229f266ab Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Thu, 23 Oct 2014 18:08:59 +0530 Subject: [PATCH 252/436] add comments for the REST API --- .../stratos/rest/endpoint/services/StratosAdmin.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index 56602ade5e..44d42a5710 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -414,6 +414,16 @@ public Response getSubscriptionsOfApplication(@PathParam("application_id") Strin return Response.ok().entity(subscriptions).build(); } + /** + * This API provides information about the application denoted by the given appId. Details includes, + * Application details, + * Top level cluster details + * details of the group and sub groups. + * @param applicationId Id of the application. + * @return Json representing the application details with 200 as HTTP status. HTTP 404 is returned when there is + * no application with given Id. + * @throws RestAPIException is thrown in case of failure occurs. + */ @GET @Path("/application/{appId}") From 25221cc3f2a0f73997fa9a793700f99c4adfb802 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 24 Oct 2014 11:42:08 +0530 Subject: [PATCH 253/436] adding missing locks in application undeployment and removal --- .../AutoscalerTopologyEventReceiver.java | 34 ++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 93b312327c..211bcd2e42 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -35,10 +35,7 @@ import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.listener.topology.*; @@ -46,6 +43,7 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.List; +import java.util.Set; /** * Autoscaler topology receiver. @@ -306,7 +304,16 @@ protected void onEvent(Event event) { log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; + + // acquire reead locks for application and relevant clusters TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } try { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). @@ -338,6 +345,12 @@ protected void onEvent(Event event) { } } finally { + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } TopologyManager. releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); } @@ -355,6 +368,13 @@ protected void onEvent(Event event) { //acquire read lock TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId()); + Set clusterDataHolders = applicationRemovedEvent.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } try { //TODO remove monitors as well as any starting or pending threads @@ -379,6 +399,12 @@ protected void onEvent(Event event) { } finally { //release read lock + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), + clusterData.getClusterId()); + } + } TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId()); } From fe38bdcfc5f761ef46e78a5db3c0e7f34141f8d9 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 24 Oct 2014 15:48:07 +0530 Subject: [PATCH 254/436] adding cluster and group in-active listeners for topology and application status in the receiver side --- .../grouping/topic/StatusEventPublisher.java | 72 +++++------------- .../AutoscalerTopologyEventReceiver.java | 14 ---- .../status/checker/StatusChecker.java | 16 +++- .../ApplicationStatusTopicReceiver.java | 16 ++++ .../controller/topology/TopologyBuilder.java | 74 +++++++++++++++++++ .../topology/TopologyEventPublisher.java | 17 +++++ 6 files changed, 141 insertions(+), 68 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 668161af43..630ffd2ceb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -11,6 +11,7 @@ import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent; import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.event.topology.*; @@ -32,10 +33,10 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str " [cluster]: " + clusterId); } - //TODO cluster - ClusterCreatedEvent clusterActivatedEvent = new ClusterCreatedEvent(appId, serviceName, null); - publishEvent(clusterActivatedEvent); + ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterCreatedEvent); } public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { @@ -45,7 +46,8 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S " [cluster]: " + clusterId); } - ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + ClusterActivatedEvent clusterActivatedEvent = + new ClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent); } @@ -57,9 +59,10 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, " [cluster]: " + clusterId); } - /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + ClusterInActivateEvent clusterInActivateEvent = + new ClusterInActivateEvent(appId, serviceName, clusterId); - publishEvent(clusterActivatedEvent);*/ + publishEvent(clusterInActivateEvent); } public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) { @@ -68,7 +71,7 @@ public static void sendClusterTerminatingEvent(String appId, String serviceName, log.info("Publishing Cluster in-activate event for [application]: " + appId + " [cluster]: " + clusterId); } - + //TODO /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent);*/ @@ -80,36 +83,12 @@ public static void sendClusterTerminatedEvent(String appId, String serviceName, log.info("Publishing Cluster in-activate event for [application]: " + appId + " [cluster]: " + clusterId); } - - /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + //TODO + /* Cluster clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent);*/ } - public static void sendClusterInMaintenanceEvent(String appId, String serviceName, String clusterId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Cluster in_maintenance event for [application]: " + appId + - " [cluster]: " + clusterId); - } - - ClusterMaintenanceModeEvent clusterInMaintenanceEvent = - new ClusterMaintenanceModeEvent(appId, serviceName, clusterId); - - publishEvent(clusterInMaintenanceEvent); - } - - public static void sendGroupCreatedEvent(String appId, String groupId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Group activated event for [application]: " + appId + - " [group]: " + groupId); - } - -/* - publishEvent(groupActivatedEvent);*/ - } - public static void sendGroupActivatedEvent(String appId, String groupId) { if (log.isInfoEnabled()) { @@ -141,9 +120,9 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); + GroupInTerminatingEvent groupInTerminatingEvent = new GroupInTerminatingEvent(appId, groupId); - publishEvent(groupInActivateEvent); + publishEvent(groupInTerminatingEvent); } public static void sendGroupTerminatedEvent(String appId, String groupId) { @@ -153,9 +132,9 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); + GroupInTerminatedEvent groupInTerminatedEvent = new GroupInTerminatedEvent(appId, groupId); - publishEvent(groupInActivateEvent); + publishEvent(groupInTerminatedEvent); } public static void sendApplicationActivatedEvent(String appId) { @@ -179,27 +158,14 @@ public static void sendApplicationInactivatedEvent(String appId){ publishEvent(applicationInActivatedEvent); } - public static void sendGroupInMaintenanceEvent(String appId, String groupId) { - + public static void sendApplicationTerminatedEvent (String appId, Set clusterData) { if (log.isInfoEnabled()) { - log.info("Publishing Group in_maintenance event for [application]: " + appId + - " [group]: " + groupId); + log.info("Publishing Application terminated event for [application]: " + appId); } - GroupMaintenanceModeEvent groupMaintenanceModeEvent = - new GroupMaintenanceModeEvent(appId, groupId); - - publishEvent(groupMaintenanceModeEvent); - } - - public static void sendApplicationTerminatingEvent (String appId) { - // TODO: implement - } - - public static void sendApplicationTerminatedEvent (String appId, Set clusterData) { - ApplicationTerminatedEvent applicationTerminatedEvent = new ApplicationTerminatedEvent(appId, clusterData); + publishEvent(applicationTerminatedEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 211bcd2e42..ce5aff08a4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -155,8 +155,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor clusterMonitor.setStatus(ClusterStatus.Active); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); @@ -174,8 +172,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor clusterMonitor.setStatus(ClusterStatus.Created); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); @@ -194,8 +190,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor clusterMonitor.setStatus(ClusterStatus.Inactive); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); @@ -215,8 +209,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor monitor.setStatus(GroupStatus.Active); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); } }); @@ -236,8 +228,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor monitor.setStatus(GroupStatus.Inactive); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); } }); @@ -257,8 +247,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor monitor.setStatus(GroupStatus.Terminating); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); } }); @@ -278,8 +266,6 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor monitor.setStatus(GroupStatus.Terminated); - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onGroupStatusChange(groupId, appId); } }); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 1366bf8572..7aef08e954 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -285,7 +285,21 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (parent instanceof Group) { //send activation to the parent log.info("sending group terminated : " + parent.getUniqueIdentifier()); - //StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || + clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || + groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) { + //send the terminated event + if (parent instanceof Application) { + //send application activated event + log.info("sending app terminating: " + appId); + StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + //StatusEventPublisher.sendApp(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group terminating : " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); } } else { log.warn("Clusters/groups not found in this [component] " + appId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 3a3be45910..604602bd19 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; +import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.listener.application.status.*; @@ -71,6 +72,13 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new ClusterInActivateEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleClusterInActivateEvent((ClusterInActivateEvent) event); + } + }); + statusEventReceiver.addEventListener(new GroupActivatedEventListener() { @Override protected void onEvent(Event event) { @@ -79,6 +87,14 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new GroupInactivateEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupInActiveEvent((GroupInactivateEvent) event); + + } + }); + statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 9b21c558fe..484cf993df 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -44,6 +44,7 @@ import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; @@ -774,6 +775,44 @@ public static void handleClusterActivatedEvent(ClusterActivatedEvent clusterActi TopologyEventPublisher.sendClusterActivatedEvent(clusterActivatedEvent1); } + public static void handleClusterInActivateEvent( + org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent clusterInActivateEvent) { + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(clusterInActivateEvent.getServiceName()); + //update the status of the cluster + if (service == null) { + log.warn(String.format("Service %s does not exist", + clusterInActivateEvent.getServiceName())); + return; + } + + Cluster cluster = service.getCluster(clusterInActivateEvent.getClusterId()); + if (cluster == null) { + log.warn(String.format("Cluster %s does not exist", + clusterInActivateEvent.getClusterId())); + return; + } + + ClusterInActivateEvent clusterActivatedEvent1 = + new ClusterInActivateEvent( + clusterInActivateEvent.getAppId(), + clusterInActivateEvent.getServiceName(), + clusterInActivateEvent.getClusterId()); + try { + TopologyManager.acquireWriteLock(); + //cluster.setStatus(Status.Activated); + cluster.setStatus(ClusterStatus.Inactive); + + log.info("Cluster in-active adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1); + } + public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(groupActivatedEvent.getAppId()); @@ -1003,6 +1042,41 @@ public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent e } } + public static void handleGroupInActiveEvent(GroupInactivateEvent event) { + Topology topology = TopologyManager.getTopology(); + Application application = topology.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + + Group group = application.getGroupRecursively(event.getGroupId()); + if (group == null) { + log.warn(String.format("Group %s does not exist", + event.getGroupId())); + return; + } + + GroupInActivateEvent groupInActivateEvent = + new GroupInActivateEvent( + event.getAppId(), + event.getGroupId()); + try { + TopologyManager.acquireWriteLock(); + group.setStatus(GroupStatus.Inactive); + log.info("Group in-active adding status started"); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + //publishing data + TopologyEventPublisher.sendGroupInActiveEvent(groupInActivateEvent); + } + + public static void handleGroupTerminatedEvent(GroupInTerminatedEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 21d82677af..9f69ee2d4d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -204,6 +204,14 @@ public static void sendClusterActivatedEvent(ClusterActivatedEvent clusterActiva publishEvent(clusterActivatedEvent); } + public static void sendClusterInActivateEvent(ClusterInActivateEvent clusterInActiveEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing cluster in-active event: [service] %s [cluster] %s [appId] %s", + clusterInActiveEvent.getServiceName(), clusterInActiveEvent.getClusterId() , clusterInActiveEvent.getAppId())); + } + publishEvent(clusterInActiveEvent); + } + public static void sendMemberTerminatedEvent(String serviceName, String clusterId, String networkPartitionId, String partitionId, String memberId, Properties properties, String groupId) { @@ -265,6 +273,15 @@ public static void sendApplicationTerminatedEvent(ApplicationTerminatedEvent app publishEvent(applicationTerminatedEvent); } + public static void sendGroupInActiveEvent(GroupInActivateEvent groupInActivateEvent) { + if(log.isInfoEnabled()) { + log.info(String.format("Publishing group in-active event: [appId] %s", + groupInActivateEvent.getAppId())); + } + publishEvent(groupInActivateEvent); + } + + public static void sendGroupTerminatedEvent(GroupTerminatedEvent groupTerminatedTopologyEvent) { if(log.isInfoEnabled()) { log.info(String.format("Publishing group terminated event: [appId] %s", From 7619d85c09ca12783ba86f209bc2db882341123f Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 24 Oct 2014 17:07:51 +0530 Subject: [PATCH 255/436] add cluster teminating/terminated event, event listeners, mesage processors --- .../grouping/topic/StatusEventPublisher.java | 8 +- .../AutoscalerTopologyEventReceiver.java | 52 ++++++- .../ApplicationStatusTopicReceiver.java | 19 ++- .../controller/topology/TopologyBuilder.java | 18 ++- .../topology/TopologyEventPublisher.java | 4 +- .../AppStatusClusterTerminatedEvent.java | 50 +++++++ .../AppStatusClusterTerminatingEvent.java | 50 +++++++ ...Event.java => ClusterInactivateEvent.java} | 4 +- ...Event.java => ClusterTerminatedEvent.java} | 31 ++-- .../topology/ClusterTerminatingEvent.java | 56 ++++++++ ...teEvent.java => GroupInactivateEvent.java} | 4 +- ...pStatusClusterTerminatedEventListener.java | 24 ++++ ...StatusClusterTerminatingEventListener.java | 24 ++++ .../ClusterTerminatedEventListener.java | 24 ++++ .../ClusterTerminatingEventListener.java | 24 ++++ ...atusClusterTerminatedMessageProcessor.java | 59 ++++++++ ...tusClusterTerminatingMessageProcessor.java | 58 ++++++++ ...pplicationStatusMessageProcessorChain.java | 13 +- .../topology/ClusterInActivateProcessor.java | 10 +- .../topology/ClusterTerminatedProcessor.java | 133 ++++++++++++++++++ .../topology/ClusterTerminatingProcessor.java | 133 ++++++++++++++++++ .../topology/GroupInActivateProcessor.java | 8 +- .../TopologyMessageProcessorChain.java | 14 +- .../exception/MetadataException.java | 4 +- .../rest/endpoint/bean/ApplicationBean.java | 3 - .../rest/endpoint/services/MyType.java | 16 --- 26 files changed, 772 insertions(+), 71 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/{ClusterInActivateEvent.java => ClusterInactivateEvent.java} (93%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/{GroupInactivatedEvent.java => ClusterTerminatedEvent.java} (62%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatingEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/{GroupInActivateEvent.java => GroupInactivateEvent.java} (91%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatingEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java delete mode 100644 components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/MyType.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 630ffd2ceb..0800b14436 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -15,7 +15,7 @@ import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; +import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.util.Constants; import java.util.Set; @@ -108,9 +108,9 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInActivateEvent groupInActivateEvent = new GroupInActivateEvent(appId, groupId); + GroupInactivateEvent groupInactivateEvent = new GroupInactivateEvent(appId, groupId); - publishEvent(groupInActivateEvent); + publishEvent(groupInactivateEvent); } public static void sendGroupTerminatingEvent(String appId, String groupId) { @@ -121,7 +121,6 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { } GroupInTerminatingEvent groupInTerminatingEvent = new GroupInTerminatingEvent(appId, groupId); - publishEvent(groupInTerminatingEvent); } @@ -133,7 +132,6 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { } GroupInTerminatedEvent groupInTerminatedEvent = new GroupInTerminatedEvent(appId, groupId); - publishEvent(groupInTerminatedEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index ce5aff08a4..63f90792c6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -181,9 +181,9 @@ protected void onEvent(Event event) { log.info("[ClusterInActivateEvent] Received: " + event.getClass()); - ClusterInActivateEvent clusterInActivateEvent = (ClusterInActivateEvent) event; - String appId = clusterInActivateEvent.getAppId(); - String clusterId = clusterInActivateEvent.getClusterId(); + ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; + String appId = clusterInactivateEvent.getAppId(); + String clusterId = clusterInactivateEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); @@ -193,6 +193,46 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ClusterTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterInActivateEvent] Received: " + event.getClass()); + + ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event; + String appId = clusterInactivateEvent.getAppId(); + String clusterId = clusterInactivateEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(ClusterStatus.Terminating); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + + topologyEventReceiver.addEventListener(new ClusterTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterInActivateEvent] Received: " + event.getClass()); + + ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event; + String appId = clusterInactivateEvent.getAppId(); + String clusterId = clusterInactivateEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(ClusterStatus.Terminated); + + //starting the status checker to decide on the status of it's parent + //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); + } + }); + topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { @Override protected void onEvent(Event event) { @@ -218,9 +258,9 @@ protected void onEvent(Event event) { log.info("[GroupInActivateEvent] Received: " + event.getClass()); - GroupInActivateEvent groupInActivateEvent = (GroupInActivateEvent) event; - String appId = groupInActivateEvent.getAppId(); - String groupId = groupInActivateEvent.getGroupId(); + GroupInactivateEvent groupInactivateEvent = (GroupInactivateEvent) event; + String appId = groupInactivateEvent.getAppId(); + String groupId = groupInactivateEvent.getGroupId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 604602bd19..5aa446744f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; -import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.listener.application.status.*; @@ -72,25 +71,31 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new ClusterInActivateEventListener() { + statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterInActivateEvent((ClusterInActivateEvent) event); + TopologyBuilder.handleClusterTerminatedEvent((ClusterActivatedEvent) event); } }); - statusEventReceiver.addEventListener(new GroupActivatedEventListener() { + statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){ @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event); + TopologyBuilder.handleClusterTerminatingEvent((ClusterActivatedEvent) event); + } + }); + statusEventReceiver.addEventListener(new ClusterInActivateEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleClusterInActivateEvent((ClusterInActivateEvent) event); } }); - statusEventReceiver.addEventListener(new GroupInactivateEventListener() { + statusEventReceiver.addEventListener(new GroupActivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupInActiveEvent((GroupInactivateEvent) event); + TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 484cf993df..80315ea1b9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -39,12 +39,12 @@ import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.GroupInactivateEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; @@ -793,8 +793,8 @@ public static void handleClusterInActivateEvent( return; } - ClusterInActivateEvent clusterActivatedEvent1 = - new ClusterInActivateEvent( + ClusterInactivateEvent clusterActivatedEvent1 = + new ClusterInactivateEvent( clusterInActivateEvent.getAppId(), clusterInActivateEvent.getServiceName(), clusterInActivateEvent.getClusterId()); @@ -1059,8 +1059,8 @@ public static void handleGroupInActiveEvent(GroupInactivateEvent event) { return; } - GroupInActivateEvent groupInActivateEvent = - new GroupInActivateEvent( + org.apache.stratos.messaging.event.topology.GroupInactivateEvent groupInActivateEvent = + new org.apache.stratos.messaging.event.topology.GroupInactivateEvent( event.getAppId(), event.getGroupId()); try { @@ -1144,4 +1144,12 @@ public static void handleGroupTerminatingEvent(GroupInTerminatingEvent event) { //publishing data TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); } + + public static void handleClusterTerminatedEvent(ClusterActivatedEvent event) { + + } + + public static void handleClusterTerminatingEvent(ClusterActivatedEvent event) { + + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 9f69ee2d4d..3c6277d726 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -204,7 +204,7 @@ public static void sendClusterActivatedEvent(ClusterActivatedEvent clusterActiva publishEvent(clusterActivatedEvent); } - public static void sendClusterInActivateEvent(ClusterInActivateEvent clusterInActiveEvent) { + public static void sendClusterInActivateEvent(ClusterInactivateEvent clusterInActiveEvent) { if(log.isInfoEnabled()) { log.info(String.format("Publishing cluster in-active event: [service] %s [cluster] %s [appId] %s", clusterInActiveEvent.getServiceName(), clusterInActiveEvent.getClusterId() , clusterInActiveEvent.getAppId())); @@ -273,7 +273,7 @@ public static void sendApplicationTerminatedEvent(ApplicationTerminatedEvent app publishEvent(applicationTerminatedEvent); } - public static void sendGroupInActiveEvent(GroupInActivateEvent groupInActivateEvent) { + public static void sendGroupInActiveEvent(GroupInactivateEvent groupInActivateEvent) { if(log.isInfoEnabled()) { log.info(String.format("Publishing group in-active event: [appId] %s", groupInActivateEvent.getAppId())); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java new file mode 100644 index 0000000000..919d0cac9b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class AppStatusClusterTerminatedEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public AppStatusClusterTerminatedEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java new file mode 100644 index 0000000000..7a6baf00e8 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class AppStatusClusterTerminatingEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public AppStatusClusterTerminatingEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInactivateEvent.java similarity index 93% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInactivateEvent.java index 36ea4362fd..0f14e4ff74 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInActivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterInactivateEvent.java @@ -23,13 +23,13 @@ /** * Cluster activated event will be sent by Autoscaler */ -public class ClusterInActivateEvent extends Event { +public class ClusterInactivateEvent extends Event { private final String serviceName; private final String clusterId; private String appId; - public ClusterInActivateEvent(String appId, String serviceName, String clusterId) { + public ClusterInactivateEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatedEvent.java similarity index 62% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatedEvent.java index 176f7090a4..c4ab872cc2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatedEvent.java @@ -21,23 +21,36 @@ import org.apache.stratos.messaging.event.Event; /** - * Group Activated Event which will be sent to Topology upon group activation + * Cluster activated event will be sent by Autoscaler */ -public class GroupInactivatedEvent extends Event { +public class ClusterTerminatedEvent extends Event { + + private final String serviceName; + private final String clusterId; private String appId; - private String groupId; - public GroupInactivatedEvent(String appId, String groupId) { + public ClusterTerminatedEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; this.appId = appId; - this.groupId = groupId; } - public String getAppId() { - return appId; + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + + "]"; } - public String getGroupId() { - return groupId; + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatingEvent.java new file mode 100644 index 0000000000..5b04fcd60f --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterTerminatingEvent.java @@ -0,0 +1,56 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Cluster activated event will be sent by Autoscaler + */ +public class ClusterTerminatingEvent extends Event { + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterTerminatingEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + + "]"; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivateEvent.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivateEvent.java index dd7007b6e9..3bcbaa94f4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInActivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupInactivateEvent.java @@ -23,11 +23,11 @@ /** * Group Activated Event which will be sent to Topology upon group activation */ -public class GroupInActivateEvent extends Event { +public class GroupInactivateEvent extends Event { private String appId; private String groupId; - public GroupInActivateEvent(String appId, String groupId) { + public GroupInactivateEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java new file mode 100644 index 0000000000..a47c371d60 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class AppStatusClusterTerminatedEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java new file mode 100644 index 0000000000..11bdb97d38 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class AppStatusClusterTerminatingEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatedEventListener.java new file mode 100644 index 0000000000..33d050df76 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterTerminatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatingEventListener.java new file mode 100644 index 0000000000..5c0820305e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterTerminatingEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterTerminatingEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java new file mode 100644 index 0000000000..a5bed11652 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppStatusClusterTerminatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util. + jsonToObject(message, AppStatusClusterTerminatedEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java new file mode 100644 index 0000000000..e387a15fd1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java @@ -0,0 +1,58 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatingEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class AppStatusClusterTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppStatusClusterTerminatingMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AppStatusClusterTerminatingEvent.class.getName().equals(type)) { + // Parse complete message and build event + AppStatusClusterTerminatingEvent event = (AppStatusClusterTerminatingEvent) Util. + jsonToObject(message, AppStatusClusterTerminatingEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster activated message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java index e8575cce97..8d2cdf6adb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java @@ -33,6 +33,8 @@ public class ApplicationStatusMessageProcessorChain extends MessageProcessorChai private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; private ApplicationStatusClusterInActivateMessageProcessor clusterInActivateMessageProcessor; + private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; + private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; private ApplicationStatusGroupInActivatedMessageProcessor groupInActivateMessageProcessor; private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; @@ -52,6 +54,11 @@ public void initialize() { clusterInActivateMessageProcessor = new ApplicationStatusClusterInActivateMessageProcessor(); add(clusterInActivateMessageProcessor); + clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor(); + add(clusterTerminatingMessageProcessor); + clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor(); + add(clusterTerminatedMessageProcessor); + groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); @@ -91,7 +98,11 @@ public void addEventListener(EventListener eventListener) { clusterInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupInactivateEventListener) { + } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){ + clusterTerminatedMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){ + clusterTerminatingMessageProcessor.addEventListener(eventListener); + }else if (eventListener instanceof GroupInactivateEventListener) { groupInActivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java index cfaad73c66..a0862b274a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterInActivateProcessor.java @@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; +import org.apache.stratos.messaging.event.topology.ClusterInactivateEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -48,15 +48,15 @@ public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (ClusterInActivateEvent.class.getName().equals(type)) { + if (ClusterInactivateEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) { return false; } // Parse complete message and build event - ClusterInActivateEvent event = (ClusterInActivateEvent) Util. - jsonToObject(message, ClusterInActivateEvent.class); + ClusterInactivateEvent event = (ClusterInactivateEvent) Util. + jsonToObject(message, ClusterInactivateEvent.class); TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { @@ -76,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess(ClusterInActivateEvent event, Topology topology) { + private boolean doProcess(ClusterInactivateEvent event, Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java new file mode 100644 index 0000000000..0536011929 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java @@ -0,0 +1,133 @@ +/* + * 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.messaging.message.processor.topology; + +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.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the cluster activated event + */ +public class ClusterTerminatedProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterTerminatedProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + + if (ClusterActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + return false; + } + + // Parse complete message and build event + ClusterActivatedEvent event = (ClusterActivatedEvent) Util. + jsonToObject(message, ClusterActivatedEvent.class); + + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess(ClusterActivatedEvent event, Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + // Apply changes to the topology + if (!cluster.isStateTransitionValid(ClusterStatus.Active)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); + } + cluster.setStatus(ClusterStatus.Active); + + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java new file mode 100644 index 0000000000..1ed2671727 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java @@ -0,0 +1,133 @@ +/* + * 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.messaging.message.processor.topology; + +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.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the cluster activated event + */ +public class ClusterTerminatingProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterTerminatingProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + + if (ClusterActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + return false; + } + + // Parse complete message and build event + ClusterActivatedEvent event = (ClusterActivatedEvent) Util. + jsonToObject(message, ClusterActivatedEvent.class); + + TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForCluster(event.getServiceName(), event.getClusterId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess(ClusterActivatedEvent event, Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + Cluster cluster = service.getCluster(event.getClusterId()); + + if (cluster == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster not exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + // Apply changes to the topology + if (!cluster.isStateTransitionValid(ClusterStatus.Active)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); + } + cluster.setStatus(ClusterStatus.Active); + + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java index ed8488c06a..f8fe7055d6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -25,7 +25,7 @@ import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; -import org.apache.stratos.messaging.event.topology.GroupInActivateEvent; +import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -52,8 +52,8 @@ public boolean process(String type, String message, Object object) { return false; // Parse complete message and build event - GroupInActivateEvent event = (GroupInActivateEvent) Util. - jsonToObject(message, GroupInActivateEvent.class); + GroupInactivateEvent event = (GroupInactivateEvent) Util. + jsonToObject(message, GroupInactivateEvent.class); TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); @@ -74,7 +74,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess(GroupInActivateEvent event, Topology topology) { + private boolean doProcess(GroupInactivateEvent event, Topology topology) { // Validate event against the existing topology Application application = topology.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 1e1930c021..1b7ba13b01 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -57,6 +57,8 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor; private GroupTerminatingProcessor groupTerminatingProcessor; private GroupTerminatedProcessor groupTerminatedProcessor; + private ClusterTerminatingProcessor clusterTerminatingProcessor; + private ClusterTerminatedProcessor clusterTerminatedProcessor; public void initialize() { // Add topology event processors @@ -81,6 +83,12 @@ public void initialize() { clusterRemovedMessageProcessor = new ClusterRemovedMessageProcessor(); add(clusterRemovedMessageProcessor); + clusterTerminatedProcessor = new ClusterTerminatedProcessor(); + add(clusterTerminatedProcessor); + + clusterTerminatingProcessor = new ClusterTerminatingProcessor(); + add(clusterTerminatingProcessor); + instanceSpawnedMessageProcessor = new InstanceSpawnedMessageProcessor(); add(instanceSpawnedMessageProcessor); @@ -151,7 +159,11 @@ public void addEventListener(EventListener eventListener) { clusterInActivateProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterRemovedEventListener) { clusterRemovedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof InstanceSpawnedEventListener) { + } else if(eventListener instanceof ClusterTerminatedEventListener){ + clusterTerminatedProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ClusterTerminatingEventListener){ + clusterTerminatingProcessor.addEventListener(eventListener); + }else if (eventListener instanceof InstanceSpawnedEventListener) { instanceSpawnedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof MemberActivatedEventListener) { memberActivatedMessageProcessor.addEventListener(eventListener); diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java index 4252b46481..8883ab11e0 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/exception/MetadataException.java @@ -1,8 +1,6 @@ package org.apache.stratos.metadataservice.exception; -/** - * Created by udara on 9/22/14. - */ + public class MetadataException extends Exception { public MetadataException(String message, Throwable cause) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java index eb90f3b5a6..59da564052 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/ApplicationBean.java @@ -6,9 +6,6 @@ import java.util.ArrayList; import java.util.List; -/** - * Created by udara on 10/17/14. - */ @XmlRootElement(name="applications") public class ApplicationBean { private String id; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/MyType.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/MyType.java deleted file mode 100644 index 0526faa09c..0000000000 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/MyType.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.apache.stratos.rest.endpoint.services; - -/** - * Created by udara on 7/7/14. - */ -public class MyType { - private int name; - - public int getName() { - return name; - } - - public void setName(int name) { - this.name = name; - } -} From 6f7baa85ee484c851f67e80922a546764805d4f2 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Fri, 24 Oct 2014 14:43:58 -0700 Subject: [PATCH 256/436] more clean up of grouping poc artifacts ... --- .../stratos/autoscaler/PartitionContext.java | 40 ------------------- .../monitor/AbstractClusterMonitor.java | 19 --------- .../monitor/cluster/ClusterMonitor.java | 21 +--------- .../rule/AutoscalerRuleEvaluator.java | 14 +------ .../modules/distribution/src/assembly/bin.xml | 6 --- .../distribution/src/main/conf/mincheck.drl | 3 -- 6 files changed, 2 insertions(+), 101 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java index 93d4b6afee..613aa4fedc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java @@ -395,46 +395,6 @@ public Set getAllMemberForTermination () { return results; } - public boolean checkStartupDependencies (String serviceType, String clusterId) { - if (log.isDebugEnabled()) { - log.debug("checkStartupDependencies for cluster with " + " clusterId: " + clusterId); - } - - - ComplexApplicationContext sgc = new ComplexApplicationContext(); - - String aServiceName = clusterId; - boolean flag = sgc.checkStartupDependencies(serviceType, aServiceName); - if (log.isDebugEnabled()) { - log.debug("checkStartupDependencies for cluster with " + - " clusterId: " + clusterId + " serviceType: " + serviceType + - " flag is :" + flag); - } - - return flag; - - } - - public boolean checkKillDependencies (String serviceType, String clusterId) { - if (log.isDebugEnabled()) { - log.debug("PartitionContext:checkServiceBootDependencies for cluster with " + " clusterId: " + clusterId + - "and serviceType " + serviceType); - } - - ComplexApplicationContext sgc = new ComplexApplicationContext(); - - String aServiceName = clusterId; - boolean flag = sgc.checkKillDependencies(serviceType, aServiceName); - if (log.isDebugEnabled()) { - log.debug("checkKillDependencies for cluster with " + - " clusterId: " + clusterId + " serviceType: " + serviceType + - " flag is :" + flag); - } - return flag; - - } - - private class PendingMemberWatcher implements Runnable { private PartitionContext ctxt; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 3993683f12..e816a42b89 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -58,7 +58,6 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected StatefulKnowledgeSession minCheckKnowledgeSession; protected StatefulKnowledgeSession scaleCheckKnowledgeSession; - protected StatefulKnowledgeSession terminateDependencyKnowledgeSession; protected StatefulKnowledgeSession terminateAllKnowledgeSession; protected boolean isDestroyed; @@ -121,7 +120,6 @@ public void destroy() { minCheckKnowledgeSession.dispose(); scaleCheckKnowledgeSession.dispose(); terminateAllKnowledgeSession.dispose(); - terminateDependencyKnowledgeSession.dispose(); setDestroyed(true); if (log.isDebugEnabled()) { log.debug("Cluster Monitor Drools session has been disposed. " + this.toString()); @@ -218,23 +216,6 @@ public void setMinCheckFactHandle(FactHandle minCheckFactHandle) { this.minCheckFactHandle = minCheckFactHandle; } - public StatefulKnowledgeSession getTerminateDependencyKnowledgeSession() { - return terminateDependencyKnowledgeSession; - } - - public void setTerminateDependencyKnowledgeSession( - StatefulKnowledgeSession terminateDependencyKnowledgeSession) { - this.terminateDependencyKnowledgeSession = terminateDependencyKnowledgeSession; - } - - public FactHandle getTerminateDependencyFactHandle() { - return terminateDependencyFactHandle; - } - - public void setTerminateDependencyFactHandle( - FactHandle terminateDependencyFactHandle) { - this.terminateDependencyFactHandle = terminateDependencyFactHandle; - } public int getMonitorInterval() { return monitorInterval; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 38b554cbab..0848d64e01 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -57,7 +57,6 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); - this.terminateDependencyKnowledgeSession = autoscalerRuleEvaluator.getTerminateDependencyStatefulSession(); this.terminateAllKnowledgeSession = autoscalerRuleEvaluator.getTerminateAllStatefulSession(); this.deploymentPolicy = deploymentPolicy; @@ -175,25 +174,7 @@ public void monitor() { } - //terminate dependency per partition - // rule terminates all members of a service which is a prerequisites for other services - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - - terminateDependencyKnowledgeSession.setGlobal("clusterId", clusterId); - terminateDependencyKnowledgeSession.setGlobal("lbRef", lbReferenceType); - terminateDependencyKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); - terminateDependencyKnowledgeSession.setGlobal("serviceId", serviceId); - - if (log.isDebugEnabled()) { - log.debug(String.format("Running terminate dependency for partition %s ", partitionContext.getPartitionId())); - } - - terminateDependencyFactHandle = AutoscalerRuleEvaluator.evaluateTerminateDependency(terminateDependencyKnowledgeSession - , terminateDependencyFactHandle, partitionContext); - - } - - boolean rifReset = networkPartitionContext.isRifReset(); + boolean rifReset = networkPartitionContext.isRifReset(); boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java index 68511b757d..e7810c9cef 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/AutoscalerRuleEvaluator.java @@ -47,13 +47,11 @@ public class AutoscalerRuleEvaluator { private static final String DRL_FILE_NAME = "mincheck.drl"; private static final String SCALING_DRL_FILE_NAME = "scaling.drl"; private static final String TERMINATE_ALL_DRL_FILE_NAME = "terminateall.drl"; - private static final String TERMINATE_DEPENDENCY_DRL_FILE_NAME = "terminatedependency.drl"; private static KnowledgeBase minCheckKbase; private static KnowledgeBase scaleCheckKbase; @SuppressWarnings("unused") private static KnowledgeBase terminateAllKbase; - private static KnowledgeBase terminateDependencyKbase; public AutoscalerRuleEvaluator(){ @@ -75,11 +73,6 @@ public AutoscalerRuleEvaluator(){ log.debug("Terminate all rule is parsed successfully"); } - terminateDependencyKbase = readKnowledgeBase(TERMINATE_DEPENDENCY_DRL_FILE_NAME); - - if (log.isDebugEnabled()) { - log.debug("Terminate dependency rule is parsed successfully"); - } } @@ -177,12 +170,7 @@ public StatefulKnowledgeSession getTerminateAllStatefulSession() { ksession.setGlobal("log", RuleLog.getInstance()); return ksession; } - public StatefulKnowledgeSession getTerminateDependencyStatefulSession() { - StatefulKnowledgeSession ksession; - ksession = terminateDependencyKbase.newStatefulKnowledgeSession(); - ksession.setGlobal("log", RuleLog.getInstance()); - return ksession; - } + public static String getLbClusterId(PartitionContext partitionContext, String nwpartitionId) { Properties props = partitionContext.getProperties(); diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 38242cd83b..edeebabe38 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -652,12 +652,6 @@ ${pom.artifactId}-${pom.version}/repository/conf true 755 - - - src/main/conf/terminatedependency.drl - ${pom.artifactId}-${pom.version}/repository/conf - true - 755 diff --git a/products/stratos/modules/distribution/src/main/conf/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/mincheck.drl index ed331cf6de..105523d3b7 100755 --- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl +++ b/products/stratos/modules/distribution/src/main/conf/mincheck.drl @@ -63,9 +63,6 @@ dialect "mvel" eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount())) eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount())) eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) ) - eval(log.debug("Grouping ... checking startup dependencies for " + clusterId)) - eval($ctxt.checkStartupDependencies(serviceId, clusterId)) - eval(log.debug("startup dependencies successfully checked for" + clusterId)) then if (isPrimary){ log.debug("[min-check] true [primary] true [primary member count] " + primaryMemberCount); From 87d77a2dfa8d9ac9ca0f53f119fcabdedffb4159 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 24 Oct 2014 17:42:37 +0530 Subject: [PATCH 257/436] removing unwanted event ApplicationUndeployed from the flow --- .../AutoscalerTopologyEventReceiver.java | 85 +++++++++++++++--- .../controller/topology/TopologyBuilder.java | 88 +++++++++++++++---- .../topology/ApplicationTerminatingEvent.java | 13 ++- 3 files changed, 159 insertions(+), 27 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 63f90792c6..2f7cca4cd5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -38,6 +38,11 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; 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; @@ -323,17 +328,78 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { +// topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { +// @Override +// protected void onEvent(Event event) { +// +// log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); +// +// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; +// +// // acquire reead locks for application and relevant clusters +// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// +// try { +// ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). +// getAppMonitor(applicationUndeployedEvent.getApplicationId()); +// +// if (appMonitor != null) { +// // update the status as Terminating +// appMonitor.setStatus(ApplicationStatus.Terminating); +// +// List clusters = appMonitor. +// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); +// +// for (String clusterId : clusters) { +// //stopping the cluster monitor and remove it from the AS +// ClusterMonitor clusterMonitor = +// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); +// if (clusterMonitor != null) { +// clusterMonitor.setDestroyed(true); +// clusterMonitor.terminateAllMembers(); +// clusterMonitor.setStatus(ClusterStatus.Terminating); +// } else { +// log.warn("No Cluster Monitor found for cluster id " + clusterId); +// } +// } +// +// } else { +// log.warn("Application Monitor cannot be found for the undeployed [application] " +// + applicationUndeployedEvent.getApplicationId()); +// } +// +// } finally { +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// TopologyManager. +// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// } +// } +// }); + + + topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { @Override protected void onEvent(Event event) { - log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); + log.info("[ApplicationTerminatingEvent] Received: " + event.getClass()); - ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; + ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event; // acquire reead locks for application and relevant clusters - TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); - Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); + TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId()); + Set clusterDataHolders = appTerminatingEvent.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), @@ -343,14 +409,14 @@ protected void onEvent(Event event) { try { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). - getAppMonitor(applicationUndeployedEvent.getApplicationId()); + getAppMonitor(appTerminatingEvent.getAppId()); if (appMonitor != null) { // update the status as Terminating appMonitor.setStatus(ApplicationStatus.Terminating); List clusters = appMonitor. - findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); + findClustersOfApplication(appTerminatingEvent.getAppId()); for (String clusterId : clusters) { //stopping the cluster monitor and remove it from the AS @@ -367,7 +433,7 @@ protected void onEvent(Event event) { } else { log.warn("Application Monitor cannot be found for the undeployed [application] " - + applicationUndeployedEvent.getApplicationId()); + + appTerminatingEvent.getAppId()); } } finally { @@ -378,12 +444,11 @@ protected void onEvent(Event event) { } } TopologyManager. - releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + releaseReadLockForApplication(appTerminatingEvent.getAppId()); } } }); - topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 80315ea1b9..d245a6fe00 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -933,29 +933,85 @@ public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) } public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent applicationTerminatingEvent = - new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent( - event.getAppId()); + Set clusterData; + String applicationId = event.getAppId(); + + // update the Application and Cluster Statuses as 'Terminating' + TopologyManager.acquireWriteLock(); + try { - TopologyManager.acquireWriteLock(); + + Topology topology = TopologyManager.getTopology(); + + if (!topology.applicationExists(applicationId)) { + log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); + return; + } + + Application application = topology.getApplication(applicationId); + // check and update application status to 'Terminating' + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully application.setStatus(ApplicationStatus.Terminating); - log.info("Application terminating adding status started for Topology"); + log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); + + // update all the Clusters' statuses to 'Terminating' + clusterData = application.getClusterDataRecursively(); + for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = topology.getService(clusterDataHolder.getServiceType()); + if (service != null) { + Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); + if (aCluster != null) { + // validate state transition + if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid state transfer from " + aCluster.getStatus() + " to " + + ClusterStatus.Terminating); + } + // for now anyway update the status forcefully + aCluster.setStatus(ClusterStatus.Terminating); + + } else { + log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + + " in Topology"); + } + + } else { + log.warn("Unable to update cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); + } + } + + // update all Group's statuses to 'Terminating' + if (application.getGroups() != null) { + updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); + } - TopologyManager.updateTopology(topology); } finally { TopologyManager.releaseWriteLock(); } - //publishing data - TopologyEventPublisher.sendApplicationTerminatingEvent(applicationTerminatingEvent); + + TopologyEventPublisher.sendApplicationTerminatingEvent( + new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent( + applicationId, clusterData)); + } + + private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection groups) { + + for (Group group : groups) { + if (!group.isStateTransitionValid(groupStatus)) { + log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus); + } + // force update for now + group.setStatus(groupStatus); + + // go recursively and update + if (group.getGroups() != null) { + updateGroupStatusesRecursively(groupStatus, group.getGroups()); + } + } } public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java index e1fbc026a9..c718f080ca 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java @@ -18,17 +18,28 @@ */ package org.apache.stratos.messaging.event.topology; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; + +import java.util.Set; + /** * This event will be sent to Topology upon terminating of application */ public class ApplicationTerminatingEvent extends TopologyEvent { + private final String appId; + private Set clusterData; - public ApplicationTerminatingEvent(String appId) { + public ApplicationTerminatingEvent(String appId, Set clusterData) { this.appId = appId; + this.clusterData = clusterData; } public String getAppId() { return appId; } + + public Set getClusterData() { + return clusterData; + } } \ No newline at end of file From 4f59f4b8bdbb4d9aeab043ea6544f9654ab2c634 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 26 Oct 2014 21:47:35 +0530 Subject: [PATCH 258/436] initial app unsubscription changes --- .../grouping/topic/StatusEventPublisher.java | 23 ++- .../AutoscalerTopologyEventReceiver.java | 141 +++++++----------- .../stratos/autoscaler/monitor/Monitor.java | 7 +- .../monitor/ParentComponentMonitor.java | 20 +-- .../application/ApplicationMonitor.java | 40 ++--- .../status/checker/StatusChecker.java | 13 +- .../ApplicationStatusTopicReceiver.java | 4 +- .../impl/CloudControllerServiceImpl.java | 4 +- .../controller/topology/TopologyBuilder.java | 129 ++++++++-------- .../topology/TopologyEventPublisher.java | 20 +++ .../topology/ApplicationTerminatedEvent.java | 12 +- .../topology/ApplicationTerminatingEvent.java | 12 +- ...atusClusterTerminatedMessageProcessor.java | 2 +- ...pplicationTerminatingMessageProcessor.java | 10 +- .../topology/ClusterTerminatedProcessor.java | 16 +- .../topology/ClusterTerminatingProcessor.java | 16 +- .../topology/GroupTerminatedProcessor.java | 4 +- 17 files changed, 243 insertions(+), 230 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 0800b14436..c0c64ac30c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -10,6 +10,7 @@ import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent; import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; @@ -72,9 +73,10 @@ public static void sendClusterTerminatingEvent(String appId, String serviceName, " [cluster]: " + clusterId); } //TODO - /*ClusterActivatedEvent clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); + AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent = + new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId); - publishEvent(clusterActivatedEvent);*/ + publishEvent(appStatusClusterTerminatingEvent); } public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) { @@ -83,10 +85,11 @@ public static void sendClusterTerminatedEvent(String appId, String serviceName, log.info("Publishing Cluster in-activate event for [application]: " + appId + " [cluster]: " + clusterId); } - //TODO - /* Cluster clusterActivatedEvent = new ClusterActivatedEvent(appId, serviceName, clusterId); - publishEvent(clusterActivatedEvent);*/ + AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent = + new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId); + + publishEvent(appStatusClusterTerminatedEvent); } public static void sendGroupActivatedEvent(String appId, String groupId) { @@ -156,6 +159,16 @@ public static void sendApplicationInactivatedEvent(String appId){ publishEvent(applicationInActivatedEvent); } + public static void sendApplicationTerminatingEvent (String appId) { + if (log.isInfoEnabled()) { + log.info("Publishing Application terminated event for [application]: " + appId); + } + + ApplicationTerminatingEvent applicationTerminatingEvent = new ApplicationTerminatingEvent(appId); + + publishEvent(applicationTerminatingEvent); + } + public static void sendApplicationTerminatedEvent (String appId, Set clusterData) { if (log.isInfoEnabled()) { log.info("Publishing Application terminated event for [application]: " + appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 2f7cca4cd5..654d5b221b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -41,7 +41,6 @@ import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterInActivateEvent; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; @@ -204,9 +203,9 @@ protected void onEvent(Event event) { log.info("[ClusterInActivateEvent] Received: " + event.getClass()); - ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event; - String appId = clusterInactivateEvent.getAppId(); - String clusterId = clusterInactivateEvent.getClusterId(); + ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; + String appId = clusterTerminatingEvent.getAppId(); + String clusterId = clusterTerminatingEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); @@ -224,9 +223,9 @@ protected void onEvent(Event event) { log.info("[ClusterInActivateEvent] Received: " + event.getClass()); - ClusterTerminatedEvent clusterInactivateEvent = (ClusterTerminatedEvent) event; - String appId = clusterInactivateEvent.getAppId(); - String clusterId = clusterInactivateEvent.getClusterId(); + ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; + String appId = clusterTerminatedEvent.getAppId(); + String clusterId = clusterTerminatedEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); @@ -328,78 +327,17 @@ protected void onEvent(Event event) { } }); -// topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { -// @Override -// protected void onEvent(Event event) { -// -// log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); -// -// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; -// -// // acquire reead locks for application and relevant clusters -// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); -// Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } -// -// try { -// ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). -// getAppMonitor(applicationUndeployedEvent.getApplicationId()); -// -// if (appMonitor != null) { -// // update the status as Terminating -// appMonitor.setStatus(ApplicationStatus.Terminating); -// -// List clusters = appMonitor. -// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); -// -// for (String clusterId : clusters) { -// //stopping the cluster monitor and remove it from the AS -// ClusterMonitor clusterMonitor = -// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); -// if (clusterMonitor != null) { -// clusterMonitor.setDestroyed(true); -// clusterMonitor.terminateAllMembers(); -// clusterMonitor.setStatus(ClusterStatus.Terminating); -// } else { -// log.warn("No Cluster Monitor found for cluster id " + clusterId); -// } -// } -// -// } else { -// log.warn("Application Monitor cannot be found for the undeployed [application] " -// + applicationUndeployedEvent.getApplicationId()); -// } -// -// } finally { -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } -// TopologyManager. -// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); -// } -// } -// }); - - - topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { + topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ApplicationTerminatingEvent] Received: " + event.getClass()); + log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); - ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event; + ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; // acquire reead locks for application and relevant clusters - TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId()); - Set clusterDataHolders = appTerminatingEvent.getClusterData(); + TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), @@ -409,31 +347,31 @@ protected void onEvent(Event event) { try { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). - getAppMonitor(appTerminatingEvent.getAppId()); + getAppMonitor(applicationUndeployedEvent.getApplicationId()); if (appMonitor != null) { // update the status as Terminating appMonitor.setStatus(ApplicationStatus.Terminating); - List clusters = appMonitor. - findClustersOfApplication(appTerminatingEvent.getAppId()); +// List clusters = appMonitor. +// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); - for (String clusterId : clusters) { + for (ClusterDataHolder clusterData : clusterDataHolders) { //stopping the cluster monitor and remove it from the AS ClusterMonitor clusterMonitor = - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)); + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); if (clusterMonitor != null) { clusterMonitor.setDestroyed(true); clusterMonitor.terminateAllMembers(); clusterMonitor.setStatus(ClusterStatus.Terminating); } else { - log.warn("No Cluster Monitor found for cluster id " + clusterId); + log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); } } } else { log.warn("Application Monitor cannot be found for the undeployed [application] " - + appTerminatingEvent.getAppId()); + + applicationUndeployedEvent.getApplicationId()); } } finally { @@ -443,6 +381,38 @@ protected void onEvent(Event event) { clusterData.getClusterId()); } } + TopologyManager. + releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + } + } + }); + + + topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationTerminatingEvent] Received: " + event.getClass()); + + ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event; + + // acquire reead locks for application and relevant clusters + TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId()); + + try { + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(appTerminatingEvent.getAppId()); + + if (appMonitor != null) { + // update the status as Terminating + appMonitor.setStatus(ApplicationStatus.Terminating); + + } else { + log.warn("Application Monitor cannot be found for the undeployed [application] " + + appTerminatingEvent.getAppId()); + } + + } finally { TopologyManager. releaseReadLockForApplication(appTerminatingEvent.getAppId()); } @@ -472,12 +442,13 @@ protected void onEvent(Event event) { ApplicationMonitor monitor = AutoscalerContext.getInstance(). getAppMonitor(applicationRemovedEvent.getApplicationId()); if (monitor != null) { - List clusters = monitor. - findClustersOfApplication(applicationRemovedEvent.getApplicationId()); - for (String clusterId : clusters) { + //List clusters = monitor. + // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); + for (ClusterDataHolder clusterData : clusterDataHolders) { //stopping the cluster monitor and remove it from the AS - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId)).setDestroyed(true); - AutoscalerContext.getInstance().removeMonitor(clusterId); + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())). + setDestroyed(true); + AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); } //removing the application monitor AutoscalerContext.getInstance(). diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 1ac0893a8a..7199ee8243 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -73,7 +73,7 @@ public void setParent(ParentComponentMonitor parent) { this.appId = parent.getAppId(); } - public boolean hasMonitors() { + public boolean hasActiveMonitors() { boolean hasMonitor = false; if(this.aliasToActiveMonitorsMap != null ) { hasMonitor = true; @@ -81,6 +81,11 @@ public boolean hasMonitors() { return hasMonitor; } + public boolean hasMonitors () { + + return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null; + } + public boolean isHasDependent() { return hasDependent; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 26eff1d024..4eb4bcbeb1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -20,7 +20,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; @@ -96,16 +95,19 @@ protected void onChildTerminatingEvent(String idOfEvent) { Monitor monitor = this.aliasToInActiveMonitorsMap.get(idOfEvent); if (monitor != null) { - for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { - if (monitor.hasMonitors()) { - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); - } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId()); + // check if aliasToActiveMonitors are null (in case of a Cluster Monitor) + if (monitor.getAliasToActiveMonitorsMap() != null) { + for (Monitor monitor1 : monitor.getAliasToActiveMonitorsMap().values()) { + if (monitor.hasActiveMonitors()) { + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, monitor1.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor1).getServiceId(), monitor.getId()); + } } } } else { - log.warn("Active Monitor not found for the id " + idOfEvent); + log.warn("Inactive Monitor not found for the id " + idOfEvent); } } @@ -123,7 +125,7 @@ protected void onChildInActiveEvent(String idOfEvent) { monitor = this.aliasToActiveMonitorsMap. get(terminationContext.getId()); //start to kill it - if (monitor.hasMonitors()) { + if (monitor.hasActiveMonitors()) { //it is a group StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index deb0950922..45530c5fbf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -61,26 +61,26 @@ public ApplicationMonitor(Application application) throws DependencyBuilderExcep * @param appId the application which contains the clusters * @return all the clusters of the application */ - public List findClustersOfApplication(String appId) { - List clusters = new ArrayList(); - Set clusterData; - - TopologyManager.acquireReadLockForApplication(appId); - try { - clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively(); - - } finally { - TopologyManager.releaseReadLockForApplication(appId); - } - - if (clusterData != null) { - for (ClusterDataHolder clusterDataHolder : clusterData) { - clusters.add(clusterDataHolder.getClusterId()); - } - } - - return clusters; - } +// public List findClustersOfApplication(String appId) { +// List clusters = new ArrayList(); +// Set clusterData; +// +// TopologyManager.acquireReadLockForApplication(appId); +// try { +// clusterData = TopologyManager.getTopology().getApplication(appId).getClusterDataRecursively(); +// +// } finally { +// TopologyManager.releaseReadLockForApplication(appId); +// } +// +// if (clusterData != null) { +// for (ClusterDataHolder clusterDataHolder : clusterData) { +// clusters.add(clusterDataHolder.getClusterId()); +// } +// } +// +// return clusters; +// } /** * Find the cluster monitor by traversing recursively in the hierarchical monitors. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 7aef08e954..7019d0bc52 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -82,6 +82,9 @@ public void onMemberTermination(String clusterId) { //TODO StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(), monitor.getClusterId()); + } else { + StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), + monitor.getClusterId()); } // TODO if cluster was in terminating, then send terminated event. } @@ -264,9 +267,9 @@ private boolean updateChildStatus(String appId, String id, Map gr clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { //send the in activation event - if (parent instanceof Application) { - //send application activated event - log.info("sending app in-active : " + appId); + if (parent instanceof Application) { + //send application activated event + log.info("sending app in-active : " + appId); StatusEventPublisher.sendApplicationInactivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent @@ -294,12 +297,12 @@ private boolean updateChildStatus(String appId, String id, Map gr if (parent instanceof Application) { //send application activated event log.info("sending app terminating: " + appId); - StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + StatusEventPublisher.sendApplicationTerminatingEvent(appId); //StatusEventPublisher.sendApp(appId); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group terminating : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier()); } } else { log.warn("Clusters/groups not found in this [component] " + appId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 5aa446744f..1a62fef155 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -74,14 +74,14 @@ protected void onEvent(Event event) { statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatedEvent((ClusterActivatedEvent) event); + TopologyBuilder.handleClusterTerminatedEvent((AppStatusClusterTerminatedEvent) event); } }); statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){ @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatingEvent((ClusterActivatedEvent) event); + TopologyBuilder.handleClusterTerminatingEvent((AppStatusClusterTerminatingEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 2fbf89ab2b..0b322f8d31 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1415,9 +1415,7 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) @Override public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - TopologyBuilder.handleApplicationUndeployed(dataHolder, applicationId, tenantId, tenantDomain); - - //persist(); + TopologyBuilder.handleApplicationUndeployed(applicationId); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index d245a6fe00..4d929b1189 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -678,8 +678,7 @@ public static synchronized void handleApplicationDeployed(Application applicatio } } - public static synchronized void handleApplicationUndeployed(FasterLookUpDataHolder dataHolder, - String applicationId, int tenantId, String tenantDomain) { + public static synchronized void handleApplicationUndeployed(String applicationId) { Set clusterData; @@ -702,7 +701,6 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold } // for now anyway update the status forcefully application.setStatus(ApplicationStatus.Terminating); - log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); // update all the Clusters' statuses to 'Terminating' clusterData = application.getClusterDataRecursively(); @@ -730,6 +728,13 @@ public static synchronized void handleApplicationUndeployed(FasterLookUpDataHold } } + // update all Group's statuses to 'Terminating' + if (application.getGroups() != null) { + updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); + } + + TopologyManager.updateTopology(topology); + } finally { TopologyManager.releaseWriteLock(); } @@ -934,10 +939,9 @@ public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) { - Set clusterData; String applicationId = event.getAppId(); - // update the Application and Cluster Statuses as 'Terminating' + // update the Application Status as 'Terminating' TopologyManager.acquireWriteLock(); try { @@ -958,44 +962,12 @@ public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent application.setStatus(ApplicationStatus.Terminating); log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); - // update all the Clusters' statuses to 'Terminating' - clusterData = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Topology"); - } - - } else { - log.warn("Unable to update cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); - } - } - - // update all Group's statuses to 'Terminating' - if (application.getGroups() != null) { - updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); - } - } finally { TopologyManager.releaseWriteLock(); } TopologyEventPublisher.sendApplicationTerminatingEvent( - new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent( - applicationId, clusterData)); + new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(applicationId)); } private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection groups) { @@ -1015,30 +987,6 @@ private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Col } public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { -// Topology topology = TopologyManager.getTopology(); -// Application application = topology.getApplication(event.getAppId()); -// //update the status of the Group -// if (application == null) { -// log.warn(String.format("Application %s does not exist", -// event.getAppId())); -// return; -// } -// -// org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent applicationTerminatedEvent = -// new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent( -// event.getAppId()); -// try { -// TopologyManager.acquireWriteLock(); -// application.setStatus(ApplicationStatus.Terminated); -// log.info("Application terminated adding status started for Topology"); -// -// TopologyManager.updateTopology(topology); -// } finally { -// TopologyManager.releaseWriteLock(); -// } -// //publishing data -// TopologyEventPublisher.sendApplicationTerminatedEvent(applicationTerminatedEvent); - Topology topology = TopologyManager.getTopology(); @@ -1051,6 +999,13 @@ public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent e } else { Application application = topology.getApplication(event.getAppId()); + + if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { + log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated); + } + // forcefully set status for now + application.setStatus(ApplicationStatus.Terminated); + int tenantId = application.getTenantId(); String tenantDomain = application.getTenantDomain(); Set clusterData = application.getClusterDataRecursively(); @@ -1201,11 +1156,57 @@ public static void handleGroupTerminatingEvent(GroupInTerminatingEvent event) { TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); } - public static void handleClusterTerminatedEvent(ClusterActivatedEvent event) { + public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent event) { + + TopologyManager.acquireWriteLock(); + + try { + Topology topology = TopologyManager.getTopology(); + Cluster cluster = topology.getService(event.getServiceName()). + getCluster(event.getClusterId()); + + if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) { + log.error("Invalid state transfer from " + cluster.getStatus() + " to " + + ClusterStatus.Terminated); + } + // forcefully update status + cluster.setStatus(ClusterStatus.Terminated); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + + ClusterTerminatedEvent clusterTerminatedEvent = new ClusterTerminatedEvent(event.getAppId(), + event.getServiceName(), event.getClusterId()); + TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent); } - public static void handleClusterTerminatingEvent(ClusterActivatedEvent event) { + public static void handleClusterTerminatingEvent(AppStatusClusterTerminatingEvent event) { + + TopologyManager.acquireWriteLock(); + + try { + Topology topology = TopologyManager.getTopology(); + Cluster cluster = topology.getService(event.getServiceName()). + getCluster(event.getClusterId()); + + if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid state transfer from " + cluster.getStatus() + " to " + + ClusterStatus.Terminating); + } + // forcefully update status + cluster.setStatus(ClusterStatus.Terminating); + + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + + ClusterTerminatingEvent clusterTerminaingEvent = new ClusterTerminatingEvent(event.getAppId(), + event.getServiceName(), event.getClusterId()); + TopologyEventPublisher.sendClusterTerminatingEvent(clusterTerminaingEvent); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 3c6277d726..cd131114e6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -297,4 +297,24 @@ public static void sendGroupTerminatingEvent(GroupTerminatingEvent groupTerminat } publishEvent(groupTerminatingTopologyEvent); } + + public static void sendClusterTerminatingEvent (ClusterTerminatingEvent clusterTerminatingEvent) { + + if(log.isInfoEnabled()) { + log.info(String.format("Publishing Cluster terminating event: [appId] %s [cluster id] %s", + clusterTerminatingEvent.getAppId(), clusterTerminatingEvent.getClusterId())); + } + + publishEvent(clusterTerminatingEvent); + } + + public static void sendClusterTerminatedEvent (ClusterTerminatedEvent clusterTerminatedEvent) { + + if(log.isInfoEnabled()) { + log.info(String.format("Publishing Cluster terminated event: [appId] %s [cluster id] %s", + clusterTerminatedEvent.getAppId(), clusterTerminatedEvent.getClusterId())); + } + + publishEvent(clusterTerminatedEvent); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java index 441b9025d8..6607a02667 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -18,17 +18,27 @@ */ package org.apache.stratos.messaging.event.topology; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; + +import java.util.Set; + /** * This event will be sent to Topology upon termination of application */ public class ApplicationTerminatedEvent extends TopologyEvent { private final String appId; + private final Set clusterData; - public ApplicationTerminatedEvent(String appId) { + public ApplicationTerminatedEvent(String appId, Set clusterData) { this.appId = appId; + this.clusterData = clusterData; } public String getAppId() { return appId; } + + public Set getClusterData() { + return clusterData; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java index c718f080ca..48fde61d41 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatingEvent.java @@ -18,28 +18,18 @@ */ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; - -import java.util.Set; - /** * This event will be sent to Topology upon terminating of application */ public class ApplicationTerminatingEvent extends TopologyEvent { private final String appId; - private Set clusterData; - public ApplicationTerminatingEvent(String appId, Set clusterData) { + public ApplicationTerminatingEvent(String appId) { this.appId = appId; - this.clusterData = clusterData; } public String getAppId() { return appId; } - - public Set getClusterData() { - return clusterData; - } } \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java index a5bed11652..6cdde510da 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java @@ -39,7 +39,7 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util. + AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util. jsonToObject(message, AppStatusClusterTerminatedEvent.class); if(log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java index cb6e887168..6ad43d86c4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java @@ -23,7 +23,7 @@ import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -48,14 +48,14 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (ApplicationInactivatedEvent.class.getName().equals(type)) { + if (ApplicationTerminatingEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) return false; // Parse complete message and build event - ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. - jsonToObject(message, ApplicationInactivatedEvent.class); + ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util. + jsonToObject(message, ApplicationTerminatingEvent.class); TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); @@ -76,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) { // Validate event against the existing topology Application application = topology.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java index 0536011929..98599d31e2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatedProcessor.java @@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -48,15 +48,15 @@ public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (ClusterActivatedEvent.class.getName().equals(type)) { + if (ClusterTerminatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) { return false; } // Parse complete message and build event - ClusterActivatedEvent event = (ClusterActivatedEvent) Util. - jsonToObject(message, ClusterActivatedEvent.class); + ClusterTerminatedEvent event = (ClusterTerminatedEvent) Util. + jsonToObject(message, ClusterTerminatedEvent.class); TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { @@ -76,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess(ClusterActivatedEvent event, Topology topology) { + private boolean doProcess(ClusterTerminatedEvent event, Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -118,10 +118,10 @@ private boolean doProcess(ClusterActivatedEvent event, Topology topology) { } } else { // Apply changes to the topology - if (!cluster.isStateTransitionValid(ClusterStatus.Active)) { - log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); + if (!cluster.isStateTransitionValid(ClusterStatus.Terminated)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminated); } - cluster.setStatus(ClusterStatus.Active); + cluster.setStatus(ClusterStatus.Terminated); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java index 1ed2671727..cd3061821f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterTerminatingProcessor.java @@ -24,7 +24,7 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; @@ -48,15 +48,15 @@ public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (ClusterActivatedEvent.class.getName().equals(type)) { + if (ClusterTerminatingEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) { return false; } // Parse complete message and build event - ClusterActivatedEvent event = (ClusterActivatedEvent) Util. - jsonToObject(message, ClusterActivatedEvent.class); + ClusterTerminatingEvent event = (ClusterTerminatingEvent) Util. + jsonToObject(message, ClusterTerminatingEvent.class); TopologyUpdater.acquireWriteLockForCluster(event.getServiceName(), event.getClusterId()); try { @@ -76,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess(ClusterActivatedEvent event, Topology topology) { + private boolean doProcess(ClusterTerminatingEvent event, Topology topology) { // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { @@ -118,10 +118,10 @@ private boolean doProcess(ClusterActivatedEvent event, Topology topology) { } } else { // Apply changes to the topology - if (!cluster.isStateTransitionValid(ClusterStatus.Active)) { - log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Active); + if (!cluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Terminating); } - cluster.setStatus(ClusterStatus.Active); + cluster.setStatus(ClusterStatus.Terminating); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java index 5e96709beb..5a308ba0fc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java @@ -93,8 +93,8 @@ private boolean doProcess (GroupTerminatedEvent event,Topology topology) { } } else { // Apply changes to the topology - if (!group.isStateTransitionValid(GroupStatus.Terminating)) { - log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + if (!group.isStateTransitionValid(GroupStatus.Terminated)) { + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated); } group.setStatus(GroupStatus.Terminated); From 4e4ba5b38b5917468987e4d9329050e40a9cfb43 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Mon, 27 Oct 2014 11:00:25 +0530 Subject: [PATCH 259/436] rename application status events, listeners and processors with prefix appstatus --- .../grouping/topic/StatusEventPublisher.java | 39 +++++------ .../ApplicationStatusTopicReceiver.java | 40 +++++------ .../controller/topology/TopologyBuilder.java | 38 +++++----- ...> AppStatusApplicationActivatedEvent.java} | 4 +- ... => AppStatusApplicationCreatedEvent.java} | 4 +- ...AppStatusApplicationInactivatedEvent.java} | 4 +- ... AppStatusApplicationTerminatedEvent.java} | 4 +- ...AppStatusApplicationTerminatingEvent.java} | 4 +- ...va => AppStatusClusterActivatedEvent.java} | 4 +- ...a => AppStatusClusterInactivateEvent.java} | 6 +- ...AppStatusClusterMaintenanceModeEvent.java} | 4 +- ...AppStatusClusterReadyToShutdownEvent.java} | 4 +- ...java => AppStatusGroupActivatedEvent.java} | 4 +- ...ava => AppStatusGroupInactivateEvent.java} | 4 +- ...> AppStatusGroupMaintenanceModeEvent.java} | 4 +- ...> AppStatusGroupReadyToShutdownEvent.java} | 4 +- ...ava => AppStatusGroupTerminatedEvent.java} | 4 +- ...va => AppStatusGroupTerminatingEvent.java} | 4 +- ...tusApplicationActivatedEventListener.java} | 2 +- ...tatusApplicationCreatedEventListener.java} | 2 +- ...sApplicationInactivatedEventListener.java} | 2 +- ...usApplicationTerminatedEventListener.java} | 2 +- ...sApplicationTerminatingEventListener.java} | 2 +- ...pStatusClusterActivatedEventListener.java} | 2 +- ...StatusClusterInactivateEventListener.java} | 2 +- ...AppStatusGroupActivatedEventListener.java} | 2 +- ...ppStatusGroupInactivateEventListener.java} | 2 +- ...ppStatusGroupTerminatedEventListener.java} | 2 +- ...pStatusGroupTerminatingEventListener.java} | 2 +- ...ApplicationActivatedMessageProcessor.java} | 14 ++-- ...usApplicationCreatedMessageProcessor.java} | 4 +- ...plicationInactivatedMessageProcessor.java} | 12 ++-- ...pplicationTerminatedMessageProcessor.java} | 12 ++-- ...plicationTerminatingMessageProcessor.java} | 12 ++-- ...atusClusterActivatedMessageProcessor.java} | 10 +-- ...tusClusterInactivateMessageProcessor.java} | 13 ++-- ...StatusGroupActivatedMessageProcessor.java} | 13 ++-- ...atusGroupInactivatedMessageProcessor.java} | 12 ++-- ...tatusGroupTerminatedMessageProcessor.java} | 12 ++-- ...atusGroupTerminatingMessageProcessor.java} | 4 +- ...va => AppStatusMessageProcessorChain.java} | 70 +++++++++---------- ...pplicationStatusEventMessageDelegator.java | 4 +- 42 files changed, 193 insertions(+), 200 deletions(-) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ApplicationActivatedEvent.java => AppStatusApplicationActivatedEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ApplicationCreatedEvent.java => AppStatusApplicationCreatedEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ApplicationInactivatedEvent.java => AppStatusApplicationInactivatedEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ApplicationTerminatedEvent.java => AppStatusApplicationTerminatedEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ApplicationTerminatingEvent.java => AppStatusApplicationTerminatingEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ClusterInActivateEvent.java => AppStatusClusterActivatedEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ClusterActivatedEvent.java => AppStatusClusterInactivateEvent.java} (89%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ClusterMaintenanceModeEvent.java => AppStatusClusterMaintenanceModeEvent.java} (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{ClusterReadyToShutdownEvent.java => AppStatusClusterReadyToShutdownEvent.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupInTerminatingEvent.java => AppStatusGroupActivatedEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupInactivateEvent.java => AppStatusGroupInactivateEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupMaintenanceModeEvent.java => AppStatusGroupMaintenanceModeEvent.java} (89%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupReadyToShutdownEvent.java => AppStatusGroupReadyToShutdownEvent.java} (89%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupActivatedEvent.java => AppStatusGroupTerminatedEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/{GroupInTerminatedEvent.java => AppStatusGroupTerminatingEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ApplicationActivatedEventListener.java => AppStatusApplicationActivatedEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ApplicationCreatedEventListener.java => AppStatusApplicationCreatedEventListener.java} (92%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ApplicationInActivatedEventListener.java => AppStatusApplicationInactivatedEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ApplicationTerminatedEventListener.java => AppStatusApplicationTerminatedEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ApplicationTerminatingEventListener.java => AppStatusApplicationTerminatingEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ClusterActivatedEventListener.java => AppStatusClusterActivatedEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupTerminatedEventListener.java => AppStatusClusterInactivateEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupTerminatingEventListener.java => AppStatusGroupActivatedEventListener.java} (92%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupActivatedEventListener.java => AppStatusGroupInactivateEventListener.java} (92%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{ClusterInActivateEventListener.java => AppStatusGroupTerminatedEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/{GroupInactivateEventListener.java => AppStatusGroupTerminatingEventListener.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusAppActivatedMessageProcessor.java => AppStatusApplicationActivatedMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusAppCreatedMessageProcessor.java => AppStatusApplicationCreatedMessageProcessor.java} (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusAppInActivatedMessageProcessor.java => AppStatusApplicationInactivatedMessageProcessor.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusAppTerminatedMessageProcessor.java => AppStatusApplicationTerminatedMessageProcessor.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusAppTerminatingMessageProcessor.java => AppStatusApplicationTerminatingMessageProcessor.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusClusterActivatedMessageProcessor.java => AppStatusClusterActivatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusClusterInActivateMessageProcessor.java => AppStatusClusterInactivateMessageProcessor.java} (78%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusGroupActivatedMessageProcessor.java => AppStatusGroupActivatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusGroupInActivatedMessageProcessor.java => AppStatusGroupInactivatedMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusGroupTerminatedMessageProcessor.java => AppStatusGroupTerminatedMessageProcessor.java} (81%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusGroupTerminatingMessageProcessor.java => AppStatusGroupTerminatingMessageProcessor.java} (93%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/{ApplicationStatusMessageProcessorChain.java => AppStatusMessageProcessorChain.java} (61%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index c0c64ac30c..3a3af88d1b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -7,14 +7,13 @@ import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; -import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent; -import org.apache.stratos.messaging.event.application.status.ClusterMaintenanceModeEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.util.Constants; @@ -47,8 +46,8 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S " [cluster]: " + clusterId); } - ClusterActivatedEvent clusterActivatedEvent = - new ClusterActivatedEvent(appId, serviceName, clusterId); + AppStatusClusterActivatedEvent clusterActivatedEvent = + new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent); } @@ -60,8 +59,8 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, " [cluster]: " + clusterId); } - ClusterInActivateEvent clusterInActivateEvent = - new ClusterInActivateEvent(appId, serviceName, clusterId); + AppStatusClusterInactivateEvent clusterInActivateEvent = + new AppStatusClusterInactivateEvent(appId, serviceName, clusterId); publishEvent(clusterInActivateEvent); } @@ -99,7 +98,7 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupActivatedEvent groupActivatedEvent = new GroupActivatedEvent(appId, groupId); + AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId); publishEvent(groupActivatedEvent); } @@ -123,7 +122,7 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInTerminatingEvent groupInTerminatingEvent = new GroupInTerminatingEvent(appId, groupId); + AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId); publishEvent(groupInTerminatingEvent); } @@ -134,7 +133,7 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInTerminatedEvent groupInTerminatedEvent = new GroupInTerminatedEvent(appId, groupId); + AppStatusGroupTerminatedEvent groupInTerminatedEvent = new AppStatusGroupTerminatedEvent(appId, groupId); publishEvent(groupInTerminatedEvent); } @@ -144,7 +143,7 @@ public static void sendApplicationActivatedEvent(String appId) { log.info("Publishing Application activated event for [application]: " + appId); } - ApplicationActivatedEvent applicationActivatedEvent = new ApplicationActivatedEvent(appId); + AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId); publishEvent(applicationActivatedEvent); } @@ -154,7 +153,7 @@ public static void sendApplicationInactivatedEvent(String appId){ log.info("Publishing Application Inactivated event for [application]: " + appId); } - ApplicationInactivatedEvent applicationInActivatedEvent = new ApplicationInactivatedEvent(appId); + AppStatusApplicationInactivatedEvent applicationInActivatedEvent = new AppStatusApplicationInactivatedEvent(appId); publishEvent(applicationInActivatedEvent); } @@ -164,7 +163,7 @@ public static void sendApplicationTerminatingEvent (String appId) { log.info("Publishing Application terminated event for [application]: " + appId); } - ApplicationTerminatingEvent applicationTerminatingEvent = new ApplicationTerminatingEvent(appId); + AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId); publishEvent(applicationTerminatingEvent); } @@ -174,8 +173,8 @@ public static void sendApplicationTerminatedEvent (String appId, Set clusterData; - public ApplicationTerminatedEvent(String appId, Set clusterData) { + public AppStatusApplicationTerminatedEvent(String appId, Set clusterData) { this.appId = appId; this.clusterData = clusterData; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java similarity index 88% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java index 9d3f966ce3..e2a3a09ddf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java @@ -23,12 +23,12 @@ /** * This event will be fired upon the application terminating is detected. */ -public class ApplicationTerminatingEvent extends StatusEvent implements Serializable { +public class AppStatusApplicationTerminatingEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; - public ApplicationTerminatingEvent(String appId) { + public AppStatusApplicationTerminatingEvent(String appId) { this.appId = appId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java index e2a588785b..c5737c68f2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterInActivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java @@ -23,14 +23,14 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class ClusterInActivateEvent extends StatusEvent { +public class AppStatusClusterActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public ClusterInActivateEvent(String appId, String serviceName, String clusterId) { + public AppStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java similarity index 89% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java index c1434ddad8..6d8ed46301 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java @@ -19,20 +19,18 @@ package org.apache.stratos.messaging.event.application.status; -import java.io.Serializable; - /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class ClusterActivatedEvent extends StatusEvent { +public class AppStatusClusterInactivateEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public ClusterActivatedEvent(String appId, String serviceName, String clusterId) { + public AppStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java similarity index 87% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java index b9f6158624..527d86e559 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java @@ -23,12 +23,12 @@ /** * This will be fired upon the cluster instability detection by either cep/autoscaler. */ -public class ClusterMaintenanceModeEvent extends StatusEvent implements Serializable { +public class AppStatusClusterMaintenanceModeEvent extends StatusEvent implements Serializable { private final String serviceName; private final String clusterId; private String appId; - public ClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) { + public AppStatusClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java similarity index 88% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java index b76bb7efbc..7841d9c70c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/ClusterReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java @@ -21,12 +21,12 @@ /** * This event is fired by autoscaler before actually terminate a cluster. */ -public class ClusterReadyToShutdownEvent extends StatusEvent { +public class AppStatusClusterReadyToShutdownEvent extends StatusEvent { private final String serviceName; private final String clusterId; private String appId; - public ClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) { + public AppStatusClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java index 6eaf5c36aa..3da86675c3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java @@ -23,13 +23,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupInTerminatingEvent extends StatusEvent { +public class AppStatusGroupActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupInTerminatingEvent(String appId, String groupId) { + public AppStatusGroupActivatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java index e81648032f..ee26292f51 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInactivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java @@ -23,13 +23,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupInactivateEvent extends StatusEvent { +public class AppStatusGroupInactivateEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupInactivateEvent(String appId, String groupId) { + public AppStatusGroupInactivateEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java similarity index 89% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java index 5e6534d0e1..a1a787c74f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java @@ -21,11 +21,11 @@ /** * This event will be fired upon the instability of group detection by autoscaler. */ -public class GroupMaintenanceModeEvent extends StatusEvent { +public class AppStatusGroupMaintenanceModeEvent extends StatusEvent { private String groupId; private String appId; - public GroupMaintenanceModeEvent(String appId, String groupId) { + public AppStatusGroupMaintenanceModeEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java similarity index 89% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java index d1ed012c43..eaba17d3d4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java @@ -21,11 +21,11 @@ /** * This event is fired by autoscaler before actually terminate a group. */ -public class GroupReadyToShutdownEvent extends StatusEvent { +public class AppStatusGroupReadyToShutdownEvent extends StatusEvent { private String groupId; private String appId; - public GroupReadyToShutdownEvent(String appId, String groupId) { + public AppStatusGroupReadyToShutdownEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java index 2357881a71..db31b64004 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java @@ -23,13 +23,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupActivatedEvent extends StatusEvent { +public class AppStatusGroupTerminatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupActivatedEvent(String appId, String groupId) { + public AppStatusGroupTerminatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java index 16cc0c73c7..52db5fbe17 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/GroupInTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java @@ -23,13 +23,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupInTerminatedEvent extends StatusEvent { +public class AppStatusGroupTerminatingEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupInTerminatedEvent(String appId, String groupId) { + public AppStatusGroupTerminatingEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java index 22f2ac1a44..4dfc8b58ab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java @@ -23,5 +23,5 @@ /** * This listener will get triggered upon the application activated event. */ -public abstract class ApplicationActivatedEventListener extends EventListener { +public abstract class AppStatusApplicationActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java similarity index 92% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java index cbeffa8c68..79a7d21961 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java @@ -23,5 +23,5 @@ /** * This listener will get triggered upon the application created event. */ -public abstract class ApplicationCreatedEventListener extends EventListener { +public abstract class AppStatusApplicationCreatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java index eecf941774..c2a356dd11 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationInActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java @@ -23,5 +23,5 @@ /** * This listener will get triggered upon the application inactivated event. */ -public abstract class ApplicationInActivatedEventListener extends EventListener { +public abstract class AppStatusApplicationInactivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java index aacde3bb5a..ad1be524c7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java @@ -23,5 +23,5 @@ /** * This listener will get triggered upon the application terminated event. */ -public abstract class ApplicationTerminatedEventListener extends EventListener { +public abstract class AppStatusApplicationTerminatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java index b35984b2dc..a454f16fc5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ApplicationTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java @@ -23,5 +23,5 @@ /** * This listener will get triggered upon the application terminating event. */ -public abstract class ApplicationTerminatingEventListener extends EventListener { +public abstract class AppStatusApplicationTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java index 383b379035..75da7b85e3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java @@ -20,5 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -public abstract class ClusterActivatedEventListener extends EventListener{ +public abstract class AppStatusClusterActivatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java index 6572516de2..03da7f7363 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java @@ -20,5 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -public abstract class GroupTerminatedEventListener extends EventListener { +public abstract class AppStatusClusterInactivateEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java similarity index 92% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java index afb65b827d..75fe2c986a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java @@ -23,5 +23,5 @@ /** * Created by reka on 9/22/14. */ -public abstract class GroupTerminatingEventListener extends EventListener { +public abstract class AppStatusGroupActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java similarity index 92% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java index 83e5a7a3f7..5c88faec91 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java @@ -23,5 +23,5 @@ /** * Created by reka on 9/22/14. */ -public abstract class GroupActivatedEventListener extends EventListener { +public abstract class AppStatusGroupInactivateEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java index 2ae73351f2..785abbd3fe 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/ClusterInActivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java @@ -20,5 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -public abstract class ClusterInActivateEventListener extends EventListener{ +public abstract class AppStatusGroupTerminatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java index bcca3fdb48..fbd7fcc123 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/GroupInactivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java @@ -23,5 +23,5 @@ /** * Created by reka on 9/22/14. */ -public abstract class GroupInactivateEventListener extends EventListener { +public abstract class AppStatusGroupTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java index 1a46cdf6df..a5056246c2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java @@ -20,18 +20,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; /** * Created by reka on 9/25/14. */ -public class ApplicationStatusAppActivatedMessageProcessor extends MessageProcessor { +public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusAppActivatedMessageProcessor.class); + LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -43,10 +41,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ApplicationActivatedEvent.class.getName().equals(type)) { + if (AppStatusApplicationActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ApplicationActivatedEvent event = - (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class); + AppStatusApplicationActivatedEvent event = + (AppStatusApplicationActivatedEvent) Util.jsonToObject(message, AppStatusApplicationActivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java index 66448ac5e7..4e2f97fba2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java @@ -24,9 +24,9 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusAppCreatedMessageProcessor extends MessageProcessor { +public class AppStatusApplicationCreatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusAppCreatedMessageProcessor.class); + LogFactory.getLog(AppStatusApplicationCreatedMessageProcessor.class); private MessageProcessor nextProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java index 20e0e129c0..972fca39da 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppInActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java @@ -20,13 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusAppInActivatedMessageProcessor extends MessageProcessor { +public class AppStatusApplicationInactivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusAppInActivatedMessageProcessor.class); + LogFactory.getLog(AppStatusApplicationInactivatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ApplicationInactivatedEvent.class.getName().equals(type)) { + if (AppStatusApplicationInactivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ApplicationInactivatedEvent event = - (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class); + AppStatusApplicationInactivatedEvent event = + (AppStatusApplicationInactivatedEvent) Util.jsonToObject(message, AppStatusApplicationInactivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java index ad5565a513..b639ac019c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java @@ -20,13 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusAppTerminatedMessageProcessor extends MessageProcessor { +public class AppStatusApplicationTerminatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusAppTerminatedMessageProcessor.class); + LogFactory.getLog(AppStatusApplicationTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ApplicationTerminatedEvent.class.getName().equals(type)) { + if (AppStatusApplicationTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ApplicationTerminatedEvent event = - (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class); + AppStatusApplicationTerminatedEvent event = + (AppStatusApplicationTerminatedEvent) Util.jsonToObject(message, AppStatusApplicationTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java index 2ace24b680..143565a2b3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusAppTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java @@ -20,13 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusAppTerminatingMessageProcessor extends MessageProcessor { +public class AppStatusApplicationTerminatingMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusAppTerminatingMessageProcessor.class); + LogFactory.getLog(AppStatusApplicationTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ApplicationTerminatingEvent.class.getName().equals(type)) { + if (AppStatusApplicationTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - ApplicationTerminatingEvent event = - (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class); + AppStatusApplicationTerminatingEvent event = + (AppStatusApplicationTerminatingEvent) Util.jsonToObject(message, AppStatusApplicationTerminatingEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java index 249a6da6f1..3f3c6eb39f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java @@ -20,13 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusClusterActivatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ApplicationStatusClusterActivatedMessageProcessor.class); +public class AppStatusClusterActivatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppStatusClusterActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,9 +36,9 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ClusterActivatedEvent.class.getName().equals(type)) { + if (AppStatusClusterActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ClusterActivatedEvent event = (ClusterActivatedEvent) Util.jsonToObject(message, ClusterActivatedEvent.class); + AppStatusClusterActivatedEvent event = (AppStatusClusterActivatedEvent) Util.jsonToObject(message, AppStatusClusterActivatedEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterActivatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java similarity index 78% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java index 4e2fe7c750..6e289722c1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusClusterInActivateMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java @@ -20,14 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.ClusterInActivateEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusClusterInActivateMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ApplicationStatusClusterInActivateMessageProcessor.class); +public class AppStatusClusterInactivateMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppStatusClusterInactivateMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ClusterInActivateEvent.class.getName().equals(type)) { + if (AppStatusClusterInactivateEvent.class.getName().equals(type)) { // Parse complete message and build event - ClusterInActivateEvent event = (ClusterInActivateEvent) Util. - jsonToObject(message, ClusterInActivateEvent.class); + AppStatusClusterInactivateEvent event = (AppStatusClusterInactivateEvent) Util. + jsonToObject(message, AppStatusClusterInactivateEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterInActivateEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java index 01c3fa6e60..473726c252 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java @@ -21,14 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.GroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusGroupActivatedMessageProcessor extends MessageProcessor { +public class AppStatusGroupActivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusGroupActivatedMessageProcessor.class); + LogFactory.getLog(AppStatusGroupActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -38,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (GroupActivatedEvent.class.getName().equals(type)) { + if (AppStatusGroupActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupActivatedEvent event = - (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); + AppStatusGroupActivatedEvent event = + (AppStatusGroupActivatedEvent) Util.jsonToObject(message, AppStatusGroupActivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupActivatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java index 2f7f231682..714ee88ddb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupInActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java @@ -21,13 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.GroupInactivateEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusGroupInActivatedMessageProcessor extends MessageProcessor { +public class AppStatusGroupInactivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusGroupInActivatedMessageProcessor.class); + LogFactory.getLog(AppStatusGroupInactivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (GroupInactivateEvent.class.getName().equals(type)) { + if (AppStatusGroupInactivateEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupInactivateEvent event = - (GroupInactivateEvent) Util.jsonToObject(message, GroupInactivateEvent.class); + AppStatusGroupInactivateEvent event = + (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupInActivateEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java similarity index 81% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java index 93dd750ad3..daa7206ef4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java @@ -21,13 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.GroupInTerminatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusGroupTerminatedMessageProcessor extends MessageProcessor { +public class AppStatusGroupTerminatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusGroupTerminatedMessageProcessor.class); + LogFactory.getLog(AppStatusGroupTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (GroupInTerminatedEvent.class.getName().equals(type)) { + if (AppStatusGroupTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupInTerminatedEvent event = - (GroupInTerminatedEvent) Util.jsonToObject(message, GroupInTerminatedEvent.class); + AppStatusGroupTerminatedEvent event = + (AppStatusGroupTerminatedEvent) Util.jsonToObject(message, AppStatusGroupTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupTerminatingEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java similarity index 93% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java index 493bd6c0f5..7445695dd8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusGroupTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java @@ -25,9 +25,9 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ApplicationStatusGroupTerminatingMessageProcessor extends MessageProcessor { +public class AppStatusGroupTerminatingMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(ApplicationStatusGroupTerminatingMessageProcessor.class); + LogFactory.getLog(AppStatusGroupTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @Override diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java similarity index 61% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java index 8d2cdf6adb..14b8bc2309 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/ApplicationStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java @@ -28,30 +28,30 @@ * Application Status processor chain is to handle the list processors to parse the application * status. */ -public class ApplicationStatusMessageProcessorChain extends MessageProcessorChain { - private static final Log log = LogFactory.getLog(ApplicationStatusMessageProcessorChain.class); +public class AppStatusMessageProcessorChain extends MessageProcessorChain { + private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class); - private ApplicationStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; - private ApplicationStatusClusterInActivateMessageProcessor clusterInActivateMessageProcessor; + private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; + private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor; private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; - private ApplicationStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; - private ApplicationStatusGroupInActivatedMessageProcessor groupInActivateMessageProcessor; - private ApplicationStatusAppActivatedMessageProcessor appActivatedMessageProcessor; - private ApplicationStatusAppCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; - private ApplicationStatusAppInActivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; - private ApplicationStatusAppTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; - private ApplicationStatusAppTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; + private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; + private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor; + private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor; + private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; + private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; + private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; + private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; - private ApplicationStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor; - private ApplicationStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor; + private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor; + private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor; public void initialize() { // Add instance notifier event processors - clusterActivatedMessageProcessor = new ApplicationStatusClusterActivatedMessageProcessor(); + clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor(); add(clusterActivatedMessageProcessor); - clusterInActivateMessageProcessor = new ApplicationStatusClusterInActivateMessageProcessor(); + clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor(); add(clusterInActivateMessageProcessor); clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor(); @@ -59,31 +59,31 @@ public void initialize() { clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor(); add(clusterTerminatedMessageProcessor); - groupActivatedMessageProcessor = new ApplicationStatusGroupActivatedMessageProcessor(); + groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); - groupInActivateMessageProcessor = new ApplicationStatusGroupInActivatedMessageProcessor(); + groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor(); add(groupInActivateMessageProcessor); - appActivatedMessageProcessor = new ApplicationStatusAppActivatedMessageProcessor(); + appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor(); add(appActivatedMessageProcessor); - applicationStatusAppCreatedMessageProcessor = new ApplicationStatusAppCreatedMessageProcessor(); + applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor(); this.add(applicationStatusAppCreatedMessageProcessor); - applicationStatusAppInActivatedMessageProcessor = new ApplicationStatusAppInActivatedMessageProcessor(); + applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor(); this.add(applicationStatusAppInActivatedMessageProcessor); - applicationStatusAppTerminatedMessageProcessor = new ApplicationStatusAppTerminatedMessageProcessor(); + applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor(); this.add(applicationStatusAppTerminatedMessageProcessor); - applicationStatusAppTerminatingMessageProcessor = new ApplicationStatusAppTerminatingMessageProcessor(); + applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor(); this.add(applicationStatusAppTerminatingMessageProcessor); - groupTerminatedMessageProcessor = new ApplicationStatusGroupTerminatedMessageProcessor(); + groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor(); this.add(groupTerminatedMessageProcessor); - groupTerminatingMessageProcessor = new ApplicationStatusGroupTerminatingMessageProcessor(); + groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor(); this.add(groupTerminatingMessageProcessor); if (log.isDebugEnabled()) { @@ -92,31 +92,31 @@ public void initialize() { } public void addEventListener(EventListener eventListener) { - if (eventListener instanceof ClusterActivatedEventListener) { + if (eventListener instanceof AppStatusClusterActivatedEventListener) { clusterActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ClusterInActivateEventListener) { + } else if (eventListener instanceof AppStatusClusterInactivateEventListener) { clusterInActivateMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupActivatedEventListener) { + } else if (eventListener instanceof AppStatusGroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){ clusterTerminatedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){ clusterTerminatingMessageProcessor.addEventListener(eventListener); - }else if (eventListener instanceof GroupInactivateEventListener) { + }else if (eventListener instanceof AppStatusGroupInactivateEventListener) { groupInActivateMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationActivatedEventListener) { + } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationInActivatedEventListener){ + } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){ applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationCreatedEventListener){ + } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){ applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatingEventListener){ + } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){ applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatedEventListener){ + } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){ applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatingEventListener){ + } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){ groupTerminatingMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatedEventListener){ + } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){ groupTerminatedMessageProcessor.addEventListener(eventListener); } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java index 2b1ad5bdbc..9eda9e00e8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; -import org.apache.stratos.messaging.message.processor.application.status.ApplicationStatusMessageProcessorChain; +import org.apache.stratos.messaging.message.processor.application.status.AppStatusMessageProcessorChain; import org.apache.stratos.messaging.util.Constants; import javax.jms.TextMessage; @@ -36,7 +36,7 @@ public class ApplicationStatusEventMessageDelegator implements Runnable { public ApplicationStatusEventMessageDelegator(ApplicationStatusEventMessageQueue messageQueue) { this.messageQueue = messageQueue; - this.processorChain = new ApplicationStatusMessageProcessorChain(); + this.processorChain = new AppStatusMessageProcessorChain(); } public void addEventListener(EventListener eventListener) { From b56e3285239b2c070d7e78062ae8dd9e26131e50 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 27 Oct 2014 13:08:58 +0530 Subject: [PATCH 260/436] removing ApplicationRemovedEvent, ApplicationRemovedEventListener and ApplicationRemovedMessageProcessor --- .../AutoscalerTopologyEventReceiver.java | 97 +++++++++--- .../controller/topology/TopologyBuilder.java | 4 +- .../topology/TopologyEventPublisher.java | 18 +-- .../StratosManagerTopologyEventReceiver.java | 13 +- .../topology/ApplicationRemovedEvent.java | 62 -------- .../topology/ApplicationTerminatedEvent.java | 15 +- .../ApplicationRemovedEventListener.java | 26 ---- ...tatusGroupTerminatingMessageProcessor.java | 8 +- .../ApplicationRemovedMessageProcessor.java | 142 ------------------ ...ApplicationTerminatedMessageProcessor.java | 76 +++++++--- .../TopologyMessageProcessorChain.java | 6 - 11 files changed, 166 insertions(+), 301 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 654d5b221b..89fe51fad2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -419,28 +419,83 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { +// topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { +// @Override +// protected void onEvent(Event event) { +// +// log.info("[ApplicationRemovedEvent] Received: " + event.getClass()); +// +// ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event; +// +// //acquire read lock +// TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId()); +// Set clusterDataHolders = applicationRemovedEvent.getClusterData(); +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// +// try { +// //TODO remove monitors as well as any starting or pending threads +// ApplicationMonitor monitor = AutoscalerContext.getInstance(). +// getAppMonitor(applicationRemovedEvent.getApplicationId()); +// if (monitor != null) { +// //List clusters = monitor. +// // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// //stopping the cluster monitor and remove it from the AS +// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())). +// setDestroyed(true); +// AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); +// } +// //removing the application monitor +// AutoscalerContext.getInstance(). +// removeAppMonitor(applicationRemovedEvent.getApplicationId()); +// } else { +// log.warn("Application Monitor cannot be found for the removed [application] " +// + applicationRemovedEvent.getApplicationId()); +// } +// +// +// } finally { +// //release read lock +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId()); +// } +// +// } +// }); + + topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ApplicationRemovedEvent] Received: " + event.getClass()); + log.info("[ApplicationTerminatedEvent] Received: " + event.getClass()); - ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event; + ApplicationTerminatedEvent applicationRemovedEvent = (ApplicationTerminatedEvent) event; + // no need to access the locks since the Topology is not accessed //acquire read lock - TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId()); + //TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getAppId()); Set clusterDataHolders = applicationRemovedEvent.getClusterData(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), - clusterData.getClusterId()); - } - } +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } try { //TODO remove monitors as well as any starting or pending threads ApplicationMonitor monitor = AutoscalerContext.getInstance(). - getAppMonitor(applicationRemovedEvent.getApplicationId()); + getAppMonitor(applicationRemovedEvent.getAppId()); if (monitor != null) { //List clusters = monitor. // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); @@ -452,22 +507,22 @@ protected void onEvent(Event event) { } //removing the application monitor AutoscalerContext.getInstance(). - removeAppMonitor(applicationRemovedEvent.getApplicationId()); + removeAppMonitor(applicationRemovedEvent.getAppId()); } else { - log.warn("Application Monitor cannot be found for the removed [application] " - + applicationRemovedEvent.getApplicationId()); + log.warn("Application Monitor cannot be found for the terminated [application] " + + applicationRemovedEvent.getAppId()); } } finally { //release read lock - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), - clusterData.getClusterId()); - } - } - TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId()); +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getAppId()); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 3e0431130e..f4606b8986 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -1044,8 +1044,8 @@ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminat log.info("Removed application [ " + event.getAppId() + " ] from Topology"); - TopologyEventPublisher.sendApplicationRemovedEvent(event.getAppId(), - clusterData, tenantId, tenantDomain); + TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(), + clusterData, tenantId, tenantDomain)); } } finally { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index cd131114e6..a3feb4d588 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -103,15 +103,15 @@ public static void sendApplicationUndeployedEvent (String applicationId, Set clusterData, - int tenantId, String tenantDomain) { - - if(log.isInfoEnabled() || log.isDebugEnabled()) { - log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId); - } - - publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain)); - } +// public static void sendApplicationRemovedEvent(String applicationId, Set clusterData, +// int tenantId, String tenantDomain) { +// +// if(log.isInfoEnabled() || log.isDebugEnabled()) { +// log.info("Publishing Application removed event: " + applicationId + " tenantId: " + tenantId); +// } +// +// publishEvent(new ApplicationRemovedEvent(applicationId, clusterData, tenantId, tenantDomain)); +// } public static void sendClusterRemovedEvent(ClusterContext ctxt, String deploymentPolicy) { 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 index 699af72fe5..6e8552b989 100644 --- 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 @@ -355,21 +355,22 @@ protected void onEvent(Event event) { }); //add listener - topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { + topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { @Override protected void onEvent(Event event) { - ApplicationRemovedEvent appRemovedEvent = (ApplicationRemovedEvent) event; + ApplicationTerminatedEvent appRemovedEvent = (ApplicationTerminatedEvent) event; - log.info("[ApplicationRemovedEventListener] Received: " + event.getClass()); + log.info("[ApplicationTerminatedEvent] Received: " + event.getClass()); try { + // no need to lock since Topology is not accessed //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForApplication(appRemovedEvent.getApplicationId()); + //TopologyManager.acquireReadLockForApplication(appRemovedEvent.getAppId()); // create and persist Application subscritpion CartridgeSubscriptionManager cartridgeSubscriptionManager = new CartridgeSubscriptionManager(); - String appId = appRemovedEvent.getApplicationId(); + String appId = appRemovedEvent.getAppId(); int tenantId = appRemovedEvent.getTenantId(); String domain = appRemovedEvent.getTenantDomain(); @@ -393,7 +394,7 @@ protected void onEvent(Event event) { } } finally { //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForApplication(appRemovedEvent.getApplicationId()); + //TopologyManager.releaseReadLockForApplication(appRemovedEvent.getAppId()); } } }); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.java deleted file mode 100644 index 3d5b9a40fd..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationRemovedEvent.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.messaging.event.topology; - - -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; - -import java.util.Set; - -public class ApplicationRemovedEvent extends TopologyEvent { - - /** - * - */ - private static final long serialVersionUID = -5499420725533165623L; - private final String applicationId; - private Set clusterData; - - private String tenantDomain; - private int tenantId; - - public ApplicationRemovedEvent(String applicationId, Set clusterData, - int tenantId, String tenantDomain) { - this.applicationId = applicationId; - this.clusterData = clusterData; - this.tenantId = tenantId; - this.tenantDomain = tenantDomain; - } - - public String getApplicationId() { - return applicationId; - } - - public int getTenantId() { - return tenantId; - } - - public String getTenantDomain() { - return tenantDomain; - } - - public Set getClusterData() { - return clusterData; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java index 6607a02667..fa0cd269e8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -28,10 +28,15 @@ public class ApplicationTerminatedEvent extends TopologyEvent { private final String appId; private final Set clusterData; + private String tenantDomain; + private int tenantId; - public ApplicationTerminatedEvent(String appId, Set clusterData) { + public ApplicationTerminatedEvent(String appId, Set clusterData, + int tenantId, String tenantDomain) { this.appId = appId; this.clusterData = clusterData; + this.tenantId = tenantId; + this.tenantDomain = tenantDomain; } public String getAppId() { @@ -41,4 +46,12 @@ public String getAppId() { public Set getClusterData() { return clusterData; } + + public String getTenantDomain() { + return tenantDomain; + } + + public int getTenantId() { + return tenantId; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.java deleted file mode 100644 index c3a1178ff5..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationRemovedEventListener.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.messaging.listener.topology; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class ApplicationRemovedEventListener extends EventListener { - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java index 7445695dd8..75012e0881 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (GroupTerminatingEvent.class.getName().equals(type)) { + if (AppStatusGroupTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - GroupTerminatingEvent event = - (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class); + AppStatusGroupTerminatingEvent event = + (AppStatusGroupTerminatingEvent) Util.jsonToObject(message, AppStatusGroupTerminatingEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupTerminatingEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java deleted file mode 100644 index 5e02565f4a..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationRemovedMessageProcessor.java +++ /dev/null @@ -1,142 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationRemovedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -import java.util.Set; - -public class ApplicationRemovedMessageProcessor extends MessageProcessor { - - private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - - if (log.isDebugEnabled()) { - log.debug("ApplicationRemovedMessageProcessor processing " + object); - } - - Topology topology = (Topology) object; - - if (ApplicationRemovedEvent.class.getName().equals(type)) { - if (!topology.isInitialized()) { - if (log.isDebugEnabled()) { - log.debug("ApplicationRemovedMessageProcessor topology not initialized ... " + object); - } - return false; - } - - ApplicationRemovedEvent event = (ApplicationRemovedEvent) Util.jsonToObject(message, ApplicationRemovedEvent.class); - if (event == null) { - log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); - return false; - } - - TopologyUpdater.acquireWriteLockForApplications(); - Set clusterDataHolders = event.getClusterData(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); - } - } - - try { - return doProcess(event, topology); - - } finally { - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); - } - } - TopologyUpdater.releaseWriteLockForApplications(); - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess (ApplicationRemovedEvent event, Topology topology) { - - // check if required properties are available - if (event.getApplicationId() == null) { - String errorMsg = "Application Id of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - if (event.getTenantDomain()== null) { - String errorMsg = "Application tenant domain of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - // check if an Application with same name exists in topology - String appId = event.getApplicationId(); - if (topology.applicationExists(appId)) { - log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); - topology.removeApplication(appId); - } - - if (event.getClusterData() != null) { - // remove the Clusters from the Topology - for (ClusterDataHolder clusterData : event.getClusterData()) { - Service service = topology.getService(clusterData.getServiceType()); - if (service != null) { - service.removeCluster(clusterData.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); - } - } else { - log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); - } - } - } - - if (log.isDebugEnabled()) { - log.debug("ApplicationRemovedMessageProcessor notifying listener "); - } - - notifyEventListeners(event); - return true; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java index 2d22c6c985..49a8d22f43 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -20,14 +20,15 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; +import java.util.Set; + /** * This processor responsible to process the application Inactivation even and update the Topology. */ @@ -48,22 +49,33 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (ApplicationInactivatedEvent.class.getName().equals(type)) { + if (ApplicationTerminatedEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) return false; // Parse complete message and build event - ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. - jsonToObject(message, ApplicationInactivatedEvent.class); + ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util. + jsonToObject(message, ApplicationTerminatedEvent.class); TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + Set clusterDataHolders = event.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); + } + } try { return doProcess(event, topology); } finally { TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); + } + } } } else { @@ -76,27 +88,47 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } else { - // Apply changes to the topology - if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { - log.error("Invalid State transfer from [ " + application.getStatus() + - " ] to [ " + ApplicationStatus.Terminated + " ]"); + // check if required properties are available + if (event.getAppId() == null) { + String errorMsg = "Application Id of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (event.getTenantDomain()== null) { + String errorMsg = "Application tenant domain of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + String appId = event.getAppId(); + if (topology.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); + topology.removeApplication(appId); + } + + if (event.getClusterData() != null) { + // remove the Clusters from the Topology + for (ClusterDataHolder clusterData : event.getClusterData()) { + Service service = topology.getService(clusterData.getServiceType()); + if (service != null) { + service.removeCluster(clusterData.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); + } + } else { + log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); + } } - application.setStatus(ApplicationStatus.Terminated); + } + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor notifying listener "); } - // Notify event listeners notifyEventListeners(event); return true; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 1b7ba13b01..4f6d3a9766 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -50,7 +50,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private GroupInActivateProcessor groupInActivateProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor; - private ApplicationRemovedMessageProcessor applicationRemovedMessageProcessor; private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor; private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor; @@ -128,9 +127,6 @@ public void initialize() { applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor(); add(applicationUndeployedMessageProcessor); - applicationRemovedMessageProcessor = new ApplicationRemovedMessageProcessor(); - add(applicationRemovedMessageProcessor); - applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); add(applicationActivatedMessageProcessor); @@ -193,8 +189,6 @@ public void addEventListener(EventListener eventListener) { applicationCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationUndeployedEventListener) { applicationUndeployedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationRemovedEventListener) { - applicationRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationActivatedEventListener) { applicationActivatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ApplicationInActivateEventListener){ From bea691b0fca8ac36b9d329d0b2a9da8369652d0f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 27 Oct 2014 13:18:18 +0530 Subject: [PATCH 261/436] fixing a issue in acquiring locks in ApplicationTerminatedMessageProcessor --- .../topology/ApplicationTerminatedMessageProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java index 49a8d22f43..3b91e3fc41 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -58,7 +58,7 @@ public boolean process(String type, String message, Object object) { ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util. jsonToObject(message, ApplicationTerminatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + TopologyUpdater.acquireWriteLockForApplications(); Set clusterDataHolders = event.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { @@ -70,7 +70,7 @@ public boolean process(String type, String message, Object object) { return doProcess(event, topology); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + TopologyUpdater.releaseWriteLockForApplications(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); From 7a5797df08bbf92483cd5993e6ce9ca576686e3d Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 14:10:15 +0530 Subject: [PATCH 262/436] fixing cep listening on topology issue by merging with master --- .../extension/CEPTopologyEventReceiver.java | 125 ++++++++++ .../FaultHandlingWindowProcessor.java | 217 ++++++++++++------ 2 files changed, 267 insertions(+), 75 deletions(-) create mode 100644 extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java new file mode 100644 index 0000000000..90c67f03eb --- /dev/null +++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/CEPTopologyEventReceiver.java @@ -0,0 +1,125 @@ +/* + * 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.cep.extension; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; +import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +/** + * CEP Topology Receiver for Fault Handling Window Processor. + */ +public class CEPTopologyEventReceiver implements Runnable { + + private static final Log log = LogFactory.getLog(CEPTopologyEventReceiver.class); + + private TopologyEventReceiver topologyEventReceiver; + private boolean terminated; + private FaultHandlingWindowProcessor faultHandler; + + public CEPTopologyEventReceiver(FaultHandlingWindowProcessor faultHandler) { + this.topologyEventReceiver = new TopologyEventReceiver(); + this.faultHandler = faultHandler; + addEventListeners(); + } + + private void addEventListeners() { + // Load member time stamp map from the topology as a one time task + topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() { + private boolean initialized; + + @Override + protected void onEvent(Event event) { + if (!initialized) { + try { + TopologyManager.acquireReadLock(); + log.info("Complete topology event received to fault handling window processor."); + CompleteTopologyEvent completeTopologyEvent = (CompleteTopologyEvent) event; + initialized = faultHandler.loadTimeStampMapFromTopology(completeTopologyEvent.getTopology()); + } catch (Exception e) { + log.error("Error loading member time stamp map from complete topology event.", e); + } finally { + TopologyManager.releaseReadLock(); + } + } + } + }); + + // Remove member from the time stamp map when MemberTerminated event is received. + topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + faultHandler.getMemberTimeStampMap().remove(memberTerminatedEvent.getMemberId()); + log.info("Member [member id] " + memberTerminatedEvent.getMemberId() + + " was removed from the time stamp map."); + } + }); + + // Add member to time stamp map whenever member is activated + topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { + @Override + protected void onEvent(Event event) { + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + + // do not put this member if we have already received a health event + faultHandler.getMemberTimeStampMap().putIfAbsent(memberActivatedEvent.getMemberId(), System.currentTimeMillis()); + log.info("Member [member id] " + memberActivatedEvent.getMemberId() + + " was added to the time stamp map."); + } + }); + } + + @Override + public void run() { + try { + Thread.sleep(15000); + } catch (InterruptedException ignore) { + } + Thread thread = new Thread(topologyEventReceiver); + thread.start(); + log.info("CEP topology receiver thread started"); + + // Keep the thread live until terminated + while (!terminated) { + try { + Thread.sleep(1000); + } catch (InterruptedException ignore) { + } + } + log.info("CEP topology receiver thread terminated"); + } + + /** + * Terminate CEP topology receiver thread. + */ + public void terminate() { + topologyEventReceiver.terminate(); + terminated = true; + } +} \ No newline at end of file diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java index 80174f4e6d..0104a03a74 100644 --- a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java +++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/FaultHandlingWindowProcessor.java @@ -18,14 +18,19 @@ */ package org.apache.stratos.cep.extension; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; 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.domain.topology.MemberStatus; -import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.health.stat.MemberFaultEvent; +import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; +import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; @@ -52,23 +57,31 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +/** + * CEP window processor to handle faulty member instances. This window processor is responsible for + * publishing MemberFault event if health stats are not received within a given time window. + */ @SiddhiExtension(namespace = "stratos", function = "faultHandling") public class FaultHandlingWindowProcessor extends WindowProcessor implements RunnableWindowProcessor { private static final int TIME_OUT = 60 * 1000; static final Logger log = Logger.getLogger(FaultHandlingWindowProcessor.class); - private ScheduledExecutorService eventRemoverScheduler; - private int subjectedAttrIndex; + private ScheduledExecutorService faultHandleScheduler; private ThreadBarrier threadBarrier; private long timeToKeep; private ISchedulerSiddhiQueue window; + private EventPublisher healthStatPublisher = EventPublisherPool.getPublisher(Constants.HEALTH_STAT_TOPIC); + private Map MemberFaultEventMap = new HashMap(); + private Map memberFaultEventMessageMap = new HashMap(); + + // Map of member id's to their last received health event time stamp private ConcurrentHashMap memberTimeStampMap = new ConcurrentHashMap(); - private ConcurrentHashMap memberIdMap = new ConcurrentHashMap(); - EventPublisher healthStatPublisher = EventPublisherPool.getPublisher(Constants.HEALTH_STAT_TOPIC); - Map MemberFaultEventMap = new HashMap(); - Map memberFaultEventMessageMap = new HashMap(); - private TopologyEventReceiver topologyEventReceiver; - private String memberID; + + // Event receiver to receive topology events published by cloud-controller + private CEPTopologyEventReceiver cepTopologyEventReceiver = new CEPTopologyEventReceiver(this); + + // Stratos member id attribute index in stream execution plan + private int memberIdAttrIndex; @Override protected void processEvent(InEvent event) { @@ -77,20 +90,34 @@ protected void processEvent(InEvent event) { @Override protected void processEvent(InListEvent listEvent) { - System.out.println(listEvent); for (int i = 0, size = listEvent.getActiveEvents(); i < size; i++) { addDataToMap((InEvent) listEvent.getEvent(i)); } } + /** + * Add new entry to time stamp map from the received event. + * + * @param event Event received by Siddhi. + */ protected void addDataToMap(InEvent event) { - if (memberID != null) { - String id = (String)event.getData()[subjectedAttrIndex]; + String id = (String) event.getData()[memberIdAttrIndex]; + //checking whether this member is the topology. + //sometimes there can be a delay between publishing member terminated events + //and actually terminating instances. Hence CEP might get events for already terminated members + //so we are checking the topology for the member existence + Member member = getMemberFromId(id); + if (null == member) { + log.debug("Member not found in the toplogy. Event rejected"); + return; + } + if (StringUtils.isNotEmpty(id)) { memberTimeStampMap.put(id, event.getTimeStamp()); - log.debug("Event received from [member-id] " + id); + } else { + log.warn("NULL member id found in the event received. Event rejected."); } - else { - log.error("NULL member ID in the event received"); + if (log.isDebugEnabled()){ + log.debug("Event received from [member-id] " + id + " [time-stamp] " + event.getTimeStamp()); } } @@ -108,55 +135,88 @@ public Iterator iterator(String predicate) { } } - /* - * Retrieve the current activated member list from the topology and put them into the - * memberTimeStampMap if not already exists. This will allow the system to recover - * from any inconsistent state caused by MB/CEP failures. - */ - private void loadFromTopology(){ - if (TopologyManager.getTopology().isInitialized()){ - TopologyManager.acquireReadLock(); - memberIdMap.clear(); - long currentTimeStamp = System.currentTimeMillis(); - Iterator servicesItr = TopologyManager.getTopology().getServices().iterator(); - while(servicesItr.hasNext()){ - Service service = servicesItr.next(); - Iterator clusterItr = service.getClusters().iterator(); - while(clusterItr.hasNext()){ - Cluster cluster = clusterItr.next(); - Iterator memberItr = cluster.getMembers().iterator(); - while(memberItr.hasNext()){ - Member member = memberItr.next(); - if (member.getStatus().equals(MemberStatus.Activated)){ - memberTimeStampMap.putIfAbsent(member.getMemberId(), currentTimeStamp); - memberIdMap.put(member.getMemberId(), member); + /** + * Retrieve the current activated members from the topology and initialize the time stamp map. + * This will allow the system to recover from a restart + * + * @param topology Topology model object + */ + boolean loadTimeStampMapFromTopology(Topology topology){ + + long currentTimeStamp = System.currentTimeMillis(); + if (topology == null || topology.getServices() == null){ + return false; + } + // TODO make this efficient by adding APIs to messaging component + for (Service service : topology.getServices()) { + if (service.getClusters() != null) { + for (Cluster cluster : service.getClusters()) { + if (cluster.getMembers() != null) { + for (Member member : cluster.getMembers()) { + // we are checking faulty status only in previously activated members + if (member != null && MemberStatus.Activated.equals(member.getStatus())) { + // Initialize the member time stamp map from the topology at the beginning + memberTimeStampMap.putIfAbsent(member.getMemberId(), currentTimeStamp); + } } } } } - TopologyManager.releaseReadLock(); } + + log.info("Member time stamp map was successfully loaded from the topology."); if (log.isDebugEnabled()){ log.debug("Member TimeStamp Map: " + memberTimeStampMap); - log.debug("Member ID Map: " + memberIdMap); } + return true; } - private void publishMemberFault(String memberID){ - Member member = memberIdMap.get(memberID); + private Member getMemberFromId(String memberId){ + if (StringUtils.isEmpty(memberId)){ + return null; + } + if (TopologyManager.getTopology().isInitialized()){ + try { + TopologyManager.acquireReadLock(); + if (TopologyManager.getTopology().getServices() == null){ + return null; + } + // TODO make this efficient by adding APIs to messaging component + for (Service service : TopologyManager.getTopology().getServices()) { + if (service.getClusters() != null) { + for (Cluster cluster : service.getClusters()) { + if (cluster.getMembers() != null) { + for (Member member : cluster.getMembers()){ + if (memberId.equals(member.getMemberId())){ + return member; + } + } + } + } + } + } + } catch (Exception e) { + log.error("Error while reading topology" + e); + } finally { + TopologyManager.releaseReadLock(); + } + } + return null; + } + + private void publishMemberFault(String memberId){ + Member member = getMemberFromId(memberId); if (member == null){ - log.error("Failed to publish MemberFault event. Member having [member-id] " + memberID + " does not exist in topology"); + log.error("Failed to publish member fault event. Member having [member-id] " + memberId + + " does not exist in topology"); return; } - MemberFaultEvent memberFaultEvent = new MemberFaultEvent(member.getClusterId(), member.getMemberId(), member.getPartitionId(), 0); - memberFaultEventMessageMap.put("message", memberFaultEvent); - Properties headers = new Properties(); - headers.put(Constants.EVENT_CLASS_NAME, memberFaultEvent.getClass().getName()); - healthStatPublisher.publish(MemberFaultEventMap, headers, true); + log.info("Publishing member fault event for [member-id] " + memberId); - if (log.isDebugEnabled()){ - log.debug("Published MemberFault event for [member-id] " + memberID); - } + MemberFaultEvent memberFaultEvent = new MemberFaultEvent(member.getClusterId(), member.getMemberId(), + member.getPartitionId(), 0); + memberFaultEventMessageMap.put("message", memberFaultEvent); + healthStatPublisher.publish(MemberFaultEventMap, true); } @@ -164,26 +224,26 @@ private void publishMemberFault(String memberID){ public void run() { try { threadBarrier.pass(); - loadFromTopology(); - Iterator it = memberTimeStampMap.entrySet().iterator(); - while ( it.hasNext() ) { - Map.Entry pair = (Map.Entry)it.next(); + for (Object o : memberTimeStampMap.entrySet()) { + Map.Entry pair = (Map.Entry) o; long currentTime = System.currentTimeMillis(); Long eventTimeStamp = (Long) pair.getValue(); if ((currentTime - eventTimeStamp) > TIME_OUT) { - log.info("Faulty member detected [member-id] " + pair.getKey() + " with [last time-stamp] " + eventTimeStamp + " [time-out] " + TIME_OUT + " milliseconds"); - it.remove(); + log.info("Faulty member detected [member-id] " + pair.getKey() + " with [last time-stamp] " + + eventTimeStamp + " [time-out] " + TIME_OUT + " milliseconds"); publishMemberFault((String) pair.getKey()); } } if (log.isDebugEnabled()){ - log.debug("Fault handling processor iteration completed with [time-stamp map length] " + memberTimeStampMap.size() + " [activated member-count] " + memberIdMap.size()); + log.debug("Fault handling processor iteration completed with [time-stamp map length] " + + memberTimeStampMap.size() + " [time-stamp map] " + memberTimeStampMap); } - eventRemoverScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS); } catch (Throwable t) { log.error(t.getMessage(), t); + } finally { + faultHandleScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS); } } @@ -200,17 +260,16 @@ protected void restoreState(Object[] data) { } @Override - protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) { + protected void init(Expression[] parameters, QueryPostProcessingElement nextProcessor, + AbstractDefinition streamDefinition, String elementId, boolean async, SiddhiContext siddhiContext) { if (parameters[0] instanceof IntConstant) { timeToKeep = ((IntConstant) parameters[0]).getValue(); } else { timeToKeep = ((LongConstant) parameters[0]).getValue(); } - memberID = ((Variable)parameters[1]).getAttributeName(); - - String subjectedAttr = ((Variable)parameters[1]).getAttributeName(); - subjectedAttrIndex = streamDefinition.getAttributePosition(subjectedAttr); + String memberIdAttrName = ((Variable) parameters[1]).getAttributeName(); + memberIdAttrIndex = streamDefinition.getAttributePosition(memberIdAttrName); if (this.siddhiContext.isDistributedProcessingEnabled()) { window = new SchedulerSiddhiQueueGrid(elementId, this, this.siddhiContext, this.async); @@ -218,29 +277,32 @@ protected void init(Expression[] parameters, QueryPostProcessingElement nextProc window = new SchedulerSiddhiQueue(this); } MemberFaultEventMap.put("org.apache.stratos.messaging.event.health.stat.MemberFaultEvent", memberFaultEventMessageMap); - this.topologyEventReceiver = new TopologyEventReceiver(); - Thread thread = new Thread(topologyEventReceiver); - thread.start(); - log.info("WSO2 CEP topology receiver thread started"); + + Thread topologyTopicSubscriberThread = new Thread(cepTopologyEventReceiver); + topologyTopicSubscriberThread.start(); //Ordinary scheduling window.schedule(); - + if (log.isDebugEnabled()){ + log.debug("Fault handling window processor initialized with [timeToKeep] " + timeToKeep + + ", [memberIdAttrName] " + memberIdAttrName + ", [memberIdAttrIndex] " + memberIdAttrIndex + + ", [distributed-enabled] " + this.siddhiContext.isDistributedProcessingEnabled()); + } } @Override public void schedule() { - eventRemoverScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS); + faultHandleScheduler.schedule(this, timeToKeep, TimeUnit.MILLISECONDS); } @Override public void scheduleNow() { - eventRemoverScheduler.schedule(this, 0, TimeUnit.MILLISECONDS); + faultHandleScheduler.schedule(this, 0, TimeUnit.MILLISECONDS); } @Override public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { - this.eventRemoverScheduler = scheduledExecutorService; + this.faultHandleScheduler = scheduledExecutorService; } @Override @@ -250,7 +312,12 @@ public void setThreadBarrier(ThreadBarrier threadBarrier) { @Override public void destroy(){ - this.topologyEventReceiver.terminate(); + // terminate topology listener thread + cepTopologyEventReceiver.terminate(); window = null; } + + public ConcurrentHashMap getMemberTimeStampMap() { + return memberTimeStampMap; + } } From 07c510997acbcbd7ab377fcbff1bd808181c3bd1 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 14:11:38 +0530 Subject: [PATCH 263/436] fixing fault handling issue in autoscaler --- .../receiver/health/AutoscalerHealthStatEventReceiver.java | 2 +- .../stratos/autoscaler/status/checker/StatusChecker.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index b9097496d5..f090fcbac9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -663,7 +663,7 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { // remove from active member list partitionCtxt.removeActiveMemberById(memberId); //Check the clusterStatus as part of the member fault event - StatusChecker.getInstance().onMemberFaultEvent(clusterId, "appId", partitionCtxt); + StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 7019d0bc52..6309e027db 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -124,12 +124,12 @@ private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { /** * @param clusterId - * @param appId * @param partitionContext is to decide in which partition has less members while others have active members */ - public void onMemberFaultEvent(final String clusterId, final String appId, final PartitionContext partitionContext) { + public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); boolean clusterInActive = getClusterInActive(monitor, partitionContext); + String appId = monitor.getAppId(); if (clusterInActive) { //TODO evaluate life cycle //send cluster In-Active event to cluster status topic From 0300d17d905f5e1629b76e2805317a1a7016dee3 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 27 Oct 2014 14:19:28 +0530 Subject: [PATCH 264/436] converting non-critical info logs to debug in TopologyLockHierarchy class --- .../locking/TopologyLockHierarchy.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java index 015fa2e9de..bb6b8fa7b9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -82,7 +82,9 @@ public void addApplicationLock (String appId, final TopologyLock topologyLock) { } } } else { - log.warn("Topology Lock for Application " + appId + " already exists"); + if (log.isDebugEnabled()) { + log.debug("Topology Lock for Application " + appId + " already exists"); + } } } @@ -100,7 +102,9 @@ public void addServiceLock (String serviceName, final TopologyLock topologyLock) } } } else { - log.warn("Topology Lock for Service " + serviceName + " already exists"); + if (log.isDebugEnabled()) { + log.debug("Topology Lock for Service " + serviceName + " already exists"); + } } } @@ -118,7 +122,9 @@ public void addClusterLock (String clusterId, final TopologyLock topologyLock) { } } } else { - log.warn("Topology Lock for Cluster " + clusterId + " already exists"); + if (log.isDebugEnabled()) { + log.debug("Topology Lock for Cluster " + clusterId + " already exists"); + } } } @@ -130,7 +136,9 @@ public void removeTopologyLockForApplication (String appId) { if (applicationIdToTopologyLockMap.remove(appId) != null) { log.info("Removed lock for Application " + appId); } else { - log.info("Lock already removed for Application " + appId); + if (log.isDebugEnabled()) { + log.debug("Lock already removed for Application " + appId); + } } } @@ -138,7 +146,9 @@ public void removeTopologyLockForService (String serviceName) { if (serviceNameToTopologyLockMap.remove(serviceName) != null) { log.info("Removed lock for Service " + serviceName); } else { - log.info("Lock already removed for Service " + serviceName); + if (log.isDebugEnabled()) { + log.debug("Lock already removed for Service " + serviceName); + } } } @@ -146,7 +156,9 @@ public void removeTopologyLockForCluster (String clusterId) { if (clusterIdToTopologyLockMap.remove(clusterId) != null) { log.info("Removed lock for Cluster " + clusterId); } else { - log.info("Lock already removed for Cluster " + clusterId); + if (log.isDebugEnabled()) { + log.debug("Lock already removed for Cluster " + clusterId); + } } } From 1b224bd86e726db82ee92b155c53c4486fd7fec8 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 15:29:13 +0530 Subject: [PATCH 265/436] fixing fault handling and fixing when setting hasDependent to child monitors --- .../health/AutoscalerHealthStatEventReceiver.java | 2 +- .../autoscaler/monitor/AbstractClusterMonitor.java | 5 ++++- .../autoscaler/monitor/ApplicationMonitorFactory.java | 11 +++++++++-- .../apache/stratos/autoscaler/monitor/Monitor.java | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index f090fcbac9..6986fbb42a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -494,7 +494,7 @@ private AbstractClusterMonitor getMonitor(String clusterId) { } return null; } - return null; + return monitor; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index e816a42b89..838929c0b9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -234,8 +234,11 @@ public void setStatus(ClusterStatus status) { * If the cluster in_active and if it is a in_dependent cluster, * then won't send the notification to parent. */ - if(!(status == ClusterStatus.Inactive && !this.hasDependent)) { + if((status == ClusterStatus.Inactive && this.hasDependent)) { MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + } else { + log.info("[Cluster] " + clusterId + "is not notifying the parent, " + + "since it is identified as the independent unit"); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 92b3eb883a..b60e6456e7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -108,8 +108,11 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Appl groupMonitor.setAppId(appId); if(parentMonitor != null) { groupMonitor.setParent(parentMonitor); - if(!parentMonitor.isHasDependent() && !context.hasChild()) { + //Setting the dependent behaviour of the monitor + if(parentMonitor.hasMonitors() && (parentMonitor.isDependent() || context.hasChild())) { groupMonitor.setHasDependent(true); + } else { + groupMonitor.setHasDependent(false); } //TODO make sure when it is async @@ -146,6 +149,8 @@ public static ApplicationMonitor getApplicationMonitor(String appId) Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { applicationMonitor = new ApplicationMonitor(application); + applicationMonitor.setHasDependent(false); + } else { String msg = "[Application] " + appId + " cannot be found in the Topology"; throw new TopologyInConsistentException(msg); @@ -286,8 +291,10 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); clusterMonitor.setParent(parentMonitor); - if(!parentMonitor.isHasDependent() && !context.hasChild()) { + if(parentMonitor.hasActiveMonitors() && (parentMonitor.isDependent() || context.hasChild())) { clusterMonitor.setHasDependent(true); + } else { + clusterMonitor.setHasDependent(false); } AutoscalerContext.getInstance().addMonitor(clusterMonitor); if (log.isInfoEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 7199ee8243..b1e2eb376b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -75,7 +75,7 @@ public void setParent(ParentComponentMonitor parent) { public boolean hasActiveMonitors() { boolean hasMonitor = false; - if(this.aliasToActiveMonitorsMap != null ) { + if(this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) { hasMonitor = true; } return hasMonitor; @@ -86,7 +86,7 @@ public boolean hasMonitors () { return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null; } - public boolean isHasDependent() { + public boolean isDependent() { return hasDependent; } From 66aeb302c2e61373ce38aace419a568701fe3462 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 17:12:13 +0530 Subject: [PATCH 266/436] fixing on member terminatiin status checker --- .../monitor/AbstractClusterMonitor.java | 6 +-- .../status/checker/StatusChecker.java | 46 +++++++++++++------ 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 838929c0b9..588d2c4177 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -234,11 +234,11 @@ public void setStatus(ClusterStatus status) { * If the cluster in_active and if it is a in_dependent cluster, * then won't send the notification to parent. */ - if((status == ClusterStatus.Inactive && this.hasDependent)) { - MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); - } else { + if(status == ClusterStatus.Inactive && !this.hasDependent) { log.info("[Cluster] " + clusterId + "is not notifying the parent, " + "since it is identified as the independent unit"); + } else { + MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 6309e027db..7b3e0ac354 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -73,20 +73,40 @@ public void onMemberStatusChange(String clusterId) { public void onMemberTermination(String clusterId) { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - //TODO get Topology status - boolean clusterMonitorHasMembers; - clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); - if(clusterMonitorHasMembers) { - //monitor.pause(); - // if cluster not having any members and if the cluster was in_active then send created Events - //TODO - StatusEventPublisher.sendClusterCreatedEvent(monitor.getAppId(), monitor.getServiceId(), - monitor.getClusterId()); - } else { - StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), - monitor.getClusterId()); + boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); + boolean clusterActive = clusterActive(monitor); + + try { + TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); + Service service = TopologyManager.getTopology().getService(monitor.getServiceId()); + Cluster cluster; + if(service != null) { + cluster = service.getCluster(monitor.getClusterId()); + if(cluster != null) { + if(!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), + monitor.getClusterId()); + } else { + log.info("Cluster has non terminated [members] and in the [status] " + + cluster.getStatus().toString()); + + /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive || + cluster.getStatus() == ClusterStatus.Terminating)) { + cluster.getStatus() + StatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(), + monitor.getServiceId(), clusterId); + + }*/ + } + } + } + + + } finally { + TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); + } - // TODO if cluster was in terminating, then send terminated event. + } private boolean clusterActive(AbstractClusterMonitor monitor) { From aef9c12cbfc204a4a5c85f6c32b6707c21b1683f Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 18:29:22 +0530 Subject: [PATCH 267/436] setting hasDependent to monitors based on kill behaviours --- .../grouping/dependency/DependencyBuilder.java | 2 +- .../dependency/context/ApplicationContext.java | 12 ++++++++++-- .../context/ApplicationContextFactory.java | 14 ++++++++------ .../monitor/ApplicationMonitorFactory.java | 4 ++-- .../autoscaler/monitor/cluster/ClusterMonitor.java | 4 ++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 14fc90eeb0..edd1c02ec5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -91,7 +91,7 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen if (start != null) { ApplicationContext applicationContext = ApplicationContextFactory. - getApplicationContext(start, component, dependencyTree.isKillDependent()); + getApplicationContext(start, component, dependencyTree); String id = applicationContext.getId(); ApplicationContext existingApplicationContext = diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java index 45e165525f..3197fb99bb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java @@ -38,12 +38,12 @@ public abstract class ApplicationContext { private Stack statusLifeCycle; - protected boolean killDependent; + protected boolean isDependent; public ApplicationContext(String id, boolean killDependent) { applicationContextList = new ArrayList(); statusLifeCycle = new Stack(); - this.killDependent = killDependent; + this.setDependent(killDependent); this.id = id; } @@ -102,4 +102,12 @@ public boolean isTerminated() { public void setTerminated(boolean terminated) { this.terminated = terminated; } + + public boolean isDependent() { + return isDependent; + } + + public void setDependent(boolean isDependent) { + this.isDependent = isDependent; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java index 970d5931e1..631e5d4712 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; +import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.ParentComponent; @@ -36,24 +37,25 @@ public class ApplicationContextFactory { * * @param startOrder reference of group/cluster in the start order * @param component The component which used to build the dependency - * @param isKillDependent kill dependent behaviour of this component + * @param tree kill dependent behaviour of this component * @return Context */ public static ApplicationContext getApplicationContext(String startOrder, ParentComponent component, - boolean isKillDependent) { + DependencyTree tree) { String id; ApplicationContext applicationContext = null; + boolean isDependent = tree.isKillDependent() || tree.isKillAll(); if (startOrder.startsWith(Constants.GROUP + ".")) { //getting the group alias id = getGroupFromStartupOrder(startOrder); - applicationContext = getGroupContext(id, isKillDependent); + applicationContext = getGroupContext(id, isDependent); } else if (startOrder.startsWith(Constants.CARTRIDGE + ".")) { //getting the cluster alias id = getClusterFromStartupOrder(startOrder); //getting the cluster-id from cluster alias ClusterDataHolder clusterDataHolder = component.getClusterDataMap().get(id); - applicationContext = getClusterContext(clusterDataHolder, isKillDependent); + applicationContext = getClusterContext(clusterDataHolder, isDependent); } else { log.warn("[Startup Order]: " + startOrder + " contains unknown reference"); @@ -91,10 +93,10 @@ public static ApplicationContext getClusterContext(ClusterDataHolder dataHolder, return applicationContext; } - public static ApplicationContext getGroupContext(String id, boolean isKillDependent) { + public static ApplicationContext getGroupContext(String id, boolean isDependent) { ApplicationContext applicationContext; applicationContext = new GroupContext(id, - isKillDependent); + isDependent); return applicationContext; } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index b60e6456e7..2ead896344 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -109,7 +109,7 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Appl if(parentMonitor != null) { groupMonitor.setParent(parentMonitor); //Setting the dependent behaviour of the monitor - if(parentMonitor.hasMonitors() && (parentMonitor.isDependent() || context.hasChild())) { + if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) { groupMonitor.setHasDependent(true); } else { groupMonitor.setHasDependent(false); @@ -291,7 +291,7 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); clusterMonitor.setParent(parentMonitor); - if(parentMonitor.hasActiveMonitors() && (parentMonitor.isDependent() || context.hasChild())) { + if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) { clusterMonitor.setHasDependent(true); } else { clusterMonitor.setHasDependent(false); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 0848d64e01..557fedb613 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -174,7 +174,7 @@ public void monitor() { } - boolean rifReset = networkPartitionContext.isRifReset(); + /*boolean rifReset = networkPartitionContext.isRifReset(); boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); @@ -208,7 +208,7 @@ public void monitor() { } else if (log.isDebugEnabled()) { log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " + "cycle for network partition %s", networkPartitionContext.getId())); - } + }*/ } } From 2f1b92be4b4f74b90da78cc0655523c232225a96 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 27 Oct 2014 18:43:28 +0530 Subject: [PATCH 268/436] using correct events and processors --- .../grouping/topic/StatusEventPublisher.java | 20 +++---------------- .../topology/GroupInActivateProcessor.java | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 3a3af88d1b..ee75f74909 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -14,8 +14,6 @@ import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; -import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.util.Constants; import java.util.Set; @@ -26,19 +24,6 @@ public class StatusEventPublisher { private static final Log log = LogFactory.getLog(StatusEventPublisher.class); - public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Cluster activated event for [application]: " + appId + - " [cluster]: " + clusterId); - } - - - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId); - - publishEvent(clusterCreatedEvent); - } - public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { @@ -110,9 +95,10 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { " [group]: " + groupId); } - GroupInactivateEvent groupInactivateEvent = new GroupInactivateEvent(appId, groupId); + AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new + AppStatusGroupInactivateEvent(appId, groupId); - publishEvent(groupInactivateEvent); + publishEvent(appStatusGroupInactivateEvent); } public static void sendGroupTerminatingEvent(String appId, String groupId) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java index f8fe7055d6..094196b057 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -46,7 +46,7 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { Topology topology = (Topology) object; - if (GroupActivatedEvent.class.getName().equals(type)) { + if (GroupInactivateEvent.class.getName().equals(type)) { // Return if topology has not been initialized if (!topology.isInitialized()) return false; From 4f6b5fe63f01c2767800edfb00c0e48d765c161a Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 27 Oct 2014 18:48:35 +0530 Subject: [PATCH 269/436] stopping transitions to self in LifeCycleStateManager --- .../lifecycle/LifeCycleStateManager.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java index f57edf8d32..db8d5d4b46 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/lifecycle/LifeCycleStateManager.java @@ -70,15 +70,22 @@ public boolean isStateTransitionValid (T nextState) { } /** - * Changes the current state to nextState + * Changes the current state to nextState, if nextState is not as same as the current state * * @param nextState the next state to change */ - public void changeState (T nextState) { - - stateStack.push(nextState); - log.info("Topology element [ " + identifier + " ]'s life Cycle State changed from [ " + - getPreviousState() + " ] to [ " + getCurrentState() + " ]"); + public synchronized void changeState (T nextState) { + + if (getCurrentState() != nextState) { + stateStack.push(nextState); + log.info("Topology element [ " + identifier + " ]'s life Cycle State changed from [ " + + getPreviousState() + " ] to [ " + getCurrentState() + " ]"); + } else { + if (log.isDebugEnabled()) { + log.debug("Topology element [ " + identifier +" ]'s life Cycle State has been " + + "already updated to [ " + nextState + " ]"); + } + } if (log.isDebugEnabled()) { printStateTransitions(stateStack); } From d7d226cb5e0c81b0f0629e8f1c843611b3cb6784 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 28 Oct 2014 00:08:46 +0530 Subject: [PATCH 270/436] fixing wrongly used topology events and fixing issue while inactivation of group and cluster --- .../grouping/dependency/DependencyTree.java | 1 + .../stratos/autoscaler/monitor/Monitor.java | 11 ++++ .../monitor/ParentComponentMonitor.java | 57 +++++++++++++------ .../monitor/group/GroupMonitor.java | 9 ++- .../ApplicationStatusTopicReceiver.java | 8 +++ ...tusApplicationCreatedMessageProcessor.java | 8 +-- ...atusClusterTerminatedMessageProcessor.java | 5 +- 7 files changed, 73 insertions(+), 26 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 48ba7b7b2e..1ec686b102 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -195,6 +195,7 @@ public List getTerminationDependencies(String id) { if (this.killDependent) { //finding the ApplicationContext of the given id //finding all the children of the found application context + allChildrenOfAppContext.add(applicationContext); findAllChildrenOfAppContext(applicationContext.getApplicationContextList(), allChildrenOfAppContext); return allChildrenOfAppContext; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index b1e2eb376b..2088351281 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -93,4 +93,15 @@ public boolean isDependent() { public void setHasDependent(boolean hasDependent) { this.hasDependent = hasDependent; } + + public boolean hasInDependentChild() { + boolean hasInDepChild = false; + for(Monitor monitor : this.aliasToActiveMonitorsMap.values()) { + if(!monitor.isDependent()) { + hasInDepChild = true; + break; + } + } + return hasInDepChild; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 4eb4bcbeb1..9f3417d006 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; import java.util.HashMap; @@ -114,30 +115,52 @@ protected void onChildTerminatingEvent(String idOfEvent) { protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; - terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); //Temporarily move the group/cluster to inactive list this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); - if (terminationList != null) { - //Checking the termination dependents status - for (ApplicationContext terminationContext : terminationList) { - //Check whether dependent is in_active, then start to kill it - monitor = this.aliasToActiveMonitorsMap. - get(terminationContext.getId()); - //start to kill it - if (monitor.hasActiveMonitors()) { - //it is a group - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); - } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); + if(this.hasDependent) { + //need to notify the parent + StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); + } else { + terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); + if(this.hasInDependentChild()) { + if(this.parent != null) { + StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id); + } /*else { + StatusEventPublisher.sendApplicationInactivatedEvent(this.appId, terminationContext.getId()); + + }*/ + + } + + if (terminationList != null) { + //Checking the termination dependents status + for (ApplicationContext terminationContext : terminationList) { + //Check whether dependent is in_active, then start to kill it + monitor = this.aliasToActiveMonitorsMap. + get(terminationContext.getId()); + //start to kill it + if(monitor != null) { + if (monitor.hasActiveMonitors()) { + //it is a group + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); + + } + } else { + log.warn("The relevant [monitor] " + terminationContext.getId() + + "is not in the active map...."); + } } + } else { + log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" + + " where child is identified as a independent"); } - } else { - log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" - + " where child is identified as a independent"); } + } protected void onChildTerminatedEvent(String idOfEvent) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 161d9b4a4a..312378298e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -95,7 +95,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() && - !this.aliasToActiveMonitorsMap.isEmpty()) { + !this.aliasToActiveMonitorsMap.isEmpty()) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); @@ -143,6 +143,11 @@ public void setStatus(GroupStatus status) { "on its state change from %s to %s", id, this.status, status)); this.status = status; //notifying the parent - MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + if (status == GroupStatus.Inactive && !this.hasDependent) { + log.info("[Group] " + this.id + "is not notifying the parent, " + + "since it is identified as the independent unit"); + } else { + MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + } } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index ca93dce2b6..4d52fce09a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -116,6 +116,14 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new AppStatusGroupInactivateEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event); + + } + }); + statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener() { @Override diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java index 4e2f97fba2..29fce0ab66 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ApplicationCreatedEvent.class.getName().equals(type)) { + if (AppStatusApplicationCreatedEvent.class.getName().equals(type)) { // Parse complete message and build event - ApplicationCreatedEvent event = - (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + AppStatusApplicationCreatedEvent event = + (AppStatusApplicationCreatedEvent) Util.jsonToObject(message, AppStatusApplicationCreatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationCreated Event in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java index 6cdde510da..55cec80f59 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; @@ -40,9 +39,9 @@ public boolean process(String type, String message, Object object) { if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util. - jsonToObject(message, AppStatusClusterTerminatedEvent.class); + jsonToObject(message, AppStatusClusterTerminatedEvent.class); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString()); } // Notify event listeners From 5efc02521c90c08e0c9928f63242acb23c667910 Mon Sep 17 00:00:00 2001 From: Martin Eppel Date: Mon, 27 Oct 2014 19:44:28 -0700 Subject: [PATCH 271/436] more cleanup of grouping pco artifacts --- .../autoscaler/ComplexApplicationContext.java | 916 ------------------ .../impl/CloudControllerServiceImpl.java | 1 - .../controller/topology/TopologyBuilder.java | 109 +-- .../controller/topology/TopologyManager.java | 2 - .../application/utils/ApplicationUtils.java | 2 - .../messaging/domain/topology/Topology.java | 7 +- .../util/CompositeApplicationBuilder.java | 226 ----- ...positeApplicationCreatedEventListener.java | 26 - ...positeApplicationRemovedEventListener.java | 26 - ...iteApplicationCreatedMessageProcessor.java | 98 -- ...iteApplicationRemovedMessageProcessor.java | 100 -- 11 files changed, 10 insertions(+), 1503 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java deleted file mode 100644 index 84df0fbec5..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/ComplexApplicationContext.java +++ /dev/null @@ -1,916 +0,0 @@ -package org.apache.stratos.autoscaler; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; - -import java.util.*; - - -public class ComplexApplicationContext { - - static { - is_kill_all_enabled_flag = new HashMap(); - is_in_kill_all_transition = new HashSet(); - } - - private static Map is_kill_all_enabled_flag; - private static HashSet is_in_kill_all_transition; - - - - private static final Log log = LogFactory.getLog(ComplexApplicationContext.class); - - // return value of true will bring up new instance (all startup dependencies are up and active) - public static boolean checkStartupDependencies (String clusterId) { - String serviceType = "undefined"; - if (log.isDebugEnabled()) { - log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); - } - return checkServiceDependencies (serviceType, clusterId, false); - } - - - public boolean checkStartupDependencies (String serviceType, String clusterId) { - if (log.isDebugEnabled()) { - log.debug("checkStartupDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); - } - return checkServiceDependencies (serviceType, clusterId, false); - } - - - // return false will terminate instances - public boolean checkKillDependencies (String clusterId) { - String serviceType = "undefined"; - if (log.isDebugEnabled()) { - log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); - } - return checkKillTerminateDependencies (serviceType, clusterId, true); - } - - public boolean checkKillDependencies (String serviceType, String clusterId) { - if (log.isDebugEnabled()) { - log.debug("checkKillDependenciesY: serviceType " + serviceType + " + clusterId "+ clusterId); - } - return checkKillTerminateDependencies (serviceType, clusterId, true); - } - - - public static boolean checkServiceDependencies(String serviceType, String clusterId, boolean kill_flag) { - - - if (log.isDebugEnabled()) { - log.debug("ServiceGroupContext:checkServiceDependencies for service with XY " + - " serviceType " + serviceType + - " clusterId: " + clusterId + " kill_flag: " + kill_flag); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null); - - - // no app configured - if (complexApplication == null) { - return true; - } - - String aServiceId = serviceType; - if (log.isDebugEnabled()) { - log.debug("checking dependencies for service alias " + aServiceId); - } - - if (aServiceId == null) { - if (log.isDebugEnabled()) { - log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)"); - } - return true; - } - - List service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType); - - String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); - - if (clusterGroupFromClusterId == null) { - if (log.isDebugEnabled()) { - log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping dependency check (return true)"); - } - } - - for (GroupTemp service_type_groupTemp : service_type_groupTemps) { - // check if cluster is in the group - if (log.isDebugEnabled()) { - log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + - "extracted group from clusterId is " + clusterGroupFromClusterId); - } - if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) { - boolean result_flag = checkServiceDependenciesForServiceType (serviceType, clusterId, kill_flag, service_type_groupTemp); - if (log.isDebugEnabled()) { - log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and startup dependency check is " + result_flag); - } - return result_flag; - } - } - - if (log.isDebugEnabled()) { - log.debug("no matching group found for cluster " + clusterId + " skipping dependency check (return true)" ); - } - - return true; - - } - - public static boolean checkServiceDependenciesForServiceType(String serviceType, String clusterId, boolean kill_flag, GroupTemp home_groupTemp) { - - String aServiceId = serviceType; - - if (home_groupTemp == null) { - if (log.isDebugEnabled()) { - log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no dependency check)" ); - } - return true; - } - - - if (ComplexApplicationContext.isInKillAllTransition(getKillInTransitionKey(serviceType, home_groupTemp.getAlias()))) { - if (log.isDebugEnabled()) { - log.debug(" subscribable " + aServiceId + " is inKillAll transition, not spawning a new instance" ); - } - return false; - } else { - if (log.isDebugEnabled()) { - log.debug(" subscribable " + aServiceId + " is not inKillAll transition, continue with dependenciy check" ); - } - } - - Map downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId); - - - if (downstreamDependencies == null || downstreamDependencies.size() == 0) { - if (log.isDebugEnabled()) { - log.debug("serviceType " + aServiceId + " has no dependencies, returning true (no kill)"); - } - return true; - } - - if (log.isDebugEnabled()) { - StringBuffer buf = new StringBuffer(); - buf.append("downstreamdependencies list: [ "); - - - Set downstream_keys = downstreamDependencies.keySet(); - for (String c : downstream_keys) { - String d = downstreamDependencies.get(c); - buf.append(c + ", in group: ").append(downstreamDependencies.get(d)); - } - - buf.append("] ").append(" serviceId ").append(aServiceId); - log.debug(buf.toString()); - } - - - List in_active_downstreams = getServiceSet_StateInActive(downstreamDependencies); - if (in_active_downstreams.size() > 0) { - if (log.isDebugEnabled()) { - log.debug("found inactive downstream dependencies for serviceType " + aServiceId + " returning false"); - for (String in_active : in_active_downstreams) { - log.debug("inactive downstream dependency " + in_active + " for " + aServiceId); - } - } - - return false; - } - - if (log.isDebugEnabled()) { - log.debug("returning true for dependency check on serviceType " + serviceType); - } - return true; - } - - // return false will terminate instances - public boolean checkKillTerminateDependencies (String serviceType, String clusterId, boolean kill_flag) { - if (log.isDebugEnabled()) { - log.debug("ServiceGroupContext:checkKillTerminateDependencies for service with X " + - " serviceType " + serviceType + - " clusterId: " + clusterId + " kill_flag: " + kill_flag); - } - - if (log.isDebugEnabled()) { - log.debug("getting app from builder "); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - CompositeApplication complexApplication = builder.buildCompositeApplication(TopologyManager.getTopology(), null); - - String aServiceId = serviceType; - if (log.isDebugEnabled()) { - log.debug("checking dependencies for service alias " + - aServiceId); - } - - if (aServiceId == null) { - if (log.isDebugEnabled()) { - log.debug("invalid serviceType null for cluster " + clusterId + "skipping dependency check (returning true)"); - } - return true; - } - - - // no app configured, don't terminate - if (complexApplication == null) { - return true; - } - - List service_type_groupTemps = complexApplication.findAllGroupsForServiceType(serviceType); - - String clusterGroupFromClusterId = extractClusterGroupFromClusterId(clusterId); - - if (clusterGroupFromClusterId == null) { - if (log.isDebugEnabled()) { - log.debug("cluster id " + clusterId + " has incompatible name to extract group, skipping terminate dependency check (return true)"); - } - } - - for (GroupTemp service_type_groupTemp : service_type_groupTemps) { - // check if cluster is in the group - if (log.isDebugEnabled()) { - log.debug(" checking if cluster " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + - "extracted group from clusterId is " + clusterGroupFromClusterId); - } - if (service_type_groupTemp.getAlias().equals(clusterGroupFromClusterId)) { - boolean result_flag = checkKillTerminateDependenciesForServiceType (serviceType, clusterId, kill_flag, - service_type_groupTemp, complexApplication); - if (log.isDebugEnabled()) { - log.debug("cluster is " + clusterId + " is in the group " + service_type_groupTemp.getAlias() + " and kill dependency check is " + result_flag); - } - return result_flag; - } - } - - if (log.isDebugEnabled()) { - log.debug("no matching group found for cluster " + clusterId + " skipping terminate dependency check (return true)" ); - } - - return true; - } - - // return false will terminate instances - public boolean checkKillTerminateDependenciesForServiceType (String serviceType, String clusterId, boolean kill_flag, - GroupTemp home_groupTemp, CompositeApplication complexApplication ) { - - String aServiceId = serviceType; - - if (home_groupTemp == null) { - if (log.isDebugEnabled()) { - log.debug(" lone cluster without top level group " + aServiceId + "skip checking and return true (no kill)" ); - } - return true; - } else if (home_groupTemp.findGroup(aServiceId) == null) { - if (log.isDebugEnabled()) { - log.debug(" lone cluster without group " + aServiceId + "skip checking and return true (no kill)" ); - } - return true; - } - - - //Group home_group = complexApplication.getTop_level().findGroup(aServiceId); - - if (log.isDebugEnabled()) { - log.debug("checking downstream dependencies for " + aServiceId ); - } - Map downstreamDependencies = null; - downstreamDependencies = home_groupTemp.getDownStreamDependenciesAsMap(aServiceId); - if (log.isDebugEnabled()) { - StringBuffer buf = new StringBuffer(); - buf.append("downstreamdependencies list: [ "); - - if (downstreamDependencies != null && downstreamDependencies.keySet().size() > 0) { - Set downstream_keys = downstreamDependencies.keySet(); - for (String c : downstream_keys) { - String d = downstreamDependencies.get(c); - buf.append(c + ", in group: ").append(d).append(" "); - } - buf.append("] ").append(" serviceId ").append(aServiceId); - } else { - buf.append(" downstreamDependencies is null "); - } - log.debug(buf.toString()); - } - - - - if (log.isDebugEnabled()) { - log.debug("checking upstream dependencies for " + aServiceId ); - } - // 2. get upstream dependencies - Map upstreamDependencies = home_groupTemp.getUpstreamDependenciesAsMap(aServiceId); - - if (log.isDebugEnabled()) { - StringBuffer buf = new StringBuffer(); - buf.append("upstreamdependencies list: [ "); - - if (upstreamDependencies != null && upstreamDependencies.keySet().size() > 0) { - Set upstream_keys = upstreamDependencies.keySet(); - for (String c : upstream_keys) { - String d = upstreamDependencies.get(c); - buf.append(c + ", in group: ").append(upstreamDependencies.get(d)).append(" "); - } - - buf.append("] ").append(" serviceId ").append(aServiceId); - } else { - buf.append(" upstreamDependencies is null "); - } - log.debug(buf.toString()); - } -; - List in_active_upstreams = this.getServiceSet_StateInActive(upstreamDependencies); - - if (log.isDebugEnabled()) { - log.debug("getting list of InActive upstream dependencies for " + aServiceId + " with size of " + in_active_upstreams.size()); - } - - String kill_behavior = Dependencies.KILL_UNDEFINED; - // return false if instances should be terminated, true if not - for (String serviceTypeAlias : in_active_upstreams) { - String gr_alias = upstreamDependencies.get(serviceTypeAlias); - GroupTemp gr = complexApplication.getGroupFromGroupAlias(gr_alias); - if (gr != null) { - - kill_behavior = gr.getDependencies().getKill_behavior(); - if (kill_behavior.equals(Dependencies.KILL_ALL)) { - if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) { - if (log.isDebugEnabled()) { - log.debug(" isKillAllEnabled is enabled on upstream (kill) for group " + gr.getAlias() + ", disabling kilAll and preventing " + - " serviceType " + aServiceId + " in group " + gr.getAlias() + - " to spin up a new instance (setting killAllTransitionFlag) "); - } - // adding to the killalltransition flag - // building key from alias + group alias - ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias,gr.getAlias())); - // building key from alias + group alias - ComplexApplicationContext.setKillAllTransitionFlag(getKillInTransitionKey(aServiceId, home_groupTemp.getAlias())); - return false; - } else { - if (log.isDebugEnabled()) { - log.debug(" isKillAllEnabled is disabled on upstream (no kill) for group " + gr.getAlias() ); - } - return true; - } - } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { - if (log.isDebugEnabled()) { - log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - // continue to check - } else if (kill_behavior.equals(Dependencies.KILL_NONE)) { - if (log.isDebugEnabled()) { - log.debug(" continue to check upstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - // continue to check - } else { - if (log.isDebugEnabled()) { - log.debug(" continue to check upstream for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - //continue to check - } - } else { - // skip - if (log.isDebugEnabled()) { - log.debug(" no group found for " + serviceTypeAlias + " while loopig over in_active_upstreams" ); - } - } - - } - - // check kill_all_enabled flag - Map all = complexApplication.getAllInPathOfAsMap(aServiceId, home_groupTemp); - String [] group_with_kill_all_aliases = home_groupTemp.findAllGroupsWithKill2(all, Dependencies.KILL_ALL); - // "persistent flag for each group" - this.updateEnableKillAllFlag(all, group_with_kill_all_aliases); - - //List in_active_downstreams = this.getClusterSet_StateInActive(dependeciesAliasArray);jj - List in_active_downstreams = this.getServiceSet_StateInActive(downstreamDependencies); - - if (log.isDebugEnabled()) { - log.debug("getting list of InActive downstream dependencies for " + aServiceId + " with size of " + in_active_downstreams.size()); - } - - kill_behavior = Dependencies.KILL_UNDEFINED; - for (String alias : in_active_downstreams) { - GroupTemp gr = home_groupTemp.findGroup(alias); - if (gr !=null) { - kill_behavior = gr.getDependencies().getKill_behavior(); - if (kill_behavior.equals(Dependencies.KILL_ALL) ) { - if (log.isDebugEnabled()) { - log.debug(" return true on downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - if (ComplexApplicationContext.isKillAllEnabled(gr.getAlias())) { - if (log.isDebugEnabled()) { - log.debug(" isKillAllEnabled is enabled on downstream (kill) for group " + gr.getAlias() + - " setting killAllTransitionFlag for" + alias); - } - // adding to the killalltransition flag - ComplexApplicationContext.setKillAllTransitionFlag(alias); - return false; - } else { - if (log.isDebugEnabled()) { - log.debug(" isKillAllEnabled is disabled on downstream (no kill) for group " + gr.getAlias() ); - } - return true; - } - } else if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { - if (log.isDebugEnabled()) { - //log.debug(" continue downstream for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - log.debug(" downstream service(s) is inactive for aServiceId " + aServiceId + - " returning false (kill) and terminating cluster members" ); - } - return false; - } else if (kill_behavior.equals(Dependencies.KILL_NONE)) { - if (log.isDebugEnabled()) { - log.debug(" continue downstream to check for kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - // continue to check - } else { - if (log.isDebugEnabled()) { - log.debug(" continue downstream to check for invalide kill_flag " + kill_behavior + " for group " + gr.getAlias() ); - } - //continue to check - } - } else { - // skip - if (log.isDebugEnabled()) { - log.debug(" no group found for " + alias + " while loopig over in_active_downstreams" ); - } - } - - } - - // this cluster - GroupTemp gr = home_groupTemp.findGroup(aServiceId); - if (gr == null) { - if (log.isDebugEnabled()) { - log.debug(" cluster without group, should not reach this code ? for " + aServiceId ); - } - return true; - } - - kill_behavior = gr.getDependencies().getKill_behavior(); - - if (kill_behavior.equals(Dependencies.KILL_DEPENDENTS)) { - if (log.isDebugEnabled()) { - log.debug(Dependencies.KILL_DEPENDENTS + " check if any downstream cluster is inactive for aServiceId " + aServiceId ); - } - if (in_active_downstreams.size() > 0) { - if (log.isDebugEnabled()) { - log.debug(" downstream cluster(s) is inactive for aServiceId " + aServiceId + - " returning false (kill) and terminating cluster members" ); - } - return false; - } else { - if (log.isDebugEnabled()) { - log.debug(" no downstream cluster(s) is inactive for aServiceId " + aServiceId + - " returning true (no kill)" ); - } - return true; - } - } - - - if (log.isDebugEnabled()) { - log.debug("returning true (no kill) for down and upstream dependency check on clusterId " + aServiceId); - } - return true; - } - - - private static boolean hasClusterActiveMember (Cluster cluster) { - boolean flag = false; - if(cluster.isLbCluster()){ - if (log.isDebugEnabled()) { - log.debug("cluster member is lbCluster, not checking " + cluster); - } - }else{ - if (log.isDebugEnabled()) { - log.debug("checking member acitve for " + - " clusterId: " + cluster.getClusterId() + - " serviceId: " + cluster.getServiceName()); - } - - Collection members = cluster.getMembers(); - for (Member member:members) { - if (log.isDebugEnabled()) { - log.debug("listing members while checking if active" + - member.getMemberId() + - " private Ip: " + member.getMemberIp() + - " public Ip:" + member.getMemberPublicIp() + - " member state: " + member.getStatus()); - } - if (member.getStatus().equals(MemberStatus.Activated)) { - log.debug("member ACTIVE found :" + member.getMemberId()); - flag = true; - break; - } - } - - } - return flag; - } - - - - private static String extractAlias(String clusterId) { - String [] s = clusterId.split("\\."); - if (log.isDebugEnabled()) { - log.debug("clusterId alias is " + clusterId + " size: " + s.length); - } - if (s.length == 0) { - return null; - } - if (log.isDebugEnabled()) { - log.debug("clusterId alias is " + clusterId + " alias: " + s[0]); - } - return s[0]; - } - - private static String extractClusterGroupFromClusterId(String clusterId) { - String sub1 = extractAlias(clusterId); - if (sub1 == null) { - return null; - } - - String [] s = sub1.split("-"); - if (log.isDebugEnabled()) { - log.debug("clusterGroup alias is " + sub1 + " size: " + s.length); - } - if (s.length == 0) { - return null; - } - if (log.isDebugEnabled()) { - log.debug("cluster " + clusterId + " is in group " + s[0]); - } - return s[0]; - } - - - - private void updateEnableKillAllFlag(Mapall_dependencies, String [] group_with_kill_all_aliases) { - if (log.isDebugEnabled()) { - log.debug("updating enable_kill_flag "); - } - if (group_with_kill_all_aliases == null) { - return; - } - //if (isClusterSet_StateActive(all_dependencies)) { // - if (isServiceSet_StateActive(all_dependencies)) { - for (String alias : group_with_kill_all_aliases) { - ComplexApplicationContext.setKillAllEnabled(alias); - if (log.isDebugEnabled()) { - log.debug("enable enable_kill_flag for subscribable" + alias); - } - } - //} else if (isClusterSet_StateInActive(all_dependencies)) { - } else if (isServiceSet_StateInActive(all_dependencies)) { - for (String alias : group_with_kill_all_aliases) { - ComplexApplicationContext.resetKillAllEnabled(alias); - if (log.isDebugEnabled()) { - log.debug("disable enable_kill_flag for subscribable" + alias); - } - } - - // resetting killalltransition flag for all subscribables - Set key_set = all_dependencies.keySet(); - for (String serviceTypeAlias : key_set) { - String group_alias = all_dependencies.get(serviceTypeAlias); - ComplexApplicationContext.resetKillAllTransitionFlag(getKillInTransitionKey(serviceTypeAlias, group_alias)); - if (log.isDebugEnabled()) { - log.debug("resetting enable_kill_flag, is_in_kill_all_transition for subscribable " + serviceTypeAlias + " in group " + group_alias); - } - } - - } else { - // do nothing - if (log.isDebugEnabled()) { - log.debug("leaving enable_kill_flag, is_in_kill_all_transition unchanged "); - } - } - - } - - private static String getKillInTransitionKey(String serviceTypeAlias, String gr_alias) { - return serviceTypeAlias + gr_alias; - } - - - private boolean isServiceSet_StateActive(MapserviceTypes) { - List result = getServiceSet_StateActive(serviceTypes); - if (result.size() == serviceTypes.size()) { - return true; - } - - return false; - } - - private boolean isServiceSet_StateInActive(Map serviceTypes) { - List result = getServiceSet_StateInActive(serviceTypes); - if (result.size() == serviceTypes.size()) { - return true; - } - - return false; - } - - - private static List getServiceSet_StateInActive(Map serviceTypesMap) { - List result = new ArrayList (); - - if (log.isDebugEnabled()) { - log.debug("checking ServiceSet_StateInActive " + serviceTypesMap.size()); - } - - if (serviceTypesMap == null) { - if (log.isDebugEnabled()) { - log.debug("skipping getting set of InActive services, serviceTypes is null "); - } - return result; - } - - if (log.isDebugEnabled()) { - log.debug("getting set of InActive clusters for serviceTypes (length)" + serviceTypesMap.size()); - } - - - Collection services = TopologyManager.getTopology().getServices(); - - Set serviceTypes = serviceTypesMap.keySet(); - - for (String serviceType : serviceTypes) { - boolean hasServiceFound = false; - for(Service service : services) { - String serviceTypeGroup = serviceTypesMap.get(serviceType); - if (log.isDebugEnabled()) { - log.debug("checking inactive state for service " + service.getServiceName() + - " with nr_of_clusters: " + service.getClusters().size() + - " against serviceType " + serviceType + " in group " + serviceTypeGroup); - } - if (serviceType.equals(service.getServiceName())) { - // matching service type - check if has active cluster - if (log.isDebugEnabled()) { - log.debug("matching service types, checking clusters for service " + serviceType); - } - hasServiceFound = true; - Collection clusters = service.getClusters(); - boolean hasClusterWithActiveMember = false; - if (clusters.size() > 0) { - // at least one cluster has to exist for service to exist - if (log.isDebugEnabled()) { - log.debug("service " + service.getServiceName() + " has at least 1 cluster "); - } - for (Cluster cluster : clusters) { - String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("checking (inactive) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + - " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); - } - // TODO if (hasClusterActiveMember (cluster)) { - // check group cluster is in - - if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup)) { - if (hasClusterActiveMember (cluster)) { - hasClusterWithActiveMember = true; - if (log.isDebugEnabled()) { - log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup); - } - break; - } - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("service " + service.getServiceName() + " in group " + serviceTypeGroup + " has no cluster, adding as inactive service "); - hasClusterWithActiveMember = false; - } - } - - if (!hasClusterWithActiveMember) { - result.add(serviceType); - if (log.isDebugEnabled()) { - log.debug("service has not a clutser with active member, adding " + serviceType + " as inactive"); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search "); - } - } - - } - // covers the case that service hasn't be deployed yet - if (!hasServiceFound) { - result.add(serviceType); - if (log.isDebugEnabled()) { - log.debug("no matching service found for " + serviceType + " adding as inactive"); - } - } - } - - return result; - } - - - private List getServiceSet_StateActive (Map serviceTypesMap) { - List result = new ArrayList (); - - if (log.isDebugEnabled()) { - log.debug("checking ServiceSet_StateActive " + serviceTypesMap.size()); - } - - if (serviceTypesMap == null) { - if (log.isDebugEnabled()) { - log.debug("skipping getting set of Active services, serviceTypes is null "); - } - return result; - } - - if (log.isDebugEnabled()) { - log.debug("getting set of Active clusters for serviceTypes (length)" + serviceTypesMap.size()); - } - - - Collection services = TopologyManager.getTopology().getServices(); - - Set serviceTypes = serviceTypesMap.keySet(); - - for (String serviceType : serviceTypes) { - boolean hasServiceFound = false; - for(Service service : services) { - String serviceTypeGroup = serviceTypesMap.get(serviceType); - if (log.isDebugEnabled()) { - log.debug("checking active state for service " + service.getServiceName() + - " with nr_of_clusters: " + service.getClusters().size() + - " against serviceType " + serviceType + " in group " + serviceTypeGroup); - } - if (serviceType.equals(service.getServiceName())) { - // matching service type - check if has active cluster - if (log.isDebugEnabled()) { - log.debug("matching service types, checking clusters for service " + serviceType); - } - hasServiceFound = true; - Collection clusters = service.getClusters(); - boolean hasClusterWithActiveMember = false; - if (clusters.size() > 0) { - // at least one cluster has to exist for service to exist - if (log.isDebugEnabled()) { - log.debug("service " + service.getServiceName() + " has at least 1 cluster "); - } - for (Cluster cluster : clusters) { - String clusterGroup = extractClusterGroupFromClusterId(cluster.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("checking (active) cluster state for " + cluster.getClusterId() + " (in group " + clusterGroup + ")" + - " and serviceType " + serviceType + " (in group " + serviceTypeGroup + ")"); - } - - if (clusterGroup != null && clusterGroup.equals(serviceTypeGroup) && hasClusterActiveMember (cluster)) { - hasClusterWithActiveMember = true; - if (log.isDebugEnabled()) { - log.debug("found active cluster for service " + cluster.getClusterId() + " in group " + serviceTypeGroup + - " , adding as active service"); - } - result.add(serviceType); - break; - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("service " + service.getServiceName() + " has no cluster, skipping service "); - hasClusterWithActiveMember = false; - } - } - - if (!hasClusterWithActiveMember) {; - if (log.isDebugEnabled()) { - log.debug("service has not a clutser with active member, skipping " + serviceType + " as active service"); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("service mismatch between " + service.getServiceName() + " and servicetype " + serviceType + " continue to search "); - } - } - - } - // covers the case that service hasn't be deployed yet - if (!hasServiceFound) { - if (log.isDebugEnabled()) { - log.debug("no matching service found for " + serviceType + " skipping as active service"); - } - } - } - - return result; - } - - /* - * get a list of clusters based on the subscription alias name - */ - private List getClusters (String [] clusterAliases) { - List clusters = new ArrayList(); - - for (String alias : clusterAliases) { - Cluster cluster = getClusterFromAlias(alias); - if (cluster != null) { - clusters.add(cluster); - } else { - if (log.isDebugEnabled()) { - log.debug("getting a (inactive) cluster retrieved as null for alias " + alias); - } - } - } - return clusters; - } - - /* - * get a cluster based on the subscription alias name - */ - private Cluster getClusterFromAlias(String findClusterId) { - Cluster result = null; - Collection services = TopologyManager.getTopology().getServices(); - for(Service service : services) { - // extract list of clusters, clusterId -> alias - if (log.isDebugEnabled()) { - log.debug("ServiceGroupContext:calculateKillBehaviorFlag:service:" + service.getServiceName()); - } - - for(Cluster cluster : service.getClusters()) { - String clusterId = cluster.getClusterId(); - String clusterIdAlias = this.extractAlias(clusterId); - if (log.isDebugEnabled()) { - log.debug("looping over cluster " + clusterId + - " extracted alias " + clusterIdAlias); - } - - if (clusterIdAlias != null && findClusterId.equals(clusterIdAlias)) { - return cluster; - } else { - if (log.isDebugEnabled()) { - log.debug(" ignoring cluster " + clusterId + " in cluster check for " + findClusterId); - } - } - - } - } - return result; - } - - private static void setKillAllEnabled(String groupId ) { - ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, true); - } - - private static void resetKillAllEnabled(String groupId ) { - // all cartridges are terminated after kill_all - ComplexApplicationContext.is_kill_all_enabled_flag.put(groupId, false); - } - - private static void resetKillAllTransitionFlag(String alias) { - ComplexApplicationContext.is_in_kill_all_transition.remove(alias); - } - - private static void setKillAllTransitionFlag(String alias) { - ComplexApplicationContext.is_in_kill_all_transition.add(alias); - } - - public static synchronized Boolean isKillAllEnabled(String groupId) { - Boolean flag = false; - if (ComplexApplicationContext.is_kill_all_enabled_flag == null) { - if (log.isDebugEnabled()) { - log.debug(" creating new is_kill_all_enabled_flag"); - } - ComplexApplicationContext.is_kill_all_enabled_flag = new HashMap(); - } - flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId); - if (flag == null) { - if (log.isDebugEnabled()) { - log.debug(" is_kill_all_enabled_flag not initialized for " + groupId + " initializing with true"); - } - - ComplexApplicationContext.setKillAllEnabled(groupId); - flag = ComplexApplicationContext.is_kill_all_enabled_flag.get(groupId); - } - return flag; - } - - - public static synchronized Boolean isInKillAllTransition(String key) { - if (ComplexApplicationContext.is_in_kill_all_transition == null) { - if (log.isDebugEnabled()) { - log.debug(" creating new is_in_kill_all_transition"); - } - ComplexApplicationContext.is_in_kill_all_transition = new HashSet(); - } - if (ComplexApplicationContext.is_in_kill_all_transition.contains(key)) { - return true; - } - return false; - } - -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 0b322f8d31..6a337bad04 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -44,7 +44,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index f4606b8986..e715130843 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -30,7 +30,6 @@ import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent; @@ -65,6 +64,7 @@ public static void handleServiceCreated(List cartridgeList) { log.warn(String.format("Cartridge list is empty")); return; } + try { TopologyManager.acquireWriteLock(); @@ -99,7 +99,7 @@ public static void handleServiceCreated(List cartridgeList) { public static void handleServiceRemoved(List cartridgeList) { Topology topology = TopologyManager.getTopology(); - for (Cartridge cartridge : cartridgeList) { + for (Cartridge cartridge : cartridgeList) { if (topology.getService(cartridge.getType()).getClusters().size() == 0) { if (topology.serviceExists(cartridge.getType())) { try { @@ -286,27 +286,6 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent return; } - //grouping - - if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - String appAlias = "compositeApplicationAlias"; - CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceStartedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceStartedEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance started event for cluster " + clusterId); - } - } - try { TopologyManager.acquireWriteLock(); // try update lifecycle state @@ -348,23 +327,6 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate return; } - // grouping - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - String appAlias = "compositeApplicationAlias"; - CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for member activated " + appAlias); - } - String clusterId = instanceActivatedEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceActivatedEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance activated event for cluster " + clusterId); - } - } - Member member = cluster.getMember(instanceActivatedEvent.getMemberId()); @@ -437,27 +399,7 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst return; } - //grouping - - if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - String appAlias = "compositeApplicationAlias"; - CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceReadyToShutdownEvent.getClusterId(); - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceReadyToShutdownEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); - } - } - + Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", @@ -521,28 +463,6 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance } - //grouping - - if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - String appAlias = "compositeApplicationAlias"; - CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - String clusterId = instanceMaintenanceModeEvent.getClusterId(); - - String groupAlias = app.extractClusterGroupFromClusterId(clusterId); - instanceMaintenanceModeEvent.setGroupId(groupAlias); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for instance ready shutdown event for cluster " + clusterId); - } - } - MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent( instanceMaintenanceModeEvent.getServiceName(), instanceMaintenanceModeEvent.getClusterId(), @@ -591,27 +511,6 @@ public static void handleMemberTerminated(String serviceName, String clusterId, return; } - //grouping - - if (log.isDebugEnabled()) { - log.debug("checking group id in ToplogyBuilder for member started event"); - } - - CompositeApplicationBuilder builder = new CompositeApplicationBuilder(); - String appAlias = "compositeApplicationAlias"; - CompositeApplication app = builder.buildCompositeApplication(topology, appAlias); - - String groupAlias = null; - if (app != null) { - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder found composite app for " + appAlias); - } - groupAlias = app.extractClusterGroupFromClusterId(clusterId); - if (log.isDebugEnabled()) { - log.debug("TopologyBuilder setting groupAlias " + groupAlias + " for member terminated event for cluster " + clusterId); - } - } - try { TopologyManager.acquireWriteLock(); properties = member.getProperties(); @@ -620,6 +519,8 @@ public static void handleMemberTerminated(String serviceName, String clusterId, } finally { TopologyManager.releaseWriteLock(); } + /* @TODO leftover from grouping_poc*/ + String groupAlias = null; TopologyEventPublisher.sendMemberTerminatedEvent(serviceName, clusterId, networkPartitionId, partitionId, memberId, properties, groupAlias); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java index bc0740477c..9862b9a49d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyManager.java @@ -81,8 +81,6 @@ public static Topology getTopology() { log.debug("Topology not found in registry, creating new"); } topology = new Topology(); - } else { - topology.getConfigCompositeApplication(); } if (log.isDebugEnabled()) { log.debug("Topology initialized"); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java index 4dbf251a0c..15d9d4476e 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/utils/ApplicationUtils.java @@ -8,8 +8,6 @@ import org.apache.stratos.manager.exception.InvalidCartridgeAliasException; import org.apache.stratos.messaging.broker.publish.EventPublisher; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; -import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; -import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; import org.apache.stratos.messaging.util.Constants; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index 76d73fe2e8..ddd5ffa81d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -38,7 +38,7 @@ public class Topology implements Serializable { private Map serviceMap; //Grouping private Map compositeApplicationMap; - private Map configCompositeApplicationMap; + // grouping_poc private Map configCompositeApplicationMap; // Key: Application.id private Map applicationMap; @@ -48,7 +48,7 @@ public class Topology implements Serializable { public Topology() { this.serviceMap = new HashMap(); this.compositeApplicationMap = new HashMap(); - this.configCompositeApplicationMap = new HashMap(); + // grouping_poc this.configCompositeApplicationMap = new HashMap(); this.applicationMap = new HashMap(); } @@ -124,6 +124,7 @@ public void removeCompositeApplication(String alias) { this.compositeApplicationMap.remove(alias); } + /* grouping_poc public Collection getConfigCompositeApplication() { if (this.configCompositeApplicationMap == null) { @@ -188,6 +189,8 @@ public Map getConfigCompositeApplicationMap( public void setConfigCompositeApplicationMap(Map configCompositeApplicationMap) { this.configCompositeApplicationMap = configCompositeApplicationMap; } + + */ public void setInitialized(boolean initialized) { this.initialized = initialized; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java deleted file mode 100644 index e29fdbba83..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/util/CompositeApplicationBuilder.java +++ /dev/null @@ -1,226 +0,0 @@ -package org.apache.stratos.messaging.domain.topology.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.*; - -import java.util.*; - - - -public class CompositeApplicationBuilder { - - private Map groups = null; - private Map cartridgesTypes = null; - - private List configGroupArray = null; - private List configCartridgeArray = null; - - private static Log log = LogFactory.getLog(CompositeApplicationBuilder.class); - - public CompositeApplication buildCompositeApplication(Topology topology, String appAlias) { - if (log.isDebugEnabled()) { - log.debug("buildCompositeApplication configComplexApplication with topology " + topology); - } - Collection configComplexApplications = topology.getConfigCompositeApplication(); - CompositeApplication complexApplication = new CompositeApplication(); - if (configComplexApplications.size() > 0) { - ConfigCompositeApplication [] complexConfigAppArray = new ConfigCompositeApplication[configComplexApplications.size()]; - complexConfigAppArray = configComplexApplications.toArray(complexConfigAppArray); - - // assuming only 1 complex app is configured - - ConfigCompositeApplication configComplexApplication = complexConfigAppArray[0]; - if (log.isDebugEnabled()) { - log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication); - } - if (configComplexApplication!= null) { - if (log.isDebugEnabled()) { - log.debug("buildCompositeApplication configComplexApplication" + configComplexApplication); - } - setConfigConfiguration(configComplexApplication); - - GroupTemp top_level = this.buildApplication(); - if (top_level != null) { - if (log.isDebugEnabled()) { - log.debug("ServiceGroupContext:configComplexApplication toplevel is " + top_level.getAlias()); - } - } else { - if (log.isDebugEnabled()) { - log.debug("buildCompositeApplication toplevel is null"); - } - } - if (top_level == null) { - log.debug("buildCompositeApplication top level group is null ..."); - return null; - } else { - log.debug("buildCompositeApplication setting top level group " + top_level.getAlias()); - //complexApplication.setTop_level(top_level); - complexApplication.setAll_groups(this.groups); - return complexApplication; - } - } else { - log.debug("buildCompositeApplication configComplexApplication is null"); - } - } else { - log.debug("buildCompositeApplication configComplexApplications is null"); - return null; - } - return null; - } - - - - public GroupTemp buildApplication() { - - for (ConfigGroup configGroup : configGroupArray) { - log.debug("deploying group " + configGroup.getAlias()); - GroupTemp realGroupTemp = new GroupTemp(configGroup.getAlias()); - groups.put(realGroupTemp.getAlias(), realGroupTemp); - } - - - for (ConfigCartridge configCartridge : configCartridgeArray) { - log.debug("deploying cartridge component " + configCartridge.getAlias()); - Cartridge realCartridge = new Cartridge(configCartridge.getAlias()); - cartridgesTypes.put(realCartridge.getAlias(), realCartridge); - } - - // building groups - // this should be done when reading the topology event in autoscaler - log.debug("converting group configuration to groups and assembling application"); - for (ConfigGroup configGroup : configGroupArray) { - GroupTemp assembleGroupTemp = groups.get(configGroup.getAlias()); - Map groupCartridges = new HashMap(); - log.debug("converting configuration for group " + assembleGroupTemp.getAlias()); - for (String key : configGroup.getSubscribables()) { - GroupTemp realgroup = groups.get(key); - if (realgroup != null) { - // try cartridges - assembleGroupTemp.add(realgroup); - realgroup.setParent(assembleGroupTemp); - realgroup.setHomeGroup(assembleGroupTemp); - } else { - Cartridge realcartridge_type = cartridgesTypes.get(key); - if (realcartridge_type != null) { - // create a copy of the cartridge type - Cartridge groupCartridge = new Cartridge(realcartridge_type.getAlias()); - groupCartridge.setCartridgeId(getCartridgeId(assembleGroupTemp.getAlias(), realcartridge_type.getAlias())); - assembleGroupTemp.add(groupCartridge); - groupCartridge.setParent(assembleGroupTemp); - groupCartridge.setHomeGroup(assembleGroupTemp); // TODO need to consolidate parent / home group - groupCartridges.put(groupCartridge.getAlias(), groupCartridge); - if (log.isDebugEnabled()) { - log.debug("added new cartrdige of type " + groupCartridge.getAlias() + " and cartrdigeId " + groupCartridge.getCartridgeId() + - " to group " + assembleGroupTemp.getAlias()); - } - } else { - log.debug("Error: no group, cartridge found for alias: " + key); - } - } - } - // build dependencies - log.debug("building dependencies for group " + assembleGroupTemp.getAlias()); - Dependencies real_dependencies = buildDependency(configGroup, groups, groupCartridges); - assembleGroupTemp.setDependencies(real_dependencies); - real_dependencies.setGroupTemp(assembleGroupTemp); - } - - GroupTemp application = getTopLevelGroup(); - log.debug("top level group is: " + application.getAlias()); - - return application; - } - - public GroupTemp getTopLevelGroup () { - String alias = null; - for (ConfigGroup configGroup : configGroupArray) { - alias = configGroup.getAlias(); - boolean isTopLevelGroup = true; - log.debug("checking if group " + alias + " is a sub component"); - for (ConfigGroup configGroupInner : configGroupArray) { - for (String key : configGroupInner.getSubscribables()) { - log.debug("in group " + configGroupInner.getAlias() ); - if (key.equals(alias)) { - log.debug("found group " + alias + " as sub component in " + configGroupInner.getAlias()); - isTopLevelGroup = false; - break; - } - } - } - if (isTopLevelGroup) { - log.debug("is top level group: " + alias); - break; - } - } - GroupTemp application = groups.get(alias); - log.debug("top level group is: " + alias); - return application; - } - - public Dependencies buildDependency(ConfigGroup configGroup, Map groups, Map groupCartridges) { - - // building dependencies - ConfigDependencies config_dep = configGroup.getDependencies(); - Dependencies real_dependencies = new Dependencies(); - if (config_dep != null) { - String kill_behavior = config_dep.getKill_behavior(); - real_dependencies.setKill_behavior(kill_behavior); - List startup_order = config_dep.getStartup_order(); - for (ConfigDependencies.Pair pair: startup_order) { - String key = pair.getKey(); - String value = pair.getValue(); - //check groups - GroupTemp gr = groups.get(value); - log.debug("checking dependency for key " + key + " /val: " + value + " in groups"); - if (gr != null) { - real_dependencies.addDependency(key, gr); - } else { - log.debug("checking dependency for key " + key + " /val: " + value + " in group cartridges"); - Cartridge cr = groupCartridges.get(value); - if (cr != null) { - real_dependencies.addDependency(key, cr); - if (log.isDebugEnabled()) { - log.debug("adding group cartridge " + cr.getCartridgeId()+ " as dependency"); - } - } else { - cr = this.cartridgesTypes.get(value); - if (cr != null) { - real_dependencies.addDependency(key, cr); - if (log.isDebugEnabled()) { - log.debug("adding a lone cartridge " + cr.getAlias() + " as dependency"); - } - } else { - log.debug("error retrieving group with name " + key); - } - } - } - - } - } - return real_dependencies; - } - - private void setConfigConfiguration(ConfigCompositeApplication configApp) { - this.groups = new HashMap(); - this.cartridgesTypes = new HashMap(); - - if (configApp.getComponents() != null) { - configGroupArray = configApp.getComponents(); - } else { - configGroupArray = new ArrayList(); - } - - if (configApp.getCartridges() != null) { - configCartridgeArray = configApp.getCartridges(); - } else { - configCartridgeArray = new ArrayList(); - } - - } - - private String getCartridgeId (String homeGroupId, String cartridgeType) { - String id = homeGroupId +":"+ cartridgeType; - return id; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.java deleted file mode 100644 index 6c3aa7ace8..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationCreatedEventListener.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.messaging.listener.topology; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class CompositeApplicationCreatedEventListener extends EventListener { - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.java deleted file mode 100644 index 04dce2bf8a..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/CompositeApplicationRemovedEventListener.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.messaging.listener.topology; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class CompositeApplicationRemovedEventListener extends EventListener { - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java deleted file mode 100644 index 1b4faa5861..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationCreatedMessageProcessor.java +++ /dev/null @@ -1,98 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; - -//Grouping -public class CompositeApplicationCreatedMessageProcessor extends MessageProcessor { - - private static final Log log = LogFactory.getLog(CompositeApplicationCreatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (log.isDebugEnabled()) { - log.debug("processing application event of type " + type + - " / topology:" + topology + " msg: " + message); - } - - if (CompositeApplicationCreatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) { - - if (log.isDebugEnabled()) { - log.debug("topology is not initialized .... need to add check ... Grouping"); - } - - //return false; - } - - // Parse complete message and build event - CompositeApplicationCreatedEvent event = - (CompositeApplicationCreatedEvent) Util.jsonToObject(message, CompositeApplicationCreatedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("processing application created event with application id: " + event.getApplicationAlias()); - } - - // Validate event against the existing topology - if (topology.compositeApplicationExists(event.getApplicationAlias())) { - if (log.isWarnEnabled()) { - log.warn(String.format("CompositeApplication already created: [com app] %s", event.getApplicationAlias())); - } - } else { - - ConfigCompositeApplication configApp = event.getCompositeApplication(); - String alias = "compositeApplicationAlias"; - if (log.isInfoEnabled()) { - log.info("adding ConfigCompositeApplication with alias " + alias + " to topology"); - } - topology.addConfigCompositeApplication(alias, configApp); - } - - // Notify event listeners - notifyEventListeners(event); - return true; - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java deleted file mode 100644 index 2bb688a585..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompositeApplicationRemovedMessageProcessor.java +++ /dev/null @@ -1,100 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.ConfigCompositeApplication; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.CompositeApplicationCreatedEvent; -import org.apache.stratos.messaging.event.topology.CompositeApplicationRemovedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; -import org.apache.stratos.messaging.domain.topology.CompositeApplication; -import org.apache.stratos.messaging.domain.topology.util.CompositeApplicationBuilder; - -//Grouping -public class CompositeApplicationRemovedMessageProcessor extends MessageProcessor { - - private static final Log log = LogFactory.getLog(CompositeApplicationRemovedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (log.isDebugEnabled()) { - log.debug("processing application event of type " + type + - " / topology:" + topology + " msg: " + message); - } - - if (CompositeApplicationRemovedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - - if (!topology.isInitialized()) { - - if (log.isDebugEnabled()) { - log.debug("topology is not initialized .... need to add check ... Grouping"); - } - //return false; - } - - // Parse complete message and build event - CompositeApplicationRemovedEvent event = - (CompositeApplicationRemovedEvent) Util.jsonToObject(message, CompositeApplicationRemovedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("processing application removed event with application id: " + event.getApplicationAlias()); - } - - // Validate event against the existing topology - if (topology.configCompositeApplicationExists(event.getApplicationAlias())) { - topology.removeAllConfigCompositeApplication(); - if (log.isDebugEnabled()) { - log.debug("CompositeApplication exists, removing all ConfigCompositeApplication" + event.getApplicationAlias()) ; - } - } else { - topology.removeAllConfigCompositeApplication(); - if (log.isWarnEnabled()) { - log.warn("ConfigCompositeApplication " + event.getApplicationAlias() + " does not exist, removing all ") ; - } - } - - - - // Notify event listeners - notifyEventListeners(event); - return true; - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} From 7b4e326440287071d6271f9583caa2c1d947fe26 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 28 Oct 2014 10:00:21 +0530 Subject: [PATCH 272/436] fixing issues while terminatnig the child and adding life cycle check for group events --- .../grouping/topic/StatusEventPublisher.java | 82 ++++++++++++++++--- .../AutoscalerTopologyEventReceiver.java | 12 ++- .../stratos/autoscaler/monitor/Monitor.java | 9 +- .../monitor/ParentComponentMonitor.java | 11 ++- .../application/ApplicationMonitor.java | 3 +- .../monitor/cluster/ClusterMonitor.java | 6 +- .../monitor/group/GroupMonitor.java | 3 +- .../status/checker/StatusChecker.java | 27 ++++-- 8 files changed, 118 insertions(+), 35 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index ee75f74909..fece5063f0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -4,7 +4,7 @@ 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.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; @@ -14,6 +14,7 @@ import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import java.util.Set; @@ -83,9 +84,25 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { " [group]: " + groupId); } - AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group.getStatus().getNextStates().contains(GroupStatus.Active)) { + AppStatusGroupActivatedEvent groupActivatedEvent = + new AppStatusGroupActivatedEvent(appId, groupId); + + publishEvent(groupActivatedEvent); + } else { + log.warn("Active is not in the possible state list of [group] " + groupId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + - publishEvent(groupActivatedEvent); } public static void sendGroupInActivateEvent(String appId, String groupId) { @@ -94,11 +111,25 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { log.info("Publishing Group in-activate event for [application]: " + appId + " [group]: " + groupId); } + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group.getStatus().getNextStates().contains(GroupStatus.Inactive)) { + AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new + AppStatusGroupInactivateEvent(appId, groupId); + + publishEvent(appStatusGroupInactivateEvent); + } else { + log.warn("InActive is not in the possible state list of [group] " + groupId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } - AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new - AppStatusGroupInactivateEvent(appId, groupId); - publishEvent(appStatusGroupInactivateEvent); } public static void sendGroupTerminatingEvent(String appId, String groupId) { @@ -107,9 +138,22 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { log.info("Publishing Group terminating event for [application]: " + appId + " [group]: " + groupId); } - - AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId); - publishEvent(groupInTerminatingEvent); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group.getStatus().getNextStates().contains(GroupStatus.Terminating)) { + AppStatusGroupTerminatingEvent groupInTerminatingEvent = + new AppStatusGroupTerminatingEvent(appId, groupId); + publishEvent(groupInTerminatingEvent); + } else { + log.warn("Terminating is not in the possible state list of [group] " + groupId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } public static void sendGroupTerminatedEvent(String appId, String groupId) { @@ -119,8 +163,24 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { " [group]: " + groupId); } - AppStatusGroupTerminatedEvent groupInTerminatedEvent = new AppStatusGroupTerminatedEvent(appId, groupId); - publishEvent(groupInTerminatedEvent); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if(application != null) { + Group group = application.getGroupRecursively(groupId); + if(group.getStatus().getNextStates().contains(GroupStatus.Terminated)) { + AppStatusGroupTerminatedEvent groupInTerminatedEvent = + new AppStatusGroupTerminatedEvent(appId, groupId); + publishEvent(groupInTerminatedEvent); + } else { + log.warn("Terminated is not in the possible state list of [group] " + groupId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + + } public static void sendApplicationActivatedEvent(String appId) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 89fe51fad2..9109d50575 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -210,7 +210,13 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(ClusterStatus.Terminating); + if (clusterMonitor != null) { + clusterMonitor.setDestroyed(true); + clusterMonitor.terminateAllMembers(); + clusterMonitor.setStatus(ClusterStatus.Terminating); + } else { + log.warn("No Cluster Monitor found for cluster id " + clusterId); + } //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); @@ -251,7 +257,9 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(GroupStatus.Active); + if(monitor != null) { + monitor.setStatus(GroupStatus.Active); + } } }); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java index 2088351281..9ef7d73af5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/Monitor.java @@ -75,13 +75,14 @@ public void setParent(ParentComponentMonitor parent) { public boolean hasActiveMonitors() { boolean hasMonitor = false; - if(this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) { + if ((this.aliasToActiveMonitorsMap != null && !this.aliasToActiveMonitorsMap.isEmpty()) || + (this.aliasToInActiveMonitorsMap != null && !this.aliasToInActiveMonitorsMap.isEmpty())) { hasMonitor = true; } return hasMonitor; } - public boolean hasMonitors () { + public boolean hasMonitors() { return this.aliasToActiveMonitorsMap != null || this.aliasToInActiveMonitorsMap != null; } @@ -96,8 +97,8 @@ public void setHasDependent(boolean hasDependent) { public boolean hasInDependentChild() { boolean hasInDepChild = false; - for(Monitor monitor : this.aliasToActiveMonitorsMap.values()) { - if(!monitor.isDependent()) { + for (Monitor monitor : this.aliasToActiveMonitorsMap.values()) { + if (!monitor.isDependent()) { hasInDepChild = true; break; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 9f3417d006..6aa76b64a6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -116,7 +116,7 @@ protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; //Temporarily move the group/cluster to inactive list - this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); + //this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); if(this.hasDependent) { //need to notify the parent @@ -171,18 +171,20 @@ protected void onChildTerminatedEvent(String idOfEvent) { context.setTerminated(true); terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); + + /** * Make sure that all the dependents have been terminated properly to start the recovery */ if (terminationList != null) { for (ApplicationContext context1 : terminationList) { - if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + if (!this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { allDependentTerminated = false; } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); allDependentTerminated = false; } else { - allDependentTerminated = true; + log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated..."); } } } @@ -213,11 +215,12 @@ protected void onChildTerminatedEvent(String idOfEvent) { //Find the non existent monitor by traversing dependency tree try { - this.startDependency(); + this.startDependencyOnTermination(); } catch (TopologyInConsistentException e) { e.printStackTrace(); } } else { + StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); log.info("Waiting for the dependent of [monitor] " + idOfEvent + " to be terminated"); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 45530c5fbf..66044ef286 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -179,8 +179,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != ApplicationStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() && - !this.aliasToActiveMonitorsMap.isEmpty()) { + if (this.status != ApplicationStatus.Terminating) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 557fedb613..a089fc6e09 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -72,12 +72,12 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo @Override public void run() { while (!isDestroyed()) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } try { if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || (this.status == ClusterStatus.Inactive && !hasDependent)) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } monitor(); } else { if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 312378298e..dff0bbaddb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -94,8 +94,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != GroupStatus.Terminating && !this.aliasToInActiveMonitorsMap.isEmpty() && - !this.aliasToActiveMonitorsMap.isEmpty()) { + if (this.status != GroupStatus.Terminating) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 7b3e0ac354..acf6d71072 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -289,8 +289,8 @@ private boolean updateChildStatus(String appId, String id, Map gr //send the in activation event if (parent instanceof Application) { //send application activated event - log.info("sending app in-active : " + appId); - StatusEventPublisher.sendApplicationInactivatedEvent(appId); + log.warn("Application can't be in in-active : " + appId); + //StatusEventPublisher.sendApplicationInactivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group in-active: " + parent.getUniqueIdentifier()); @@ -301,9 +301,22 @@ private boolean updateChildStatus(String appId, String id, Map gr groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { //send the terminated event if (parent instanceof Application) { - //send application activated event - log.info("sending app terminated: " + appId); - StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + //validating the life cycle + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if(application.getStatus().equals(ApplicationStatus.Terminating)) { + log.info("sending app terminated: " + appId); + StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + } else { + log.info("[Application] " + appId + " is in the [status] " + + application.getStatus().toString() + ". Hence not sending terminated event"); + } + + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + //StatusEventPublisher.sendApp(appId); } else if (parent instanceof Group) { //send activation to the parent @@ -316,8 +329,8 @@ private boolean updateChildStatus(String appId, String id, Map gr //send the terminated event if (parent instanceof Application) { //send application activated event - log.info("sending app terminating: " + appId); - StatusEventPublisher.sendApplicationTerminatingEvent(appId); + log.warn("Application can't be in terminating: " + appId); + //StatusEventPublisher.sendApplicationTerminatingEvent(appId); //StatusEventPublisher.sendApp(appId); } else if (parent instanceof Group) { //send activation to the parent From c95377ff9b98b0138b17b52a696b5cedcc68fa2c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 28 Oct 2014 10:58:12 +0530 Subject: [PATCH 273/436] adding Cluster details to the SM's Topology model --- .../StratosManagerTopologyEventReceiver.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 index 6e8552b989..d4e90cc13c 100644 --- 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 @@ -36,6 +36,8 @@ import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.wso2.carbon.context.PrivilegedCarbonContext; +import java.util.List; + public class StratosManagerTopologyEventReceiver implements Runnable { private static final Log log = LogFactory.getLog(StratosManagerTopologyEventReceiver.class); @@ -347,6 +349,18 @@ protected void onEvent(Event event) { } finally { PrivilegedCarbonContext.endTenantFlow(); } + + // add the clusters to the topology information model + List 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()); From dd210b59206a445e8ae3fef8f97f937012dd528c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 28 Oct 2014 11:05:11 +0530 Subject: [PATCH 274/436] correcting wrong state transition in GroupTerminatingProcessor --- .../message/processor/topology/GroupTerminatingProcessor.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java index 210279c7b8..ecf6873b61 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java @@ -93,8 +93,8 @@ private boolean doProcess (GroupTerminatingEvent event,Topology topology) { } } else { // Apply changes to the topology - if (!group.isStateTransitionValid(GroupStatus.Active)) { - log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + if (!group.isStateTransitionValid(GroupStatus.Terminating)) { + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminating); } group.setStatus(GroupStatus.Terminating); From 097e884bd2e5c5942c3023eb5b5cbbf6d82331bf Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 28 Oct 2014 12:13:04 +0530 Subject: [PATCH 275/436] fixing STRATOS-918 --- .../topology/AutoscalerTopologyEventReceiver.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 9109d50575..e5bbd55ce3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; @@ -364,11 +365,13 @@ protected void onEvent(Event event) { // List clusters = appMonitor. // findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); + boolean clusterMonitorsFound = false; for (ClusterDataHolder clusterData : clusterDataHolders) { //stopping the cluster monitor and remove it from the AS ClusterMonitor clusterMonitor = ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); if (clusterMonitor != null) { + clusterMonitorsFound = true; clusterMonitor.setDestroyed(true); clusterMonitor.terminateAllMembers(); clusterMonitor.setStatus(ClusterStatus.Terminating); @@ -377,9 +380,19 @@ protected void onEvent(Event event) { } } + // if by any chance, the cluster monitors have failed, we still need to undeploy this application + // hence, check if the Cluster Monitors are not found and send the Application Terminated event + if (!clusterMonitorsFound) { + StatusEventPublisher.sendApplicationTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), clusterDataHolders); + } + } else { log.warn("Application Monitor cannot be found for the undeployed [application] " + applicationUndeployedEvent.getApplicationId()); + // send the App Terminated event to cleanup + StatusEventPublisher.sendApplicationTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), clusterDataHolders); } } finally { From 2ae7e2b947f9ad1635fecad739643f2379807efe Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 28 Oct 2014 13:14:40 +0530 Subject: [PATCH 276/436] adding the valid transition check for status changes --- .../grouping/topic/StatusEventPublisher.java | 198 +++++++++++++----- .../AutoscalerTopologyEventReceiver.java | 22 +- .../monitor/AbstractClusterMonitor.java | 24 ++- .../application/ApplicationMonitor.java | 4 +- .../monitor/group/GroupMonitor.java | 17 +- 5 files changed, 183 insertions(+), 82 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index fece5063f0..5b09a21322 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -7,13 +7,6 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; @@ -32,10 +25,23 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S " [cluster]: " + clusterId); } - AppStatusClusterActivatedEvent clusterActivatedEvent = - new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); - - publishEvent(clusterActivatedEvent); + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Active)) { + AppStatusClusterActivatedEvent clusterActivatedEvent = + new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterActivatedEvent); + } else { + log.warn("Active is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); + } } public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) { @@ -45,36 +51,77 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, " [cluster]: " + clusterId); } - AppStatusClusterInactivateEvent clusterInActivateEvent = - new AppStatusClusterInactivateEvent(appId, serviceName, clusterId); + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) { + AppStatusClusterInactivateEvent clusterInActivateEvent = + new AppStatusClusterInactivateEvent(appId, serviceName, clusterId); + + publishEvent(clusterInActivateEvent); + } else { + log.warn("In-active is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - publishEvent(clusterInActivateEvent); + } } public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { - log.info("Publishing Cluster in-activate event for [application]: " + appId + + log.info("Publishing Cluster Terminating event for [application]: " + appId + " [cluster]: " + clusterId); } - //TODO - AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent = - new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId); + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) { + AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent = + new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId); + + publishEvent(appStatusClusterTerminatingEvent); + } else { + log.warn("Terminating is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); + + } - publishEvent(appStatusClusterTerminatingEvent); } public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) { if (log.isInfoEnabled()) { - log.info("Publishing Cluster in-activate event for [application]: " + appId + + log.info("Publishing Cluster terminated event for [application]: " + appId + " [cluster]: " + clusterId); } + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) { + AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent = + new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId); + + publishEvent(appStatusClusterTerminatedEvent); + } else { + log.warn("Terminated is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent = - new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId); - - publishEvent(appStatusClusterTerminatedEvent); + } } public static void sendGroupActivatedEvent(String appId, String groupId) { @@ -87,9 +134,9 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if(application != null) { + if (application != null) { Group group = application.getGroupRecursively(groupId); - if(group.getStatus().getNextStates().contains(GroupStatus.Active)) { + if (group.isStateTransitionValid(GroupStatus.Active)) { AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId); @@ -101,8 +148,6 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { } finally { TopologyManager.releaseReadLockForApplication(appId); } - - } public static void sendGroupInActivateEvent(String appId, String groupId) { @@ -114,10 +159,10 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if(application != null) { + if (application != null) { Group group = application.getGroupRecursively(groupId); - if(group.getStatus().getNextStates().contains(GroupStatus.Inactive)) { - AppStatusGroupInactivateEvent appStatusGroupInactivateEvent= new + if (group.isStateTransitionValid(GroupStatus.Inactive)) { + AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new AppStatusGroupInactivateEvent(appId, groupId); publishEvent(appStatusGroupInactivateEvent); @@ -128,8 +173,6 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { } finally { TopologyManager.releaseReadLockForApplication(appId); } - - } public static void sendGroupTerminatingEvent(String appId, String groupId) { @@ -141,9 +184,9 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if(application != null) { + if (application != null) { Group group = application.getGroupRecursively(groupId); - if(group.getStatus().getNextStates().contains(GroupStatus.Terminating)) { + if (group.isStateTransitionValid(GroupStatus.Terminating)) { AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId); publishEvent(groupInTerminatingEvent); @@ -166,9 +209,9 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if(application != null) { + if (application != null) { Group group = application.getGroupRecursively(groupId); - if(group.getStatus().getNextStates().contains(GroupStatus.Terminated)) { + if (group.isStateTransitionValid(GroupStatus.Terminated)) { AppStatusGroupTerminatedEvent groupInTerminatedEvent = new AppStatusGroupTerminatedEvent(appId, groupId); publishEvent(groupInTerminatedEvent); @@ -189,40 +232,87 @@ public static void sendApplicationActivatedEvent(String appId) { log.info("Publishing Application activated event for [application]: " + appId); } - AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + if (application.isStateTransitionValid(ApplicationStatus.Active)) { + AppStatusApplicationActivatedEvent applicationActivatedEvent = + new AppStatusApplicationActivatedEvent(appId); - publishEvent(applicationActivatedEvent); + publishEvent(applicationActivatedEvent); + } else { + log.warn("Active is not in the possible state list of [application] " + appId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } - public static void sendApplicationInactivatedEvent(String appId){ + public static void sendApplicationInactivatedEvent(String appId) { if (log.isInfoEnabled()) { - log.info("Publishing Application Inactivated event for [application]: " + appId); + log.info("Publishing Application In-activated event for [application]: " + appId); } - AppStatusApplicationInactivatedEvent applicationInActivatedEvent = new AppStatusApplicationInactivatedEvent(appId); - - publishEvent(applicationInActivatedEvent); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + if (application.isStateTransitionValid(ApplicationStatus.Inactive)) { + AppStatusApplicationInactivatedEvent applicationInActivatedEvent = + new AppStatusApplicationInactivatedEvent(appId); + publishEvent(applicationInActivatedEvent); + } else { + log.warn("Inactive is not in the possible state list of [application] " + appId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } - public static void sendApplicationTerminatingEvent (String appId) { + public static void sendApplicationTerminatingEvent(String appId) { if (log.isInfoEnabled()) { log.info("Publishing Application terminated event for [application]: " + appId); } - AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId); - - publishEvent(applicationTerminatingEvent); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + if (application.isStateTransitionValid(ApplicationStatus.Terminating)) { + AppStatusApplicationTerminatingEvent applicationTerminatingEvent = + new AppStatusApplicationTerminatingEvent(appId); + publishEvent(applicationTerminatingEvent); + } else { + log.warn("Terminating is not in the possible state list of [application] " + appId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } - public static void sendApplicationTerminatedEvent (String appId, Set clusterData) { + public static void sendApplicationTerminatedEvent(String appId, Set clusterData) { if (log.isInfoEnabled()) { log.info("Publishing Application terminated event for [application]: " + appId); } - - AppStatusApplicationTerminatedEvent applicationTerminatedEvent = - new AppStatusApplicationTerminatedEvent(appId, clusterData); - - publishEvent(applicationTerminatedEvent); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + if (application.isStateTransitionValid(ApplicationStatus.Terminated)) { + AppStatusApplicationTerminatedEvent applicationTerminatedEvent = + new AppStatusApplicationTerminatedEvent(appId, clusterData); + publishEvent(applicationTerminatedEvent); + } else { + log.warn("Terminated is not in the possible state list of [application] " + appId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } public static void publishEvent(Event event) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index e5bbd55ce3..99aa69c568 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -39,10 +39,6 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; -import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; 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; @@ -237,7 +233,9 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(ClusterStatus.Terminated); + if (clusterMonitor != null) { + clusterMonitor.setStatus(ClusterStatus.Terminated); + } //starting the status checker to decide on the status of it's parent //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); @@ -258,7 +256,7 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - if(monitor != null) { + if (monitor != null) { monitor.setStatus(GroupStatus.Active); } @@ -279,7 +277,9 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(GroupStatus.Inactive); + if (monitor != null) { + monitor.setStatus(GroupStatus.Inactive); + } } }); @@ -298,7 +298,9 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(GroupStatus.Terminating); + if (monitor != null) { + monitor.setStatus(GroupStatus.Terminating); + } } }); @@ -317,7 +319,9 @@ protected void onEvent(Event event) { GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); //changing the status in the monitor, will notify its parent monitor - monitor.setStatus(GroupStatus.Terminated); + if (monitor != null) { + monitor.setStatus(GroupStatus.Terminated); + } } }); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 588d2c4177..0a9d628e53 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -228,17 +228,19 @@ public ClusterStatus getStatus() { public void setStatus(ClusterStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", clusterId, this.status, status)); - this.status = status; - /** - * notifying the parent monitor about the state change - * If the cluster in_active and if it is a in_dependent cluster, - * then won't send the notification to parent. - */ - if(status == ClusterStatus.Inactive && !this.hasDependent) { - log.info("[Cluster] " + clusterId + "is not notifying the parent, " + - "since it is identified as the independent unit"); - } else { - MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + if(this.status != status) { + this.status = status; + /** + * notifying the parent monitor about the state change + * If the cluster in_active and if it is a in_dependent cluster, + * then won't send the notification to parent. + */ + if (status == ClusterStatus.Inactive && !this.hasDependent) { + log.info("[Cluster] " + clusterId + "is not notifying the parent, " + + "since it is identified as the independent unit"); + } else { + MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 66044ef286..966c8b2c10 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -142,7 +142,9 @@ private Monitor findGroupMonitor(String id, Collection monitors) { public void setStatus(ApplicationStatus status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); - this.status = status; + if(this.status != status) { + this.status = status; + } } @Override diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index dff0bbaddb..ab3ef16690 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -140,13 +140,16 @@ public GroupStatus getStatus() { public void setStatus(GroupStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); - this.status = status; - //notifying the parent - if (status == GroupStatus.Inactive && !this.hasDependent) { - log.info("[Group] " + this.id + "is not notifying the parent, " + - "since it is identified as the independent unit"); - } else { - MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + if(this.status != status) { + this.status = status; + //notifying the parent + if (status == GroupStatus.Inactive && !this.hasDependent) { + log.info("[Group] " + this.id + "is not notifying the parent, " + + "since it is identified as the independent unit"); + } else { + MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + } } + } } From 4bca87eee4bb9b0b966aaf3813acaeaeeebc0557 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 10:42:51 +0530 Subject: [PATCH 277/436] removing created headers from java files --- .../autoscaler/grouping/dependency/context/GroupContext.java | 3 --- .../apache/stratos/autoscaler/monitor/events/MonitorEvent.java | 3 --- .../status/AppStatusGroupActivatedEventListener.java | 3 --- .../status/AppStatusGroupInactivateEventListener.java | 3 --- .../status/AppStatusGroupTerminatingEventListener.java | 3 --- .../listener/topology/ClusterActivatedEventListener.java | 3 --- .../listener/topology/ClusterInActivateEventListener.java | 3 --- .../status/AppStatusApplicationActivatedMessageProcessor.java | 3 --- 8 files changed, 24 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java index 0e65d2b107..408272aec2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java @@ -18,9 +18,6 @@ */ package org.apache.stratos.autoscaler.grouping.dependency.context; -/** - * Created by reka on 10/1/14. - */ public class GroupContext extends ApplicationContext { public GroupContext(String id, boolean killDependent) { super(id ,killDependent); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java index a733a0eed4..52317991d2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/MonitorEvent.java @@ -18,9 +18,6 @@ */ package org.apache.stratos.autoscaler.monitor.events; -/** - * Created by reka on 10/20/14. - */ public abstract class MonitorEvent { protected String id; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java index 75fe2c986a..e6381e3674 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/22/14. - */ public abstract class AppStatusGroupActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java index 5c88faec91..0873a70b75 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/22/14. - */ public abstract class AppStatusGroupInactivateEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java index fbd7fcc123..8d56555868 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/22/14. - */ public abstract class AppStatusGroupTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java index 9514541e5a..00efcfdd4f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterActivatedEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/17/14. - */ public abstract class ClusterActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java index 03a4768a88..551f1b8247 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterInActivateEventListener.java @@ -20,8 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -/** - * Created by reka on 9/17/14. - */ public abstract class ClusterInActivateEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java index a5056246c2..8b88724ac6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java @@ -24,9 +24,6 @@ import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -/** - * Created by reka on 9/25/14. - */ public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class); From c947820858960606a5d7b3c5e90c5086aadbdabb Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 10:45:47 +0530 Subject: [PATCH 278/436] add delete application to metadata service --- .../DefaultMetaDataServiceClient.java | 11 ++++++++ .../defaults/MetaDataServiceClient.java | 2 ++ .../client/rest/DefaultRestClient.java | 2 ++ .../registry/CarbonRegistry.java | 25 ++++++++++++++++++- .../metadataservice/registry/DataStore.java | 1 + .../registry/GRegRegistry.java | 4 +++ .../services/MetaDataAdmin.java | 22 ++++++++++++++++ 7 files changed, 66 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java index fbebab9ae3..ff7ac4a201 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/DefaultMetaDataServiceClient.java @@ -96,6 +96,17 @@ public PropertyBean getProperty(String appId, String clusterId, String propertyN return gson.fromJson(responseContent, PropertyBean.class); } + public void deleteApplicationProperties(String appId) throws MetaDataServiceClientException{ + StringBuilder applicationPath = new StringBuilder(baseUrl).append("application/").append(appId); + HttpResponse response; + try { + response = restClient.doDelete(String.valueOf(applicationPath)); + } catch (RestClientException e) { + String msg= "Error occured while deleting application"; + throw new MetaDataServiceClientException(msg, e); + } + } + private String readResponseContent(HttpResponse response) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8")); diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java index 8fdb9a7dfe..4703e77a63 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/defaults/MetaDataServiceClient.java @@ -60,6 +60,8 @@ public interface MetaDataServiceClient { */ public org.apache.stratos.metadata.client.beans.PropertyBean getProperty(String appId, String clusterID, String propertyKey) throws MetaDataServiceClientException; + public void deleteApplicationProperties(String applicationId) throws MetaDataServiceClientException; + /** * Shutdown the MetaDataServiceClient. Should be called once after using the client. */ diff --git a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java index 160ca15cae..d3a3f7fc99 100644 --- a/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java +++ b/components/org.apache.stratos.metadata.client/src/main/java/org/apache/stratos/metadata/client/rest/DefaultRestClient.java @@ -122,6 +122,7 @@ private void addPayloadJsonString(Object payload, HttpPost post) { public HttpResponse doGet(String resourcePath) throws RestClientException { HttpGet get = new HttpGet(resourcePath); + setAuthHeader(get); try { return httpClient.execute(get); @@ -138,6 +139,7 @@ public HttpResponse doGet(String resourcePath) throws RestClientException { public HttpResponse doDelete(String resourcePath) throws RestClientException { HttpDelete delete = new HttpDelete(resourcePath); + setAuthHeader(delete); try { return httpClient.execute(delete); 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 e9d590d5ba..89250b33b4 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 @@ -18,6 +18,7 @@ */ 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.metadataservice.definition.NewProperty; @@ -102,7 +103,29 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp } /** - * Add properties to clustor + * Delete the resource identified by the applicationId, if exist. + * @param applicationId ID of the application. + * @return True if resource exist and able to delete, else false. + * @throws RegistryException + */ + public boolean deleteApplication(String applicationId) throws RegistryException { + if(StringUtils.isEmpty(applicationId)){ + throw new IllegalArgumentException("Application ID can not be null"); + } + Registry tempRegistry = getGovernanceUserRegistry(); + String resourcePath = mainResource + applicationId; + + if(tempRegistry.resourceExists(resourcePath)){ + tempRegistry.delete(resourcePath); + log.info(String.format("Application removed from registry %s", applicationId)); + return true; + } + + return false; + } + + /** + * Add properties to cluster * @param applicationName * @param clusterId * @param properties diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java index 0ad845914e..33f322956b 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/DataStore.java @@ -36,4 +36,5 @@ public List getPropertiesOfCluster(String applicationName, String c public void addPropertyToCluster(String applicationId, String clusterId, NewProperty property) throws RegistryException; + public boolean deleteApplication(String applicationId) throws RegistryException; } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java index ffe38f110a..c2ba22e241 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/registry/GRegRegistry.java @@ -102,4 +102,8 @@ public void addPropertyToCluster(String applicationId, String clusterId, NewProp } + public boolean deleteApplication(String applicationId) { + return false; + } + } diff --git a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java index 55887a3eeb..e88bc2acdd 100644 --- a/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java +++ b/components/org.apache.stratos.metadataservice/src/main/java/org/apache/stratos/metadataservice/services/MetaDataAdmin.java @@ -162,5 +162,27 @@ public Response addPropertiesToACluster(@PathParam("application_id") String appl return Response.created(url).build(); } + @DELETE + @Path("application/{application_id}") + @Produces("application/json") + @Consumes("application/json") + @AuthorizationAction("/permission/protected/manage/monitor/tenants") + public Response deleteApplicationProperties(@PathParam("application_id") String applicationId) + throws RestAPIException { + + try { + boolean deleted = registry.deleteApplication(applicationId); + if(!deleted){ + log.warn(String.format("Either no metadata is associated with given appId %s Or resources could not be deleted", applicationId)); + } + } catch (RegistryException e) { + String msg= "Resource attached with appId could not be deleted"; + log.error(msg, e); + throw new RestAPIException(" ", e); + } + + return Response.ok().build(); + } + } From 195303244312d60cb83a1e0d7a0c44f221d05014 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 16:31:31 +0530 Subject: [PATCH 279/436] delete application from metadata service when app is undeployed --- .../controller/topology/TopologyBuilder.java | 23 ++++++++++++------- .../topology/GroupTerminatingProcessor.java | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index e715130843..fac667146b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -31,19 +31,13 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient; +import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient; import org.wso2.carbon.registry.core.exceptions.RegistryException; import java.util.*; @@ -939,10 +933,14 @@ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminat } } + + // remove application topology.removeApplication(event.getAppId()); TopologyManager.updateTopology(topology); + deleteAppResourcesFromMetadataService(event); + log.info("Removed application [ " + event.getAppId() + " ] from Topology"); TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(), @@ -954,6 +952,15 @@ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminat } } + private static void deleteAppResourcesFromMetadataService(AppStatusApplicationTerminatedEvent event) { + try { + MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient(); + metadataClient.deleteApplicationProperties(event.getAppId()); + } catch (Exception e) { + log.error("Error occurred while deleting the application resources frm metadata service " , e); + } + } + public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java index ecf6873b61..27b5cff43b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java @@ -94,7 +94,7 @@ private boolean doProcess (GroupTerminatingEvent event,Topology topology) { } else { // Apply changes to the topology if (!group.isStateTransitionValid(GroupStatus.Terminating)) { - log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminating); + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); } group.setStatus(GroupStatus.Terminating); From 7618c7b172df604ebf8563b278e0ea0a6d31cd3e Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 16:32:09 +0530 Subject: [PATCH 280/436] CNF when calling metadata client --- .../org.apache.stratos.metadata.client/pom.xml | 4 ++-- .../pom.xml | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.metadata.client/pom.xml b/components/org.apache.stratos.metadata.client/pom.xml index 4f92ca75be..11daa790eb 100644 --- a/components/org.apache.stratos.metadata.client/pom.xml +++ b/components/org.apache.stratos.metadata.client/pom.xml @@ -18,13 +18,12 @@ org.apache.httpcomponents httpclient 4.3.5 - provided commons-configuration commons-configuration 1.9 - provided + com.google.code.gson @@ -55,6 +54,7 @@ !org.apache.stratos.metadata.client, org.apache.commons.logging; version=0.0.0, org.apache.commons.configuration; version=0.0.0, + org.apache.http.conn.ssl;version=0.0.0, *;resolution:=optional * diff --git a/features/common/org.apache.stratos.metadata.client.feature/pom.xml b/features/common/org.apache.stratos.metadata.client.feature/pom.xml index 6a8402f515..09857d0217 100644 --- a/features/common/org.apache.stratos.metadata.client.feature/pom.xml +++ b/features/common/org.apache.stratos.metadata.client.feature/pom.xml @@ -50,6 +50,17 @@ httpclient-osgi 4.3.5 + + org.apache.httpcomponents + httpclient + 4.3.5 + + + + org.apache.httpcomponents + httpcore + 4.3.2 + org.apache.httpcomponents httpcore-osgi @@ -88,10 +99,8 @@ org.apache.stratos:org.apache.stratos.metadata.client:${project.version} com.google.code.gson:gson:${gson2.version} org.apache.commons:commons-lang3:3.1 - From ae75efc371f17d7c11db207c288cbf2e466bdf03 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 16:36:58 +0530 Subject: [PATCH 281/436] change configuration of metadataservice.xml --- .../distribution/src/main/conf/metadataservice.xml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml index 5e8bb1d689..5073e24520 100644 --- a/products/stratos/modules/distribution/src/main/conf/metadataservice.xml +++ b/products/stratos/modules/distribution/src/main/conf/metadataservice.xml @@ -18,6 +18,7 @@ under the License. --> + + + https://localhost:9443/stratosmetadataservice/ + admin + admin + + + From 636d9bb0e85a6e91d454157cdce61851738c0a6d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 28 Oct 2014 19:59:23 +0530 Subject: [PATCH 282/436] fixing STRATOS-921 --- .../topic/InstanceNotificationPublisher.java | 42 +++++++++++++++++++ .../AutoscalerTopologyEventReceiver.java | 32 +++++++++++--- .../impl/CloudControllerServiceImpl.java | 2 +- 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java new file mode 100644 index 0000000000..d745d79123 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java @@ -0,0 +1,42 @@ +/* + * 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.autoscaler.grouping.topic; + +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.InstanceCleanupClusterEvent; +import org.apache.stratos.messaging.util.Constants; + +public class InstanceNotificationPublisher { + private static final Log log = LogFactory.getLog(InstanceNotificationPublisher.class); + + private static void publish(Event event) { + EventPublisher instanceNotifyingEvent = EventPublisherPool.getPublisher(Constants.INSTANCE_NOTIFIER_TOPIC); + instanceNotifyingEvent.publish(event); + } + + public static void sendInstanceCleanupEventForCluster(String clusterId) { + log.info(String.format("Publishing Instance Cleanup Event: [cluster] %s", clusterId)); + publish(new InstanceCleanupClusterEvent(clusterId)); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 99aa69c568..bff46c27ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; @@ -377,8 +378,21 @@ protected void onEvent(Event event) { if (clusterMonitor != null) { clusterMonitorsFound = true; clusterMonitor.setDestroyed(true); - clusterMonitor.terminateAllMembers(); - clusterMonitor.setStatus(ClusterStatus.Terminating); + //clusterMonitor.terminateAllMembers(); + if (clusterMonitor.getStatus() == ClusterStatus.Active) { + // terminated gracefully + clusterMonitor.setStatus(ClusterStatus.Terminating); + InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId()); + } else { + // if not active, forcefully terminate + clusterMonitor.setStatus(ClusterStatus.Terminating); + try { + CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); + } catch (TerminationException e) { + log.error("Unable to terminate instances for [ cluster id ] " + + clusterData.getClusterId(), e); + } + } } else { log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); } @@ -526,16 +540,22 @@ protected void onEvent(Event event) { // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); for (ClusterDataHolder clusterData : clusterDataHolders) { //stopping the cluster monitor and remove it from the AS - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())). - setDestroyed(true); - AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); + ClusterMonitor clusterMonitor = ((ClusterMonitor) + AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); + if (clusterMonitor != null) { + clusterMonitor.setDestroyed(true); + AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); + } else { + log.warn("Cluster Monitor not found for [ cluster id ] " + + clusterData.getClusterId() + ", unable to remove"); + } } //removing the application monitor AutoscalerContext.getInstance(). removeAppMonitor(applicationRemovedEvent.getAppId()); } else { log.warn("Application Monitor cannot be found for the terminated [application] " - + applicationRemovedEvent.getAppId()); + + applicationRemovedEvent.getAppId() + ", unable to remove"); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 6a337bad04..6e003b1f69 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -916,7 +916,7 @@ public void terminateAllInstances(String clusterId) throws InvalidClusterExcepti List ctxts = dataHolder.getMemberContextsOfClusterId(clusterId); - if(ctxts == null) { + if(ctxts == null || ctxts.isEmpty()) { String msg = "Instance termination failed. No members found for cluster id: "+clusterId; log.warn(msg); return; From 128fe3e08b531f1353102282c0e6f17038902b66 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 28 Oct 2014 21:26:51 +0530 Subject: [PATCH 283/436] sending Cluster Terminated event when the Cluster Monitor is not available/failed --- .../receiver/topology/AutoscalerTopologyEventReceiver.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index bff46c27ca..142338538b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -395,6 +395,11 @@ protected void onEvent(Event event) { } } else { log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); + // if Cluster Monitor is not found, still the Cluster Terminated + // should be sent to update the parent Monitor + StatusEventPublisher.sendClusterTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), + clusterData.getServiceType(), clusterData.getClusterId()); } } From 01315a7455a2a10c24285b605d7db4e5e2cb390c Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 28 Oct 2014 21:28:14 +0530 Subject: [PATCH 284/436] add metadataservice conf to sh --- products/stratos/modules/distribution/src/bin/stratos.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/products/stratos/modules/distribution/src/bin/stratos.sh b/products/stratos/modules/distribution/src/bin/stratos.sh index eda37301d3..a289a87200 100755 --- a/products/stratos/modules/distribution/src/bin/stratos.sh +++ b/products/stratos/modules/distribution/src/bin/stratos.sh @@ -300,6 +300,7 @@ do -Dfile.encoding=UTF8 \ -Ddisable.cassandra.server.startup=true \ -Djndi.properties.dir="$CARBON_HOME/repository/conf" \ + -DMETADATA_CLIENT_CONFIG_FILE="$CARBON_HOME/repository/conf/metadataservice.xml" \ org.wso2.carbon.bootstrap.Bootstrap $* status=$? done From 1b7064daee10880ddfbf5c1a848c0fd0f108fdc0 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 11:33:06 +0530 Subject: [PATCH 285/436] adding flag upon member fault and refactoring statusChecker --- .../grouping/topic/StatusEventPublisher.java | 86 ++++---- .../AutoscalerHealthStatEventReceiver.java | 6 +- .../AutoscalerTopologyEventReceiver.java | 15 +- .../monitor/AbstractClusterMonitor.java | 13 +- .../application/ApplicationMonitor.java | 4 +- .../monitor/cluster/ClusterMonitor.java | 3 +- .../monitor/group/GroupMonitor.java | 4 +- .../status/checker/StatusChecker.java | 188 +++++++++--------- 8 files changed, 155 insertions(+), 164 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 5b09a21322..7bbe8ce5f5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -19,18 +19,16 @@ public class StatusEventPublisher { private static final Log log = LogFactory.getLog(StatusEventPublisher.class); public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Cluster activated event for [application]: " + appId + - " [cluster]: " + clusterId); - } - try { TopologyManager.acquireReadLockForCluster(serviceName, clusterId); Service service = TopologyManager.getTopology().getService(serviceName); if (service != null) { Cluster cluster = service.getCluster(clusterId); if (cluster.isStateTransitionValid(ClusterStatus.Active)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster activated event for [application]: " + appId + + " [cluster]: " + clusterId); + } AppStatusClusterActivatedEvent clusterActivatedEvent = new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); @@ -45,18 +43,16 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S } public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Cluster in-activate event for [application]: " + appId + - " [cluster]: " + clusterId); - } - try { TopologyManager.acquireReadLockForCluster(serviceName, clusterId); Service service = TopologyManager.getTopology().getService(serviceName); if (service != null) { Cluster cluster = service.getCluster(clusterId); if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster in-activate event for [application]: " + appId + + " [cluster]: " + clusterId); + } AppStatusClusterInactivateEvent clusterInActivateEvent = new AppStatusClusterInactivateEvent(appId, serviceName, clusterId); @@ -73,16 +69,16 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster Terminating event for [application]: " + appId + - " [cluster]: " + clusterId); - } try { TopologyManager.acquireReadLockForCluster(serviceName, clusterId); Service service = TopologyManager.getTopology().getService(serviceName); if (service != null) { Cluster cluster = service.getCluster(clusterId); if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster Terminating event for [application]: " + appId + + " [cluster]: " + clusterId); + } AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent = new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId); @@ -99,17 +95,16 @@ public static void sendClusterTerminatingEvent(String appId, String serviceName, } public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Cluster terminated event for [application]: " + appId + - " [cluster]: " + clusterId); - } try { TopologyManager.acquireReadLockForCluster(serviceName, clusterId); Service service = TopologyManager.getTopology().getService(serviceName); if (service != null) { Cluster cluster = service.getCluster(clusterId); if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster terminated event for [application]: " + appId + + " [cluster]: " + clusterId); + } AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent = new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId); @@ -125,18 +120,16 @@ public static void sendClusterTerminatedEvent(String appId, String serviceName, } public static void sendGroupActivatedEvent(String appId, String groupId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Group activated event for [application]: " + appId + - " [group]: " + groupId); - } - try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Active)) { + if (log.isInfoEnabled()) { + log.info("Publishing Group activated event for [application]: " + appId + + " [group]: " + groupId); + } AppStatusGroupActivatedEvent groupActivatedEvent = new AppStatusGroupActivatedEvent(appId, groupId); @@ -151,17 +144,16 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { } public static void sendGroupInActivateEvent(String appId, String groupId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Group in-activate event for [application]: " + appId + - " [group]: " + groupId); - } try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Inactive)) { + if (log.isInfoEnabled()) { + log.info("Publishing Group in-activate event for [application]: " + appId + + " [group]: " + groupId); + } AppStatusGroupInactivateEvent appStatusGroupInactivateEvent = new AppStatusGroupInactivateEvent(appId, groupId); @@ -176,17 +168,16 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { } public static void sendGroupTerminatingEvent(String appId, String groupId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Group terminating event for [application]: " + appId + - " [group]: " + groupId); - } try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Terminating)) { + if (log.isInfoEnabled()) { + log.info("Publishing Group terminating event for [application]: " + appId + + " [group]: " + groupId); + } AppStatusGroupTerminatingEvent groupInTerminatingEvent = new AppStatusGroupTerminatingEvent(appId, groupId); publishEvent(groupInTerminatingEvent); @@ -227,16 +218,14 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { } public static void sendApplicationActivatedEvent(String appId) { - - if (log.isInfoEnabled()) { - log.info("Publishing Application activated event for [application]: " + appId); - } - try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Active)) { + if (log.isInfoEnabled()) { + log.info("Publishing Application activated event for [application]: " + appId); + } AppStatusApplicationActivatedEvent applicationActivatedEvent = new AppStatusApplicationActivatedEvent(appId); @@ -273,15 +262,14 @@ public static void sendApplicationInactivatedEvent(String appId) { } public static void sendApplicationTerminatingEvent(String appId) { - if (log.isInfoEnabled()) { - log.info("Publishing Application terminated event for [application]: " + appId); - } - try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Terminating)) { + if (log.isInfoEnabled()) { + log.info("Publishing Application terminated event for [application]: " + appId); + } AppStatusApplicationTerminatingEvent applicationTerminatingEvent = new AppStatusApplicationTerminatingEvent(appId); publishEvent(applicationTerminatingEvent); @@ -295,14 +283,14 @@ public static void sendApplicationTerminatingEvent(String appId) { } public static void sendApplicationTerminatedEvent(String appId, Set clusterData) { - if (log.isInfoEnabled()) { - log.info("Publishing Application terminated event for [application]: " + appId); - } try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Terminated)) { + if (log.isInfoEnabled()) { + log.info("Publishing Application terminated event for [application]: " + appId); + } AppStatusApplicationTerminatedEvent applicationTerminatedEvent = new AppStatusApplicationTerminatedEvent(appId, clusterData); publishEvent(applicationTerminatedEvent); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index 6986fbb42a..cf072f37be 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -656,15 +656,15 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { } return; } + //Check the clusterStatus as part of the member fault event + StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt); + // terminate the faulty member CloudControllerClient ccClient = CloudControllerClient.getInstance(); ccClient.terminate(memberId); // remove from active member list partitionCtxt.removeActiveMemberById(memberId); - //Check the clusterStatus as part of the member fault event - StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt); - if (log.isInfoEnabled()) { log.info(String.format("Faulty member is terminated and removed from the active members list: [member] %s [partition] %s [cluster] %s ", diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 142338538b..7b411b8a32 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -155,7 +155,9 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(ClusterStatus.Active); + if(clusterMonitor!= null) { + clusterMonitor.setStatus(ClusterStatus.Active); + } } }); @@ -190,7 +192,9 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStatus(ClusterStatus.Inactive); + if(clusterMonitor!= null) { + clusterMonitor.setStatus(ClusterStatus.Inactive); + } } }); @@ -237,9 +241,6 @@ protected void onEvent(Event event) { if (clusterMonitor != null) { clusterMonitor.setStatus(ClusterStatus.Terminated); } - - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); @@ -337,7 +338,9 @@ protected void onEvent(Event event) { String appId = applicationActivatedEvent.getAppId(); ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - appMonitor.setStatus(ApplicationStatus.Active); + if(appMonitor != null) { + appMonitor.setStatus(ApplicationStatus.Active); + } } }); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 0a9d628e53..1461b6ec20 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -65,6 +65,8 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected String serviceId; protected String appId; + protected boolean hasFaultyMember = false; + protected ClusterStatus status; //protected ParentComponentMonitor parent; @@ -228,7 +230,7 @@ public ClusterStatus getStatus() { public void setStatus(ClusterStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", clusterId, this.status, status)); - if(this.status != status) { + //if(this.status != status) { this.status = status; /** * notifying the parent monitor about the state change @@ -241,7 +243,7 @@ public void setStatus(ClusterStatus status) { } else { MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); } - } + //} } @@ -260,4 +262,11 @@ public void onEvent(MonitorScalingEvent scalingEvent) { } + public boolean isHasFaultyMember() { + return hasFaultyMember; + } + + public void setHasFaultyMember(boolean hasFaultyMember) { + this.hasFaultyMember = hasFaultyMember; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 966c8b2c10..a147b354be 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -142,9 +142,9 @@ private Monitor findGroupMonitor(String id, Collection monitors) { public void setStatus(ApplicationStatus status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); - if(this.status != status) { + //if(this.status != status) { this.status = status; - } + //} } @Override diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index a089fc6e09..d67b4f4e8d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -74,7 +74,8 @@ public void run() { while (!isDestroyed()) { try { if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || - (this.status == ClusterStatus.Inactive && !hasDependent)) { + (this.status == ClusterStatus.Inactive && !hasDependent) || + this.hasFaultyMember) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index ab3ef16690..261f7451f1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -140,7 +140,7 @@ public GroupStatus getStatus() { public void setStatus(GroupStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); - if(this.status != status) { + //if(this.status != status) { this.status = status; //notifying the parent if (status == GroupStatus.Inactive && !this.hasDependent) { @@ -149,7 +149,7 @@ public void setStatus(GroupStatus status) { } else { MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); } - } + //} } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index acf6d71072..d2d8b441b6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -54,40 +54,48 @@ public static StatusChecker getInstance() { * * @param clusterId id of the cluster */ - public void onMemberStatusChange(String clusterId) { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterActive = false; - if(monitor != null) { - clusterActive = clusterActive(monitor); + public void onMemberStatusChange(final String clusterId) { + Runnable group = new Runnable() { + public void run() { + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterActive = false; + if (monitor != null) { + clusterActive = clusterActive(monitor); - } - log.info("Status checker running for [cluster] " + clusterId + - " the status [clusterActive] " + clusterActive); - // if active then notify upper layer - if (clusterActive) { - //send event to cluster status topic - StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), - monitor.getServiceId(), monitor.getClusterId()); - } + } + log.info("Status checker running for [cluster] " + clusterId + + " the status [clusterActive] " + clusterActive); + // if active then notify upper layer + if (clusterActive) { + //send event to cluster status topic + StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), + monitor.getServiceId(), monitor.getClusterId()); + } + } + }; + Thread groupThread = new Thread(group); + groupThread.start(); } - public void onMemberTermination(String clusterId) { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); - boolean clusterActive = clusterActive(monitor); - - try { - TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); - Service service = TopologyManager.getTopology().getService(monitor.getServiceId()); - Cluster cluster; - if(service != null) { - cluster = service.getCluster(monitor.getClusterId()); - if(cluster != null) { - if(!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { - StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), - monitor.getClusterId()); - } else { - log.info("Cluster has non terminated [members] and in the [status] " + public void onMemberTermination(final String clusterId) { + Runnable group = new Runnable() { + public void run() { + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); + boolean clusterActive = clusterActive(monitor); + + try { + TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); + Service service = TopologyManager.getTopology().getService(monitor.getServiceId()); + Cluster cluster; + if (service != null) { + cluster = service.getCluster(monitor.getClusterId()); + if (cluster != null) { + if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), + monitor.getClusterId()); + } else { + log.info("Cluster has non terminated [members] and in the [status] " + cluster.getStatus().toString()); /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive || @@ -97,15 +105,19 @@ public void onMemberTermination(String clusterId) { monitor.getServiceId(), clusterId); }*/ + } + } } - } - } - } finally { - TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); + } finally { + TopologyManager.releaseReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); - } + } + } + }; + Thread groupThread = new Thread(group); + groupThread.start(); } @@ -147,21 +159,30 @@ private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { * @param partitionContext is to decide in which partition has less members while others have active members */ public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterInActive = getClusterInActive(monitor, partitionContext); - String appId = monitor.getAppId(); - if (clusterInActive) { - //TODO evaluate life cycle - //send cluster In-Active event to cluster status topic - StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId); + Runnable group = new Runnable() { + public void run() { + ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + boolean clusterInActive = getClusterInActive(monitor, partitionContext); + String appId = monitor.getAppId(); + if (clusterInActive) { + //if the monitor is dependent, temporarily pausing it + if(monitor.isDependent()) { + monitor.setHasFaultyMember(true); + } + //send cluster In-Active event to cluster status topic + StatusEventPublisher.sendClusterInActivateEvent(appId, monitor.getServiceId(), clusterId); + + } else { + boolean clusterActive = clusterActive(monitor); + if (clusterActive) { + StatusEventPublisher.sendClusterActivatedEvent(appId, monitor.getServiceId(), clusterId); + } + } - } else { - boolean clusterActive = clusterActive(monitor); - if (clusterActive) { - //TODO evaluate life cycle - //send clusterActive event to cluster status topic } - } + }; + Thread groupThread = new Thread(group); + groupThread.start(); } private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) { @@ -195,7 +216,7 @@ public void run() { try { TopologyManager.acquireReadLockForApplication(appId); ParentComponent component; - if(groupId.equals(appId)) { + if (groupId.equals(appId)) { //it is an application component = TopologyManager.getTopology(). getApplication(appId); @@ -244,29 +265,6 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("cluster found: " + clusterFound); if (clusterFound || groups.containsKey(id)) { childFound = true; - /*if (!clusterData.isEmpty() && !groups.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("group active found: " + clusterFound); - } - - if (log.isDebugEnabled()) { - log.debug("Active cluster" + clustersActive + " and group: " + groupActive); - } - groupActive = clustersActive == ClusterStatus.Active && groupsActive == GroupStatus.Active; - } else if (!groups.isEmpty()) { - groupsActive = getGroupStatus(groups); - if (log.isDebugEnabled()) { - log.info("group active found: " + clusterFound); - } - groupActive = groupsActive == GroupStatus.Active; - } else if (!clusterData.isEmpty()) { - clustersActive = getClusterStatus(clusterData); - if (log.isDebugEnabled()) { - log.debug("Active cluster" + clustersActive + " and group: " + groupActive); - } - groupActive = clustersActive == ClusterStatus.Active; - } */ - clusterStatus = getClusterStatus(clusterData); groupStatus = getGroupStatus(groups); @@ -286,10 +284,10 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { - //send the in activation event - if (parent instanceof Application) { - //send application activated event - log.warn("Application can't be in in-active : " + appId); + //send the in activation event + if (parent instanceof Application) { + //send application activated event + log.warn("Application can't be in in-active : " + appId); //StatusEventPublisher.sendApplicationInactivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent @@ -299,13 +297,13 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { - //send the terminated event + //send the terminated event if (parent instanceof Application) { //validating the life cycle try { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if(application.getStatus().equals(ApplicationStatus.Terminating)) { + if (application.getStatus().equals(ApplicationStatus.Terminating)) { log.info("sending app terminated: " + appId); StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); } else { @@ -351,33 +349,25 @@ private boolean updateChildStatus(String appId, String id, Map gr } private GroupStatus getGroupStatus(Map groups) { - boolean groupActiveStatus = false; GroupStatus status = null; boolean groupActive = false; boolean groupTerminated = false; for (Group group : groups.values()) { - /*if (group.getTempStatus() == Status.Activated) { - groupActiveStatus = true; - } else { - groupActiveStatus = false; - break; - }*/ - if (group.getStatus() == GroupStatus.Active) { groupActive = true; groupTerminated = false; - } else if(group.getStatus() == GroupStatus.Inactive){ + } else if (group.getStatus() == GroupStatus.Inactive) { status = GroupStatus.Inactive; break; - } else if(group.getStatus() == GroupStatus.Terminated) { + } else if (group.getStatus() == GroupStatus.Terminated) { groupActive = false; groupTerminated = true; - } else if(group.getStatus() == GroupStatus.Created) { + } else if (group.getStatus() == GroupStatus.Created) { groupActive = false; groupTerminated = false; status = GroupStatus.Created; - } else if(group.getStatus() == GroupStatus.Terminating) { + } else if (group.getStatus() == GroupStatus.Terminating) { groupActive = false; groupTerminated = false; status = GroupStatus.Terminating; @@ -385,9 +375,9 @@ private GroupStatus getGroupStatus(Map groups) { } } - if(groupActive) { + if (groupActive) { status = GroupStatus.Active; - } else if(groupTerminated) { + } else if (groupTerminated) { status = GroupStatus.Terminated; } return status; @@ -404,28 +394,28 @@ private ClusterStatus getClusterStatus(Map clusterDat if (cluster.getStatus() == ClusterStatus.Active) { clusterActive = true; clusterTerminated = false; - } else if(cluster.getStatus() == ClusterStatus.Inactive){ + } else if (cluster.getStatus() == ClusterStatus.Inactive) { status = ClusterStatus.Inactive; clusterActive = false; clusterTerminated = false; break; - } else if(cluster.getStatus() == ClusterStatus.Terminated) { + } else if (cluster.getStatus() == ClusterStatus.Terminated) { clusterActive = false; clusterTerminated = true; - } else if(cluster.getStatus() == ClusterStatus.Terminating) { + } else if (cluster.getStatus() == ClusterStatus.Terminating) { status = ClusterStatus.Terminating; clusterActive = false; clusterTerminated = false; - } else if(cluster.getStatus() == ClusterStatus.Created) { + } else if (cluster.getStatus() == ClusterStatus.Created) { status = ClusterStatus.Created; clusterActive = false; clusterTerminated = false; } } - if(clusterActive) { + if (clusterActive) { status = ClusterStatus.Active; - } else if(clusterTerminated) { + } else if (clusterTerminated) { status = ClusterStatus.Terminated; } return status; From d474b13671ccdfc4fdff31d15795dc71f5ad62f9 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 11:51:16 +0530 Subject: [PATCH 286/436] moving force termination to a separate thread --- .../AutoscalerTopologyEventReceiver.java | 14 +++-- .../monitor/cluster/ClusterMonitor.java | 57 +++++++++++++++---- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 7b411b8a32..608100a9a8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -389,12 +389,14 @@ protected void onEvent(Event event) { } else { // if not active, forcefully terminate clusterMonitor.setStatus(ClusterStatus.Terminating); - try { - CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); - } catch (TerminationException e) { - log.error("Unable to terminate instances for [ cluster id ] " + - clusterData.getClusterId(), e); - } + clusterMonitor.terminateAllMembers(); +// try { +// // TODO: introduce a task to do this cleanup +// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); +// } catch (TerminationException e) { +// log.error("Unable to terminate instances for [ cluster id ] " + +// clusterData.getClusterId(), e); +// } } } else { log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index d67b4f4e8d..69dac23988 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -22,7 +22,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; @@ -101,17 +103,52 @@ public void run() { @Override public void terminateAllMembers() { - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - //if (log.isDebugEnabled()) { - log.info("Starting to terminate all members in Network Partition [ " + - networkPartitionContext.getId() + " ], Partition [ " + - partitionContext.getPartitionId() + " ]"); - // } - - terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll - (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); + Thread memberTerminator = new Thread(new Runnable(){ + public void run(){ + + for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + //if (log.isDebugEnabled()) { + log.info("Starting to terminate all members in Network Partition [ " + + networkPartitionContext.getId() + " ], Partition [ " + + partitionContext.getPartitionId() + " ]"); + // } + // need to terminate active, pending and obsolete members + + // active members + for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) { + log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId()); + terminateMember(activeMemberCtxt.getMemberId()); + } + + // pending members + for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { + log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); + terminateMember(pendingMemberCtxt.getMemberId()); + } + + // obsolete members + for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) { + log.info("Terminating obsolete member [member id] " + obsoleteMemberId); + terminateMember(obsoleteMemberId); + } + +// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll +// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); + } + } } + }, "Member Terminator - [cluster id] " + this.clusterId); + + memberTerminator.start(); + } + + private static void terminateMember (String memberId) { + try { + CloudControllerClient.getInstance().terminate(memberId); + + } catch (TerminationException e) { + log.error("Unable to terminate member [member id ] " + memberId, e); } } From ed1af704a37b430f1926a8a39a837935673f2c8f Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 14:23:54 +0530 Subject: [PATCH 287/436] adding correct log message and refactoring --- .../topology/AutoscalerTopologyEventReceiver.java | 4 ++-- .../monitor/application/ApplicationMonitor.java | 2 ++ .../autoscaler/monitor/cluster/ClusterMonitor.java | 2 +- .../stratos/cloud/controller/iaases/AWSEC2Iaas.java | 4 ++-- .../cloud/controller/topology/TopologyBuilder.java | 12 ++++++------ .../processor/topology/GroupInActivateProcessor.java | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 608100a9a8..ac8b6c99a1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -203,7 +203,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ClusterInActivateEvent] Received: " + event.getClass()); + log.info("[ClusterTerminatingEvent] Received: " + event.getClass()); ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; String appId = clusterTerminatingEvent.getAppId(); @@ -229,7 +229,7 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { - log.info("[ClusterInActivateEvent] Received: " + event.getClass()); + log.info("[ClusterTerminatedEvent] Received: " + event.getClass()); ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; String appId = clusterTerminatedEvent.getAppId(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index a147b354be..f6a4d18781 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -25,6 +25,7 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; @@ -144,6 +145,7 @@ public void setStatus(ApplicationStatus status) { "state changes from %s to %s", id, this.status, status)); //if(this.status != status) { this.status = status; + //} } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 69dac23988..b47fb152cb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -77,7 +77,7 @@ public void run() { try { if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || (this.status == ClusterStatus.Inactive && !hasDependent) || - this.hasFaultyMember) { + !this.hasFaultyMember) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java index a637edc7c4..3e46e52334 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/AWSEC2Iaas.java @@ -99,7 +99,7 @@ public void buildTemplate() { templateBuilder.locationId(iaasInfo.getType()); } - if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) { + /*if(iaasInfo.getProperty(CloudControllerConstants.AVAILABILITY_ZONE) != null) { Set locations = iaasInfo.getComputeService().listAssignableLocations(); for(Location location : locations) { if(location.getScope().toString().equalsIgnoreCase(CloudControllerConstants.ZONE_ELEMENT) && @@ -110,7 +110,7 @@ public void buildTemplate() { break; } } - } + }*/ if (iaasInfo.getProperty(CloudControllerConstants.INSTANCE_TYPE) != null) { // set instance type eg: m1.large diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index fac667146b..b6e3470928 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -665,7 +665,7 @@ public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent cl //cluster.setStatus(Status.Activated); cluster.setStatus(ClusterStatus.Active); - log.info("Cluster activated adding status started"); + log.info("Cluster activated adding status started for" + cluster.getClusterId()); TopologyManager.updateTopology(topology); } finally { @@ -703,7 +703,7 @@ public static void handleClusterInActivateEvent( //cluster.setStatus(Status.Activated); cluster.setStatus(ClusterStatus.Inactive); - log.info("Cluster in-active adding status started"); + log.info("Cluster in-active adding status started for " + cluster.getClusterId()); TopologyManager.updateTopology(topology); } finally { @@ -737,7 +737,7 @@ public static void handleGroupActivatedEvent(AppStatusGroupActivatedEvent groupA try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Active); - log.info("Group activated adding status started"); + log.info("Group activated adding status started for " + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { @@ -985,7 +985,7 @@ public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Inactive); - log.info("Group in-active adding status started"); + log.info("Group in-active adding status started for" + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { @@ -1020,7 +1020,7 @@ public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent even try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Terminated); - log.info("Group activated adding status started"); + log.info("Group activated adding status started for" + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { @@ -1054,7 +1054,7 @@ public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent ev try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Terminating); - log.info("Group activated adding status started"); + log.info("Group activated adding status started for " + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java index 094196b057..d5dcd6587e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -95,7 +95,7 @@ private boolean doProcess(GroupInactivateEvent event, Topology topology) { } else { group.setStatus(GroupStatus.Inactive); if (log.isInfoEnabled()) { - log.info(String.format("Group updated as activated : %s", + log.info(String.format("Group updated as in-activated : %s", group.getUniqueIdentifier())); } } From 3b51d5c8f184643b8aa9cc7c6d8855b1f09596b5 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 14:52:22 +0530 Subject: [PATCH 288/436] fixing inActive handling issue --- .../monitor/ParentComponentMonitor.java | 75 ++++++++++--------- .../application/ApplicationMonitor.java | 4 +- .../monitor/group/GroupMonitor.java | 2 +- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 6aa76b64a6..bd50f42d33 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -30,7 +30,6 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; import java.util.HashMap; @@ -115,50 +114,54 @@ protected void onChildTerminatingEvent(String idOfEvent) { protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; - //Temporarily move the group/cluster to inactive list - //this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); - if(this.hasDependent) { + if (this.hasDependent) { //need to notify the parent StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); } else { terminationList = this.dependencyTree.getTerminationDependencies(idOfEvent); - if(this.hasInDependentChild()) { - if(this.parent != null) { + //Checking whether all children are to be terminated. + if (terminationList.size() == + (this.aliasToActiveMonitorsMap.size() + this.aliasToInActiveMonitorsMap.size())) { + if (this.parent != null) { + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, this.id); + } + } else { + //TODO application InActive + if (this.parent != null) { StatusEventPublisher.sendGroupInActivateEvent(this.appId, this.id); - } /*else { - StatusEventPublisher.sendApplicationInactivatedEvent(this.appId, terminationContext.getId()); - - }*/ - - } - - if (terminationList != null) { - //Checking the termination dependents status - for (ApplicationContext terminationContext : terminationList) { - //Check whether dependent is in_active, then start to kill it - monitor = this.aliasToActiveMonitorsMap. - get(terminationContext.getId()); - //start to kill it - if(monitor != null) { - if (monitor.hasActiveMonitors()) { - //it is a group - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); + } + //Since it is reached the most independent unit and has few independent monitors, + // has to put the children down to terminating + + if (terminationList != null) { + //Checking the termination dependents status + for (ApplicationContext terminationContext : terminationList) { + //Check whether dependent is in_active, then start to kill it + monitor = this.aliasToActiveMonitorsMap. + get(terminationContext.getId()); + //start to kill it + if (monitor != null) { + if (monitor.hasActiveMonitors()) { + //it is a group + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); + } else { + StatusEventPublisher.sendClusterTerminatingEvent(this.appId, + ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); + } } else { - StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); - + log.warn("The relevant [monitor] " + terminationContext.getId() + + "is not in the active map...."); } - } else { - log.warn("The relevant [monitor] " + terminationContext.getId() + - "is not in the active map...."); - } + } + } else { + log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" + + " where child is identified as a independent"); } - } else { - log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" - + " where child is identified as a independent"); } + + } } @@ -210,7 +213,7 @@ protected void onChildTerminatedEvent(String idOfEvent) { } } - if((terminationList != null && allDependentTerminated || terminationList == null) && + if ((terminationList != null && allDependentTerminated || terminationList == null) && (parentContexts != null && canStart || parentContexts == null)) { //Find the non existent monitor by traversing dependency tree @@ -249,7 +252,7 @@ public void startDependency() throws TopologyInConsistentException { public void startDependencyOnTermination() throws TopologyInConsistentException { //start the first dependency which went to terminated List applicationContexts = this.dependencyTree. - getStarAbleDependenciesByTermination(); + getStarAbleDependenciesByTermination(); startDependency(applicationContexts); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index f6a4d18781..77def36b72 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -176,9 +176,9 @@ protected void monitor(MonitorStatusEvent statusEvent) { onChildInActiveEvent(id); //TODO update the status of the Application as in_active when child becomes in_active - } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { + /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { onChildTerminatingEvent(id); - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 261f7451f1..e6f8495832 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -88,7 +88,7 @@ protected void monitor(MonitorStatusEvent statusEvent) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - onChildTerminatingEvent(id); + //onChildTerminatingEvent(id); StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { From ff315c990eb33532bcd28eecba32d2b86256991c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 15:13:47 +0530 Subject: [PATCH 289/436] initial parent to child status notification --- .../AutoscalerTopologyEventReceiver.java | 2 +- .../monitor/AbstractClusterMonitor.java | 2 +- .../autoscaler/monitor/EventHandler.java | 11 ++++-- .../monitor/MonitorStatusEventBuilder.java | 8 +++-- .../monitor/ParentComponentMonitor.java | 35 +++++++++++++++++++ .../application/ApplicationMonitor.java | 9 ++--- .../monitor/cluster/ClusterMonitor.java | 7 +++- .../monitor/group/GroupMonitor.java | 9 +++-- 8 files changed, 67 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index ac8b6c99a1..8c2d1a15bc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -470,7 +470,7 @@ protected void onEvent(Event event) { // topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { // @Override -// protected void onEvent(Event event) { +// protected void onChildEvent(Event event) { // // log.info("[ApplicationRemovedEvent] Received: " + event.getClass()); // diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 1461b6ec20..1eda837dca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -248,7 +248,7 @@ public void setStatus(ClusterStatus status) { } @Override - public void onEvent(MonitorStatusEvent statusEvent) { + public void onChildEvent(MonitorStatusEvent statusEvent) { } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java index e4eb816d25..06c722cd27 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/EventHandler.java @@ -27,11 +27,18 @@ */ public interface EventHandler { /** - * Triggered when an event is received. + * Triggered when an event is received from a child. * * @param statusEvent */ - public abstract void onEvent(MonitorStatusEvent statusEvent); + public abstract void onChildEvent(MonitorStatusEvent statusEvent); + + /** + * Triggered when an event is received from the parent. + * + * @param statusEvent + */ + public abstract void onParentEvent(MonitorStatusEvent statusEvent); /** * Triggered when termination decision is made. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index fcb0f06364..30187ea7f6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -50,8 +50,12 @@ public static void handleApplicationStatusEvent(ParentComponentMonitor parent, A } private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEvent statusEvent) { - parent.onEvent(statusEvent); + parent.onChildEvent(statusEvent); } - + public static void notifyChildren (ParentComponentMonitor parent, MonitorStatusEvent statusEvent) { + for (Monitor activeChildMonitor : parent.getAliasToActiveMonitorsMap().values()) { + activeChildMonitor.onParentEvent(statusEvent); + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index bd50f42d33..7ad0a43c05 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -30,6 +30,8 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; import java.util.HashMap; @@ -111,6 +113,39 @@ protected void onChildTerminatingEvent(String idOfEvent) { } } + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + + if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == + ApplicationStatus.Terminating) { + + // parent monitor is in Terminating state. send Terminating event for all monitors + for (Monitor childMonitor : this.getAliasToActiveMonitorsMap().values()) { + if (childMonitor.hasActiveMonitors()) { + // this is a Group Monitor, send Group Terminating + StatusEventPublisher.sendGroupTerminatingEvent(appId, childMonitor.getId()); + markMonitorAsInactive(childMonitor.getId()); + } else { + // this is a Cluster Monitor, send Cluster Terminating + StatusEventPublisher.sendClusterTerminatingEvent(appId, + ((AbstractClusterMonitor) childMonitor).getServiceId(), + ((AbstractClusterMonitor) childMonitor).getClusterId()); + markMonitorAsInactive(((AbstractClusterMonitor) childMonitor).getClusterId()); + } + + } + } + } + + // move to inactive monitors list to use in the Terminated event + private synchronized void markMonitorAsInactive (String monitorKey) { + + if (!this.aliasToInActiveMonitorsMap.containsKey(monitorKey)) { + this.aliasToInActiveMonitorsMap.put(monitorKey, + this.aliasToActiveMonitorsMap.remove(monitorKey)); + } + } + protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 77def36b72..337a5c5c66 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -27,6 +27,7 @@ import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; +import org.apache.stratos.autoscaler.monitor.events.ApplicationStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; @@ -143,14 +144,14 @@ private Monitor findGroupMonitor(String id, Collection monitors) { public void setStatus(ApplicationStatus status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); - //if(this.status != status) { - this.status = status; - //} + this.status = status; + //notify the children about the state change + MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId)); } @Override - public void onEvent(MonitorStatusEvent statusEvent) { + public void onChildEvent(MonitorStatusEvent statusEvent) { monitor(statusEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index b47fb152cb..b9f6cbf8bd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -275,7 +275,12 @@ public void setHasPrimary(boolean hasPrimary) { } @Override - public void onEvent(MonitorStatusEvent statusEvent) { + public void onChildEvent(MonitorStatusEvent statusEvent) { } + + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + // doesn't have to do anything since this is not a Parent Monitor + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index e6f8495832..2fe5ae7ccc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -25,9 +25,7 @@ import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; +import org.apache.stratos.autoscaler.monitor.events.*; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Group; @@ -59,7 +57,7 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException } @Override - public void onEvent(MonitorStatusEvent statusEvent) { + public void onChildEvent(MonitorStatusEvent statusEvent) { monitor(statusEvent); } @@ -150,6 +148,7 @@ public void setStatus(GroupStatus status) { MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); } //} - + //notify the children about the state change + MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId())); } } From fcd8a7ca407a5653d7a0a4fbae2a1958e214873b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 15:20:58 +0530 Subject: [PATCH 290/436] fix compilation failure --- .../stratos/autoscaler/monitor/cluster/LbClusterMonitor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java index cc21205cdb..6697d7356f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java @@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.topology.ClusterStatus; @@ -121,4 +122,8 @@ public String toString() { } + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + + } } From 062cd7b404e2b4c506de72399b487a85855786f4 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 15:32:45 +0530 Subject: [PATCH 291/436] fixing issue when terminating the cluster --- .../topic/InstanceNotificationPublisher.java | 11 + .../AutoscalerTopologyEventReceiver.java | 16 +- .../monitor/ParentComponentMonitor.java | 312 ++---------------- 3 files changed, 45 insertions(+), 294 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java index d745d79123..80fa295b99 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java @@ -25,6 +25,7 @@ import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupClusterEvent; +import org.apache.stratos.messaging.event.instance.notifier.InstanceCleanupMemberEvent; import org.apache.stratos.messaging.util.Constants; public class InstanceNotificationPublisher { @@ -39,4 +40,14 @@ public static void sendInstanceCleanupEventForCluster(String clusterId) { log.info(String.format("Publishing Instance Cleanup Event: [cluster] %s", clusterId)); publish(new InstanceCleanupClusterEvent(clusterId)); } + + /** + * 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)); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 8c2d1a15bc..d66795c182 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -206,22 +206,24 @@ protected void onEvent(Event event) { log.info("[ClusterTerminatingEvent] Received: " + event.getClass()); ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; - String appId = clusterTerminatingEvent.getAppId(); String clusterId = clusterTerminatingEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor if (clusterMonitor != null) { - clusterMonitor.setDestroyed(true); - clusterMonitor.terminateAllMembers(); - clusterMonitor.setStatus(ClusterStatus.Terminating); + if (clusterMonitor.getStatus() == ClusterStatus.Active) { + // terminated gracefully + clusterMonitor.setStatus(ClusterStatus.Terminating); + InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId); + } else { + clusterMonitor.setStatus(ClusterStatus.Terminating); + clusterMonitor.terminateAllMembers(); + } + } else { log.warn("No Cluster Monitor found for cluster id " + clusterId); } - - //starting the status checker to decide on the status of it's parent - //StatusChecker.getInstance().onClusterStatusChange(clusterId, appId); } }); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 7ad0a43c05..f6857f7502 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -44,12 +44,8 @@ public abstract class ParentComponentMonitor extends Monitor { private static final Log log = LogFactory.getLog(ParentComponentMonitor.class); - //id of the monitor, it can be alias or the id - //protected String id; - //The monitors dependency tree with all the startable/killable dependencies + //The monitors dependency tree with all the start-able/kill-able dependencies protected DependencyTree dependencyTree; - //Application id of this particular monitor - //protected String appId; public ParentComponentMonitor(ParentComponent component) throws DependencyBuilderException { aliasToActiveMonitorsMap = new HashMap(); @@ -68,6 +64,11 @@ public ParentComponentMonitor(ParentComponent component) throws DependencyBuilde protected abstract void monitor(MonitorStatusEvent statusEvent); + /** + * This will start the child monitors based on the active of siblings according to start up order + * + * @param idOfEvent parent id of the event which received + */ protected void onChildActivatedEvent(String idOfEvent) { try { //if the activated monitor is in in_active map move it to active map @@ -89,7 +90,7 @@ protected void onChildActivatedEvent(String idOfEvent) { } - protected void onChildTerminatingEvent(String idOfEvent) { + /*protected void onChildTerminatingEvent(String idOfEvent) { //Check whether hasDependent true if (!this.aliasToInActiveMonitorsMap.containsKey(idOfEvent)) { this.aliasToInActiveMonitorsMap.put(idOfEvent, this.aliasToActiveMonitorsMap.remove(idOfEvent)); @@ -111,7 +112,7 @@ protected void onChildTerminatingEvent(String idOfEvent) { } else { log.warn("Inactive Monitor not found for the id " + idOfEvent); } - } + }*/ @Override public void onParentEvent(MonitorStatusEvent statusEvent) { @@ -146,6 +147,10 @@ private synchronized void markMonitorAsInactive (String monitorKey) { } } + /** + * + * @param idOfEvent + */ protected void onChildInActiveEvent(String idOfEvent) { List terminationList; Monitor monitor; @@ -179,10 +184,12 @@ protected void onChildInActiveEvent(String idOfEvent) { if (monitor != null) { if (monitor.hasActiveMonitors()) { //it is a group - StatusEventPublisher.sendGroupTerminatingEvent(this.appId, terminationContext.getId()); + StatusEventPublisher.sendGroupTerminatingEvent(this.appId, + terminationContext.getId()); } else { StatusEventPublisher.sendClusterTerminatingEvent(this.appId, - ((AbstractClusterMonitor) monitor).getServiceId(), terminationContext.getId()); + ((AbstractClusterMonitor) monitor).getServiceId(), + terminationContext.getId()); } } else { log.warn("The relevant [monitor] " + terminationContext.getId() + @@ -191,8 +198,8 @@ protected void onChildInActiveEvent(String idOfEvent) { } } else { - log.warn("Wrong inActive event received from [Child] " + idOfEvent + " to the [parent]" - + " where child is identified as a independent"); + log.warn("Wrong inActive event received from [Child] " + idOfEvent + + " to the [parent]" + " where child is identified as a independent"); } } @@ -216,13 +223,14 @@ protected void onChildTerminatedEvent(String idOfEvent) { */ if (terminationList != null) { for (ApplicationContext context1 : terminationList) { - if (!this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - allDependentTerminated = false; - } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); allDependentTerminated = false; - } else { + } else if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated..."); + allDependentTerminated = false; + } else { + allDependentTerminated = true; } } } @@ -251,11 +259,11 @@ protected void onChildTerminatedEvent(String idOfEvent) { if ((terminationList != null && allDependentTerminated || terminationList == null) && (parentContexts != null && canStart || parentContexts == null)) { //Find the non existent monitor by traversing dependency tree - try { this.startDependencyOnTermination(); } catch (TopologyInConsistentException e) { - e.printStackTrace(); + //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription + log.error("Error while starting the monitor upon termination" + e); } } else { StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); @@ -428,274 +436,4 @@ public void run() { } } } - - - /*protected synchronized void startGroupMonitor(ParentComponentMonitor parent, GroupContext groupContext) { - Thread th = null; - //String groupId = group.getUniqueIdentifier(); - if (!this.aliasToActiveMonitorsMap.containsKey(groupId)) { - if (log.isDebugEnabled()) { - log.debug(String - .format("Group monitor Adder has been added: [group] %s ", - groupId)); - } - th = new Thread( - new GroupMonitorAdder(parent, groupId, this.appId)); - } - - if (th != null) { - th.start(); - *//*try { - th.join(); - } catch (InterruptedException ignore) { - }*//* - - log.info(String - .format("Group monitor thread has been started successfully: [group] %s ", - groupId)); - } - } -*/ - - /*private Group getGroupFromTopology(String groupId) throws TopologyInConsistentException { - Application application = TopologyManager.getTopology().getApplication(this.appId); - if(application != null) { - Group group = application.getGroupRecursively(groupId); - if(group != null) { - return group; - } else { - String msg = "[Group] " + groupId + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - } - } else { - String msg = "[Application] " + this.appId + " cannot be found in the Topology"; - throw new TopologyInConsistentException(msg); - } - }*/ - - /*protected synchronized void startClusterMonitor(ParentComponentMonitor parent, ApplicationContext clusterContext) { - Thread th = null; - if (!this.aliasToActiveMonitorsMap.containsKey(clusterContext.getId())) { - th = new Thread( - new ClusterMonitorAdder(parent, clusterContext)); - if (log.isDebugEnabled()) { - log.debug(String - .format("Cluster monitor Adder has been added: [cluster] %s ", - clusterContext.getClusterId())); - } - } - if (th != null) { - th.start(); - log.info(String - .format("Cluster monitor thread has been started successfully: [cluster] %s ", - clusterContext.getClusterId())); - } - }*/ - - - /*public Map getClusterIdToClusterMonitorsMap() { - return clusterIdToClusterMonitorsMap; - } - - public void setClusterIdToClusterMonitorsMap(Map clusterIdToClusterMonitorsMap) { - this.clusterIdToClusterMonitorsMap = clusterIdToClusterMonitorsMap; - } - - public void addAbstractMonitor(AbstractClusterMonitor monitor) { - this.clusterIdToClusterMonitorsMap.put(monitor.getClusterId(), monitor); - } - - public AbstractClusterMonitor getAbstractMonitor(String clusterId) { - return this.clusterIdToClusterMonitorsMap.get(clusterId); - } -*/ - - - /*private class ClusterMonitorAdder implements Runnable { - private Cluster cluster; - private ParentComponentMonitor parent; - - public ClusterMonitorAdder(ParentComponentMonitor parent, Cluster cluster) { - this.parent = parent; - this.cluster = cluster; - } - - public void run() { - ClusterMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - if (log.isDebugEnabled()) { - log.debug("CLuster monitor is going to be started for [cluster] " - + cluster.getClusterId()); - } - monitor = AutoscalerUtil.getClusterMonitor(cluster); - monitor.setParent(parent); - //setting the status of cluster monitor w.r.t Topology cluster - //if(cluster.getStatus() != Status.Created && - if(cluster.getStatus() != monitor.getStatus()) { - //updating the status, so that it will notify the parent - monitor.setStatus(cluster.getStatus()); - } - //monitor.addObserver(parent); - success = true; - //TODO start the status checker - } catch (PolicyValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - - } catch (PartitionValidationException e) { - String msg = "Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - } - - } while (!success && retries != 0); - - - if (monitor == null) { - String msg = "Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); - log.error(msg); - //TODO parent.notify(); - throw new RuntimeException(msg); - } - - Thread th = new Thread(monitor); - th.start(); - - AutoscalerContext.getInstance().addMonitor(monitor); - aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor); - if (log.isInfoEnabled()) { - log.info(String.format("Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); - } - } - } -*/ - - - /*private class GroupMonitorAdder implements Runnable { - private ParentComponentMonitor parent; - private String groupId; - private String appId; - - public GroupMonitorAdder(ParentComponentMonitor parent, String groupId, String appId) { - this.parent = parent; - this.groupId = groupId; - this.appId = appId; - } - - public void run() { - GroupMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - - try { - if (log.isDebugEnabled()) { - log.debug("Group monitor is going to be started for [group] " - + groupId ); - } - monitor = AutoscalerUtil.getGroupMonitor(groupId, appId); - //setting the parent monitor - monitor.setParent(parent); - //setting the status of cluster monitor w.r.t Topology cluster - //if(group.getStatus() != Status.Created && - - //monitor.addObserver(parent); - success = true; - } catch (DependencyBuilderException e) { - String msg = "Group monitor creation failed for group: " + groupId; - log.warn(msg, e); - retries--; - } catch (TopologyInConsistentException e) { - String msg = "Group monitor creation failed for group: " + groupId; - log.warn(msg, e); - retries--; - } - } while (!success && retries != 0); - - if (monitor == null) { - String msg = "Group monitor creation failed, even after retrying for 5 times, " - + "for group: " + groupId; - log.error(msg); - //TODO parent.notify(); as it got to failed - - throw new RuntimeException(msg); - } - - aliasToActiveMonitorsMap.put(groupId, monitor); - //parent.addObserver(monitor); - - if (log.isInfoEnabled()) { - log.info(String.format("Group monitor has been added successfully: [group] %s", - groupId)); - } - } - } - - private class LBClusterMonitorAdder implements Runnable { - private Cluster cluster; - - public LBClusterMonitorAdder(Cluster cluster) { - this.cluster = cluster; - } - - public void run() { - LbClusterMonitor monitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - monitor = AutoscalerUtil.getLBClusterMonitor(cluster); - success = true; - - } catch (PolicyValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - - } catch (PartitionValidationException e) { - String msg = "LB Cluster monitor creation failed for cluster: " + cluster.getClusterId(); - log.warn(msg, e); - retries--; - } - } while (!success && retries <= 0); - - if (monitor == null) { - String msg = "LB Cluster monitor creation failed, even after retrying for 5 times, " - + "for cluster: " + cluster.getClusterId(); - log.error(msg); - throw new RuntimeException(msg); - } - - Thread th = new Thread(monitor); - th.start(); - AutoscalerContext.getInstance().addLbMonitor(monitor); - aliasToActiveMonitorsMap.put(cluster.getClusterId(), monitor); - if (log.isInfoEnabled()) { - log.info(String.format("LB Cluster monitor has been added successfully: [cluster] %s", - cluster.getClusterId())); - } - } - }*/ - - } From 55e3eff1fb0a8a341c1adc0f9122aaad33be0756 Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 15:40:54 +0530 Subject: [PATCH 292/436] refatcoring the monitors --- .../monitor/ParentComponentMonitor.java | 10 +--- .../application/ApplicationMonitor.java | 41 +++++++--------- .../monitor/group/GroupMonitor.java | 47 +++++++++---------- 3 files changed, 41 insertions(+), 57 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index f6857f7502..298516cd99 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -55,15 +55,7 @@ public ParentComponentMonitor(ParentComponent component) throws DependencyBuilde //Building the dependency for this monitor within the immediate children dependencyTree = DependencyBuilder.getInstance().buildDependency(component); } - - /** - * Will monitor the immediate children upon any event triggers from parent/children - * - * @param statusEvent will be sent by parent/children with the current status - */ - protected abstract void monitor(MonitorStatusEvent statusEvent); - - + /** * This will start the child monitors based on the active of siblings according to start up order * diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 337a5c5c66..35f4a702f8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; @@ -32,11 +31,13 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.*; +import java.util.Collection; /** * ApplicationMonitor is to control the child monitors @@ -107,7 +108,7 @@ public AbstractClusterMonitor findClusterMonitorWithId(String clusterId) { public Monitor findGroupMonitorWithId(String groupId) { Monitor monitor; monitor = findGroupMonitor(groupId, aliasToActiveMonitorsMap.values()); - if(monitor == null) { + if (monitor == null) { monitor = findGroupMonitor(groupId, aliasToInActiveMonitorsMap.values()); } return monitor; @@ -145,28 +146,13 @@ public void setStatus(ApplicationStatus status) { log.info(String.format("[ApplicationMonitor] %s " + "state changes from %s to %s", id, this.status, status)); - this.status = status; - //notify the children about the state change - MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId)); + this.status = status; + //notify the children about the state change + MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId)); } @Override public void onChildEvent(MonitorStatusEvent statusEvent) { - monitor(statusEvent); - } - - @Override - public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { - - } - - @Override - public void onEvent(MonitorScalingEvent scalingEvent) { - - } - - @Override - protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); LifeCycleState status1 = statusEvent.getStatus(); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination @@ -191,6 +177,15 @@ protected void monitor(MonitorStatusEvent statusEvent) { log.info("Executing the un-subscription request for the [monitor] " + id); } } + } + + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 2fe5ae7ccc..64cc28c848 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -25,7 +25,10 @@ import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; -import org.apache.stratos.autoscaler.monitor.events.*; +import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Group; @@ -58,22 +61,6 @@ public GroupMonitor(Group group, String appId) throws DependencyBuilderException @Override public void onChildEvent(MonitorStatusEvent statusEvent) { - monitor(statusEvent); - } - - @Override - public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { - this.terminateChildren = true; - - } - - @Override - public void onEvent(MonitorScalingEvent scalingEvent) { - - } - - @Override - protected void monitor(MonitorStatusEvent statusEvent) { String id = statusEvent.getId(); LifeCycleState status1 = statusEvent.getStatus(); //Events coming from parent are In_Active(in faulty detection), Scaling events, termination @@ -99,6 +86,16 @@ protected void monitor(MonitorStatusEvent statusEvent) { log.info("Executing the un-subscription request for the [monitor] " + id); } } + } + + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + this.terminateChildren = true; + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { } @@ -139,14 +136,14 @@ public void setStatus(GroupStatus status) { log.info(String.format("[Monitor] %s is notifying the parent" + "on its state change from %s to %s", id, this.status, status)); //if(this.status != status) { - this.status = status; - //notifying the parent - if (status == GroupStatus.Inactive && !this.hasDependent) { - log.info("[Group] " + this.id + "is not notifying the parent, " + - "since it is identified as the independent unit"); - } else { - MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); - } + this.status = status; + //notifying the parent + if (status == GroupStatus.Inactive && !this.hasDependent) { + log.info("[Group] " + this.id + "is not notifying the parent, " + + "since it is identified as the independent unit"); + } else { + MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); + } //} //notify the children about the state change MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId())); From 6fbb9525bd5555a2589fb7475c1e99aa98af38a7 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 15:42:06 +0530 Subject: [PATCH 293/436] refactoring current undeployment logic in Autoscaler --- .../AutoscalerTopologyEventReceiver.java | 171 ++++++++++-------- 1 file changed, 93 insertions(+), 78 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index d66795c182..c8663395a1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -354,87 +354,102 @@ protected void onEvent(Event event) { ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; - // acquire reead locks for application and relevant clusters - TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); - Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), - clusterData.getClusterId()); - } - } - - try { - ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). - getAppMonitor(applicationUndeployedEvent.getApplicationId()); - - if (appMonitor != null) { - // update the status as Terminating - appMonitor.setStatus(ApplicationStatus.Terminating); + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationUndeployedEvent.getApplicationId()); -// List clusters = appMonitor. -// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); + if (appMonitor != null) { + // set Application Monitor state to 'Terminating' + appMonitor.setStatus(ApplicationStatus.Terminating); - boolean clusterMonitorsFound = false; - for (ClusterDataHolder clusterData : clusterDataHolders) { - //stopping the cluster monitor and remove it from the AS - ClusterMonitor clusterMonitor = - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); - if (clusterMonitor != null) { - clusterMonitorsFound = true; - clusterMonitor.setDestroyed(true); - //clusterMonitor.terminateAllMembers(); - if (clusterMonitor.getStatus() == ClusterStatus.Active) { - // terminated gracefully - clusterMonitor.setStatus(ClusterStatus.Terminating); - InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId()); - } else { - // if not active, forcefully terminate - clusterMonitor.setStatus(ClusterStatus.Terminating); - clusterMonitor.terminateAllMembers(); -// try { -// // TODO: introduce a task to do this cleanup -// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); -// } catch (TerminationException e) { -// log.error("Unable to terminate instances for [ cluster id ] " + -// clusterData.getClusterId(), e); -// } - } - } else { - log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); - // if Cluster Monitor is not found, still the Cluster Terminated - // should be sent to update the parent Monitor - StatusEventPublisher.sendClusterTerminatedEvent( - applicationUndeployedEvent.getApplicationId(), - clusterData.getServiceType(), clusterData.getClusterId()); - } - } - - // if by any chance, the cluster monitors have failed, we still need to undeploy this application - // hence, check if the Cluster Monitors are not found and send the Application Terminated event - if (!clusterMonitorsFound) { - StatusEventPublisher.sendApplicationTerminatedEvent( - applicationUndeployedEvent.getApplicationId(), clusterDataHolders); - } - - } else { - log.warn("Application Monitor cannot be found for the undeployed [application] " - + applicationUndeployedEvent.getApplicationId()); - // send the App Terminated event to cleanup - StatusEventPublisher.sendApplicationTerminatedEvent( - applicationUndeployedEvent.getApplicationId(), clusterDataHolders); - } - - } finally { - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), - clusterData.getClusterId()); - } - } - TopologyManager. - releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); + } else { + // ApplicationMonitor is not found, send Terminating event to clean up + StatusEventPublisher.sendApplicationTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData()); } + +// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; +// +// // acquire reead locks for application and relevant clusters +// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// +// try { +// ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). +// getAppMonitor(applicationUndeployedEvent.getApplicationId()); +// +// if (appMonitor != null) { +// // update the status as Terminating +// appMonitor.setStatus(ApplicationStatus.Terminating); +// +//// List clusters = appMonitor. +//// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); +// +// boolean clusterMonitorsFound = false; +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// //stopping the cluster monitor and remove it from the AS +// ClusterMonitor clusterMonitor = +// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); +// if (clusterMonitor != null) { +// clusterMonitorsFound = true; +// clusterMonitor.setDestroyed(true); +// //clusterMonitor.terminateAllMembers(); +// if (clusterMonitor.getStatus() == ClusterStatus.Active) { +// // terminated gracefully +// clusterMonitor.setStatus(ClusterStatus.Terminating); +// InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId()); +// } else { +// // if not active, forcefully terminate +// clusterMonitor.setStatus(ClusterStatus.Terminating); +// clusterMonitor.terminateAllMembers(); +//// try { +//// // TODO: introduce a task to do this cleanup +//// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); +//// } catch (TerminationException e) { +//// log.error("Unable to terminate instances for [ cluster id ] " + +//// clusterData.getClusterId(), e); +//// } +// } +// } else { +// log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); +// // if Cluster Monitor is not found, still the Cluster Terminated +// // should be sent to update the parent Monitor +// StatusEventPublisher.sendClusterTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), +// clusterData.getServiceType(), clusterData.getClusterId()); +// } +// } +// +// // if by any chance, the cluster monitors have failed, we still need to undeploy this application +// // hence, check if the Cluster Monitors are not found and send the Application Terminated event +// if (!clusterMonitorsFound) { +// StatusEventPublisher.sendApplicationTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); +// } +// +// } else { +// log.warn("Application Monitor cannot be found for the undeployed [application] " +// + applicationUndeployedEvent.getApplicationId()); +// // send the App Terminated event to cleanup +// StatusEventPublisher.sendApplicationTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); +// } +// +// } finally { +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// TopologyManager. +// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// } } }); From caa6f1b155ba103664f889e17a5f56f5f8f916f5 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 16:11:39 +0530 Subject: [PATCH 294/436] fixing a NPE is ApplicationMonitor --- .../autoscaler/monitor/application/ApplicationMonitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 35f4a702f8..dc53403af4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -148,7 +148,7 @@ public void setStatus(ApplicationStatus status) { this.status = status; //notify the children about the state change - MonitorStatusEventBuilder.notifyChildren(this.parent, new ApplicationStatusEvent(status, appId)); + MonitorStatusEventBuilder.notifyChildren(this, new ApplicationStatusEvent(status, appId)); } @Override From e2994c4ff22053162922fb9cba0415b55fb5b04d Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 16:23:22 +0530 Subject: [PATCH 295/436] implementing onParentEvent method in ClusterMonitor --- .../autoscaler/monitor/cluster/ClusterMonitor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index b9f6cbf8bd..6d7e8caca0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -25,6 +25,7 @@ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.TerminationException; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; @@ -32,7 +33,9 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import java.util.ArrayList; import java.util.List; @@ -281,6 +284,10 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { @Override public void onParentEvent(MonitorStatusEvent statusEvent) { - // doesn't have to do anything since this is not a Parent Monitor + // send the ClusterTerminating event + if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == + ApplicationStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); + } } } From 3c43277e73f2ab096a65f944d90d9e101c8c4e14 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 17:27:57 +0530 Subject: [PATCH 296/436] correcting an issue in notify child logic --- .../monitor/ParentComponentMonitor.java | 24 ------------------- .../application/ApplicationMonitor.java | 5 ++++ .../monitor/group/GroupMonitor.java | 11 +++++++++ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 298516cd99..fa8f425f86 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -106,30 +106,6 @@ protected void onChildActivatedEvent(String idOfEvent) { } }*/ - @Override - public void onParentEvent(MonitorStatusEvent statusEvent) { - - if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == - ApplicationStatus.Terminating) { - - // parent monitor is in Terminating state. send Terminating event for all monitors - for (Monitor childMonitor : this.getAliasToActiveMonitorsMap().values()) { - if (childMonitor.hasActiveMonitors()) { - // this is a Group Monitor, send Group Terminating - StatusEventPublisher.sendGroupTerminatingEvent(appId, childMonitor.getId()); - markMonitorAsInactive(childMonitor.getId()); - } else { - // this is a Cluster Monitor, send Cluster Terminating - StatusEventPublisher.sendClusterTerminatingEvent(appId, - ((AbstractClusterMonitor) childMonitor).getServiceId(), - ((AbstractClusterMonitor) childMonitor).getClusterId()); - markMonitorAsInactive(((AbstractClusterMonitor) childMonitor).getClusterId()); - } - - } - } - } - // move to inactive monitors list to use in the Terminated event private synchronized void markMonitorAsInactive (String monitorKey) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index dc53403af4..1ec7399b21 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -179,6 +179,11 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } } + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + // nothing to do + } + @Override public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 64cc28c848..9b9695a2b4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; @@ -30,6 +31,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Group; import org.apache.stratos.messaging.domain.topology.GroupStatus; @@ -88,6 +90,15 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } } + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + // send the ClusterTerminating event + if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == + ApplicationStatus.Terminating) { + StatusEventPublisher.sendGroupTerminatingEvent(appId, id); + } + } + @Override public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { this.terminateChildren = true; From b51b0b793961bd9b3784a996730225a05988bd8f Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 17:29:41 +0530 Subject: [PATCH 297/436] fixing the logic which decides cluster inActive --- .../health/AutoscalerHealthStatEventReceiver.java | 3 ++- .../monitor/application/ApplicationMonitor.java | 2 +- .../autoscaler/monitor/group/GroupMonitor.java | 2 +- .../autoscaler/status/checker/StatusChecker.java | 12 ++++++------ 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index cf072f37be..f192cee767 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -656,8 +656,9 @@ private void handleMemberFaultEvent(String clusterId, String memberId) { } return; } + //Check the clusterStatus as part of the member fault event - StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionCtxt); + StatusChecker.getInstance().onMemberFaultEvent(clusterId, partitionId); // terminate the faulty member CloudControllerClient ccClient = CloudControllerClient.getInstance(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 1ec7399b21..2bf85a62e0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -170,7 +170,7 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != ApplicationStatus.Terminating) { + if (this.status != ApplicationStatus.Terminating || this.status != ApplicationStatus.Terminated) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 9b9695a2b4..55f3b4e647 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -81,7 +81,7 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. this.aliasToInActiveMonitorsMap.remove(id); - if (this.status != GroupStatus.Terminating) { + if (this.status != GroupStatus.Terminating || this.status != GroupStatus.Terminated) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index d2d8b441b6..3a925d1b8b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -156,13 +156,13 @@ private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { /** * @param clusterId - * @param partitionContext is to decide in which partition has less members while others have active members + * @param partitionId is to decide in which partition has less members while others have active members */ - public void onMemberFaultEvent(final String clusterId, final PartitionContext partitionContext) { + public void onMemberFaultEvent(final String clusterId, final String partitionId) { Runnable group = new Runnable() { public void run() { ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - boolean clusterInActive = getClusterInActive(monitor, partitionContext); + boolean clusterInActive = getClusterInActive(monitor, partitionId); String appId = monitor.getAppId(); if (clusterInActive) { //if the monitor is dependent, temporarily pausing it @@ -185,12 +185,12 @@ public void run() { groupThread.start(); } - private boolean getClusterInActive(AbstractClusterMonitor monitor, PartitionContext partitionContext) { + private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) { boolean clusterInActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { - if (partitionContext.getPartitionId().equals(partition.getPartitionId()) && - partition.getActiveMemberCount() < partition.getMinimumMemberCount()) { + if (partitionId.equals(partition.getPartitionId()) && + partition.getActiveMemberCount() <= partition.getMinimumMemberCount()) { clusterInActive = true; return clusterInActive; } From 08d68656f4b81704996761dc4615973f901bfcbc Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 17:53:05 +0530 Subject: [PATCH 298/436] stopping notifying parent in Cluster Monitor and Group Monitor if its in Terminating state --- .../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 6 ++++++ .../stratos/autoscaler/monitor/group/GroupMonitor.java | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 1eda837dca..da4cba8af2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -240,6 +240,12 @@ public void setStatus(ClusterStatus status) { if (status == ClusterStatus.Inactive && !this.hasDependent) { log.info("[Cluster] " + clusterId + "is not notifying the parent, " + "since it is identified as the independent unit"); + + } else if (status == ClusterStatus.Terminating) { + // notify parent + log.info("[Cluster] " + clusterId + " is not notifying the parent, " + + "since it is in Terminating State"); + } else { MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 55f3b4e647..0f213a953e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -152,7 +152,13 @@ public void setStatus(GroupStatus status) { if (status == GroupStatus.Inactive && !this.hasDependent) { log.info("[Group] " + this.id + "is not notifying the parent, " + "since it is identified as the independent unit"); + + } else if (status == GroupStatus.Terminating) { + log.info("[Group] " + this.id + " is not notifying the parent, " + + "since it is in Terminating State"); + } else { + // notify parent MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); } //} From 5196529d41c0b56c3c362f5f547191e4ba237129 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 18:22:26 +0530 Subject: [PATCH 299/436] fixing a concurrent modification issue in PartitionContext --- .../org/apache/stratos/autoscaler/PartitionContext.java | 6 +++--- .../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 3 +-- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java index 613aa4fedc..d0886a3261 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java @@ -88,9 +88,9 @@ public PartitionContext(Partition partition) { this.setPartition(partition); this.minimumMemberCount = partition.getPartitionMin(); this.partitionId = partition.getId(); - this.pendingMembers = new ArrayList(); - this.activeMembers = new ArrayList(); - this.terminationPendingMembers = new ArrayList(); + this.pendingMembers = new CopyOnWriteArrayList(); + this.activeMembers = new CopyOnWriteArrayList(); + this.terminationPendingMembers = new CopyOnWriteArrayList(); this.obsoletedMembers = new CopyOnWriteArrayList(); memberStatsContexts = new ConcurrentHashMap(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index da4cba8af2..fb23985930 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -228,8 +228,7 @@ public ClusterStatus getStatus() { } public void setStatus(ClusterStatus status) { - log.info(String.format("[Monitor] %s is notifying the parent" + - "on its state change from %s to %s", clusterId, this.status, status)); + //if(this.status != status) { this.status = status; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 0f213a953e..b42e840009 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -144,8 +144,7 @@ public GroupStatus getStatus() { * @param status */ public void setStatus(GroupStatus status) { - log.info(String.format("[Monitor] %s is notifying the parent" + - "on its state change from %s to %s", id, this.status, status)); + //if(this.status != status) { this.status = status; //notifying the parent From 5e69c7fe6d5eb00c64e7bc7c4159859632b7fd0a Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 18:23:04 +0530 Subject: [PATCH 300/436] fixing recursive call when terminating cluster/group --- .../stratos/autoscaler/monitor/MonitorStatusEventBuilder.java | 4 ++-- .../apache/stratos/autoscaler/monitor/group/GroupMonitor.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index 30187ea7f6..59bb4c0fab 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -53,8 +53,8 @@ private static void notifyParent(ParentComponentMonitor parent, MonitorStatusEve parent.onChildEvent(statusEvent); } - public static void notifyChildren (ParentComponentMonitor parent, MonitorStatusEvent statusEvent) { - for (Monitor activeChildMonitor : parent.getAliasToActiveMonitorsMap().values()) { + public static void notifyChildren (ParentComponentMonitor componentMonitor, MonitorStatusEvent statusEvent) { + for (Monitor activeChildMonitor : componentMonitor.getAliasToActiveMonitorsMap().values()) { activeChildMonitor.onParentEvent(statusEvent); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index b42e840009..b1b7882d70 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -162,6 +162,6 @@ public void setStatus(GroupStatus status) { } //} //notify the children about the state change - MonitorStatusEventBuilder.notifyChildren(this.parent, new GroupStatusEvent(status, getId())); + MonitorStatusEventBuilder.notifyChildren(this, new GroupStatusEvent(status, getId())); } } From f959b108a447bd61471b91ca682684d8f24d4554 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 20:46:42 +0530 Subject: [PATCH 301/436] making ArrayLists in PartitionContext synchronised --- .../stratos/autoscaler/PartitionContext.java | 119 +++++++++--------- .../AutoscalerTopologyEventReceiver.java | 15 +++ 2 files changed, 76 insertions(+), 58 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java index d0886a3261..467bbc28ee 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/PartitionContext.java @@ -26,13 +26,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -88,9 +82,10 @@ public PartitionContext(Partition partition) { this.setPartition(partition); this.minimumMemberCount = partition.getPartitionMin(); this.partitionId = partition.getId(); - this.pendingMembers = new CopyOnWriteArrayList(); - this.activeMembers = new CopyOnWriteArrayList(); - this.terminationPendingMembers = new CopyOnWriteArrayList(); + // TODO: fix properly, maybe with CopyOnWriteArrayList? + this.pendingMembers = Collections.synchronizedList(new ArrayList()); + this.activeMembers = Collections.synchronizedList(new ArrayList()); + this.terminationPendingMembers = Collections.synchronizedList(new ArrayList()); this.obsoletedMembers = new CopyOnWriteArrayList(); memberStatsContexts = new ConcurrentHashMap(); @@ -152,14 +147,16 @@ public boolean removePendingMember(String id) { if (id == null) { return false; } - for (Iterator iterator = pendingMembers.iterator(); iterator.hasNext();) { - MemberContext pendingMember = (MemberContext) iterator.next(); - if(id.equals(pendingMember.getMemberId())){ - iterator.remove(); - return true; - } - - } + synchronized (pendingMembers) { + for (Iterator iterator = pendingMembers.iterator(); iterator.hasNext(); ) { + MemberContext pendingMember = (MemberContext) iterator.next(); + if (id.equals(pendingMember.getMemberId())) { + iterator.remove(); + return true; + } + + } + } return false; } @@ -168,25 +165,27 @@ public void movePendingMemberToActiveMembers(String memberId) { if (memberId == null) { return; } - Iterator iterator = pendingMembers.listIterator(); - while (iterator.hasNext()) { - MemberContext pendingMember = iterator.next(); - if(pendingMember == null) { - iterator.remove(); - continue; - } - if(memberId.equals(pendingMember.getMemberId())){ - // member is activated - // remove from pending list - iterator.remove(); - // add to the activated list - this.activeMembers.add(pendingMember); - pendingMembersFailureCount = 0; - if (log.isDebugEnabled()) { - log.debug(String.format("Pending member is removed and added to the " + - "activated member list. [Member Id] %s",memberId)); + synchronized (pendingMembers) { + Iterator iterator = pendingMembers.listIterator(); + while (iterator.hasNext()) { + MemberContext pendingMember = iterator.next(); + if (pendingMember == null) { + iterator.remove(); + continue; + } + if (memberId.equals(pendingMember.getMemberId())) { + // member is activated + // remove from pending list + iterator.remove(); + // add to the activated list + this.activeMembers.add(pendingMember); + pendingMembersFailureCount = 0; + if (log.isDebugEnabled()) { + log.debug(String.format("Pending member is removed and added to the " + + "activated member list. [Member Id] %s", memberId)); + } + break; } - break; } } } @@ -196,24 +195,26 @@ public void moveActiveMemberToTerminationPendingMembers(String memberId) { if (memberId == null) { return; } - Iterator iterator = activeMembers.listIterator(); - while ( iterator.hasNext()) { - MemberContext activeMember = iterator.next(); - if(activeMember == null) { - iterator.remove(); - continue; - } - if(memberId.equals(activeMember.getMemberId())){ - // member is activated - // remove from pending list - iterator.remove(); - // add to the activated list - this.terminationPendingMembers.add(activeMember); - if (log.isDebugEnabled()) { - log.debug(String.format("Active member is removed and added to the " + - "termination pending member list. [Member Id] %s", memberId)); + synchronized (activeMembers) { + Iterator iterator = activeMembers.listIterator(); + while (iterator.hasNext()) { + MemberContext activeMember = iterator.next(); + if (activeMember == null) { + iterator.remove(); + continue; + } + if (memberId.equals(activeMember.getMemberId())) { + // member is activated + // remove from pending list + iterator.remove(); + // add to the activated list + this.terminationPendingMembers.add(activeMember); + if (log.isDebugEnabled()) { + log.debug(String.format("Active member is removed and added to the " + + "termination pending member list. [Member Id] %s", memberId)); + } + break; } - break; } } } @@ -228,11 +229,13 @@ public void removeActiveMember(MemberContext ctxt) { public boolean removeTerminationPendingMember(String memberId) { boolean terminationPendingMemberAvailable = false; - for (MemberContext memberContext: terminationPendingMembers){ - if(memberContext.getMemberId().equals(memberId)){ - terminationPendingMemberAvailable = true; - terminationPendingMembers.remove(memberContext); - break; + synchronized (terminationPendingMembers) { + for (MemberContext memberContext : terminationPendingMembers) { + if (memberContext.getMemberId().equals(memberId)) { + terminationPendingMemberAvailable = true; + terminationPendingMembers.remove(memberContext); + break; + } } } return terminationPendingMemberAvailable; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index c8663395a1..5f6e503bf9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -357,6 +357,21 @@ protected void onEvent(Event event) { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). getAppMonitor(applicationUndeployedEvent.getApplicationId()); + // if any of Cluster Monitors are not added yet, should send the + // Cluster Terminated event for those clusters + Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { + if (AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId()) == null) { + // Cluster Monitor not found; send Cluster Terminated event to cleanup + StatusEventPublisher.sendClusterTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), + clusterDataHolder.getServiceType(), + clusterDataHolder.getClusterId()); + } + } + } + if (appMonitor != null) { // set Application Monitor state to 'Terminating' appMonitor.setStatus(ApplicationStatus.Terminating); From f7bd78805d85a53f558f9c732abb5a28eb776d4a Mon Sep 17 00:00:00 2001 From: reka Date: Wed, 29 Oct 2014 22:45:38 +0530 Subject: [PATCH 302/436] mark terminating cluster/group as different map --- .../stratos/autoscaler/monitor/ParentComponentMonitor.java | 2 +- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index fa8f425f86..537e855266 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -107,7 +107,7 @@ protected void onChildActivatedEvent(String idOfEvent) { }*/ // move to inactive monitors list to use in the Terminated event - private synchronized void markMonitorAsInactive (String monitorKey) { + protected synchronized void markMonitorAsInactive (String monitorKey) { if (!this.aliasToInActiveMonitorsMap.containsKey(monitorKey)) { this.aliasToInActiveMonitorsMap.put(monitorKey, diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index b1b7882d70..01bf148fdf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -74,9 +74,9 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { //To update the status of the Group StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { + /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { //onChildTerminatingEvent(id); - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. @@ -96,6 +96,7 @@ public void onParentEvent(MonitorStatusEvent statusEvent) { if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) { StatusEventPublisher.sendGroupTerminatingEvent(appId, id); + this.markMonitorAsInactive(id); } } From 8047060a58f8963303a1aa5756255d5be4d1a215 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Wed, 29 Oct 2014 23:10:00 +0530 Subject: [PATCH 303/436] stopping the Cluster Monitor before terminating instances --- .../topology/AutoscalerTopologyEventReceiver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 5f6e503bf9..b02b2c982f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -362,12 +362,18 @@ protected void onEvent(Event event) { Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { - if (AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId()) == null) { + ClusterMonitor clusterMonitor = + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId())); + if (clusterMonitor == null) { // Cluster Monitor not found; send Cluster Terminated event to cleanup StatusEventPublisher.sendClusterTerminatedEvent( applicationUndeployedEvent.getApplicationId(), clusterDataHolder.getServiceType(), clusterDataHolder.getClusterId()); + } else { + // if the Cluster Monitor exists, mark it as destroyed to stop it from spawning + // more instances + clusterMonitor.setDestroyed(true); } } } From 25340242f9e2fd27202d21365ef673a533a10d91 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Thu, 30 Oct 2014 10:33:23 +0530 Subject: [PATCH 304/436] Fixing messaging component merge issues --- .../org.apache.stratos.messaging/pom.xml | 66 +++++++++---------- .../messaging/domain/topology/Cluster.java | 11 +--- .../messaging/domain/topology/Member.java | 3 +- .../InstanceSpawnedMessageProcessor.java | 2 +- ...ApplicationStatusEventMessageListener.java | 46 +++++++++---- .../stratos/messaging/util/Constants.java | 3 +- 6 files changed, 72 insertions(+), 59 deletions(-) diff --git a/components/org.apache.stratos.messaging/pom.xml b/components/org.apache.stratos.messaging/pom.xml index 9f50b00ac4..c1f09db07f 100644 --- a/components/org.apache.stratos.messaging/pom.xml +++ b/components/org.apache.stratos.messaging/pom.xml @@ -31,7 +31,7 @@ bundle Apache Stratos - Messaging Component http://apache.org - + junit @@ -39,19 +39,19 @@ ${junit.version} - org.apache.geronimo.specs - geronimo-jms_1.1_spec - 1.1 - - - com.google.code.gson - gson - 2.2.4 - + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + - org.apache.commons - commons-lang3 - 3.1 + com.google.code.gson + gson + 2.2.4 + + + org.apache.commons + commons-lang3 + 3.1 commons-collections @@ -69,16 +69,16 @@ ${wso2carbon.version} - com.jamesmurty.utils - java-xmlbuilder - 0.6 - - - org.eclipse.paho - mqtt-client - 0.4.0 - - + com.jamesmurty.utils + java-xmlbuilder + 0.6 + + + org.eclipse.paho + mqtt-client + 0.4.0 + + org.apache.activemq activemq-core 5.2.0 @@ -92,18 +92,15 @@ - + - methods - 15 + + src/test/resources/testng.xml + - + org.apache.felix maven-scr-plugin @@ -118,12 +115,11 @@ ${project.artifactId} ${project.artifactId} - !org.apache.stratos.messaging.message.processor.topology.updater, org.apache.stratos.messaging.*, - - org.apache.stratos.messaging.message.processor.topology.updater; - + !org.apache.commons.logging, org.apache.commons.logging; version=0.0.0, diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 97b4d999cb..462af30207 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.domain.topology; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang.StringUtils; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.Util; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; @@ -171,7 +171,7 @@ public void setKubernetesCluster(boolean isKubernetesCluster) { * @return */ public boolean tenantIdInRange(int tenantId) { - if (StringUtils.isBlank(getTenantRange())) { + if (StringUtils.isEmpty(getTenantRange())) { return false; } @@ -203,7 +203,7 @@ public boolean tenantIdInRange(int tenantId) { public Collection findPartitionIds() { Map partitionIds = new HashMap(); for (Member member : getMembers()) { - if ((StringUtils.isNotBlank(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) { + if ((StringUtils.isNotEmpty(member.getPartitionId())) && (!partitionIds.containsKey(member.getPartitionId()))) { partitionIds.put(member.getPartitionId(), true); } } @@ -225,13 +225,8 @@ public ClusterStatus getStatus() { return clusterStateManager.getCurrentState(); } - public void setStatus(ClusterStatus status) { - this.status = status; - } - public void setStatus(ClusterStatus newStatus) { clusterStateManager.changeState(newStatus); - //this.status = newStatus; } public boolean equals(Object other) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java index 989f079a71..3ba66ee6a6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Member.java @@ -19,6 +19,7 @@ package org.apache.stratos.messaging.domain.topology; +import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import org.apache.stratos.messaging.util.bean.type.map.MapAdapter; import javax.xml.bind.annotation.XmlRootElement; @@ -176,7 +177,7 @@ public void setMemberPublicIp(String memberPublicIp) { public String toString() { return "Member [serviceName=" + serviceName + ", clusterId=" + clusterId + ", networkPartitionId=" + networkPartitionId + ", partitionId=" + partitionId + ", memberId=" + memberId + ", initTime=" + initTime + ", portMap=" - + portMap + ", memberPublicIp=" + memberPublicIp + ", status=" + status + ", memberIp=" + memberIp + + portMap + ", memberPublicIp=" + memberPublicIp + ", status=" + getStatus() + ", memberIp=" + memberIp + ", properties=" + properties + ", lbClusterId=" + lbClusterId + "]"; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java index 7d7b5938c1..0fabdbc285 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/InstanceSpawnedMessageProcessor.java @@ -130,7 +130,7 @@ private boolean doProcess (InstanceSpawnedEvent event,Topology topology){ } else { // Apply changes to the topology - Member member = new Member(event.getServiceName(), event.getClusterId(), event.getNetworkPartitionId(), event.getPartitionId(), event.getMemberId()); + Member member = new Member(event.getServiceName(), event.getClusterId(), event.getNetworkPartitionId(), event.getPartitionId(), event.getMemberId(), event.getInitTime()); //member.setStatus(MemberStatus.Created); member.setMemberPublicIp(event.getMemberPublicIp()); member.setMemberIp(event.getMemberIp()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java index 93eeb542fc..e53e0832f5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java @@ -18,15 +18,21 @@ */ package org.apache.stratos.messaging.message.receiver.application.status; +import org.apache.activemq.command.ActiveMQTextMessage; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.messaging.util.Util; +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttMessage; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; -public class ApplicationStatusEventMessageListener implements MessageListener { +public class ApplicationStatusEventMessageListener implements MqttCallback { private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class); private ApplicationStatusEventMessageQueue messageQueue; @@ -36,19 +42,33 @@ public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue } @Override - public void onMessage(Message message) { - if (message instanceof TextMessage) { - TextMessage receivedMessage = (TextMessage) message; - try { - if (log.isDebugEnabled()) { - log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText())); - } - // Add received message to the queue - messageQueue.add(receivedMessage); - - } catch (JMSException e) { - log.error(e.getMessage(), e); + public void connectionLost(Throwable throwable) { + log.warn("Connection is lost", throwable); + } + + @Override + public void deliveryComplete(IMqttDeliveryToken deliveryToken) { + if (log.isDebugEnabled()) { + log.debug(String.format("Message delivery is complete: %s", + ((deliveryToken != null) ? deliveryToken.toString() : ""))); + } + } + + @Override + public void messageArrived(String topicName, MqttMessage message) throws Exception { + TextMessage textMessage = new ActiveMQTextMessage(); + textMessage.setText(new String(message.getPayload())); + textMessage.setStringProperty(Constants.EVENT_CLASS_NAME, Util.getEventNameForTopic(topicName)); + + try { + if (log.isDebugEnabled()) { + log.debug(String.format("Tenant message received: %s", textMessage.getText())); } + // Add received message to the queue + messageQueue.add(textMessage); + + } catch (JMSException e) { + log.error(e.getMessage(), e); } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index ea029b83dc..f677d113f3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -24,7 +24,8 @@ public class Constants { public static final String HEALTH_STAT_TOPIC = "summarized-health-stats"; public static final String INSTANCE_STATUS_TOPIC = "instance/status/#"; public static final String INSTANCE_NOTIFIER_TOPIC = "instance/notifier/#"; - public static final String PING_TOPIC = "ping"; + public static final String APPLICATION_STATUS_TOPIC = "application-status"; + public static final String PING_TOPIC = "ping"; public static final String TENANT_TOPIC = "tenant/#"; public static final String TENANT_RANGE_ALL = "*"; From 304aa6c834834f12c265faaf17268d46558b8eb5 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 11:25:58 +0530 Subject: [PATCH 305/436] fixing sending inActive events twice from autoscaler --- .../autoscaler/monitor/application/ApplicationMonitor.java | 5 ----- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 6 ------ 2 files changed, 11 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 2bf85a62e0..e7e3238606 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -161,11 +161,6 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); - //TODO update the status of the Application as in_active when child becomes in_active - - /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - onChildTerminatingEvent(id); - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 01bf148fdf..fc79c59648 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -71,12 +71,6 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); - //To update the status of the Group - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); - - /*} else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { - //onChildTerminatingEvent(id); - StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId);*/ } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. From 24e8a1d58846f617194c705bcb7024c1e6a16acf Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 30 Oct 2014 13:23:54 +0530 Subject: [PATCH 306/436] renaming term 'kill' to 'terminate' --- .../apache/stratos/autoscaler/Constants.java | 6 ++-- .../dependency/DependencyBuilder.java | 12 +++---- .../parser/DefaultApplicationParser.java | 25 +++++++++++++-- .../pojo/application/DependencyContext.java | 10 +++--- .../CompositeApplicationParseTest.java | 12 +++---- .../DefaultCompositeApplicationParser.java | 6 ++-- .../definitions/DependencyDefinitions.java | 10 +++--- .../deployer/DefaultServiceGroupDeployer.java | 31 +++++++++++++++---- .../domain/topology/DependencyOrder.java | 12 +++---- .../bean/util/converter/PojoConverter.java | 2 +- .../webapp/stratos/WEB-INF/schemas/schema.xsd | 2 +- 11 files changed, 81 insertions(+), 47 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java index 59717f754a..3e9e5e2fcd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java @@ -73,9 +73,9 @@ public class Constants { public static final String MEMBER_EXPIRY_INTERVAL = "member.expiry.interval"; //Grouping - public static final String KILL_NONE = "kill-none"; - public static final String KILL_ALL = "kill-all"; - public static final String KILL_DEPENDENTS = "kill-dependents"; + public static final String TERMINATE_NONE = "terminate-none"; + public static final String TERMINATE_ALL = "terminate-all"; + public static final String TERMINATE_DEPENDENTS = "terminate-dependents"; public static final String GROUP = "group"; public static final String CARTRIDGE = "cartridge"; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index edd1c02ec5..4e678481ee 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -24,8 +24,6 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory; -import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.messaging.domain.topology.*; import java.util.Set; @@ -64,17 +62,17 @@ public DependencyTree buildDependency(ParentComponent component) throws Dependen log.info("Building dependency for the Application/Group " + identifier); //Parsing the kill behaviour - String killBehavior = dependencyOrder.getKillbehavior(); + String terminationBehaviour = dependencyOrder.getTerminationBehaviour(); - if (Constants.KILL_NONE.equals(killBehavior)) { + if (Constants.TERMINATE_NONE.equals(terminationBehaviour)) { dependencyTree.setKillNone(true); - } else if (Constants.KILL_ALL.equals(killBehavior)) { + } else if (Constants.TERMINATE_ALL.equals(terminationBehaviour)) { dependencyTree.setKillAll(true); - } else if (Constants.KILL_DEPENDENTS.equals(killBehavior)) { + } else if (Constants.TERMINATE_DEPENDENTS.equals(terminationBehaviour)) { dependencyTree.setKillDependent(true); } - log.info("Setting the [killBehavior] " + killBehavior + " to the " + + log.info("Setting the [terminationBehaviour] " + terminationBehaviour + " to the " + "[dependency-tree] " + dependencyTree.getId()); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 9d909caabb..9cd4f902bf 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -279,7 +279,9 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias()); } } - appDependencyOrder.setKillbehavior(appCtxt.getComponents().getDependencyContext().getKillBehaviour()); + String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour(); + validateTerminationBehavior(terminationBehavior); + appDependencyOrder.setTerminationBehaviour(terminationBehavior); application.setDependencyOrder(appDependencyOrder); } @@ -290,6 +292,25 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, return application; } + /** + * Validates terminationBehavior. The terminationBehavior should be one of the following: + * 1. terminate-none + * 2. terminate-dependents + * 3. terminate-all + * + * @throws ApplicationDefinitionException if terminationBehavior is different to what is + * listed above + */ + private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException { + + if (terminationBehavior != null && terminationBehavior != "terminate-none" && + terminationBehavior != "terminate-dependents" && terminationBehavior != "terminate-all") { + throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " + + terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " + + " 'terminate-all' "); + } + } + /** * Parse Group information * @@ -402,7 +423,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g if (startupOrders != null) { dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt)); } - dependencyOrder.setKillbehavior(getKillbehaviour(groupCtxt.getName())); + dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName())); group.setDependencyOrder(dependencyOrder); Map clusterDataMap; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java index 0459f36b5e..a99dcb0d4e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java @@ -24,14 +24,14 @@ public class DependencyContext { private String [] startupOrdersContexts; - private String killBehaviour; + private String terminationBehaviour; - public String getKillBehaviour() { - return killBehaviour; + public String getTerminationBehaviour() { + return terminationBehaviour; } - public void setKillBehaviour(String killBehaviour) { - this.killBehaviour = killBehaviour; + public void setTerminationBehaviour(String terminationBehaviour) { + this.terminationBehaviour = terminationBehaviour; } public String [] getStartupOrdersContexts() { diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index 7798274ce5..1fc808e2f9 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -53,7 +53,7 @@ public static void setUpBeforeClass() { group1.setName("group1"); group1.setCartridges(new String[]{"mysql"}); Dependencies group1Dependencies = new Dependencies(); - group1Dependencies.setKillBehaviour("kill-none"); + group1Dependencies.setKillBehaviour("terminate-none"); group1.setDependencies(group1Dependencies); dataHolder.addServiceGroup(group1); // add group2 @@ -63,7 +63,7 @@ public static void setUpBeforeClass() { group2.setSubGroups(new String[]{"group1"}); Dependencies group2Dependencies = new Dependencies(); group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"}); - group2Dependencies.setKillBehaviour("kill-dependents"); + group2Dependencies.setKillBehaviour("terminate-dependents"); group2.setDependencies(group2Dependencies); dataHolder.addServiceGroup(group2); } @@ -206,7 +206,7 @@ public void testParseSimpleApplicationWithMultipleSubsriptions () throws Applica simpleAppMySqlSubscribableContext}); DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"}); simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); @@ -256,7 +256,7 @@ public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrde simpleAppMySqlSubscribableContext}); DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); // startup order is invalid, without prefix 'cartridge.' for mysql1 simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"}); simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); @@ -419,7 +419,7 @@ public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws Applica simpleAppCtxt.setComponents(simpleAppComponentCtxt); // dependencies DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"}); simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); // subscribable information @@ -475,7 +475,7 @@ public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws simpleAppCtxt.setComponents(simpleAppComponentCtxt); // dependencies DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setKillBehaviour("kill-dependents"); + simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); // invalid startup order, starting with 'group1' simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"}); simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 9a49e2c20e..38956bef49 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -30,13 +30,11 @@ import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; import org.apache.stratos.manager.composite.application.structure.GroupContext; -import org.apache.stratos.manager.composite.application.structure.StartupOrder; import org.apache.stratos.manager.composite.application.structure.SubscribableContext; import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.exception.CompositeApplicationDefinitionException; import org.apache.stratos.manager.exception.PersistenceManagerException; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; -import org.apache.stratos.manager.grouping.definitions.StartupOrderDefinition; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import java.rmi.RemoteException; @@ -217,7 +215,7 @@ private CompositeAppContext buildCompositeAppStructure (ApplicationDefinition co startupOrders = startupOrderList.toArray(startupOrders); compositeAppContext.setStartupOrders(startupOrders); - compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour()); + compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getTerminationBehaviour()); } } @@ -367,7 +365,7 @@ private String getKillbehaviour (String serviceGroupName) throws CompositeApplic } if (groupDefinition.getDependencies() != null) { - return groupDefinition.getDependencies().getKillBehaviour(); + return groupDefinition.getDependencies().getTerminationBehaviour(); } return null; 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 index 782bce0857..7510a21195 100644 --- 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 @@ -33,14 +33,14 @@ public class DependencyDefinitions implements Serializable { private List startupOrders; - private String killBehaviour; + private String terminationBehaviour; - public String getKillBehaviour() { - return killBehaviour; + public String getTerminationBehaviour() { + return terminationBehaviour; } - public void setKillBehaviour(String killBehaviour) { - this.killBehaviour = killBehaviour; + public void setTerminationBehaviour(String terminationBehaviour) { + this.terminationBehaviour = terminationBehaviour; } public List getStartupOrders() { 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 index 8885ebd2a0..58d27548c0 100644 --- 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 @@ -73,7 +73,6 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro 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) { @@ -232,7 +231,7 @@ public void undeployServiceGroupDefinition (String name) throws ADCException, Se } - private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) { + private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGroupDefinition ) throws ServiceGroupDefinitioException { ServiceGroup servicegroup = new ServiceGroup(); // implement conversion (mostly List -> Array) @@ -268,7 +267,9 @@ private ServiceGroup populateServiceGroupPojo (ServiceGroupDefinition serviceGro startupOrders = startupOrdersDef.toArray(startupOrders); deps.setStartupOrders(startupOrders); } - deps.setKillBehaviour(depDefs.getKillBehaviour()); + // validate termination behavior + validateTerminationBehavior(depDefs.getTerminationBehaviour()); + deps.setKillBehaviour(depDefs.getTerminationBehaviour()); servicegroup.setDependencies(deps); } @@ -290,7 +291,7 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup depsDef.setStartupOrders(startupOrdersDef); } - depsDef.setKillBehaviour(deps.getKillBehaviour()); + depsDef.setTerminationBehaviour(deps.getKillBehaviour()); servicegroupDef.setDependencies(depsDef); } @@ -302,8 +303,26 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup 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 && terminationBehavior != "terminate-none" && + terminationBehavior != "terminate-dependents" && terminationBehavior != "terminate-all") { + 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 diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java index 1d8699fe92..bdba59ca98 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java @@ -20,8 +20,6 @@ package org.apache.stratos.messaging.domain.topology; import java.io.Serializable; -import java.util.HashSet; -import java.util.List; import java.util.Set; public class DependencyOrder implements Serializable { @@ -30,18 +28,18 @@ public class DependencyOrder implements Serializable { private Set startupOrders; - private String killbehavior; + private String terminationBehaviour; public DependencyOrder () { } - public String getKillbehavior() { - return killbehavior; + public String getTerminationBehaviour() { + return terminationBehaviour; } - public void setKillbehavior(String killbehavior) { - this.killbehavior = killbehavior; + public void setTerminationBehaviour(String terminationBehaviour) { + this.terminationBehaviour = terminationBehaviour; } public Set getStartupOrders() { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index cc3ae4abd6..d5e6882cd9 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -736,7 +736,7 @@ private static SubscribableInfoContext[] getSubscribableInfoContextArrFromSubscr private static DependencyContext getDependencyContextFromDependencyDefinition (DependencyDefinitions dependencyDefinitions) { DependencyContext dependencyContext = new DependencyContext(); - dependencyContext.setKillBehaviour(dependencyDefinitions.getKillBehaviour()); + dependencyContext.setKillBehaviour(dependencyDefinitions.getTerminationBehaviour()); if (dependencyDefinitions != null && dependencyDefinitions.getStartupOrders() != null) { String [] startupOrders = new String [dependencyDefinitions.getStartupOrders().size()]; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd index 83155e01da..994353c8d1 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd +++ b/components/org.apache.stratos.rest.endpoint/src/main/webapp/stratos/WEB-INF/schemas/schema.xsd @@ -246,7 +246,7 @@ - + From 605b92f1b269cfd66f81d63ee884d100e4a7b6c4 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 30 Oct 2014 14:05:58 +0530 Subject: [PATCH 307/436] fixing a bug in checking string equality --- .../application/parser/DefaultApplicationParser.java | 4 ++-- .../grouping/deployer/DefaultServiceGroupDeployer.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 9cd4f902bf..06f749a12a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -303,8 +303,8 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, */ private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException { - if (terminationBehavior != null && terminationBehavior != "terminate-none" && - terminationBehavior != "terminate-dependents" && terminationBehavior != "terminate-all") { + if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) || + "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) { throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " + terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " + " 'terminate-all' "); 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 index 58d27548c0..be0c4ee5a6 100644 --- 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 @@ -315,8 +315,8 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup */ private static void validateTerminationBehavior (String terminationBehavior) throws ServiceGroupDefinitioException { - if (terminationBehavior != null && terminationBehavior != "terminate-none" && - terminationBehavior != "terminate-dependents" && terminationBehavior != "terminate-all") { + 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' "); From be8885862eb7c18230b7c1a066f06a35fee42c53 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Thu, 30 Oct 2014 14:30:55 +0530 Subject: [PATCH 308/436] Fixing autoscaler component merge issues --- .../org.apache.stratos.autoscaler/pom.xml | 1 - .../internal/AutoscalerServerComponent.java | 22 +- .../monitor/AbstractClusterMonitor.java | 46 ++- .../monitor/ApplicationMonitorFactory.java | 127 +------- .../KubernetesServiceClusterMonitor.java | 8 +- .../monitor/VMLbClusterMonitor.java | 30 +- .../monitor/VMServiceClusterMonitor.java | 40 +-- .../monitor/cluster/ClusterMonitor.java | 293 ------------------ .../monitor/cluster/LbClusterMonitor.java | 129 -------- .../status/checker/StatusChecker.java | 15 +- 10 files changed, 108 insertions(+), 603 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml index c188021a45..6fcd1f08fa 100644 --- a/components/org.apache.stratos.autoscaler/pom.xml +++ b/components/org.apache.stratos.autoscaler/pom.xml @@ -149,7 +149,6 @@ org.apache.stratos org.apache.stratos.messaging ${project.version} - provided org.apache.stratos diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java index 529663573f..4a8b269723 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java @@ -53,9 +53,9 @@ public class AutoscalerServerComponent { private static final Log log = LogFactory.getLog(AutoscalerServerComponent.class); - AutoscalerTopologyEventReceiver asTopologyReceiver; -// TopicSubscriber healthStatTopicSubscriber; - AutoscalerHealthStatEventReceiver autoscalerHealthStatEventReceiver; + + private AutoscalerTopologyEventReceiver asTopologyReceiver; + private AutoscalerHealthStatEventReceiver autoscalerHealthStatEventReceiver; protected void activate(ComponentContext componentContext) throws Exception { try { @@ -66,21 +66,13 @@ protected void activate(ComponentContext componentContext) throws Exception { if (log.isDebugEnabled()) { log.debug("Topology receiver thread started"); } -// healthStatTopicSubscriber = new TopicSubscriber(Constants.HEALTH_STAT_TOPIC); -// healthStatTopicSubscriber.setMessageListener(new HealthEventMessageReceiver()); -// Thread healthStatTopicSubscriberThread = new Thread(healthStatTopicSubscriber); -// healthStatTopicSubscriberThread.start(); -// if (log.isDebugEnabled()) { -// log.debug("Health event message receiver thread started"); -// } - // Start health stat receiver autoscalerHealthStatEventReceiver = new AutoscalerHealthStatEventReceiver(); Thread healthDelegatorThread = new Thread(autoscalerHealthStatEventReceiver); healthDelegatorThread.start(); if (log.isDebugEnabled()) { - log.debug("Health message processor thread started"); + log.debug("Health statistics receiver thread started"); } // Adding the registry stored partitions to the information model @@ -122,10 +114,10 @@ protected void activate(ComponentContext componentContext) throws Exception { } if (log.isInfoEnabled()) { - log.info("Autoscaler Server Component activated"); + log.info("Autoscaler server Component activated"); } } catch (Throwable e) { - log.error("Error in activating the autoscaler component ", e); + log.error("Error in activating autoscaler component", e); } } @@ -149,7 +141,7 @@ protected void setRegistryService(RegistryService registryService) { protected void unsetRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { - log.debug("Unsetting the Registry Service"); + log.debug("Un-setting the Registry Service"); } ServiceReferenceHolder.getInstance().setRegistry(null); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 972ddad745..030bc53bd0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -23,9 +23,15 @@ import java.util.concurrent.TimeUnit; import org.apache.stratos.autoscaler.exception.InvalidArgumentException; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; +import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; import org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent; @@ -54,11 +60,11 @@ /* * Every cluster monitor, which are monitoring a cluster, should extend this class. */ -public abstract class AbstractClusterMonitor implements Runnable { +public abstract class AbstractClusterMonitor extends Monitor implements Runnable { private String clusterId; private String serviceId; - private ClusterStatus status; + protected ClusterStatus status; private int monitoringIntervalMilliseconds; protected FactHandle minCheckFactHandle; @@ -68,6 +74,7 @@ public abstract class AbstractClusterMonitor implements Runnable { private boolean isDestroyed; private AutoscalerRuleEvaluator autoscalerRuleEvaluator; + protected boolean hasFaultyMember = false; private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); @@ -159,7 +166,7 @@ public abstract void handleMemberReadyToShutdownEvent( public abstract void handleMemberTerminatedEvent(MemberTerminatedEvent memberTerminatedEvent); public abstract void handleClusterRemovedEvent(ClusterRemovedEvent clusterRemovedEvent); - + public abstract void handleDynamicUpdates(Properties properties) throws InvalidArgumentException; public String getClusterId() { @@ -244,4 +251,37 @@ public void setAutoscalerRuleEvaluator( AutoscalerRuleEvaluator autoscalerRuleEvaluator) { this.autoscalerRuleEvaluator = autoscalerRuleEvaluator; } + + + @Override + public void onParentEvent(MonitorStatusEvent statusEvent) { + // send the ClusterTerminating event + if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == + ApplicationStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); + } + } + + @Override + public void onChildEvent(MonitorStatusEvent statusEvent) { + + } + + @Override + public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { + + } + + @Override + public void onEvent(MonitorScalingEvent scalingEvent) { + + } + + public void setHasFaultyMember(boolean hasFaultyMember) { + this.hasFaultyMember = hasFaultyMember; + } + + public boolean isHasFaultyMember() { + return hasFaultyMember; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 2ead896344..9cf3709604 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -34,7 +34,7 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.policy.PolicyManager; @@ -172,7 +172,7 @@ public static ApplicationMonitor getApplicationMonitor(String appId) * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException */ - public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor, + public static VMClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor, ClusterContext context, String appId) throws PolicyValidationException, PartitionValidationException, @@ -182,7 +182,7 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni String serviceName = context.getServiceName(); Cluster cluster; - ClusterMonitor clusterMonitor; + AbstractClusterMonitor clusterMonitor; //acquire read lock for the service and cluster TopologyManager.acquireReadLockForCluster(serviceName, clusterId); try { @@ -207,126 +207,17 @@ public static ClusterMonitor getClusterMonitor(ParentComponentMonitor parentMoni } - String autoscalePolicyName = cluster.getAutoscalePolicyName(); - String deploymentPolicyName = cluster.getDeploymentPolicyName(); - if (log.isDebugEnabled()) { - log.debug("Deployment policy name: " + deploymentPolicyName); - log.debug("Autoscaler policy name: " + autoscalePolicyName); - } - - AutoscalePolicy policy = - PolicyManager.getInstance() - .getAutoscalePolicy(autoscalePolicyName); - DeploymentPolicy deploymentPolicy = - PolicyManager.getInstance() - .getDeploymentPolicy(deploymentPolicyName); - - if (deploymentPolicy == null) { - String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } - - Partition[] allPartitions = deploymentPolicy.getAllPartitions(); - if (allPartitions == null) { - String msg = - "Deployment Policy's Partitions are null. Policy name: " + - deploymentPolicyName; - log.error(msg); - throw new PolicyValidationException(msg); - } - - CloudControllerClient.getInstance().validateDeploymentPolicy(cluster.getServiceName(), deploymentPolicy); - - clusterMonitor = new ClusterMonitor(cluster.getClusterId(), cluster.getServiceName(), - deploymentPolicy, policy); - - for (PartitionGroup partitionGroup : deploymentPolicy.getPartitionGroups()) { - - NetworkPartitionContext networkPartitionContext = new NetworkPartitionContext(partitionGroup.getId(), - partitionGroup.getPartitionAlgo(), partitionGroup.getPartitions()); - - for (Partition partition : partitionGroup.getPartitions()) { - PartitionContext partitionContext = new PartitionContext(partition); - partitionContext.setServiceName(cluster.getServiceName()); - partitionContext.setProperties(cluster.getProperties()); - partitionContext.setNetworkPartitionId(partitionGroup.getId()); - - for (Member member : cluster.getMembers()) { - String memberId = member.getMemberId(); - if (member.getPartitionId().equalsIgnoreCase(partition.getId())) { - MemberContext memberContext = new MemberContext(); - memberContext.setClusterId(member.getClusterId()); - memberContext.setMemberId(memberId); - memberContext.setPartition(partition); - memberContext.setProperties(convertMemberPropsToMemberContextProps(member.getProperties())); - - if (MemberStatus.Activated.equals(member.getStatus())) { - partitionContext.addActiveMember(memberContext); - //triggering the status checker -// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); -// partitionContext.incrementCurrentActiveMemberCount(1); - - } else if (MemberStatus.Created.equals(member.getStatus()) || MemberStatus.Starting.equals(member.getStatus())) { - partitionContext.addPendingMember(memberContext); - -// networkPartitionContext.increaseMemberCountOfPartition(partition.getNetworkPartitionId(), 1); - } else if (MemberStatus.Suspended.equals(member.getStatus())) { -// partitionContext.addFaultyMember(memberId); - } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added: [member] %s", memberId)); - } - } - - } - networkPartitionContext.addPartitionContext(partitionContext); - if (log.isInfoEnabled()) { - log.info(String.format("Partition context has been added: [partition] %s", - partitionContext.getPartitionId())); - } - } - - clusterMonitor.addNetworkPartitionCtxt(networkPartitionContext); - clusterMonitor.setParent(parentMonitor); - if(parentMonitor.isDependent() || (context.isDependent() && context.hasChild())) { - clusterMonitor.setHasDependent(true); - } else { - clusterMonitor.setHasDependent(false); - } - AutoscalerContext.getInstance().addMonitor(clusterMonitor); - if (log.isInfoEnabled()) { - log.info(String.format("Network partition context has been added: [network partition] %s", - networkPartitionContext.getId())); - } - } - //TODO to make sure when group monitor is async - //if cluster is not in created state then notify the parent monitor - if (cluster.getStatus() != clusterMonitor.getStatus()) { - //updating the status, so that it will notify the parent - clusterMonitor.setStatus(cluster.getStatus()); - } - - if (!cluster.hasMembers()) { - //triggering the status checker if cluster has members to decide - // on the current status of the cluster - StatusChecker.getInstance().onMemberStatusChange(clusterId); + clusterMonitor = ClusterMonitorFactory.getMonitor(cluster); + if (clusterMonitor instanceof VMClusterMonitor) { + return (VMClusterMonitor) clusterMonitor; + } else if (clusterMonitor != null) { + log.warn("Unknown cluster monitor found: " + clusterMonitor.getClass().toString()); } + return null; } finally { - //release read lock for the service and cluster TopologyManager.releaseReadLockForCluster(serviceName, clusterId); } - - // set hasPrimary property - // hasPrimary is true if there are primary members available in that cluster - if (cluster.getProperties() != null) { - clusterMonitor.setHasPrimary(Boolean.parseBoolean(cluster.getProperties().getProperty(Constants.IS_PRIMARY))); - } - - log.info("Cluster monitor created: " + clusterMonitor.toString()); - return clusterMonitor; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java index 67850baf76..15b14b6d84 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java @@ -64,19 +64,19 @@ public KubernetesServiceClusterMonitor(KubernetesClusterContext kubernetesCluste public void run() { if (log.isDebugEnabled()) { - log.debug("KubernetesServiceClusterMonitor is running.. " + this.toString()); + log.debug("KubernetesServiceClusterMonitor is running..." + this.toString()); } try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { + if (!ClusterStatus.Active.getNextStates().contains(getStatus())) { monitor(); } else { if (log.isDebugEnabled()) { log.debug("KubernetesServiceClusterMonitor is suspended as the cluster is in " - + ClusterStatus.In_Maintenance + " mode......"); + + getStatus() + "state"); } } } catch (Exception e) { - log.error("KubernetesServiceClusterMonitor : Monitor failed." + this.toString(), + log.error("KubernetesServiceClusterMonitor: Monitor failed." + this.toString(), e); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java index 2ed78f1444..3e6cddc1de 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java @@ -63,20 +63,26 @@ public VMLbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy d @Override public void run() { - if (log.isDebugEnabled()) { - log.debug("VMLbClusterMonitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("VMLbClusterMonitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + while (!isDestroyed()) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } + try { + if (!ClusterStatus.Inactive.equals(status)) { + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("LB Cluster monitor is suspended as the cluster is in " + + ClusterStatus.Inactive + " mode......"); + } } + } catch (Exception e) { + log.error("Cluster monitor: Monitor failed. " + this.toString(), e); + } + try { + Thread.sleep(getMonitorIntervalMilliseconds()); + } catch (InterruptedException ignore) { } - } catch (Exception e) { - log.error("VMLbClusterMonitor : Monitor failed. " + this.toString(), e); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java index 9aec2792e3..9a26b427c6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java @@ -63,28 +63,28 @@ public VMServiceClusterMonitor(String clusterId, String serviceId, @Override public void run() { - - try { - // TODO make this configurable, - // this is the delay the min check of normal cluster monitor to wait until LB monitor is added - Thread.sleep(60000); - } catch (InterruptedException ignore) { - } - - if (log.isDebugEnabled()) { - log.debug("VMServiceClusterMonitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.In_Maintenance.equals(getStatus())) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("VMServiceClusterMonitor is suspended as the cluster is in " + - ClusterStatus.In_Maintenance + " mode......"); + while (!isDestroyed()) { + try { + if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || + (this.status == ClusterStatus.Inactive && !hasDependent) || + !this.hasFaultyMember) { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is running.. " + this.toString()); + } + monitor(); + } else { + if (log.isDebugEnabled()) { + log.debug("Cluster monitor is suspended as the cluster is in " + + ClusterStatus.Inactive + " mode......"); + } } + } catch (Exception e) { + log.error("Cluster monitor: Monitor failed." + this.toString(), e); + } + try { + Thread.sleep(getMonitorIntervalMilliseconds()); + } catch (InterruptedException ignore) { } - } catch (Exception e) { - log.error("VMServiceClusterMonitor : Monitor failed." + this.toString(), e); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java deleted file mode 100644 index 6d7e8caca0..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ /dev/null @@ -1,293 +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.autoscaler.monitor.cluster; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.TerminationException; -import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Is responsible for monitoring a service cluster. This runs periodically - * and perform minimum instance check and scaling check using the underlying - * rules engine. - */ -public class ClusterMonitor extends AbstractClusterMonitor { - - private static final Log log = LogFactory.getLog(ClusterMonitor.class); - private String lbReferenceType; - private boolean hasPrimary; - - - public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, - AutoscalePolicy autoscalePolicy) { - this.clusterId = clusterId; - this.id = clusterId; - this.serviceId = serviceId; - - this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); - this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); - this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); - this.terminateAllKnowledgeSession = autoscalerRuleEvaluator.getTerminateAllStatefulSession(); - - this.deploymentPolicy = deploymentPolicy; - this.autoscalePolicy = autoscalePolicy; - if (log.isDebugEnabled()) { - log.debug("ClusterMonitor:autoScalePolicy:" + autoscalePolicy); - } - networkPartitionCtxts = new ConcurrentHashMap(); - //status = ClusterStatus.Created; - } - - - @Override - public void run() { - while (!isDestroyed()) { - try { - if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || - (this.status == ClusterStatus.Inactive && !hasDependent) || - !this.hasFaultyMember) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is suspended as the cluster is in " + - ClusterStatus.Inactive + " mode......"); - } - } - } catch (Exception e) { - log.error("Cluster monitor: Monitor failed." + this.toString(), e); - } - try { - Thread.sleep(monitorInterval); - } catch (InterruptedException ignore) { - } - } - - - } - - @Override - public void terminateAllMembers() { - - Thread memberTerminator = new Thread(new Runnable(){ - public void run(){ - - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - //if (log.isDebugEnabled()) { - log.info("Starting to terminate all members in Network Partition [ " + - networkPartitionContext.getId() + " ], Partition [ " + - partitionContext.getPartitionId() + " ]"); - // } - // need to terminate active, pending and obsolete members - - // active members - for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) { - log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId()); - terminateMember(activeMemberCtxt.getMemberId()); - } - - // pending members - for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { - log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); - terminateMember(pendingMemberCtxt.getMemberId()); - } - - // obsolete members - for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) { - log.info("Terminating obsolete member [member id] " + obsoleteMemberId); - terminateMember(obsoleteMemberId); - } - -// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll -// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); - } - } - } - }, "Member Terminator - [cluster id] " + this.clusterId); - - memberTerminator.start(); - } - - private static void terminateMember (String memberId) { - try { - CloudControllerClient.getInstance().terminate(memberId); - - } catch (TerminationException e) { - log.error("Unable to terminate member [member id ] " + memberId, e); - } - } - - private boolean isPrimaryMember(MemberContext memberContext) { - Properties props = memberContext.getProperties(); - if (log.isDebugEnabled()) { - log.debug(" Properties [" + props + "] "); - } - if (props != null && props.getProperties() != null) { - for (Property prop : props.getProperties()) { - if (prop.getName().equals("PRIMARY")) { - if (Boolean.parseBoolean(prop.getValue())) { - log.debug("Adding member id [" + memberContext.getMemberId() + "] " + - "member instance id [" + memberContext.getInstanceId() + "] as a primary member"); - return true; - } - } - } - } - return false; - } - - public void monitor() { - //TODO make this concurrent - - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - // store primary members in the network partition context - List primaryMemberListInNetworkPartition = new ArrayList(); - //minimum check per partition - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - // store primary members in the partition context - List primaryMemberListInPartition = new ArrayList(); - // get active primary members in this partition context - for (MemberContext memberContext : partitionContext.getActiveMembers()) { - if (isPrimaryMember(memberContext)) { - primaryMemberListInPartition.add(memberContext.getMemberId()); - } - } - - // get pending primary members in this partition context - for (MemberContext memberContext : partitionContext.getPendingMembers()) { - if (isPrimaryMember(memberContext)) { - primaryMemberListInPartition.add(memberContext.getMemberId()); - } - } - primaryMemberListInNetworkPartition.addAll(primaryMemberListInPartition); - minCheckKnowledgeSession.setGlobal("clusterId", clusterId); - minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); - minCheckKnowledgeSession.setGlobal("isPrimary", hasPrimary); - - - if (log.isDebugEnabled()) { - log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); - } - - minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession - , minCheckFactHandle, partitionContext); - - //checking the status of the cluster - - - } - - /*boolean rifReset = networkPartitionContext.isRifReset(); - boolean memoryConsumptionReset = networkPartitionContext.isMemoryConsumptionReset(); - boolean loadAverageReset = networkPartitionContext.isLoadAverageReset(); - - if (log.isDebugEnabled()) { - log.debug("flag of rifReset: " + rifReset + " flag of memoryConsumptionReset" + memoryConsumptionReset - + " flag of loadAverageReset" + loadAverageReset); - } - if (rifReset || memoryConsumptionReset || loadAverageReset) { - - scaleCheckKnowledgeSession.setGlobal("clusterId", clusterId); - //scaleCheckKnowledgeSession.setGlobal("deploymentPolicy", deploymentPolicy); - scaleCheckKnowledgeSession.setGlobal("autoscalePolicy", autoscalePolicy); - scaleCheckKnowledgeSession.setGlobal("rifReset", rifReset); - scaleCheckKnowledgeSession.setGlobal("mcReset", memoryConsumptionReset); - scaleCheckKnowledgeSession.setGlobal("laReset", loadAverageReset); - scaleCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); - scaleCheckKnowledgeSession.setGlobal("isPrimary", false); - scaleCheckKnowledgeSession.setGlobal("primaryMembers", primaryMemberListInNetworkPartition); - - if (log.isDebugEnabled()) { - log.debug(String.format("Running scale check for network partition %s ", networkPartitionContext.getId())); - log.debug(" Primary members : " + primaryMemberListInNetworkPartition); - } - - scaleCheckFactHandle = AutoscalerRuleEvaluator.evaluateScaleCheck(scaleCheckKnowledgeSession - , scaleCheckFactHandle, networkPartitionContext); - - networkPartitionContext.setRifReset(false); - networkPartitionContext.setMemoryConsumptionReset(false); - networkPartitionContext.setLoadAverageReset(false); - } else if (log.isDebugEnabled()) { - log.debug(String.format("Scale rule will not run since the LB statistics have not received before this " + - "cycle for network partition %s", networkPartitionContext.getId())); - }*/ - } - } - - @Override - public String toString() { - return "ClusterMonitor [clusterId=" + clusterId + ", serviceId=" + serviceId + - ", deploymentPolicy=" + deploymentPolicy + ", autoscalePolicy=" + autoscalePolicy + - ", lbReferenceType=" + lbReferenceType + - ", hasPrimary=" + hasPrimary + " ]"; - } - - public String getLbReferenceType() { - return lbReferenceType; - } - - public void setLbReferenceType(String lbReferenceType) { - this.lbReferenceType = lbReferenceType; - } - - public boolean isHasPrimary() { - return hasPrimary; - } - - public void setHasPrimary(boolean hasPrimary) { - this.hasPrimary = hasPrimary; - } - - @Override - public void onChildEvent(MonitorStatusEvent statusEvent) { - - } - - @Override - public void onParentEvent(MonitorStatusEvent statusEvent) { - // send the ClusterTerminating event - if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == - ApplicationStatus.Terminating) { - StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); - } - } -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java deleted file mode 100644 index 6697d7356f..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/LbClusterMonitor.java +++ /dev/null @@ -1,129 +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.autoscaler.monitor.cluster; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; - -import java.util.concurrent.ConcurrentHashMap; - -/** - * Is responsible for monitoring a service cluster. This runs periodically - * and perform minimum instance check and scaling check using the underlying - * rules engine. - */ -public class LbClusterMonitor extends AbstractClusterMonitor { - - private static final Log log = LogFactory.getLog(LbClusterMonitor.class); - - public LbClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deploymentPolicy, - AutoscalePolicy autoscalePolicy) { - this.clusterId = clusterId; - this.serviceId = serviceId; - - this.autoscalerRuleEvaluator = new AutoscalerRuleEvaluator(); - this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); - this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); - this.terminateAllKnowledgeSession = autoscalerRuleEvaluator.getTerminateAllStatefulSession(); - - this.deploymentPolicy = deploymentPolicy; - this.deploymentPolicy = deploymentPolicy; - networkPartitionCtxts = new ConcurrentHashMap(); - } - - @Override - public void run() { - - while (!isDestroyed()) { - if (log.isDebugEnabled()) { - log.debug("Cluster monitor is running.. " + this.toString()); - } - try { - if (!ClusterStatus.Inactive.equals(status)) { - monitor(); - } else { - if (log.isDebugEnabled()) { - log.debug("LB Cluster monitor is suspended as the cluster is in " + - ClusterStatus.Inactive + " mode......"); - } - } - } catch (Exception e) { - log.error("Cluster monitor: Monitor failed. " + this.toString(), e); - } - try { - Thread.sleep(monitorInterval); - } catch (InterruptedException ignore) { - } - } - } - - @Override - public void terminateAllMembers() { - //To change body of implemented methods use File | Settings | File Templates. - } - - private void monitor() { - // TODO make this concurrent - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - - // minimum check per partition - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts() - .values()) { - - if (partitionContext != null) { - minCheckKnowledgeSession.setGlobal("clusterId", clusterId); - minCheckKnowledgeSession.setGlobal("isPrimary", false); - - if (log.isDebugEnabled()) { - log.debug(String.format("Running minimum check for partition %s ", - partitionContext.getPartitionId())); - } - - minCheckFactHandle = - AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession, - minCheckFactHandle, - partitionContext); - // start only in the first partition context - break; - } - - } - - } - } - - @Override - public String toString() { - return "LbClusterMonitor [clusterId=" + clusterId + ", serviceId=" + serviceId + "]"; - } - - - @Override - public void onParentEvent(MonitorStatusEvent statusEvent) { - - } -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 3a925d1b8b..5f3b590a5d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -24,8 +24,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.autoscaler.monitor.VMClusterMonitor; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -57,7 +56,7 @@ public static StatusChecker getInstance() { public void onMemberStatusChange(final String clusterId) { Runnable group = new Runnable() { public void run() { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId); boolean clusterActive = false; if (monitor != null) { clusterActive = clusterActive(monitor); @@ -80,7 +79,7 @@ public void run() { public void onMemberTermination(final String clusterId) { Runnable group = new Runnable() { public void run() { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId); boolean clusterMonitorHasMembers = clusterMonitorHasMembers(monitor); boolean clusterActive = clusterActive(monitor); @@ -121,7 +120,7 @@ public void run() { } - private boolean clusterActive(AbstractClusterMonitor monitor) { + private boolean clusterActive(VMClusterMonitor monitor) { boolean clusterActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { //minimum check per partition @@ -140,7 +139,7 @@ private boolean clusterActive(AbstractClusterMonitor monitor) { return clusterActive; } - private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { + private boolean clusterMonitorHasMembers(VMClusterMonitor monitor) { boolean hasMember = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { //minimum check per partition @@ -161,7 +160,7 @@ private boolean clusterMonitorHasMembers(AbstractClusterMonitor monitor) { public void onMemberFaultEvent(final String clusterId, final String partitionId) { Runnable group = new Runnable() { public void run() { - ClusterMonitor monitor = (ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); + VMClusterMonitor monitor = (VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId); boolean clusterInActive = getClusterInActive(monitor, partitionId); String appId = monitor.getAppId(); if (clusterInActive) { @@ -185,7 +184,7 @@ public void run() { groupThread.start(); } - private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) { + private boolean getClusterInActive(VMClusterMonitor monitor, String partitionId) { boolean clusterInActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { From 08de40fd9b0ea8128f0aec4612e54df27a6a925c Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Thu, 30 Oct 2014 15:19:07 +0530 Subject: [PATCH 309/436] Fixing STRATOS-930 --- .../pom.xml | 5 + .../impl/CloudControllerServiceImpl.java | 350 +++++++++--------- .../internal/CloudControllerDSComponent.java | 1 + .../controller/topology/TopologyBuilder.java | 298 ++++++++------- .../topology/TopologyEventPublisher.java | 72 +--- 5 files changed, 352 insertions(+), 374 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/pom.xml b/components/org.apache.stratos.cloud.controller/pom.xml index 1f63e3f965..2f44e925c0 100644 --- a/components/org.apache.stratos.cloud.controller/pom.xml +++ b/components/org.apache.stratos.cloud.controller/pom.xml @@ -311,6 +311,11 @@ org.wso2.carbon.ntask.core 4.2.0 + + org.apache.stratos + org.apache.stratos.metadata.client + ${project.version} + 2.2 diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 3d7be2a5de..34a611fea5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -20,13 +20,20 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; + +import org.apache.commons.collections.ListUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; +import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor; import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor; import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; +import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToKubernetesService; +import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToReplicationController; +import org.apache.stratos.cloud.controller.functions.PodToMemberContext; import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.interfaces.Iaas; @@ -49,7 +56,6 @@ import org.apache.stratos.kubernetes.client.model.Pod; import org.apache.stratos.kubernetes.client.model.ReplicationController; import org.apache.stratos.kubernetes.client.model.Service; -import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; @@ -59,6 +65,7 @@ import org.jclouds.compute.domain.Template; import org.jclouds.rest.ResourceNotFoundException; import org.wso2.carbon.registry.core.exceptions.RegistryException; +import org.apache.stratos.messaging.domain.topology.Application; import java.util.*; import java.util.Map.Entry; @@ -74,7 +81,7 @@ */ public class CloudControllerServiceImpl implements CloudControllerService { - private static final Log log = LogFactory + private static final Log LOG = LogFactory .getLog(CloudControllerServiceImpl.class); private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder .getInstance(); @@ -102,22 +109,22 @@ private void acquireData() { currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); currentData.setCartridges(serializedObj.getCartridges()); currentData.setKubClusterIdToKubClusterContext(serializedObj.getKubClusterIdToKubClusterContext()); - currentData.setServiceGroups(serializedObj.getServiceGroups()); + currentData.setServiceGroups(serializedObj.getServiceGroups()); - if(log.isDebugEnabled()) { + if(LOG.isDebugEnabled()) { - log.debug("Cloud Controller Data is retrieved from registry."); + LOG.debug("Cloud Controller Data is retrieved from registry."); } } else { - if(log.isDebugEnabled()) { + if(LOG.isDebugEnabled()) { - log.debug("Cloud Controller Data cannot be found in registry."); + LOG.debug("Cloud Controller Data cannot be found in registry."); } } } catch (Exception e) { String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected."; - log.warn(msg, e); + LOG.warn(msg, e); } } @@ -128,8 +135,8 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In handleNullObject(cartridgeConfig, "Invalid Cartridge Definition: Definition is null."); - if(log.isDebugEnabled()){ - log.debug("Cartridge definition: " + cartridgeConfig.toString()); + if(LOG.isDebugEnabled()){ + LOG.debug("Cartridge definition: " + cartridgeConfig.toString()); } Cartridge cartridge = null; @@ -141,7 +148,7 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In "Invalid Cartridge Definition: Cartridge Type: " + cartridgeConfig.getType()+ ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage(); - log.error(msg, e); + LOG.error(msg, e); throw new InvalidCartridgeDefinitionException(msg, e); } @@ -156,11 +163,19 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In throw new InvalidCartridgeDefinitionException(msg); } - for (IaasProvider iaasProvider : iaases) { - CloudControllerUtil.getIaas(iaasProvider); - } - } - + if (iaases == null || iaases.isEmpty()) { + String msg = + "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType()+ + ". Cause: Iaases of this Cartridge is null or empty."; + LOG.error(msg); + throw new InvalidCartridgeDefinitionException(msg); + } + + for (IaasProvider iaasProvider : iaases) { + CloudControllerUtil.getIaas(iaasProvider); + } + // TODO transaction begins String cartridgeType = cartridge.getType(); if(dataHolder.getCartridge(cartridgeType) != null) { @@ -184,8 +199,10 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In TopologyBuilder.handleServiceCreated(cartridgeList); // transaction ends - - log.info("Successfully deployed the Cartridge definition: " + cartridgeType); + + LOG.info("Successfully deployed the Cartridge definition: " + cartridgeType); + + } } private void populateNewCartridge(Cartridge cartridge, @@ -201,8 +218,8 @@ private void populateNewCartridge(Cartridge cartridge, String partitionId = entry.getKey(); IaasProvider oldIaasProvider = entry.getValue(); if (newIaasProviders.contains(oldIaasProvider)) { - if (log.isDebugEnabled()) { - log.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " + if (LOG.isDebugEnabled()) { + LOG.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() ); } cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider))); @@ -219,8 +236,8 @@ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCart // invalidate partition validation cache dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType); - if (log.isDebugEnabled()) { - log.debug("Partition cache invalidated for cartridge "+cartridgeType); + if (LOG.isDebugEnabled()) { + LOG.debug("Partition cache invalidated for cartridge "+cartridgeType); } persist(); @@ -230,150 +247,150 @@ public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCart cartridgeList.add(cartridge); TopologyBuilder.handleServiceRemoved(cartridgeList); - if(log.isInfoEnabled()) { - log.info("Successfully undeployed the Cartridge definition: " + cartridgeType); + if(LOG.isInfoEnabled()) { + LOG.info("Successfully undeployed the Cartridge definition: " + cartridgeType); } return; } } String msg = "Cartridge [type] "+cartridgeType+" is not a deployed Cartridge type."; - log.error(msg); + LOG.error(msg); throw new InvalidCartridgeTypeException(msg); } - + public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException { - - if (servicegroup == null) { + + if (servicegroup == null) { String msg = "Invalid ServiceGroup Definition: Definition is null."; - log.error(msg); + LOG.error(msg); throw new IllegalArgumentException(msg); } - - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName()); + + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName()); } + + String [] subGroups = servicegroup.getCartridges(); + - String [] subGroups = servicegroup.getCartridges(); - - - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups); + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups); if (subGroups != null) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length); + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length); } else { - log.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null"); + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null"); } } - - - Dependencies dependencies = servicegroup.getDependencies(); - - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); - } - - if (dependencies != null) { - String [] startupOrders = dependencies.getStartupOrders(); - - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); - - if (startupOrders != null) { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); - } else { - log.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); - } - } + + + Dependencies dependencies = servicegroup.getDependencies(); + + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); } - - dataHolder.addServiceGroup(servicegroup); - - this.persist(); - + + if (dependencies != null) { + String [] startupOrders = dependencies.getStartupOrders(); + + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); + + if (startupOrders != null) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); + } else { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); + } + } + } + + dataHolder.addServiceGroup(servicegroup); + + this.persist(); + } - + public void undeployServiceGroup(String name) throws InvalidServiceGroupException { - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:undeployServiceGroup: " + name); + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:undeployServiceGroup: " + name); } - + ServiceGroup serviceGroup = null; - + serviceGroup = dataHolder.getServiceGroup(name); - + if (serviceGroup != null) { if (dataHolder.getServiceGroups().remove(serviceGroup)) { persist(); - if(log.isInfoEnabled()) { - log.info("Successfully undeployed the Service Group definition: " + serviceGroup); + if(LOG.isInfoEnabled()) { + LOG.info("Successfully undeployed the Service Group definition: " + serviceGroup); } return; } - } - + } + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; - log.error(msg); + LOG.error(msg); throw new InvalidServiceGroupException(msg); - + } - + @Override public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupException { - - if(log.isDebugEnabled()) { - log.debug("getServiceGroupDefinition:" + name); + + if(LOG.isDebugEnabled()) { + LOG.debug("getServiceGroupDefinition:" + name); } - - ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); - - if (serviceGroup == null) { - if(log.isDebugEnabled()) { - log.debug("getServiceGroupDefinition: no entry found for service group " + name); + + ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); + + if (serviceGroup == null) { + if(LOG.isDebugEnabled()) { + LOG.debug("getServiceGroupDefinition: no entry found for service group " + name); } - String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; - throw new InvalidServiceGroupException(msg); - } - - return serviceGroup; + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; + throw new InvalidServiceGroupException(msg); + } + + return serviceGroup; } - + public String [] getServiceGroupSubGroups (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - - return serviceGroup.getSubGroups(); + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + + return serviceGroup.getSubGroups(); } - + /** - * + * */ public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - String [] cs = serviceGroup.getCartridges(); - return cs; - + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + String [] cs = serviceGroup.getCartridges(); + return cs; + } - + public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - return serviceGroup.getDependencies(); + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + return serviceGroup.getDependencies(); } - + @Override public MemberContext startInstance(MemberContext memberContext) throws UnregisteredCartridgeException, InvalidIaasProviderException { - if(log.isDebugEnabled()) { - log.debug("CloudControllerServiceImpl:startInstance"); + if(LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:startInstance"); } handleNullObject(memberContext, "Instance start-up failed. Member is null."); @@ -385,7 +402,6 @@ public MemberContext startInstance(MemberContext memberContext) throws LOG.debug("Received an instance spawn request : " + memberContext); } - ComputeService computeService = null; Template template = null; handleNullObject(partition, "Instance start-up failed. Specified Partition is null. " + @@ -413,8 +429,8 @@ public MemberContext startInstance(MemberContext memberContext) throws IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partitionId); if (iaasProvider == null) { - if (log.isDebugEnabled()) { - log.debug("IaasToPartitionMap "+cartridge.hashCode() + if (LOG.isDebugEnabled()) { + LOG.debug("IaasToPartitionMap "+cartridge.hashCode() + " for cartridge "+cartridgeType+ " and for partition: "+partitionId); } String msg = "Instance start-up failed. " @@ -427,7 +443,7 @@ public MemberContext startInstance(MemberContext memberContext) throws + cartridge.getPartitionToIaasProvider().keySet() .toString() + ". " + memberContext.toString() + ". "; - log.fatal(msg); + LOG.fatal(msg); throw new InvalidIaasProviderException(msg); } String type = iaasProvider.getType(); @@ -513,7 +529,7 @@ public MemberContext startInstance(MemberContext memberContext) throws } catch (Exception e) { String msg = "Failed to start an instance. " + memberContext.toString()+" Cause: "+e.getMessage(); - log.error(msg, e); + LOG.error(msg, e); throw new IllegalStateException(msg, e); } @@ -527,8 +543,8 @@ private void createVolumeAndSetInClusterContext(Volume volume, String snapshotId = volume.getSnapshotId(); if(StringUtils.isNotEmpty(volume.getVolumeId())){ // volumeID is specified, so not creating additional volumes - if(log.isDebugEnabled()){ - log.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId()); + if(LOG.isDebugEnabled()){ + LOG.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId()); } volume.setId(volume.getVolumeId()); }else{ @@ -544,8 +560,8 @@ private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) { StringBuilder persistencePayload = new StringBuilder(); if(isPersistenceMappingAvailable(ctx)){ for(Volume volume : ctx.getVolumes()){ - if(log.isDebugEnabled()){ - log.debug("Adding persistence mapping " + volume.toString()); + if(LOG.isDebugEnabled()){ + LOG.debug("Adding persistence mapping " + volume.toString()); } if(persistencePayload.length() != 0) { persistencePayload.append("|"); @@ -558,8 +574,8 @@ private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) { persistencePayload.append(volume.getMappingPath()); } } - if(log.isDebugEnabled()){ - log.debug("Persistence payload is" + persistencePayload.toString()); + if(LOG.isDebugEnabled()){ + LOG.debug("Persistence payload is" + persistencePayload.toString()); } return persistencePayload; } @@ -583,7 +599,7 @@ private void persist() { } catch (RegistryException e) { String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; - log.fatal(msg); + LOG.fatal(msg); throw new CloudControllerException(msg, e); } } @@ -603,7 +619,7 @@ public void terminateInstance(String memberId) throws InvalidMemberException, In if(ctxt == null) { String msg = "Termination failed. Invalid Member Id: "+memberId; - log.error(msg); + LOG.error(msg); throw new InvalidMemberException(msg); } @@ -633,7 +649,7 @@ public void run() { // these will never be null, since we do not add null values for these. Cartridge cartridge = dataHolder.getCartridge(cartridgeType); - log.info("Starting to terminate an instance with member id : " + memberId + + LOG.info("Starting to terminate an instance with member id : " + memberId + " in partition id: " + partitionId + " of cluster id: " + clusterId + " and of cartridge type: " + cartridgeType); @@ -642,7 +658,7 @@ public void run() { "Termination of Member Id: " + memberId + " failed. " + "Cannot find a matching Cartridge for type: " + cartridgeType; - log.error(msg); + LOG.error(msg); throw new InvalidCartridgeTypeException(msg); } @@ -655,7 +671,7 @@ public void run() { // log information logTermination(ctxt); - log.error(msg); + LOG.error(msg); throw new InvalidMemberException(msg); } @@ -670,26 +686,24 @@ public void run() { } catch (Exception e) { String msg = "Instance termination failed. "+ctxt.toString(); - log.error(msg, e); + LOG.error(msg, e); throw new CloudControllerException(msg, e); } } } - private class IpAllocator implements Runnable { + private class JcloudsInstanceCreator implements Runnable { private MemberContext memberContext; private IaasProvider iaasProvider; private String cartridgeType; - NodeMetadata node; - public IpAllocator(MemberContext memberContext, IaasProvider iaasProvider, - String cartridgeType, NodeMetadata node) { + public JcloudsInstanceCreator(MemberContext memberContext, IaasProvider iaasProvider, + String cartridgeType) { this.memberContext = memberContext; this.iaasProvider = iaasProvider; this.cartridgeType = cartridgeType; - this.node = node; } @Override @@ -897,7 +911,7 @@ public void run() { } catch (Exception e) { String msg = "Error occurred while allocating an ip address. " + memberContext.toString(); - log.error(msg, e); + LOG.error(msg, e); throw new CloudControllerException(msg, e); } @@ -952,7 +966,7 @@ private IaasProvider terminate(IaasProvider iaasProvider, String msg = "Instance termination failed. " +ctxt.toString() + ". Cause: Unable to build Iaas of this " + iaasProvider.toString(); - log.error(msg, e); + LOG.error(msg, e); throw new CloudControllerException(msg, e); } @@ -969,7 +983,7 @@ private IaasProvider terminate(IaasProvider iaasProvider, iaas.releaseAddress(ctxt.getAllocatedIpAddress()); } - log.info("Member is terminated: "+ctxt.toString()); + LOG.info("Member is terminated: "+ctxt.toString()); return iaasProvider; } @@ -986,8 +1000,8 @@ private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { Iaas iaas = iaasProvider.getIaas(); iaas.detachVolume(ctxt.getInstanceId(), volumeId); } catch (ResourceNotFoundException ignore) { - if(log.isDebugEnabled()) { - log.debug(ignore); + if(LOG.isDebugEnabled()) { + LOG.debug(ignore); } } } @@ -1166,7 +1180,7 @@ public void unregisterService(String clusterId) throws UnregisteredClusterExcept } else { - TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); +// TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); Runnable terminateInTimeout = new Runnable() { @Override @@ -1418,6 +1432,24 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } + public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + Application application = applicationParser.parse(applicationContext); + + // Create a Cluster Context obj. for each of the Clusters in the Application + for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { + dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), + applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), + applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster(), null)); + } + + TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), + applicationParser.getPayloadData()); + + persist(); + } + @Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException { @@ -1833,6 +1865,12 @@ public MemberContext[] updateContainers(String clusterId, int replicas) } } + @Override + public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { + + TopologyBuilder.handleApplicationUndeployed(applicationId); + } + @Override public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException { @@ -1887,29 +1925,5 @@ private void handleNullObject(Object obj, String errorMsg) { } } - public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - Application application = applicationParser.parse(applicationContext); - - // Create a Cluster Context obj. for each of the Clusters in the Application - for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { - dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), - applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), - applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); - } - - TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), - applicationParser.getPayloadData()); - - persist(); - } - - @Override - public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - - TopologyBuilder.handleApplicationUndeployed(applicationId); - } - } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 88ff2b6a94..797f2998f6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -32,6 +32,7 @@ import org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageListener; import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; +import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; import org.apache.stratos.messaging.util.Constants; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index bf7409511a..550926665e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -57,8 +57,8 @@ public static void handleServiceCreated(List cartridgeList) { Service service; Topology topology = TopologyManager.getTopology(); if (cartridgeList == null) { - log.warn(String.format("Cartridge list is empty")); - return; + log.warn(String.format("Cartridge list is empty")); + return; } try { @@ -95,7 +95,7 @@ public static void handleServiceCreated(List cartridgeList) { public static void handleServiceRemoved(List cartridgeList) { Topology topology = TopologyManager.getTopology(); - for (Cartridge cartridge : cartridgeList) { + for (Cartridge cartridge : cartridgeList) { if (topology.getService(cartridge.getType()).getClusters().size() == 0) { if (topology.serviceExists(cartridge.getType())) { try { @@ -107,7 +107,7 @@ public static void handleServiceRemoved(List cartridgeList) { } TopologyEventPublisher.sendServiceRemovedEvent(cartridgeList); } else { - log.warn(String.format("Service %s does not exist..", cartridge.getType())); + log.warn(String.format("Service %s does not exist..", cartridge.getType())); } } else { log.warn("Subscription already exists. Hence not removing the service:" + cartridge.getType() @@ -116,8 +116,10 @@ public static void handleServiceRemoved(List cartridgeList) { } } + public static void handleClusterCreated(Registrant registrant, boolean isLb) { - /*Topology topology = TopologyManager.getTopology(); + /** + Topology topology = TopologyManager.getTopology(); Service service; try { TopologyManager.acquireWriteLock(); @@ -129,17 +131,17 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { } Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); - + Cluster cluster; String clusterId = registrant.getClusterId(); if (service.clusterExists(clusterId)) { // update the cluster cluster = service.getCluster(clusterId); cluster.addHostName(registrant.getHostName()); - if (service.getServiceType() == ServiceType.MultiTenant) { + if(service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); } - if (service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { + if(service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { props.setProperty(Constants.IS_PRIMARY, service.getProperties().getProperty(Constants.IS_PRIMARY)); } cluster.setProperties(props); @@ -147,17 +149,16 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { setKubernetesCluster(cluster); } else { cluster = new Cluster(cartridgeType, clusterId, - registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName(), null); + registrant.getDeploymentPolicyName(), registrant.getAutoScalerPolicyName()); cluster.addHostName(registrant.getHostName()); - if (service.getServiceType() == ServiceType.MultiTenant) { + if(service.getServiceType() == ServiceType.MultiTenant) { cluster.setTenantRange(registrant.getTenantRange()); } - if (service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { + if(service.getProperties().getProperty(Constants.IS_PRIMARY) != null) { props.setProperty(Constants.IS_PRIMARY, service.getProperties().getProperty(Constants.IS_PRIMARY)); } cluster.setProperties(props); cluster.setLbCluster(isLb); - //cluster.setStatus(Status.Created); setKubernetesCluster(cluster); cluster.setStatus(ClusterStatus.Created); service.addCluster(cluster); @@ -167,9 +168,11 @@ public static void handleClusterCreated(Registrant registrant, boolean isLb) { } finally { TopologyManager.releaseWriteLock(); - }*/ + } + **/ } + private static void setKubernetesCluster(Cluster cluster) { boolean isKubernetesCluster = (cluster.getProperties().getProperty(StratosConstants.KUBERNETES_CLUSTER_ID) != null); if (log.isDebugEnabled()) { @@ -183,16 +186,16 @@ public static void handleClusterRemoved(ClusterContext ctxt) { Service service = topology.getService(ctxt.getCartridgeType()); String deploymentPolicy; if (service == null) { - log.warn(String.format("Service %s does not exist", + log.warn(String.format("Service %s does not exist", ctxt.getCartridgeType())); - return; + return; } if (!service.clusterExists(ctxt.getClusterId())) { - log.warn(String.format("Cluster %s does not exist for service %s", + log.warn(String.format("Cluster %s does not exist for service %s", ctxt.getClusterId(), ctxt.getCartridgeType())); - return; + return; } try { @@ -206,96 +209,94 @@ public static void handleClusterRemoved(ClusterContext ctxt) { TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy); } - /*public static void handleClusterMaintenanceMode(ClusterContext ctxt) { - - Topology topology = TopologyManager.getTopology(); - Service service = topology.getService(ctxt.getCartridgeType()); - if (service == null) { - log.warn(String.format("Service %s does not exist", - ctxt.getCartridgeType())); - return; - } + public static void handleMemberSpawned(String serviceName, + String clusterId, String partitionId, + String privateIp, String publicIp, MemberContext context) { + // adding the new member to the cluster after it is successfully started + // in IaaS. + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(serviceName); + Cluster cluster = service.getCluster(clusterId); + String memberId = context.getMemberId(); + String networkPartitionId = context.getNetworkPartitionId(); + String lbClusterId = context.getLbClusterId(); + long initTime = context.getInitTime(); + + if (cluster.memberExists(memberId)) { + log.warn(String.format("Member %s already exists", memberId)); + return; + } - if (!service.clusterExists(ctxt.getClusterId())) { - log.warn(String.format("Cluster %s does not exist for service %s", - ctxt.getClusterId(), - ctxt.getCartridgeType())); - return; - } + try { + TopologyManager.acquireWriteLock(); + Member member = new Member(serviceName, clusterId, + networkPartitionId, partitionId, memberId, initTime); + member.setStatus(MemberStatus.Created); + member.setMemberIp(privateIp); + member.setLbClusterId(lbClusterId); + member.setMemberPublicIp(publicIp); + member.setProperties(CloudControllerUtil.toJavaUtilProperties(context.getProperties())); + try { + // Update port mappings with generated service proxy port + // TODO: Need to properly fix with the latest Kubernetes version + String serviceHostPortStr = CloudControllerUtil.getProperty(context.getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT); + if(StringUtils.isEmpty(serviceHostPortStr)) { + log.warn("Kubernetes service host port not found for member: [member-id] " + memberId); + } - try { - TopologyManager.acquireWriteLock(); - Cluster cluster = service.getCluster(ctxt.getClusterId()); - if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) { - log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); + Cartridge cartridge = FasterLookUpDataHolder.getInstance(). + getCartridge(serviceName); + List portMappings = cartridge.getPortMappings(); + Port port; + // Adding ports to the member + for (PortMapping portMapping : portMappings) { + if (cluster.isKubernetesCluster() && (StringUtils.isNotEmpty(serviceHostPortStr))) { + port = new Port(portMapping.getProtocol(), + Integer.parseInt(serviceHostPortStr), + Integer.parseInt(portMapping.getProxyPort())); + member.addPort(port); + } else { + port = new Port(portMapping.getProtocol(), + Integer.parseInt(portMapping.getPort()), + Integer.parseInt(portMapping.getProxyPort())); + member.addPort(port); + } + } + } catch (Exception e) { + log.error("Could not update member port-map: [member-id] " + memberId, e); } - cluster.setStatus(ClusterStatus.Inactive); - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - TopologyEventPublisher.sendClusterMaintenanceModeEvent(ctxt); - }*/ - - - public static void handleMemberSpawned(String serviceName, - String clusterId, String partitionId, - String privateIp, String publicIp, MemberContext context) { - // adding the new member to the cluster after it is successfully started - // in IaaS. - Topology topology = TopologyManager.getTopology(); - Service service = topology.getService(serviceName); - Cluster cluster = service.getCluster(clusterId); - String memberId = context.getMemberId(); - String networkPartitionId = context.getNetworkPartitionId(); - String lbClusterId = context.getLbClusterId(); - - if (cluster.memberExists(memberId)) { - log.warn(String.format("Member %s already exists", memberId)); - return; - } - - try { - TopologyManager.acquireWriteLock(); - Member member = new Member(serviceName, clusterId, - networkPartitionId, partitionId, memberId); - //member.setStatus(MemberStatus.Created); - member.setMemberIp(privateIp); - member.setLbClusterId(lbClusterId); - member.setMemberPublicIp(publicIp); - member.setProperties(CloudControllerUtil.toJavaUtilProperties(context.getProperties())); - cluster.addMember(member); - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendInstanceSpawnedEvent(serviceName, clusterId, - networkPartitionId, partitionId, memberId, lbClusterId, - publicIp, privateIp, context); - } - + cluster.addMember(member); + TopologyManager.updateTopology(topology); + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendInstanceSpawnedEvent(serviceName, clusterId, + networkPartitionId, partitionId, memberId, lbClusterId, + publicIp, privateIp, context); + } + public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceStartedEvent.getServiceName()); if (service == null) { - log.warn(String.format("Service %s does not exist", + log.warn(String.format("Service %s does not exist", instanceStartedEvent.getServiceName())); - return; + return; } if (!service.clusterExists(instanceStartedEvent.getClusterId())) { - log.warn(String.format("Cluster %s does not exist in service %s", + log.warn(String.format("Cluster %s does not exist in service %s", instanceStartedEvent.getClusterId(), instanceStartedEvent.getServiceName())); - return; + return; } Member member = service.getCluster(instanceStartedEvent.getClusterId()). getMember(instanceStartedEvent.getMemberId()); if (member == null) { - log.warn(String.format("Member %s does not exist", + log.warn(String.format("Member %s does not exist", instanceStartedEvent.getMemberId())); - return; + return; } try { @@ -315,12 +316,12 @@ public static void handleMemberStarted(InstanceStartedEvent instanceStartedEvent TopologyEventPublisher.sendMemberStartedEvent(instanceStartedEvent); //publishing data CartridgeInstanceDataPublisher.publish(instanceStartedEvent.getMemberId(), - instanceStartedEvent.getPartitionId(), - instanceStartedEvent.getNetworkPartitionId(), - instanceStartedEvent.getClusterId(), - instanceStartedEvent.getServiceName(), - MemberStatus.Starting.toString(), - null); + instanceStartedEvent.getPartitionId(), + instanceStartedEvent.getNetworkPartitionId(), + instanceStartedEvent.getClusterId(), + instanceStartedEvent.getServiceName(), + MemberStatus.Starting.toString(), + null); } public static void handleMemberActivated(InstanceActivatedEvent instanceActivatedEvent) { @@ -328,28 +329,27 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate Service service = topology.getService(instanceActivatedEvent.getServiceName()); if (service == null) { log.warn(String.format("Service %s does not exist", - instanceActivatedEvent.getServiceName())); + instanceActivatedEvent.getServiceName())); return; } - + Cluster cluster = service.getCluster(instanceActivatedEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceActivatedEvent.getClusterId())); + instanceActivatedEvent.getClusterId())); return; } - Member member = cluster.getMember(instanceActivatedEvent.getMemberId()); if (member == null) { - log.warn(String.format("Member %s does not exist", + log.warn(String.format("Member %s does not exist", instanceActivatedEvent.getMemberId())); - return; + return; } MemberActivatedEvent memberActivatedEvent = new MemberActivatedEvent(instanceActivatedEvent.getServiceName(), - instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); + instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); // grouping - set grouid memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId()); @@ -361,9 +361,19 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate } member.setStatus(MemberStatus.Activated); log.info("member started event adding status activated"); - // Adding ports to the event - // TODO: Need to remove this since ports are now set in member spawned event - memberActivatedEvent.addPorts(member.getPorts()); + Cartridge cartridge = FasterLookUpDataHolder.getInstance(). + getCartridge(instanceActivatedEvent.getServiceName()); + + List portMappings = cartridge.getPortMappings(); + Port port; + //adding ports to the event + for (PortMapping portMapping : portMappings) { + port = new Port(portMapping.getProtocol(), + Integer.parseInt(portMapping.getPort()), + Integer.parseInt(portMapping.getProxyPort())); + member.addPort(port); + memberActivatedEvent.addPort(port); + } memberActivatedEvent.setMemberIp(member.getMemberIp()); memberActivatedEvent.setMemberPublicIp(member.getMemberPublicIp()); @@ -375,29 +385,29 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate TopologyEventPublisher.sendMemberActivatedEvent(memberActivatedEvent); //publishing data CartridgeInstanceDataPublisher.publish(memberActivatedEvent.getMemberId(), - memberActivatedEvent.getPartitionId(), - memberActivatedEvent.getNetworkPartitionId(), - memberActivatedEvent.getClusterId(), - memberActivatedEvent.getServiceName(), - MemberStatus.Activated.toString(), - null); + memberActivatedEvent.getPartitionId(), + memberActivatedEvent.getNetworkPartitionId(), + memberActivatedEvent.getClusterId(), + memberActivatedEvent.getServiceName(), + MemberStatus.Activated.toString(), + null); } public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent instanceReadyToShutdownEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceReadyToShutdownEvent.getServiceName()); //update the status of the member if (service == null) { - log.warn(String.format("Service %s does not exist", - instanceReadyToShutdownEvent.getServiceName())); - return; + log.warn(String.format("Service %s does not exist", + instanceReadyToShutdownEvent.getServiceName())); + return; } Cluster cluster = service.getCluster(instanceReadyToShutdownEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceReadyToShutdownEvent.getClusterId())); + instanceReadyToShutdownEvent.getClusterId())); return; } @@ -409,11 +419,11 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst return; } MemberReadyToShutdownEvent memberReadyToShutdownEvent = new MemberReadyToShutdownEvent( - instanceReadyToShutdownEvent.getServiceName(), - instanceReadyToShutdownEvent.getClusterId(), - instanceReadyToShutdownEvent.getNetworkPartitionId(), - instanceReadyToShutdownEvent.getPartitionId(), - instanceReadyToShutdownEvent.getMemberId()); + instanceReadyToShutdownEvent.getServiceName(), + instanceReadyToShutdownEvent.getClusterId(), + instanceReadyToShutdownEvent.getNetworkPartitionId(), + instanceReadyToShutdownEvent.getPartitionId(), + instanceReadyToShutdownEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); @@ -430,30 +440,30 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst TopologyEventPublisher.sendMemberReadyToShutdownEvent(memberReadyToShutdownEvent); //publishing data CartridgeInstanceDataPublisher.publish(instanceReadyToShutdownEvent.getMemberId(), - instanceReadyToShutdownEvent.getPartitionId(), - instanceReadyToShutdownEvent.getNetworkPartitionId(), - instanceReadyToShutdownEvent.getClusterId(), - instanceReadyToShutdownEvent.getServiceName(), - MemberStatus.ReadyToShutDown.toString(), - null); + instanceReadyToShutdownEvent.getPartitionId(), + instanceReadyToShutdownEvent.getNetworkPartitionId(), + instanceReadyToShutdownEvent.getClusterId(), + instanceReadyToShutdownEvent.getServiceName(), + MemberStatus.ReadyToShutDown.toString(), + null); //termination of particular instance will be handled by autoscaler } - public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) - throws InvalidMemberException, InvalidCartridgeTypeException { + public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instanceMaintenanceModeEvent) + throws InvalidMemberException, InvalidCartridgeTypeException { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(instanceMaintenanceModeEvent.getServiceName()); //update the status of the member if (service == null) { log.warn(String.format("Service %s does not exist", - instanceMaintenanceModeEvent.getServiceName())); + instanceMaintenanceModeEvent.getServiceName())); return; } Cluster cluster = service.getCluster(instanceMaintenanceModeEvent.getClusterId()); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - instanceMaintenanceModeEvent.getClusterId())); + instanceMaintenanceModeEvent.getClusterId())); return; } @@ -466,11 +476,11 @@ public static void handleMemberMaintenance(InstanceMaintenanceModeEvent instance MemberMaintenanceModeEvent memberMaintenanceModeEvent = new MemberMaintenanceModeEvent( - instanceMaintenanceModeEvent.getServiceName(), - instanceMaintenanceModeEvent.getClusterId(), - instanceMaintenanceModeEvent.getNetworkPartitionId(), - instanceMaintenanceModeEvent.getPartitionId(), - instanceMaintenanceModeEvent.getMemberId()); + instanceMaintenanceModeEvent.getServiceName(), + instanceMaintenanceModeEvent.getClusterId(), + instanceMaintenanceModeEvent.getNetworkPartitionId(), + instanceMaintenanceModeEvent.getPartitionId(), + instanceMaintenanceModeEvent.getMemberId()); try { TopologyManager.acquireWriteLock(); // try update lifecycle state @@ -495,23 +505,23 @@ public static void handleMemberTerminated(String serviceName, String clusterId, Properties properties; if (service == null) { log.warn(String.format("Service %s does not exist", - serviceName)); + serviceName)); return; } Cluster cluster = service.getCluster(clusterId); if (cluster == null) { log.warn(String.format("Cluster %s does not exist", - clusterId)); + clusterId)); return; } - + Member member = cluster.getMember(memberId); - if (member == null) { - log.warn(String.format("Member with nodeID %s does not exist", - memberId)); - return; - } + if (member == null) { + log.warn(String.format("Member with member id %s does not exist", + memberId)); + return; + } try { TopologyManager.acquireWriteLock(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 7ac8334647..b561afe842 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -1,4 +1,3 @@ -package org.apache.stratos.cloud.controller.topology; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -17,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -import java.util.List; -import java.util.Properties; + +package org.apache.stratos.cloud.controller.topology; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -29,25 +28,10 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; 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.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Port; -import org.apache.stratos.messaging.domain.topology.ServiceType; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; -import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; -import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; -import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; -import org.apache.stratos.messaging.event.topology.InstanceSpawnedEvent; -import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; -import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; -import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; -import org.apache.stratos.messaging.event.topology.MemberStartedEvent; -import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; -import org.apache.stratos.messaging.event.topology.ServiceCreatedEvent; -import org.apache.stratos.messaging.event.topology.ServiceRemovedEvent; +import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.util.Util; import java.util.List; @@ -58,8 +42,7 @@ * this is to send the relevant events from cloud controller to topology topic */ public class TopologyEventPublisher { - private static final Log log = LogFactory - .getLog(TopologyEventPublisher.class); + private static final Log log = LogFactory.getLog(TopologyEventPublisher.class); public static void sendServiceCreateEvent(List cartridgeList) { ServiceCreatedEvent serviceCreatedEvent; @@ -100,13 +83,11 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } } - public static void sendClusterCreatedEvent(String serviceName, - String clusterId, Cluster cluster) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent( - serviceName, clusterId, cluster); + public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { + ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId); if (log.isInfoEnabled()) { - log.info("Publishing cluster created event: " + cluster.toString()); + log.info("Publishing cluster created event: " + clusterId); } publishEvent(clusterCreatedEvent); } @@ -140,7 +121,8 @@ public static void sendApplicationUndeployedEvent (String applicationId, Set Date: Thu, 30 Oct 2014 15:21:12 +0530 Subject: [PATCH 310/436] Fixing cli component merge issues --- .../java/org/apache/stratos/cli/Command.java | 5 +--- .../stratos/cli/RestCommandLineService.java | 1 - .../stratos/cli/StratosApplication.java | 8 ++--- .../cli/commands/ActivateTenantCommand.java | 3 +- .../cli/commands/AddDomainMappingCommand.java | 3 +- .../cli/commands/AddTenantCommand.java | 30 ++++++++----------- .../cli/commands/DeactivateTenantCommand.java | 3 +- .../cli/commands/DeleteTenantCommand.java | 3 +- .../DescribeAutoScalingPolicyCommand.java | 2 +- .../commands/DescribeCartridgeCommand.java | 2 +- .../DescribeDeploymentPolicyCommand.java | 2 +- .../commands/DescribePartitionCommand.java | 3 +- .../stratos/cli/commands/ExitCommand.java | 3 +- .../stratos/cli/commands/HelpCommand.java | 3 +- .../stratos/cli/commands/InfoCommand.java | 3 +- .../stratos/cli/commands/ListAllTenants.java | 3 +- .../cli/commands/ListCartridgesCommand.java | 3 +- .../commands/ListDeployServiceCommand.java | 3 +- .../cli/commands/ListMemberCommand.java | 14 ++++----- .../stratos/cli/commands/SyncCommand.java | 3 +- .../UndeployCartridgeDefinitionCommand.java | 3 +- .../UndeployServiceDefinitionCommand.java | 3 +- .../cli/commands/UnsubscribeCommand.java | 9 ++---- .../src/main/resources/log4j.properties | 2 +- 24 files changed, 41 insertions(+), 76 deletions(-) diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java index 5f777ce788..65165561bc 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/Command.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.exception.CommandException; @@ -59,12 +58,10 @@ public interface Command { * The context assoicated with the Command Line Application * @param args * The arguments for the command - * @param already_parsed_opts - * Options parsed by any parent parsers. * @return The status code * @throws org.apache.stratos.cli.exception.CommandException * if any errors occur when executing the command */ - int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException; + int execute(T context, String[] args) throws CommandException; } 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 a2d4702176..64df59ebf8 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 @@ -785,7 +785,6 @@ public void subscribe(String cartridgeType, String alias, String externalRepoURL DefaultHttpClient httpClient = new DefaultHttpClient(); CartridgeInfoBean cartridgeInfoBean = new CartridgeInfoBean(); - GsonBuilder gsonBuilder = new GsonBuilder(); Gson gson = gsonBuilder.create(); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java index 9fcaf9be3e..a528e61e02 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java @@ -249,8 +249,6 @@ public int run(String[] args) { // Command action String action = null; - // Command action options - Option[] actionOptions = null; String usernameInput = null; String passwordInput = null; @@ -268,7 +266,6 @@ public int run(String[] args) { CommandLine commandLine; try { // Must add all options. Otherwise actions cannot be performed directly by command line. - // This is because the parser trips over unrecognised options. Options allCommandOptions = new Options(); for (Command command : commands.values()) { Options commandOptions = command.getOptions(); @@ -287,7 +284,6 @@ public int run(String[] args) { commandLine = parser.parse(options, args, true); remainingArgs = commandLine.getArgs(); - actionOptions = commandLine.getOptions(); if (remainingArgs != null && remainingArgs.length > 0) { // Get command action action = remainingArgs[0]; @@ -353,7 +349,7 @@ public int run(String[] args) { if (logger.isDebugEnabled()) { logger.debug("Executing Action: {} {}", action, Arrays.asList(actionArgs)); } - int returnCode = command.execute(context, actionArgs, actionOptions); + int returnCode = command.execute(context, actionArgs); if (logger.isDebugEnabled()) { logger.debug("Exiting with error code {} after executing action {}", returnCode, action); } @@ -449,7 +445,7 @@ protected int executeCommand(String line) { return CliConstants.COMMAND_FAILED; } try { - return command.execute(context, actionArgs, new Option[0]); + return command.execute(context, actionArgs); } catch (CommandException e) { if (logger.isErrorEnabled()) { logger.error("Error executing command: " + action, e); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java index ea050f4260..4f4ca3b4eb 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ActivateTenantCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java index d6ccfa3994..773e64f590 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddDomainMappingCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -52,7 +51,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java index 23c6017c62..3b9b218837 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/AddTenantCommand.java @@ -29,8 +29,6 @@ import org.apache.commons.cli.Options; import org.apache.commons.cli.Option; -import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; - public class AddTenantCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(AddTenantCommand.class); @@ -89,7 +87,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -107,48 +105,46 @@ public int execute(StratosCommandContext context, String[] args, Option[] alread try { commandLine = parser.parse(options, args); - //merge newly discovered options with previously discovered ones. - Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Add tenant"); } - if (opts.hasOption(CliConstants.USERNAME_OPTION)) { + if (commandLine.hasOption(CliConstants.USERNAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Username option is passed"); } - admin = opts.getOption(CliConstants.USERNAME_OPTION).getValue(); + admin = commandLine.getOptionValue(CliConstants.USERNAME_OPTION); } - if (opts.hasOption(CliConstants.FIRST_NAME_OPTION)) { + if (commandLine.hasOption(CliConstants.FIRST_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("First name option is passed"); } - firstName = opts.getOption(CliConstants.FIRST_NAME_OPTION).getValue(); + firstName = commandLine.getOptionValue(CliConstants.FIRST_NAME_OPTION); } - if (opts.hasOption(CliConstants.LAST_NAME_OPTION)) { + if (commandLine.hasOption(CliConstants.LAST_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Last name option is passed"); } - lastaName = opts.getOption(CliConstants.LAST_NAME_OPTION).getValue(); + lastaName = commandLine.getOptionValue(CliConstants.LAST_NAME_OPTION); } - if (opts.hasOption(CliConstants.PASSWORD_OPTION)) { + if (commandLine.hasOption(CliConstants.PASSWORD_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Password option is passed"); } - password = opts.getOption(CliConstants.PASSWORD_OPTION).getValue(); + password = commandLine.getOptionValue(CliConstants.PASSWORD_OPTION); } - if (opts.hasOption(CliConstants.DOMAIN_NAME_OPTION)) { + if (commandLine.hasOption(CliConstants.DOMAIN_NAME_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Domain name option is passed"); } - domain = opts.getOption(CliConstants.DOMAIN_NAME_OPTION).getValue(); + domain = commandLine.getOptionValue(CliConstants.DOMAIN_NAME_OPTION); } - if (opts.hasOption(CliConstants.EMAIL_OPTION)) { + if (commandLine.hasOption(CliConstants.EMAIL_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Email option is passed"); } - email = opts.getOption(CliConstants.EMAIL_OPTION).getValue(); + email = commandLine.getOptionValue(CliConstants.EMAIL_OPTION); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java index a82fd1ed5e..ee9e15a250 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeactivateTenantCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java index eebedd9800..3c0b3f5e02 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeleteTenantCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java index efe04bfeb4..a7e6945f6e 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeAutoScalingPolicyCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java index 066c2e198c..cb4608e312 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeCartridgeCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java index 811027d4c1..3fe22ef8c5 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribeDeploymentPolicyCommand.java @@ -51,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java index aa0ce817a4..3709f4d7e7 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DescribePartitionCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java index a437d65a5d..46051130d7 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ExitCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +49,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { // Nothing to execute here. This is a special command. if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java index 8c1ed13e78..2257f1144e 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/HelpCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,7 +49,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } 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 dde7a12738..a15e215afe 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 @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,7 +50,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java index 9f60ccded3..1540c7ccd2 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListAllTenants.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -47,7 +46,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java index 9208c20a02..3492d76e9c 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListCartridgesCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.RestCommandLineService; import org.slf4j.Logger; @@ -47,7 +46,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java index d1d2c7d8a0..a45ac0200c 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListDeployServiceCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -47,7 +46,7 @@ public String getArgumentSyntax() { return null; } - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java index 7aa07a0109..cbdf0391dd 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/ListMemberCommand.java @@ -27,8 +27,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; - public class ListMemberCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(ListMemberCommand.class); @@ -80,7 +78,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -92,23 +90,21 @@ public int execute(StratosCommandContext context, String[] args, Option[] alread CommandLine commandLine; try { commandLine = parser.parse(options, args); - //merge newly discovered options with previously discovered ones. - Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); if (logger.isDebugEnabled()) { logger.debug("Subscribing to {} cartridge with alias {}", type, alias); } - if (opts.hasOption(CliConstants.CARTRIDGE_TYPE_OPTION)) { + if (commandLine.hasOption(CliConstants.CARTRIDGE_TYPE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Autoscaling policy option is passed"); } - type = opts.getOption(CliConstants.CARTRIDGE_TYPE_OPTION).getValue(); + type = commandLine.getOptionValue(CliConstants.CARTRIDGE_TYPE_OPTION); } - if (opts.hasOption(CliConstants.ALIAS_OPTION)) { + if (commandLine.hasOption(CliConstants.ALIAS_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Deployment policy option is passed"); } - alias = opts.getOption(CliConstants.ALIAS_OPTION).getValue(); + alias = commandLine.getOptionValue(CliConstants.ALIAS_OPTION); } if (type == null) { diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java index 760e6fd66f..017bf15ba8 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/SyncCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -51,7 +50,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java index b22bf5b7a5..9af7b3628e 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployCartridgeDefinitionCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java index c634335e8c..37e1a76318 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceDefinitionCommand.java @@ -18,7 +18,6 @@ */ package org.apache.stratos.cli.commands; -import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.stratos.cli.Command; import org.apache.stratos.cli.RestCommandLineService; @@ -52,7 +51,7 @@ public Options getOptions() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java index ff4967ab29..c56db7d458 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UnsubscribeCommand.java @@ -32,8 +32,6 @@ import org.apache.stratos.cli.exception.CommandException; import org.apache.stratos.cli.utils.CliConstants; -import static org.apache.stratos.cli.utils.CommandLineUtils.mergeOptionArrays; - public class UnsubscribeCommand implements Command { private static final Logger logger = LoggerFactory.getLogger(UnsubscribeCommand.class); @@ -73,7 +71,7 @@ public String getArgumentSyntax() { } @Override - public int execute(StratosCommandContext context, String[] args, Option[] already_parsed_opts) throws CommandException { + public int execute(StratosCommandContext context, String[] args) throws CommandException { if (logger.isDebugEnabled()) { logger.debug("Executing {} command...", getName()); } @@ -86,9 +84,6 @@ public int execute(StratosCommandContext context, String[] args, Option[] alread try { commandLine = parser.parse(options, args); remainingArgs = commandLine.getArgs(); - //merge newly discovered options with previously discovered ones. - Options opts = mergeOptionArrays(already_parsed_opts, commandLine.getOptions()); - if (remainingArgs != null && remainingArgs.length == 1) { // Get alias alias = remainingArgs[0]; @@ -100,7 +95,7 @@ public int execute(StratosCommandContext context, String[] args, Option[] alread return CliConstants.COMMAND_FAILED; } - if (opts.hasOption(CliConstants.FORCE_OPTION)) { + if (commandLine.hasOption(CliConstants.FORCE_OPTION)) { if (logger.isTraceEnabled()) { logger.trace("Force option is passed"); } diff --git a/components/org.apache.stratos.cli/src/main/resources/log4j.properties b/components/org.apache.stratos.cli/src/main/resources/log4j.properties index 15304ee3e5..5826f682e6 100644 --- a/components/org.apache.stratos.cli/src/main/resources/log4j.properties +++ b/components/org.apache.stratos.cli/src/main/resources/log4j.properties @@ -33,4 +33,4 @@ log4j.appender.file.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %c #Loggers log4j.rootLogger=info, file -log4j.logger.org.wso2.carbon.adc.mgt.cli=DEBUG +log4j.logger.org.wso2.carbon.adc.mgt.cli=INFO From 4a475b699315b8e386b4fe900e707231d3dfeac3 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Thu, 30 Oct 2014 15:37:32 +0530 Subject: [PATCH 311/436] Removing cluster maintenance mode event listener in autoscaler --- .../AutoscalerTopologyEventReceiver.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index de058ece6a..e03ff52674 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -33,14 +33,12 @@ import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterMaintenanceModeEventListener; import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener; import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; @@ -158,31 +156,6 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new ClusterMaintenanceModeEventListener() { - @Override - protected void onEvent(Event event) { - try { - log.info("Event received: " + event); - ClusterMaintenanceModeEvent clusterMaintenanceModeEvent = (ClusterMaintenanceModeEvent) event; - TopologyManager.acquireReadLock(); - Service service = TopologyManager.getTopology().getService(clusterMaintenanceModeEvent.getServiceName()); - Cluster cluster = service.getCluster(clusterMaintenanceModeEvent.getClusterId()); - AbstractClusterMonitor monitor; - monitor = AutoscalerContext.getInstance().getClusterMonitor(cluster.getClusterId()); - if (null == monitor) { - log.error("cluster monitor not exists for the cluster: " + cluster.toString()); - return; - } - monitor.setStatus(clusterMaintenanceModeEvent.getStatus()); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } finally { - TopologyManager.releaseReadLock(); - } - } - }); - topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override protected void onEvent(Event event) { From 932f31f2bce87c3b48c9bf373c744b5ec1f029c5 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 15:31:27 +0530 Subject: [PATCH 312/436] fixing issues faced while evaluating status --- .../monitor/AbstractClusterMonitor.java | 5 +- .../monitor/ParentComponentMonitor.java | 78 +++++++++++-------- .../application/ApplicationMonitor.java | 11 ++- .../monitor/cluster/ClusterMonitor.java | 29 ++++--- .../monitor/group/GroupMonitor.java | 19 ++++- .../status/checker/StatusChecker.java | 24 +++--- 6 files changed, 103 insertions(+), 63 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index fb23985930..881f838be3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -240,12 +240,13 @@ public void setStatus(ClusterStatus status) { log.info("[Cluster] " + clusterId + "is not notifying the parent, " + "since it is identified as the independent unit"); - } else if (status == ClusterStatus.Terminating) { + /*} else if (status == ClusterStatus.Terminating) { // notify parent log.info("[Cluster] " + clusterId + " is not notifying the parent, " + "since it is in Terminating State"); - +*/ } else { + log.info("[Group] " + this.id + "is notifying the [parent] " + this.parent.getId()); MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); } //} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 537e855266..58cdb1ab8b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.Application; import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; @@ -190,42 +191,17 @@ protected void onChildTerminatedEvent(String idOfEvent) { * Make sure that all the dependents have been terminated properly to start the recovery */ if (terminationList != null) { - for (ApplicationContext context1 : terminationList) { - if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { - log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); - allDependentTerminated = false; - } else if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated..."); - allDependentTerminated = false; - } else { - allDependentTerminated = true; - } - } + allDependentTerminated = allDependentTerminated(terminationList); } List parentContexts = this.dependencyTree.findAllParentContextWithId(idOfEvent); - boolean canStart = false; + boolean parentsTerminated = false; if (parentContexts != null) { - for (ApplicationContext context1 : parentContexts) { - if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { - log.info("Waiting for the [Parent Monitor] " + context1.getId() - + " to be terminated"); - canStart = false; - } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { - if (canStart) { - log.warn("Found the Dependent [monitor] " + context1.getId() - + " in the active list wrong state"); - } - } else { - log.info("[Parent Monitor] " + context1.getId() - + " has already been terminated"); - canStart = true; - } - } + parentsTerminated = allParentTerminated(parentContexts); } if ((terminationList != null && allDependentTerminated || terminationList == null) && - (parentContexts != null && canStart || parentContexts == null)) { + (parentContexts != null && parentsTerminated || parentContexts == null)) { //Find the non existent monitor by traversing dependency tree try { this.startDependencyOnTermination(); @@ -235,13 +211,53 @@ protected void onChildTerminatedEvent(String idOfEvent) { } } else { StatusChecker.getInstance().onChildStatusChange(idOfEvent, this.id, this.appId); - log.info("Waiting for the dependent of [monitor] " + idOfEvent - + " to be terminated"); + log.info("" + + "Checking the status of group/application as no dependent found..."); } } + private boolean allDependentTerminated(List terminationList) { + boolean allDependentTerminated = false; + for (ApplicationContext context1 : terminationList) { + if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + log.warn("Dependent [monitor] " + context1.getId() + " not in the correct state"); + allDependentTerminated = false; + return allDependentTerminated; + } else if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [dependent] " + context1.getId() + " to be terminated..."); + allDependentTerminated = false; + return allDependentTerminated; + } else { + allDependentTerminated = true; + } + } + return allDependentTerminated; + } + + + private boolean allParentTerminated(List parentContexts) { + boolean parentsTerminated = false; + for (ApplicationContext context1 : parentContexts) { + if (this.aliasToInActiveMonitorsMap.containsKey(context1.getId())) { + log.info("Waiting for the [Parent Monitor] " + context1.getId() + + " to be terminated"); + parentsTerminated = false; + return parentsTerminated; + } else if (this.aliasToActiveMonitorsMap.containsKey(context1.getId())) { + if (parentsTerminated) { + log.warn("Found the Dependent [monitor] " + context1.getId() + + " in the active list wrong state"); + } + } else { + log.info("[Parent Monitor] " + context1.getId() + + " has already been terminated"); + parentsTerminated = true; + } + } + return parentsTerminated; + } /** * This will start the parallel dependencies at once from the top level. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index e7e3238606..6256c02da2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -162,9 +162,18 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) { + //mark the child monitor as inActive in the map + this.markMonitorAsInactive(id); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. - this.aliasToInActiveMonitorsMap.remove(id); + if(this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToInActiveMonitorsMap.remove(id); + } else { + log.warn("[monitor] " + id + " cannot be found in the inActive monitors list"); + } + if (this.status != ApplicationStatus.Terminating || this.status != ApplicationStatus.Terminated) { onChildTerminatedEvent(id); } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 6d7e8caca0..67539ed4d9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -73,18 +73,26 @@ public ClusterMonitor(String clusterId, String serviceId, DeploymentPolicy deplo //status = ClusterStatus.Created; } + private static void terminateMember(String memberId) { + try { + CloudControllerClient.getInstance().terminate(memberId); + + } catch (TerminationException e) { + log.error("Unable to terminate member [member id ] " + memberId, e); + } + } @Override public void run() { while (!isDestroyed()) { try { - if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || - (this.status == ClusterStatus.Inactive && !hasDependent) || - !this.hasFaultyMember) { + if (((this.status.getCode() <= ClusterStatus.Active.getCode()) || + (this.status == ClusterStatus.Inactive && !hasDependent)) && !this.hasFaultyMember) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } monitor(); + } else { if (log.isDebugEnabled()) { log.debug("Cluster monitor is suspended as the cluster is in " + @@ -106,8 +114,8 @@ public void run() { @Override public void terminateAllMembers() { - Thread memberTerminator = new Thread(new Runnable(){ - public void run(){ + Thread memberTerminator = new Thread(new Runnable() { + public void run() { for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { @@ -125,7 +133,7 @@ public void run(){ } // pending members - for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { + for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); terminateMember(pendingMemberCtxt.getMemberId()); } @@ -146,15 +154,6 @@ public void run(){ memberTerminator.start(); } - private static void terminateMember (String memberId) { - try { - CloudControllerClient.getInstance().terminate(memberId); - - } catch (TerminationException e) { - log.error("Unable to terminate member [member id ] " + memberId, e); - } - } - private boolean isPrimaryMember(MemberContext memberContext) { Properties props = memberContext.getProperties(); if (log.isDebugEnabled()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index fc79c59648..a9aeb57725 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.EventHandler; +import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; @@ -72,15 +73,25 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) { + //mark the child monitor as inActive in the map + this.markMonitorAsInactive(id); + } else if (status1 == ClusterStatus.Terminated || status1 == GroupStatus.Terminated) { //Check whether all dependent goes Terminated and then start them in parallel. - this.aliasToInActiveMonitorsMap.remove(id); + if(this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToInActiveMonitorsMap.remove(id); + } else { + log.warn("[monitor] " + id + " cannot be found in the inActive monitors list"); + } + if (this.status != GroupStatus.Terminating || this.status != GroupStatus.Terminated) { onChildTerminatedEvent(id); } else { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); } + } } @@ -90,7 +101,6 @@ public void onParentEvent(MonitorStatusEvent statusEvent) { if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) { StatusEventPublisher.sendGroupTerminatingEvent(appId, id); - this.markMonitorAsInactive(id); } } @@ -147,12 +157,13 @@ public void setStatus(GroupStatus status) { log.info("[Group] " + this.id + "is not notifying the parent, " + "since it is identified as the independent unit"); - } else if (status == GroupStatus.Terminating) { + /*} else if (status == GroupStatus.Terminating) { log.info("[Group] " + this.id + " is not notifying the parent, " + "since it is in Terminating State"); - +*/ } else { // notify parent + log.info("[Group] " + this.id + "is notifying the [parent] " + this.parent.getId()); MonitorStatusEventBuilder.handleGroupStatusEvent(this.parent, this.status, this.id); } //} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 3a925d1b8b..bc08c56df0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -68,6 +68,7 @@ public void run() { // if active then notify upper layer if (clusterActive) { //send event to cluster status topic + monitor.setHasFaultyMember(false); StatusEventPublisher.sendClusterActivatedEvent(monitor.getAppId(), monitor.getServiceId(), monitor.getClusterId()); } @@ -251,7 +252,10 @@ public void run() { */ private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { - boolean groupActive = false; + boolean groupsActive = false; + boolean groupsTerminated = false; + boolean groupsInActive = false; + boolean groupsTerminating = false; ClusterStatus clusterStatus; GroupStatus groupStatus; boolean childFound = false; @@ -350,19 +354,19 @@ private boolean updateChildStatus(String appId, String id, Map gr private GroupStatus getGroupStatus(Map groups) { GroupStatus status = null; - boolean groupActive = false; - boolean groupTerminated = false; + boolean groupActive = true; + boolean groupTerminated = true; for (Group group : groups.values()) { if (group.getStatus() == GroupStatus.Active) { - groupActive = true; - groupTerminated = false; + groupActive = groupActive && true; + groupTerminated = false; } else if (group.getStatus() == GroupStatus.Inactive) { status = GroupStatus.Inactive; break; } else if (group.getStatus() == GroupStatus.Terminated) { groupActive = false; - groupTerminated = true; + groupTerminated = groupTerminated && true; } else if (group.getStatus() == GroupStatus.Created) { groupActive = false; groupTerminated = false; @@ -386,13 +390,13 @@ private GroupStatus getGroupStatus(Map groups) { private ClusterStatus getClusterStatus(Map clusterData) { ClusterStatus status = null; - boolean clusterActive = false; - boolean clusterTerminated = false; + boolean clusterActive = true; + boolean clusterTerminated = true; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); if (cluster.getStatus() == ClusterStatus.Active) { - clusterActive = true; + clusterActive = clusterActive && true; clusterTerminated = false; } else if (cluster.getStatus() == ClusterStatus.Inactive) { status = ClusterStatus.Inactive; @@ -401,7 +405,7 @@ private ClusterStatus getClusterStatus(Map clusterDat break; } else if (cluster.getStatus() == ClusterStatus.Terminated) { clusterActive = false; - clusterTerminated = true; + clusterTerminated = clusterTerminated && true; } else if (cluster.getStatus() == ClusterStatus.Terminating) { status = ClusterStatus.Terminating; clusterActive = false; From 5a171c559641591efc3c536fcc4217fa7f38f78b Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 15:50:10 +0530 Subject: [PATCH 313/436] fixing the wrongly used log statement --- .../stratos/cloud/controller/topology/TopologyBuilder.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index b6e3470928..1daec32e76 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -1020,7 +1020,7 @@ public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent even try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Terminated); - log.info("Group activated adding status started for" + group.getUniqueIdentifier()); + log.info("Group Terminated adding status started for" + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { @@ -1054,7 +1054,7 @@ public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent ev try { TopologyManager.acquireWriteLock(); group.setStatus(GroupStatus.Terminating); - log.info("Group activated adding status started for " + group.getUniqueIdentifier()); + log.info("Group Terminating adding status started for " + group.getUniqueIdentifier()); TopologyManager.updateTopology(topology); } finally { From 255087ddae1b984ef40ad705e8caa5cf62b11c13 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 16:07:02 +0530 Subject: [PATCH 314/436] fixing terminating issues --- .../monitor/application/ApplicationMonitor.java | 8 ++++---- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 6256c02da2..4632361efd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -162,7 +162,7 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); - } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) { + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { //mark the child monitor as inActive in the map this.markMonitorAsInactive(id); @@ -174,11 +174,11 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { log.warn("[monitor] " + id + " cannot be found in the inActive monitors list"); } - if (this.status != ApplicationStatus.Terminating || this.status != ApplicationStatus.Terminated) { - onChildTerminatedEvent(id); - } else { + if (this.status == ApplicationStatus.Terminating || this.status == ApplicationStatus.Terminated) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); + } else { + onChildTerminatedEvent(id); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index a9aeb57725..4a789bfb54 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -73,7 +73,7 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); - } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminated) { + } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { //mark the child monitor as inActive in the map this.markMonitorAsInactive(id); @@ -85,11 +85,12 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { log.warn("[monitor] " + id + " cannot be found in the inActive monitors list"); } - if (this.status != GroupStatus.Terminating || this.status != GroupStatus.Terminated) { - onChildTerminatedEvent(id); - } else { + if (this.status == GroupStatus.Terminating || this.status == GroupStatus.Terminated) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); + } else { + onChildTerminatedEvent(id); + } } From dcf4e24f24093947bab4e4aae672f3f3fb5c0244 Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 16:48:30 +0530 Subject: [PATCH 315/436] fixing to read empty list --- .../stratos/autoscaler/monitor/ParentComponentMonitor.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 58cdb1ab8b..ced698c2e9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -179,7 +179,7 @@ protected void onChildInActiveEvent(String idOfEvent) { protected void onChildTerminatedEvent(String idOfEvent) { List terminationList; - boolean allDependentTerminated = true; + boolean allDependentTerminated = false; ApplicationContext context = this.dependencyTree.findApplicationContextWithId(idOfEvent); context.setTerminated(true); @@ -200,8 +200,8 @@ protected void onChildTerminatedEvent(String idOfEvent) { parentsTerminated = allParentTerminated(parentContexts); } - if ((terminationList != null && allDependentTerminated || terminationList == null) && - (parentContexts != null && parentsTerminated || parentContexts == null)) { + if ((terminationList != null && allDependentTerminated || terminationList.isEmpty()) && + (parentContexts != null && parentsTerminated || parentContexts.isEmpty())) { //Find the non existent monitor by traversing dependency tree try { this.startDependencyOnTermination(); From be580189e419253bd869b9b66d5ebbdfeb9a39d7 Mon Sep 17 00:00:00 2001 From: lasinducharith Date: Thu, 30 Oct 2014 17:15:59 +0530 Subject: [PATCH 316/436] Updating CC & AS wsdls and fixing compilation errors in SM --- .../client/CloudControllerServiceClient.java | 2 +- .../manager/CartridgeSubscriptionManager.java | 18 +- .../src/main/resources/AutoScalerService.wsdl | 1562 ++++++++--------- .../resources/CloudControllerService.wsdl | 1420 ++++++++++----- 4 files changed, 1759 insertions(+), 1243 deletions(-) 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 75f48d876a..5c84a7c1cb 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 @@ -24,7 +24,7 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.internal.DataHolder; 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 index eedd1e502e..7d59bc952e 100644 --- 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 @@ -254,17 +254,7 @@ public void persistApplicationSubscription (ApplicationSubscription compositeApp throw new ADCException(e); } } - - public SubscriptionInfo subscribeToCartridgeWithProperties(SubscriptionData subscriptionData) throws ADCException, - InvalidCartridgeAliasException, - DuplicateCartridgeAliasException, - PolicyException, - UnregisteredCartridgeException, - RepositoryRequiredException, - RepositoryCredentialsRequiredException, - RepositoryTransportException, - AlreadySubscribedException, - InvalidRepositoryException { + /** * * @param subscriptionData @@ -662,7 +652,7 @@ public SubscriptionDomain getSubscriptionDomain(int tenantId, String subscriptio } } - public boolean isSubscriptionDomainValid(String domainName) throws ADCException { + public static boolean isSubscriptionDomainValid(String domainName) throws ADCException { try { if(log.isDebugEnabled()) { log.debug(String.format("Validating domain: %s", domainName)); @@ -712,7 +702,7 @@ public Collection getCartridgeSubscriptions (int tenantId } } - public CartridgeSubscription getCartridgeSubscription (int tenantId, String subscriptionAlias) { + public static CartridgeSubscription getCartridgeSubscription (int tenantId, String subscriptionAlias) { return new DataInsertionAndRetrievalManager().getCartridgeSubscription(tenantId, subscriptionAlias); } @@ -777,7 +767,7 @@ public void unsubscribeFromCartridge (String tenantDomain, String alias) } } - private Properties getPersistenceMappingProperties (PersistenceContext persistenceCtxt, CartridgeInfo cartridgeInfo) throws ADCException { + private static Properties getPersistenceMappingProperties (PersistenceContext persistenceCtxt, CartridgeInfo cartridgeInfo) throws ADCException { if (!cartridgeInfo.isPersistenceSpecified()) { // Persistence Mapping not supported in the cartridge definition - error diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index ad13570cc7..7d56741488 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,2065 +1,2065 @@ - + AutoScalerService - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - + + + + - - - - - - - - - - - - - - + + + + - + - - + + - + - + + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + + + - + - + - + - + + + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - + - + - + - + + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - - - + - + - + - + - - - + - + - + - + - - - - + - + - + - + - - - - + - + - + - + - - + + - + - + - + - + - + - - + + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - - + + - - - + + + - - - - - - + + + + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - - - - + + + + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - - - + + + + - - + + - - + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - - + + - + - + + + + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - - + + - + - + + + + - + - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - - + + - + - + + + + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - - + + - + - + + + + - + - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - - - - - - - + - + - + + + + + + + - + - + - + - + - + - + \ No newline at end of file diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 26ecead78d..a72d88d646 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,1251 +1,1777 @@ - + CloudControllerService - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + + + + + + + + + - + - + - + - + - + - - - - + + + + + - + - + - + - + - - + + - + - + - - + + - + - + - + - + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - + - + - + - + + + + + + + + - + - + - + + + + + + + + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + + + + + + + + - + - + + + + + + + + - - - + + + - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - - + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - + + - - + + - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - + - - - + + + - - + + - - - - - - - + + + + + + + - + - + - + - + + + + - + - + - + - + + + + + + + + + + - + - + - + + + + + + + - + - + - - + + - - + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + + - + - + + + + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + - - - + + + - - + + + - - - - + + + + + + + + + - - - + + + + + + + + - - - + + + - - - - + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + - - - + + + + + + + - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - + + + + + + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + + + + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + + + + - + + + + + + + + + + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + + + + + + + + + - + - + - + - + - + - + + + + + + + + + + + + + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + \ No newline at end of file From 58f42cee3f3fbc31c4f323553851f1769e9b3aab Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 30 Oct 2014 17:45:43 +0530 Subject: [PATCH 317/436] enabling state transition from Terminating to Created in Cluster and Group Statuses --- .../apache/stratos/messaging/domain/topology/ClusterStatus.java | 2 +- .../apache/stratos/messaging/domain/topology/GroupStatus.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java index afc0b30b97..b6b4a39341 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterStatus.java @@ -58,7 +58,7 @@ public Set getNextStates() { @Override public Set getNextStates() { return new HashSet(Arrays.asList(ClusterStatus.Terminating, - ClusterStatus.Terminated)); + ClusterStatus.Terminated, ClusterStatus.Created)); } }, Terminated(5) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java index 42873be35c..fbbaebcdc0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java @@ -50,7 +50,7 @@ public Set getNextStates() { @Override public Set getNextStates() { return new HashSet(Arrays.asList(GroupStatus.Terminating, - GroupStatus.Terminated)); + GroupStatus.Terminated, GroupStatus.Created)); } }, Terminated(4) { From 62240464052b72134a9d0feab29730e350ddf9e1 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Thu, 30 Oct 2014 17:48:01 +0530 Subject: [PATCH 318/436] STRATOS-934 --- .../manager/CartridgeSubscriptionManager.java | 10 +++++----- .../bean/util/converter/PojoConverter.java | 15 +++++++-------- .../rest/endpoint/services/ServiceUtils.java | 8 ++------ .../rest/endpoint/services/StratosAdmin.java | 2 -- 4 files changed, 14 insertions(+), 21 deletions(-) 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 index 7d59bc952e..69919472af 100644 --- 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 @@ -616,7 +616,7 @@ public static void removeSubscriptionDomain(int tenantId, String subscriptionAli eventPublisher.publish(event); } - public List getSubscriptionDomains(int tenantId, String subscriptionAlias) + public static List getSubscriptionDomains(int tenantId, String subscriptionAlias) throws ADCException { try { @@ -634,7 +634,7 @@ public List getSubscriptionDomains(int tenantId, String subs } } - public SubscriptionDomain getSubscriptionDomain(int tenantId, String subscriptionAlias, String domain) + public static SubscriptionDomain getSubscriptionDomain(int tenantId, String subscriptionAlias, String domain) throws ADCException { try { @@ -692,7 +692,7 @@ public static boolean isSubscriptionDomainValid(String domainName) throws ADCExc } } - public Collection getCartridgeSubscriptions (int tenantId, String type) throws ADCException { + public static Collection getCartridgeSubscriptions (int tenantId, String type) throws ADCException { if (type == null || type.isEmpty()) { return new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenantId); @@ -715,7 +715,7 @@ public static CartridgeSubscription getCartridgeSubscription (int tenantId, Stri * @throws ADCException * @throws NotSubscribedException */ - public void unsubscribeFromCartridge (String tenantDomain, String alias) + public static void unsubscribeFromCartridge (String tenantDomain, String alias) throws ADCException, NotSubscribedException { DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); @@ -791,7 +791,7 @@ private static Properties getPersistenceMappingProperties (PersistenceContext pe * @param cartridgeType * @return */ - public Collection isCartridgeSubscribed(int tenantId, String cartridgeType) { + public static Collection isCartridgeSubscribed(int tenantId, String cartridgeType) { DataInsertionAndRetrievalManager dataInsertionAndRetrievalManager = new DataInsertionAndRetrievalManager(); return dataInsertionAndRetrievalManager.getCartridgeSubscriptions(tenantId, cartridgeType); diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 871078f8e0..172f252f87 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -24,8 +24,13 @@ import org.apache.stratos.autoscaler.stub.kubernetes.PropertyE; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.ComponentContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.DependencyContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.GroupContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableContext; +import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableInfoContext; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.cloud.controller.stub.pojo.application.*; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; @@ -197,16 +202,12 @@ private static IaasConfig[] getIaasConfigsAsArray(List iaasPro } public static Persistence getPersistence(PersistenceBean persistenceBean) { - public static Persistence getPersistence(PersistenceBean persistenceBean) { - Persistence persistence = new Persistence(); persistence.setPersistanceRequired(persistenceBean.isRequired); VolumeBean[] volumeBean = new VolumeBean[persistenceBean.volume.size()]; persistenceBean.volume.toArray(volumeBean); Volume[] volumes = new Volume[persistenceBean.volume.size()]; for (int i = 0; i < volumes.length; i++) { - Volume[] volumes = new Volume[persistenceBean.volume.size()]; - for (int i = 0 ; i < volumes.length ; i++) { Volume volume = new Volume(); volume.setId(volumeBean[i].id); volume.setVolumeId(volumeBean[i].volumeId); @@ -892,8 +893,6 @@ private static PortRange populatePortRangePojo(org.apache.stratos.autoscaler.stu return portRangeBean; } - private static Log log = LogFactory.getLog(PojoConverter.class); - public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) { ApplicationContext applicationContext = new ApplicationContext(); @@ -985,7 +984,7 @@ private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List subscribableDefinitions) { + private static SubscribableContext[] getSubscribableContextArrayFromSubscribableDefinitions(List subscribableDefinitions) { SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()]; int i = 0; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 53b8e52f07..dc164b8625 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -25,15 +25,14 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; +import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager; @@ -42,10 +41,6 @@ import org.apache.stratos.manager.deploy.service.ServiceDeploymentManager; import org.apache.stratos.manager.dto.Cartridge; import org.apache.stratos.manager.dto.SubscriptionInfo; -import org.apache.stratos.manager.exception.ADCException; -import org.apache.stratos.manager.exception.DomainMappingExistsException; -import org.apache.stratos.manager.exception.NotSubscribedException; -import org.apache.stratos.manager.exception.ServiceDoesNotExistException; import org.apache.stratos.manager.exception.*; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.grouping.manager.ServiceGroupingManager; @@ -82,6 +77,7 @@ 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; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java index f889e02744..f28a8e6fa8 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/StratosAdmin.java @@ -547,8 +547,6 @@ public Response getAvailableSingleTenantCartridgeInfo(@PathParam("cartridgeType" public Response getAvailableLbCartridges() throws RestAPIException { List lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext()); return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build(); - List lbCartridges = ServiceUtils.getAvailableLbCartridges(false, getConfigContext()); - return Response.ok().entity(lbCartridges.isEmpty() ? new Cartridge[0] : lbCartridges.toArray(new Cartridge[lbCartridges.size()])).build(); } @GET From 2414bca4bf4ffcd373f010156c7d683afd11567d Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 17:57:09 +0530 Subject: [PATCH 319/436] adding created events for cluster and group in topology and in app statuc topics --- .../status/AppStatusClusterCreatedEvent.java | 50 ++++++++ .../status/AppStatusGroupCreatedEvent.java | 44 +++++++ .../event/topology/GroupCreatedEvent.java | 43 +++++++ .../AppStatusClusterCreatedEventListener.java | 24 ++++ .../AppStatusGroupCreatedEventListener.java | 24 ++++ .../topology/GroupCreatedEventListener.java | 27 +++++ ...pStatusClusterCreatedMessageProcessor.java | 58 ++++++++++ ...AppStatusGroupCreatedMessageProcessor.java | 62 ++++++++++ .../AppStatusMessageProcessorChain.java | 15 ++- .../topology/GroupCreatedProcessor.java | 109 ++++++++++++++++++ .../TopologyMessageProcessorChain.java | 6 + 11 files changed, 461 insertions(+), 1 deletion(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java new file mode 100644 index 0000000000..6480af2e72 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class AppStatusClusterCreatedEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public AppStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java new file mode 100644 index 0000000000..04ee30ee91 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.application.status; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class AppStatusGroupCreatedEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private String groupId; + private String appId; + + public AppStatusGroupCreatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getGroupId() { + return this.groupId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java new file mode 100644 index 0000000000..e3794f0390 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/GroupCreatedEvent.java @@ -0,0 +1,43 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Group Activated Event which will be sent to Topology upon group activation + */ +public class GroupCreatedEvent extends Event { + private String appId; + private String groupId; + + public GroupCreatedEvent(String appId, String groupId) { + this.appId = appId; + this.groupId = groupId; + } + + public String getAppId() { + return appId; + } + + public String getGroupId() { + return groupId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java new file mode 100644 index 0000000000..c0c62f9b5a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class AppStatusClusterCreatedEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java new file mode 100644 index 0000000000..82386a3eb7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.application.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class AppStatusGroupCreatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java new file mode 100644 index 0000000000..3fb2d11f16 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered by the groups activation processor after processing the event + */ +public abstract class GroupCreatedEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java new file mode 100644 index 0000000000..a743c43b22 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java @@ -0,0 +1,58 @@ +/* + * 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.messaging.message.processor.application.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusClusterCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class AppStatusClusterCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppStatusClusterCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AppStatusClusterCreatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + AppStatusClusterCreatedEvent event = (AppStatusClusterCreatedEvent) Util.jsonToObject(message, AppStatusClusterCreatedEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received AppStatusClusterCreatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java new file mode 100644 index 0000000000..b9a1c6d6e5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.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.messaging.message.processor.application.status; + + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; +import org.apache.stratos.messaging.event.application.status.AppStatusGroupCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +public class AppStatusGroupCreatedMessageProcessor extends MessageProcessor { + private static final Log log = + LogFactory.getLog(AppStatusGroupCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AppStatusGroupCreatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + AppStatusGroupCreatedEvent event = + (AppStatusGroupCreatedEvent) Util.jsonToObject(message, AppStatusGroupCreatedEvent.class); + + if (log.isDebugEnabled()) { + log.debug("Received AppStatusGroupCreatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException( + String.format("Failed to process group created message " + + "using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java index 14b8bc2309..34cd02b0cc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java @@ -31,10 +31,12 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain { private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class); + private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor; private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor; private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; + private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor; private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor; private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor; @@ -48,6 +50,9 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain { public void initialize() { // Add instance notifier event processors + clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor(); + add(clusterCreatedMessageProcessor); + clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor(); add(clusterActivatedMessageProcessor); @@ -56,9 +61,13 @@ public void initialize() { clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor(); add(clusterTerminatingMessageProcessor); + clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor(); add(clusterTerminatedMessageProcessor); + groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor(); + add(groupCreatedMessageProcessor); + groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); @@ -92,10 +101,14 @@ public void initialize() { } public void addEventListener(EventListener eventListener) { - if (eventListener instanceof AppStatusClusterActivatedEventListener) { + if(eventListener instanceof AppStatusClusterCreatedEventListener) { + clusterCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof AppStatusClusterActivatedEventListener) { clusterActivatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof AppStatusClusterInactivateEventListener) { clusterInActivateMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof AppStatusGroupCreatedEventListener) { + groupCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof AppStatusGroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){ diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java new file mode 100644 index 0000000000..4a8a744d09 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java @@ -0,0 +1,109 @@ +/* + * 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.messaging.message.processor.topology; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; +import org.apache.stratos.messaging.event.topology.GroupCreatedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +/** + * This processor will act upon the Group activation events + */ +public class GroupCreatedProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + + if (GroupCreatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + + // Parse complete message and build event + GroupCreatedEvent event = (GroupCreatedEvent) Util. + jsonToObject(message, GroupCreatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (GroupCreatedEvent event,Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } + Group group = application.getGroupRecursively(event.getGroupId()); + + if (group == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Group not exists in service: [AppId] %s [groupId] %s", event.getAppId(), + event.getGroupId())); + } + } else { + // Apply changes to the topology + if (!group.isStateTransitionValid(GroupStatus.Created)) { + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + } + group.setStatus(GroupStatus.Created); + + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 4f6d3a9766..1ed5576d7a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -46,6 +46,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor; private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; + private GroupCreatedProcessor groupCreatedProcessor; private GroupActivatedProcessor groupActivatedProcessor; private GroupInActivateProcessor groupInActivateProcessor; private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; @@ -109,6 +110,9 @@ public void initialize() { memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor(); add(memberTerminatedMessageProcessor); + groupCreatedProcessor = new GroupCreatedProcessor(); + add(groupCreatedProcessor); + groupActivatedProcessor = new GroupActivatedProcessor(); add(groupActivatedProcessor); @@ -179,6 +183,8 @@ public void addEventListener(EventListener eventListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupCreatedEventListener) { + groupCreatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupInActivateEventListener) { groupInActivateProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupTerminatedEventListener){ From 65d96bce5237a4bee999fe35d21956d886dca1cc Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 18:01:17 +0530 Subject: [PATCH 320/436] support cluster created when auto-recovery case in the member fault --- .../grouping/topic/StatusEventPublisher.java | 24 +++++++++++++++++++ .../monitor/ParentComponentMonitor.java | 2 ++ .../status/checker/StatusChecker.java | 19 +++++++++++++-- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 7bbe8ce5f5..8058c85226 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -18,6 +18,30 @@ public class StatusEventPublisher { private static final Log log = LogFactory.getLog(StatusEventPublisher.class); + public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Active)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster activated event for [application]: " + appId + + " [cluster]: " + clusterId); + } + AppStatusClusterActivatedEvent clusterActivatedEvent = + new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterActivatedEvent); + } else { + log.warn("Active is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); + } + } + public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { try { TopologyManager.acquireReadLockForCluster(serviceName, clusterId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index ced698c2e9..91d5275205 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -205,6 +205,8 @@ protected void onChildTerminatedEvent(String idOfEvent) { //Find the non existent monitor by traversing dependency tree try { this.startDependencyOnTermination(); + List applicationContexts = this.dependencyTree. + getStarAbleDependenciesByTermination(); } catch (TopologyInConsistentException e) { //TODO revert the siblings and notify parent, change a flag for reverting/un-subscription log.error("Error while starting the monitor upon termination" + e); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index bc08c56df0..97f6476bf8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -89,12 +89,24 @@ public void run() { TopologyManager.acquireReadLockForCluster(monitor.getServiceId(), monitor.getClusterId()); Service service = TopologyManager.getTopology().getService(monitor.getServiceId()); Cluster cluster; + String appId = monitor.getAppId(); if (service != null) { cluster = service.getCluster(monitor.getClusterId()); if (cluster != null) { + try { + + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { - StatusEventPublisher.sendClusterTerminatedEvent(monitor.getAppId(), monitor.getServiceId(), - monitor.getClusterId()); + if(application.getStatus() == ApplicationStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(), + monitor.getClusterId()); + } else { + StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(), + monitor.getClusterId()); + } + } else { log.info("Cluster has non terminated [members] and in the [status] " + cluster.getStatus().toString()); @@ -107,6 +119,9 @@ public void run() { }*/ } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } } } From a5dcbaa7d515c8e4d0f56cbd4144859832166b0e Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Thu, 30 Oct 2014 18:07:57 +0530 Subject: [PATCH 321/436] giving correct drools source to assembly --- .../stratos/modules/distribution/src/assembly/bin.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 8e2e0e05b4..82ae6fc218 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -669,20 +669,20 @@ true 755 - - src/main/conf/mincheck.drl + + src/main/conf/drools/mincheck.drl ${pom.artifactId}-${pom.version}/repository/conf true 755 - src/main/conf/scaling.drl + src/main/conf/drools/scaling.drl ${pom.artifactId}-${pom.version}/repository/conf true 755 - src/main/conf/terminateall.drl + src/main/conf/drools/terminateall.drl ${pom.artifactId}-${pom.version}/repository/conf true 755 From 38221dbd73ba241a22e49c85dca00763bd6ee0af Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 18:17:58 +0530 Subject: [PATCH 322/436] support group/cluster created upon termination of all members when the application is not in Terminating --- .../grouping/topic/StatusEventPublisher.java | 36 +++- .../status/checker/StatusChecker.java | 179 ++++++++++-------- 2 files changed, 125 insertions(+), 90 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 8058c85226..9b39a52dd8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -24,17 +24,17 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str Service service = TopologyManager.getTopology().getService(serviceName); if (service != null) { Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Active)) { + if (cluster.isStateTransitionValid(ClusterStatus.Created)) { if (log.isInfoEnabled()) { - log.info("Publishing Cluster activated event for [application]: " + appId + + log.info("Publishing Cluster created event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterActivatedEvent clusterActivatedEvent = - new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); + AppStatusClusterCreatedEvent clusterCreatedEvent = + new AppStatusClusterCreatedEvent(appId, serviceName, clusterId); - publishEvent(clusterActivatedEvent); + publishEvent(clusterCreatedEvent); } else { - log.warn("Active is not in the possible state list of [cluster] " + clusterId); + log.warn("Created is not in the possible state list of [cluster] " + clusterId); } } } finally { @@ -143,6 +143,30 @@ public static void sendClusterTerminatedEvent(String appId, String serviceName, } } + public static void sendGroupCreatedEvent(String appId, String groupId) { + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + if (application != null) { + Group group = application.getGroupRecursively(groupId); + if (group.isStateTransitionValid(GroupStatus.Created)) { + if (log.isInfoEnabled()) { + log.info("Publishing Group created event for [application]: " + appId + + " [group]: " + groupId); + } + AppStatusGroupCreatedEvent groupCreatedEvent = + new AppStatusGroupCreatedEvent(appId, groupId); + + publishEvent(groupCreatedEvent); + } else { + log.warn("Created is not in the possible state list of [group] " + groupId); + } + } + } finally { + TopologyManager.releaseReadLockForApplication(appId); + } + } + public static void sendGroupActivatedEvent(String appId, String groupId) { try { TopologyManager.acquireReadLockForApplication(appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 97f6476bf8..348537eb77 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -98,18 +98,18 @@ public void run() { TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { - if(application.getStatus() == ApplicationStatus.Terminating) { - StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(), - monitor.getClusterId()); - } else { - StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(), - monitor.getClusterId()); - } + if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { + if (application.getStatus() == ApplicationStatus.Terminating) { + StatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(), + monitor.getClusterId()); + } else { + StatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(), + monitor.getClusterId()); + } - } else { - log.info("Cluster has non terminated [members] and in the [status] " - + cluster.getStatus().toString()); + } else { + log.info("Cluster has non terminated [members] and in the [status] " + + cluster.getStatus().toString()); /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive || cluster.getStatus() == ClusterStatus.Terminating)) { @@ -118,7 +118,7 @@ public void run() { monitor.getServiceId(), clusterId); }*/ - } + } } finally { TopologyManager.releaseReadLockForApplication(appId); } @@ -182,7 +182,7 @@ public void run() { String appId = monitor.getAppId(); if (clusterInActive) { //if the monitor is dependent, temporarily pausing it - if(monitor.isDependent()) { + if (monitor.isDependent()) { monitor.setHasFaultyMember(true); } //send cluster In-Active event to cluster status topic @@ -201,7 +201,7 @@ public void run() { groupThread.start(); } - private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) { + private boolean getClusterInActive(AbstractClusterMonitor monitor, String partitionId) { boolean clusterInActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { for (PartitionContext partition : networkPartitionContext.getPartitionCtxts().values()) { @@ -267,10 +267,6 @@ public void run() { */ private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { - boolean groupsActive = false; - boolean groupsTerminated = false; - boolean groupsInActive = false; - boolean groupsTerminating = false; ClusterStatus clusterStatus; GroupStatus groupStatus; boolean childFound = false; @@ -286,42 +282,42 @@ private boolean updateChildStatus(String appId, String id, Map gr childFound = true; clusterStatus = getClusterStatus(clusterData); groupStatus = getGroupStatus(groups); - - if (groups.isEmpty() && clusterStatus == ClusterStatus.Active || - clusterData.isEmpty() && groupStatus == GroupStatus.Active || - groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) { - //send activation event - if (parent instanceof Application) { - //send application activated event - log.info("sending app activate: " + appId); - StatusEventPublisher.sendApplicationActivatedEvent(appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group activate: " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); - } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || - clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || - groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { - //send the in activation event - if (parent instanceof Application) { - //send application activated event - log.warn("Application can't be in in-active : " + appId); - //StatusEventPublisher.sendApplicationInactivatedEvent(appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group in-active: " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); - } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || - clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || - groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { - //send the terminated event - if (parent instanceof Application) { - //validating the life cycle - try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + try { + TopologyManager.acquireReadLockForApplication(appId); + Application application = TopologyManager.getTopology().getApplication(appId); + + if (groups.isEmpty() && clusterStatus == ClusterStatus.Active || + clusterData.isEmpty() && groupStatus == GroupStatus.Active || + groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) { + //send activation event + if (parent instanceof Application) { + //send application activated event + log.info("sending app activate: " + appId); + StatusEventPublisher.sendApplicationActivatedEvent(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group activate: " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || + clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || + groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { + //send the in activation event + if (parent instanceof Application) { + //send application activated event + log.warn("Application can't be in in-active : " + appId); + //StatusEventPublisher.sendApplicationInactivatedEvent(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group in-active: " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || + clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || + groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { + //send the terminated event + if (parent instanceof Application) { + //validating the life cycle if (application.getStatus().equals(ApplicationStatus.Terminating)) { log.info("sending app terminated: " + appId); StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); @@ -329,33 +325,38 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("[Application] " + appId + " is in the [status] " + application.getStatus().toString() + ". Hence not sending terminated event"); } - - } finally { - TopologyManager.releaseReadLockForApplication(appId); + //StatusEventPublisher.sendApp(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group created : " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); } - - //StatusEventPublisher.sendApp(appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group terminated : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); - } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || - clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || - groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) { - //send the terminated event - if (parent instanceof Application) { - //send application activated event - log.warn("Application can't be in terminating: " + appId); - //StatusEventPublisher.sendApplicationTerminatingEvent(appId); - //StatusEventPublisher.sendApp(appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group terminating : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier()); + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || + clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || + groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) { + if (parent instanceof Application) { + log.info("Application can't be in terminating: " + appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group terminating : " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created || + clusterData.isEmpty() && groupStatus == GroupStatus.Created || + groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) { + if (parent instanceof Application) { + log.info("[Application] " + appId + "couldn't change to Created, since it is" + + "already in " + application.getStatus().toString()); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group created : " + parent.getUniqueIdentifier()); + StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + } + } else { + log.warn("Clusters/groups not found in this [component] " + appId); } - } else { - log.warn("Clusters/groups not found in this [component] " + appId); + } finally { + TopologyManager.releaseReadLockForApplication(appId); } @@ -371,24 +372,28 @@ private GroupStatus getGroupStatus(Map groups) { GroupStatus status = null; boolean groupActive = true; boolean groupTerminated = true; + boolean groupCreated = true; for (Group group : groups.values()) { if (group.getStatus() == GroupStatus.Active) { groupActive = groupActive && true; - groupTerminated = false; + groupTerminated = false; + groupCreated = false; } else if (group.getStatus() == GroupStatus.Inactive) { status = GroupStatus.Inactive; break; } else if (group.getStatus() == GroupStatus.Terminated) { groupActive = false; + groupCreated = false; groupTerminated = groupTerminated && true; } else if (group.getStatus() == GroupStatus.Created) { groupActive = false; groupTerminated = false; - status = GroupStatus.Created; + groupCreated = groupCreated && true; } else if (group.getStatus() == GroupStatus.Terminating) { groupActive = false; groupTerminated = false; + groupCreated = false; status = GroupStatus.Terminating; } @@ -398,6 +403,8 @@ private GroupStatus getGroupStatus(Map groups) { status = GroupStatus.Active; } else if (groupTerminated) { status = GroupStatus.Terminated; + } else if(groupCreated) { + status = GroupStatus.Created; } return status; @@ -407,28 +414,30 @@ private ClusterStatus getClusterStatus(Map clusterDat ClusterStatus status = null; boolean clusterActive = true; boolean clusterTerminated = true; + boolean clusterCreated = true; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); if (cluster.getStatus() == ClusterStatus.Active) { clusterActive = clusterActive && true; clusterTerminated = false; + clusterCreated = false; } else if (cluster.getStatus() == ClusterStatus.Inactive) { status = ClusterStatus.Inactive; - clusterActive = false; - clusterTerminated = false; break; } else if (cluster.getStatus() == ClusterStatus.Terminated) { clusterActive = false; + clusterCreated = false; clusterTerminated = clusterTerminated && true; } else if (cluster.getStatus() == ClusterStatus.Terminating) { status = ClusterStatus.Terminating; clusterActive = false; clusterTerminated = false; + clusterCreated = false; } else if (cluster.getStatus() == ClusterStatus.Created) { - status = ClusterStatus.Created; clusterActive = false; clusterTerminated = false; + clusterCreated = clusterCreated && true; } } @@ -436,6 +445,8 @@ private ClusterStatus getClusterStatus(Map clusterDat status = ClusterStatus.Active; } else if (clusterTerminated) { status = ClusterStatus.Terminated; + } else if(clusterCreated) { + status = ClusterStatus.Created; } return status; } From db1fd260a24dfceeb4b85312f7588defe4e4f30f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 30 Oct 2014 18:25:30 +0530 Subject: [PATCH 323/436] resetting Cluster and Group statuses to Created from Terminating in Topology --- .../ApplicationStatusTopicReceiver.java | 15 ++++ .../controller/topology/TopologyBuilder.java | 74 +++++++++++++++++++ .../topology/TopologyEventPublisher.java | 9 +++ .../ClusterCreatedMessageProcessor.java | 9 ++- .../topology/GroupCreatedProcessor.java | 3 +- 5 files changed, 105 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 4d52fce09a..e155875b6f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -64,6 +64,13 @@ public void run() { private void addEventListeners() { // Listen to topology events that affect clusters + statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleClusterReset((AppStatusClusterCreatedEvent) event); + } + }); + statusEventReceiver.addEventListener(new AppStatusClusterActivatedEventListener() { @Override protected void onEvent(Event event) { @@ -92,6 +99,14 @@ protected void onEvent(Event event) { } }); + + statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleGroupReset((AppStatusGroupCreatedEvent) event); + } + }); + statusEventReceiver.addEventListener(new AppStatusGroupActivatedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 1daec32e76..5d14971033 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -114,6 +114,80 @@ public static void handleServiceRemoved(List cartridgeList) { } } + public static void handleClusterReset (AppStatusClusterCreatedEvent event) { + + TopologyManager.acquireWriteLock(); + + try { + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(event.getServiceName()); + if (service == null) { + log.error("Service " + event.getServiceName() + + " not found in Topology, unable to update the cluster status to Created"); + return; + } + + Cluster cluster = service.getCluster(event.getClusterId()); + if (cluster == null) { + log.error("Cluster " + event.getClusterId() + " not found in Topology, unable to update " + + "status to Created"); + return; + } + + // update the cluster status to Created + if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { + log.error("Invalid state transition from " + cluster.getStatus() + " to " + + ClusterStatus.Created + " for cluster id " + event.getClusterId()); + } + // forcefully update the status + cluster.setStatus(ClusterStatus.Created); + TopologyManager.updateTopology(topology); + + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendClusterCreatedEvent(event.getAppId(), event.getServiceName(), + event.getClusterId()); + } + + public static void handleGroupReset (AppStatusGroupCreatedEvent event) { + + TopologyManager.acquireWriteLock(); + + try { + Topology topology = TopologyManager.getTopology(); + + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + log.error("Application " + event.getAppId() + + " not found in Topology, unable to update the Group status to Created"); + return; + } + + Group group = application.getGroupRecursively(event.getGroupId()); + if (group == null) { + log.error("Group " + event.getGroupId() + + " not found in Topology, unable to update the Group status to Created"); + return; + } + + // update the cluster status to Created + if (!group.isStateTransitionValid(GroupStatus.Created)) { + log.error("Invalid state transition from " + group.getStatus() + " to " + + GroupStatus.Created + " for group " + event.getGroupId()); + } + // forcefully update the status + group.setStatus(GroupStatus.Created); + TopologyManager.updateTopology(topology); + + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendGroupCreatedEvent(new GroupCreatedEvent(event.getAppId(), event.getGroupId())); + } + public static void handleClusterCreated(Registrant registrant, boolean isLb) { /*Topology topology = TopologyManager.getTopology(); Service service; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index a3feb4d588..c9337d216a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -188,6 +188,15 @@ public static void sendMemberMaintenanceModeEvent(MemberMaintenanceModeEvent mem publishEvent(memberMaintenanceModeEvent); } + public static void sendGroupCreatedEvent (GroupCreatedEvent groupCreatedEvent) { + + if(log.isInfoEnabled()) { + log.info(String.format("Publishing group created event: [appId] %s [group] %s", + groupCreatedEvent.getAppId(), groupCreatedEvent.getGroupId())); + } + publishEvent(groupCreatedEvent); + } + public static void sendGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { if(log.isInfoEnabled()) { log.info(String.format("Publishing group activated event: [appId] %s [group] %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index 613c5df42d..b8cd80f796 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -20,10 +20,7 @@ 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.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; @@ -125,6 +122,10 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { // Apply changes to the topology Cluster cluster = service.getCluster(event.getClusterId()); + if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " + + "for cluster " + cluster.getClusterId()); + } cluster.setStatus(ClusterStatus.Created); if (log.isInfoEnabled()) { log.info(String.format("Cluster created: %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java index 4a8a744d09..b6d2da9ef7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java @@ -96,7 +96,8 @@ private boolean doProcess (GroupCreatedEvent event,Topology topology) { } else { // Apply changes to the topology if (!group.isStateTransitionValid(GroupStatus.Created)) { - log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " + + "for Group " + group.getAlias()); } group.setStatus(GroupStatus.Created); From d41da06c6ab034c382f25503dc926781ddac3bd2 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Thu, 30 Oct 2014 18:39:12 +0530 Subject: [PATCH 324/436] renaming couple of methods --- .../status/receiver/ApplicationStatusTopicReceiver.java | 4 ++-- .../stratos/cloud/controller/topology/TopologyBuilder.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index e155875b6f..9db0998889 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -67,7 +67,7 @@ private void addEventListeners() { statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterReset((AppStatusClusterCreatedEvent) event); + TopologyBuilder.handleClusterCreated((AppStatusClusterCreatedEvent) event); } }); @@ -103,7 +103,7 @@ protected void onEvent(Event event) { statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupReset((AppStatusGroupCreatedEvent) event); + TopologyBuilder.handleGroupCreated((AppStatusGroupCreatedEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 5d14971033..2cf490537a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -114,7 +114,7 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterReset (AppStatusClusterCreatedEvent event) { + public static void handleClusterCreated (AppStatusClusterCreatedEvent event) { TopologyManager.acquireWriteLock(); @@ -151,7 +151,7 @@ public static void handleClusterReset (AppStatusClusterCreatedEvent event) { event.getClusterId()); } - public static void handleGroupReset (AppStatusGroupCreatedEvent event) { + public static void handleGroupCreated (AppStatusGroupCreatedEvent event) { TopologyManager.acquireWriteLock(); From fe4ccedd3c31bd0c4ca3153dee0affad1880360f Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 19:02:30 +0530 Subject: [PATCH 325/436] fixing appId issue and calculating status issue --- .../stratos/autoscaler/monitor/AbstractClusterMonitor.java | 1 - .../stratos/autoscaler/status/checker/StatusChecker.java | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 881f838be3..8ec65c7af0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -63,7 +63,6 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected String clusterId; protected String serviceId; - protected String appId; protected boolean hasFaultyMember = false; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 348537eb77..a23e5bdb83 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -381,6 +381,9 @@ private GroupStatus getGroupStatus(Map groups) { groupCreated = false; } else if (group.getStatus() == GroupStatus.Inactive) { status = GroupStatus.Inactive; + groupActive = false; + groupTerminated = false; + groupCreated = false; break; } else if (group.getStatus() == GroupStatus.Terminated) { groupActive = false; @@ -424,6 +427,9 @@ private ClusterStatus getClusterStatus(Map clusterDat clusterCreated = false; } else if (cluster.getStatus() == ClusterStatus.Inactive) { status = ClusterStatus.Inactive; + clusterActive = false; + clusterTerminated = false; + clusterCreated = false; break; } else if (cluster.getStatus() == ClusterStatus.Terminated) { clusterActive = false; From ae257c168a7b7590475d0f07a8cd7bda758bbaef Mon Sep 17 00:00:00 2001 From: reka Date: Thu, 30 Oct 2014 20:13:25 +0530 Subject: [PATCH 326/436] fixing evaluating the status --- .../AutoscalerTopologyEventReceiver.java | 1 + .../monitor/AbstractClusterMonitor.java | 10 +++++++ .../monitor/cluster/ClusterMonitor.java | 3 ++- .../monitor/group/GroupMonitor.java | 14 ++++++---- .../status/checker/StatusChecker.java | 27 ++++++++++--------- 5 files changed, 36 insertions(+), 19 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index b02b2c982f..54a1461197 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -174,6 +174,7 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStop(true); clusterMonitor.setStatus(ClusterStatus.Created); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java index 8ec65c7af0..ac0871db56 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java @@ -66,6 +66,8 @@ abstract public class AbstractClusterMonitor extends Monitor implements Runnable protected boolean hasFaultyMember = false; + protected boolean stop = false; + protected ClusterStatus status; //protected ParentComponentMonitor parent; @@ -274,4 +276,12 @@ public boolean isHasFaultyMember() { public void setHasFaultyMember(boolean hasFaultyMember) { this.hasFaultyMember = hasFaultyMember; } + + public boolean isStop() { + return stop; + } + + public void setStop(boolean stop) { + this.stop = stop; + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 67539ed4d9..988f266f38 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -87,7 +87,8 @@ public void run() { while (!isDestroyed()) { try { if (((this.status.getCode() <= ClusterStatus.Active.getCode()) || - (this.status == ClusterStatus.Inactive && !hasDependent)) && !this.hasFaultyMember) { + (this.status == ClusterStatus.Inactive && !hasDependent)) && !this.hasFaultyMember + && !stop) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 4a789bfb54..3623de946f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -73,6 +73,15 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else if (status1 == ClusterStatus.Inactive || status1 == GroupStatus.Inactive) { onChildInActiveEvent(id); + } else if (status1 == ClusterStatus.Created || status1 == GroupStatus.Created) { + if(this.aliasToInActiveMonitorsMap.containsKey(id)) { + this.aliasToInActiveMonitorsMap.remove(id); + } + if (this.status == GroupStatus.Terminating) { + StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); + } else { + onChildTerminatedEvent(id); + } } else if (status1 == ClusterStatus.Terminating || status1 == GroupStatus.Terminating) { //mark the child monitor as inActive in the map this.markMonitorAsInactive(id); @@ -84,15 +93,10 @@ public void onChildEvent(MonitorStatusEvent statusEvent) { } else { log.warn("[monitor] " + id + " cannot be found in the inActive monitors list"); } - if (this.status == GroupStatus.Terminating || this.status == GroupStatus.Terminated) { StatusChecker.getInstance().onChildStatusChange(id, this.id, this.appId); log.info("Executing the un-subscription request for the [monitor] " + id); - } else { - onChildTerminatedEvent(id); - } - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index a23e5bdb83..a742b89997 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -331,7 +331,7 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("sending group created : " + parent.getUniqueIdentifier()); StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || + /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) { if (parent instanceof Application) { @@ -340,7 +340,7 @@ private boolean updateChildStatus(String appId, String id, Map gr //send activation to the parent log.info("sending group terminating : " + parent.getUniqueIdentifier()); StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier()); - } + }*/ } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created || clusterData.isEmpty() && groupStatus == GroupStatus.Created || groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) { @@ -393,15 +393,15 @@ private GroupStatus getGroupStatus(Map groups) { groupActive = false; groupTerminated = false; groupCreated = groupCreated && true; - } else if (group.getStatus() == GroupStatus.Terminating) { - groupActive = false; - groupTerminated = false; - groupCreated = false; - status = GroupStatus.Terminating; - } } + if(groups == null || groups != null && groups.isEmpty()) { + groupActive = false; + groupTerminated = false; + groupCreated = false; + } + if (groupActive) { status = GroupStatus.Active; } else if (groupTerminated) { @@ -435,11 +435,6 @@ private ClusterStatus getClusterStatus(Map clusterDat clusterActive = false; clusterCreated = false; clusterTerminated = clusterTerminated && true; - } else if (cluster.getStatus() == ClusterStatus.Terminating) { - status = ClusterStatus.Terminating; - clusterActive = false; - clusterTerminated = false; - clusterCreated = false; } else if (cluster.getStatus() == ClusterStatus.Created) { clusterActive = false; clusterTerminated = false; @@ -447,6 +442,12 @@ private ClusterStatus getClusterStatus(Map clusterDat } } + if(clusterData == null || clusterData != null && clusterData.isEmpty()) { + clusterActive = false; + clusterTerminated = false; + clusterCreated = false; + } + if (clusterActive) { status = ClusterStatus.Active; } else if (clusterTerminated) { From e1f37d63f291d091f6bf9daf216a66a171162ec1 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Fri, 31 Oct 2014 09:33:56 +0530 Subject: [PATCH 327/436] Adding autoscaler topology event listeners introduced by service grouping --- .../stratos/autoscaler/AutoscalerContext.java | 47 +- .../autoscaler/api/AutoScalerServiceImpl.java | 2 +- .../AutoscalerHealthStatEventReceiver.java | 2 +- .../AutoscalerTopologyEventReceiver.java | 803 +++++++++++++++--- .../monitor/ParentComponentMonitor.java | 5 +- .../application/ApplicationMonitor.java | 2 +- .../ApplicationMonitorFactory.java | 22 +- .../{ => cluster}/AbstractClusterMonitor.java | 5 +- .../{ => cluster}/ClusterMonitorFactory.java | 4 +- .../KubernetesClusterMonitor.java | 12 +- .../KubernetesServiceClusterMonitor.java | 7 +- .../{ => cluster}/VMClusterMonitor.java | 55 +- .../{ => cluster}/VMLbClusterMonitor.java | 2 +- .../VMServiceClusterMonitor.java | 2 +- .../status/checker/StatusChecker.java | 2 +- 15 files changed, 795 insertions(+), 177 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => application}/ApplicationMonitorFactory.java (90%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/AbstractClusterMonitor.java (98%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/ClusterMonitorFactory.java (99%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/KubernetesClusterMonitor.java (98%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/KubernetesServiceClusterMonitor.java (96%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/VMClusterMonitor.java (92%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/VMLbClusterMonitor.java (99%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/{ => cluster}/VMServiceClusterMonitor.java (99%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 2d10954ea9..e8553bc4ea 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -25,7 +25,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; /** * It holds all cluster monitors which are active in stratos. @@ -35,16 +36,15 @@ public class AutoscalerContext { private static final Log log = LogFactory.getLog(AutoscalerContext.class); private static final AutoscalerContext INSTANCE = new AutoscalerContext(); - private AutoscalerContext() { - try { - setClusterMonitors(new HashMap()); - } catch (Exception e) { - log.error("Rule evaluateMinCheck error", e); - } - } - // Map private Map clusterMonitors; + // Map + private Map applicationMonitors; + + private AutoscalerContext() { + clusterMonitors = new HashMap(); + applicationMonitors = new HashMap(); + } public static AutoscalerContext getInstance() { return INSTANCE; @@ -58,22 +58,27 @@ public AbstractClusterMonitor getClusterMonitor(String clusterId) { return clusterMonitors.get(clusterId); } - public Map getClusterMonitors() { - return clusterMonitors; + public AbstractClusterMonitor removeClusterMonitor(String clusterId) { + return clusterMonitors.remove(clusterId); } - public void setClusterMonitors(Map clusterMonitors) { - this.clusterMonitors = clusterMonitors; + public void addAppMonitor(ApplicationMonitor applicationMonitor) { + applicationMonitors.put(applicationMonitor.getId(), applicationMonitor); } - public AbstractClusterMonitor removeClusterMonitor(String clusterId) { + public ApplicationMonitor getAppMonitor(String applicationId) { + return applicationMonitors.get(applicationId); + } + + public void removeAppMonitor(String applicationId) { + applicationMonitors.remove(applicationId); + } + + public boolean appMonitorExist(String applicationId) { + return applicationMonitors.containsKey(applicationId); + } - AbstractClusterMonitor monitor = clusterMonitors.remove(clusterId); - if (monitor == null) { - log.fatal("ClusterMonitor not found for cluster id: " + clusterId); - } else { - log.info("Removed ClusterMonitor [cluster id]: " + clusterId); - } - return monitor; + public boolean clusterMonitorExist(String clusterId) { + return clusterMonitors.containsKey(clusterId); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 7748c09864..306603439b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.exception.*; import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface; import org.apache.stratos.autoscaler.kubernetes.KubernetesManager; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java index cd9aa9de01..a5c6577547 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index e03ff52674..d6a140a8cb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -21,37 +21,35 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.ClusterMonitorFactory; -import org.apache.stratos.autoscaler.monitor.VMClusterMonitor; +import org.apache.stratos.autoscaler.*; +import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; +import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.*; +import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; +import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; +import org.apache.stratos.autoscaler.monitor.cluster.KubernetesClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; +import org.apache.stratos.autoscaler.partition.PartitionManager; +import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; -import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; -import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; -import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; -import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; -import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; -import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener; -import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; -import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener; -import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener; -import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; -import org.apache.stratos.messaging.listener.topology.ServiceRemovedEventListener; +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 org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; +import java.util.List; +import java.util.Set; + /** * Autoscaler topology receiver. */ @@ -61,6 +59,7 @@ public class AutoscalerTopologyEventReceiver implements Runnable { private TopologyEventReceiver topologyEventReceiver; private boolean terminated; + private boolean topologyInitialized; public AutoscalerTopologyEventReceiver() { this.topologyEventReceiver = new TopologyEventReceiver(); @@ -97,146 +96,614 @@ private void addEventListeners() { topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() { @Override protected void onEvent(Event event) { - try { + if (!topologyInitialized) { + log.info("[CompleteTopologyEvent] Received: " + event.getClass()); + TopologyManager.acquireReadLock(); - for (Service service : TopologyManager.getTopology().getServices()) { - for (Cluster cluster : service.getClusters()) { - startClusterMonitor(cluster); + try { + for (Application application : TopologyManager.getTopology().getApplications()) { + startApplicationMonitor(application.getUniqueIdentifier()); } + + topologyInitialized = true; + } catch (Exception e) { + log.error("Error processing event", e); + } finally { + TopologyManager.releaseReadLock(); } - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } finally { - TopologyManager.releaseReadLock(); } } }); - topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { + topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() { @Override protected void onEvent(Event event) { try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent) event; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } - return; + log.info("[ApplicationCreatedEvent] Received: " + event.getClass()); + ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; + try { + + //acquire read lock + TopologyManager.acquireReadLockForApplication( + applicationCreatedEvent.getApplication().getUniqueIdentifier()); + //start the application monitor + startApplicationMonitor(applicationCreatedEvent.getApplication().getUniqueIdentifier()); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } finally { + //release read lock + TopologyManager.releaseReadLockForApplication( + applicationCreatedEvent.getApplication().getUniqueIdentifier()); } - monitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); + } catch (ClassCastException e) { + String msg = "Error while casting the event " + e.getLocalizedMessage(); log.error(msg, e); } + + } + }); + + topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { + @Override + protected void onEvent(Event event) { + log.info("[ClusterActivatedEvent] Received: " + event.getClass()); + + ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; + String appId = clusterActivatedEvent.getAppId(); + String clusterId = clusterActivatedEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + if(clusterMonitor!= null) { + clusterMonitor.setStatus(ClusterStatus.Active); + } + } }); topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { @Override protected void onEvent(Event event) { + + log.info("[ClusterCreatedEvent] Received: " + event.getClass()); + + ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; + String clusterId = clusterCreatedEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + clusterMonitor.setStatus(ClusterStatus.Created); + + } + }); + + topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterInActivateEvent] Received: " + event.getClass()); + + ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; + String appId = clusterInactivateEvent.getAppId(); + String clusterId = clusterInactivateEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + if(clusterMonitor!= null) { + clusterMonitor.setStatus(ClusterStatus.Inactive); + } + + } + }); + + topologyEventReceiver.addEventListener(new ClusterTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterTerminatingEvent] Received: " + event.getClass()); + + ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; + String clusterId = clusterTerminatingEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + if (clusterMonitor != null) { + if (clusterMonitor.getStatus() == ClusterStatus.Active) { + // terminated gracefully + clusterMonitor.setStatus(ClusterStatus.Terminating); + InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId); + } else { + clusterMonitor.setStatus(ClusterStatus.Terminating); + clusterMonitor.terminateAllMembers(); + } + + } else { + log.warn("No Cluster Monitor found for cluster id " + clusterId); + } + } + }); + + topologyEventReceiver.addEventListener(new ClusterTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterTerminatedEvent] Received: " + event.getClass()); + + ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; + String appId = clusterTerminatedEvent.getAppId(); + String clusterId = clusterTerminatedEvent.getClusterId(); + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterId); + + //changing the status in the monitor, will notify its parent monitor + if (clusterMonitor != null) { + clusterMonitor.setStatus(ClusterStatus.Terminated); + } + } + }); + + topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupActivatedEvent] Received: " + event.getClass()); + + GroupActivatedEvent groupActivatedEvent = (GroupActivatedEvent) event; + String appId = groupActivatedEvent.getAppId(); + String groupId = groupActivatedEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + if (monitor != null) { + monitor.setStatus(GroupStatus.Active); + } + } + }); + + topologyEventReceiver.addEventListener(new GroupInActivateEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupInActivateEvent] Received: " + event.getClass()); + + GroupInactivateEvent groupInactivateEvent = (GroupInactivateEvent) event; + String appId = groupInactivateEvent.getAppId(); + String groupId = groupInactivateEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + if (monitor != null) { + monitor.setStatus(GroupStatus.Inactive); + } + + } + }); + + topologyEventReceiver.addEventListener(new GroupTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupTerminatingEvent] Received: " + event.getClass()); + + GroupTerminatingEvent groupTerminatingEvent = (GroupTerminatingEvent) event; + String appId = groupTerminatingEvent.getAppId(); + String groupId = groupTerminatingEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + if (monitor != null) { + monitor.setStatus(GroupStatus.Terminating); + } + + } + }); + + topologyEventReceiver.addEventListener(new GroupTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[GroupTerminatedEvent] Received: " + event.getClass()); + + GroupTerminatedEvent groupTerminatedEvent = (GroupTerminatedEvent) event; + String appId = groupTerminatedEvent.getAppId(); + String groupId = groupTerminatedEvent.getGroupId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); + + //changing the status in the monitor, will notify its parent monitor + if (monitor != null) { + monitor.setStatus(GroupStatus.Terminated); + } + + } + }); + + topologyEventReceiver.addEventListener(new ApplicationActivatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationActivatedEvent] Received: " + event.getClass()); + + ApplicationActivatedEvent applicationActivatedEvent = (ApplicationActivatedEvent) event; + String appId = applicationActivatedEvent.getAppId(); + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + if(appMonitor != null) { + appMonitor.setStatus(ApplicationStatus.Active); + } + } + }); + + topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); + + ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationUndeployedEvent.getApplicationId()); + + // if any of Cluster Monitors are not added yet, should send the + // Cluster Terminated event for those clusters + Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { + AbstractClusterMonitor clusterMonitor = + AutoscalerContext.getInstance().getClusterMonitor(clusterDataHolder.getClusterId()); + if (clusterMonitor == null) { + // Cluster Monitor not found; send Cluster Terminated event to cleanup + StatusEventPublisher.sendClusterTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), + clusterDataHolder.getServiceType(), + clusterDataHolder.getClusterId()); + } else { + // if the Cluster Monitor exists, mark it as destroyed to stop it from spawning + // more instances + clusterMonitor.setDestroyed(true); + } + } + } + + if (appMonitor != null) { + // set Application Monitor state to 'Terminating' + appMonitor.setStatus(ApplicationStatus.Terminating); + + } else { + // ApplicationMonitor is not found, send Terminating event to clean up + StatusEventPublisher.sendApplicationTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData()); + } + } + }); + + + topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationTerminatingEvent] Received: " + event.getClass()); + + ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event; + + // acquire read locks for application and relevant clusters + TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId()); + try { - log.info("Event received: " + event); - ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; - TopologyManager.acquireReadLock(); - Service service = TopologyManager.getTopology().getService(clusterCreatedEvent.getServiceName()); - Cluster cluster = service.getCluster(clusterCreatedEvent.getClusterId()); - startClusterMonitor(cluster); + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(appTerminatingEvent.getAppId()); + + if (appMonitor != null) { + // update the status as Terminating + appMonitor.setStatus(ApplicationStatus.Terminating); + + } else { + log.warn("Application Monitor cannot be found for the undeployed [application] " + + appTerminatingEvent.getAppId()); + } + + } finally { + TopologyManager. + releaseReadLockForApplication(appTerminatingEvent.getAppId()); + } + } + }); + + topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationTerminatedEvent] Received: " + event.getClass()); + + ApplicationTerminatedEvent applicationRemovedEvent = (ApplicationTerminatedEvent) event; + Set clusterDataHolders = applicationRemovedEvent.getClusterData(); + + try { + //TODO remove monitors as well as any starting or pending threads + ApplicationMonitor monitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationRemovedEvent.getAppId()); + if (monitor != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + //stopping the cluster monitor and remove it from the AS + VMClusterMonitor clusterMonitor = ((VMClusterMonitor) + AutoscalerContext.getInstance().getClusterMonitor(clusterData.getClusterId())); + if (clusterMonitor != null) { + clusterMonitor.setDestroyed(true); + AutoscalerContext.getInstance().removeClusterMonitor(clusterData.getClusterId()); + } else { + log.warn("Cluster Monitor not found for [ cluster id ] " + + clusterData.getClusterId() + ", unable to remove"); + } + } + //removing the application monitor + AutoscalerContext.getInstance(). + removeAppMonitor(applicationRemovedEvent.getAppId()); + } else { + log.warn("Application Monitor cannot be found for the terminated [application] " + + applicationRemovedEvent.getAppId() + ", unable to remove"); + } + + } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); + String msg = "Error processing event " + e.getMessage(); log.error(msg, e); - } finally { - TopologyManager.releaseReadLock(); } } }); - topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { + topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { @Override protected void onEvent(Event event) { try { - ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event; - String clusterId = clusterRemovedEvent.getClusterId(); + MemberReadyToShutdownEvent memberReadyToShutdownEvent = + (MemberReadyToShutdownEvent) event; AutoscalerContext asCtx = AutoscalerContext.getInstance(); AbstractClusterMonitor monitor; - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { + String clusterId = memberReadyToShutdownEvent.getClusterId(); + String memberId = memberReadyToShutdownEvent.getMemberId(); + + if (asCtx.clusterMonitorExist(clusterId)) { + monitor = asCtx.getClusterMonitor(clusterId); + } else { if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); + log.debug(String.format("A cluster monitor is not found " + + "in autoscaler context [cluster] %s", clusterId)); } return; } - monitor.handleClusterRemovedEvent(clusterRemovedEvent); - asCtx.removeClusterMonitor(clusterId); - monitor.destroy(); - log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", - clusterId)); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); + + if(monitor instanceof VMClusterMonitor) { + VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; + NetworkPartitionContext nwPartitionCtxt; + nwPartitionCtxt = vmClusterMonitor.getNetworkPartitionCtxt( + memberReadyToShutdownEvent.getNetworkPartitionId()); + + String partitionId = vmClusterMonitor.getPartitionOfMember(memberId); + PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); + + // terminate the member + CloudControllerClient ccClient = CloudControllerClient.getInstance(); + ccClient.terminate(memberId); + + // remove from active member list + partitionCtxt.removeActiveMemberById(memberId); + + + if (log.isInfoEnabled()) { + log.info(String.format("Member is terminated and removed from the active " + + "members list: [member] %s [partition] %s [cluster] %s ", + memberId, partitionId, clusterId)); + } + } else if(monitor instanceof KubernetesClusterMonitor) { + KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; + kubernetesClusterMonitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); + } + } catch (TerminationException e) { + log.error(e); } } + }); - topologyEventReceiver.addEventListener(new MemberStartedEventListener() { + topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @Override protected void onEvent(Event event) { - } + ClusterRemovedEvent clusterRemovedEvent = null; + try { + clusterRemovedEvent = (ClusterRemovedEvent) event; + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); + + String clusterId = clusterRemovedEvent.getClusterId(); + String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); + + AbstractClusterMonitor monitor; + + if (clusterRemovedEvent.isLbCluster()) { + DeploymentPolicy depPolicy = PolicyManager.getInstance(). + getDeploymentPolicy(deploymentPolicy); + if (depPolicy != null) { + List lbHolders = PartitionManager.getInstance() + .getNetworkPartitionLbHolders(depPolicy); + + for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) { + // removes lb cluster ids + boolean isRemoved = networkPartitionLbHolder.removeLbClusterId(clusterId); + if (isRemoved) { + log.info("Removed the lb cluster [id]:" + + clusterId + + " reference from Network Partition [id]: " + + networkPartitionLbHolder + .getNetworkPartitionId()); + + } + if (log.isDebugEnabled()) { + log.debug(networkPartitionLbHolder); + } + + } + } + monitor = AutoscalerContext.getInstance() + .removeClusterMonitor(clusterId); + } else { + monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() + .removeClusterMonitor(clusterId); + } + + // runTerminateAllRule(monitor); + if (monitor != null) { + monitor.destroy(); + log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", + clusterId)); + } + } catch (Exception e) { + log.error("Error processing event", e); + } finally { + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), + clusterRemovedEvent.getClusterId()); + } + } }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { @Override protected void onEvent(Event event) { + + MemberTerminatedEvent memberTerminatedEvent = null; try { - MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + //TopologyManager.acquireReadLock(); + + memberTerminatedEvent = (MemberTerminatedEvent) event; + String networkPartitionId = memberTerminatedEvent.getNetworkPartitionId(); String clusterId = memberTerminatedEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } + String partitionId = memberTerminatedEvent.getPartitionId(); + + TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); + + AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); + if(monitor == null) { + log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); return; } - monitor.handleMemberTerminatedEvent(memberTerminatedEvent); + + if(monitor instanceof VMClusterMonitor) { + VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; + NetworkPartitionContext networkPartitionContext = vmClusterMonitor. + getNetworkPartitionCtxt(networkPartitionId); + + PartitionContext partitionContext = networkPartitionContext. + getPartitionCtxt(partitionId); + String memberId = memberTerminatedEvent.getMemberId(); + partitionContext.removeMemberStatsContext(memberId); + + + if (partitionContext.removeTerminationPendingMember(memberId)) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is removed from termination pending " + + "members list: [member] %s", memberId)); + } + } else if (partitionContext.removePendingMember(memberId)) { + if (log.isDebugEnabled()) { + log.debug(String.format("Member is removed from pending members list: " + + "[member] %s", memberId)); + } + } else if (partitionContext.removeActiveMemberById(memberId)) { + log.warn(String.format("Member is in the wrong list and it is removed " + + "from active members list", memberId)); + } else { + log.warn(String.format("Member is not available in any of the list " + + "active, pending and termination pending", memberId)); + } + + if (log.isInfoEnabled()) { + log.info(String.format("Member stat context has been removed " + + " successfully: [member] %s", memberId)); + } + //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated + StatusChecker.getInstance().onMemberTermination(clusterId); + } else if(monitor instanceof KubernetesClusterMonitor) { + KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; + kubernetesClusterMonitor.handleMemberTerminatedEvent(memberTerminatedEvent); + } + } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); + log.error("Error processing event", e); + } finally { + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), + memberTerminatedEvent.getClusterId()); } } - }); topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { @Override protected void onEvent(Event event) { + + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); + try { - MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + + String networkPartitionId = memberActivatedEvent.getNetworkPartitionId(); String clusterId = memberActivatedEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } + String partitionId = memberActivatedEvent.getPartitionId(); + String memberId = memberActivatedEvent.getMemberId(); + + AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); + if(monitor == null) { + log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); return; } - monitor.handleMemberActivatedEvent(memberActivatedEvent); + + if(monitor instanceof VMClusterMonitor) { + VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; + NetworkPartitionContext networkPartitionContext = vmClusterMonitor. + getNetworkPartitionCtxt(networkPartitionId); + PartitionContext partitionContext = networkPartitionContext. + getPartitionCtxt(partitionId); + + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); + // TODO starting the pending clusters which are waiting for this member activation in a cluster + if (log.isInfoEnabled()) { + log.info(String.format("Member stat context has been added " + + "successfully: [member] %s", memberId)); + } + partitionContext.movePendingMemberToActiveMembers(memberId); + //triggering the status checker + StatusChecker.getInstance().onMemberStatusChange(memberActivatedEvent.getClusterId()); + } else if(monitor instanceof KubernetesClusterMonitor) { + KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; + kubernetesClusterMonitor.handleMemberActivatedEvent(memberActivatedEvent); + } + } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); + log.error("Error processing event", e); + } finally { + //TopologyManager.releaseReadLock(); + TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); } } }); @@ -244,34 +711,51 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { @Override protected void onEvent(Event event) { + + MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; + + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); + try { - MemberMaintenanceModeEvent maintenanceModeEvent = (MemberMaintenanceModeEvent) event; - String clusterId = maintenanceModeEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { + + String memberId = memberMaintenanceModeEvent.getMemberId(); + String partitionId = memberMaintenanceModeEvent.getPartitionId(); + String networkPartitionId = memberMaintenanceModeEvent.getNetworkPartitionId(); + + PartitionContext partitionContext; + String clusterId = memberMaintenanceModeEvent.getClusterId(); + + AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); + if(monitor == null) { + log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); + return; + } + + if(monitor instanceof VMClusterMonitor) { + VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; + partitionContext = vmClusterMonitor.getNetworkPartitionCtxt(networkPartitionId). + getPartitionCtxt(partitionId); + partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); + log.debug(String.format("Member has been moved as pending termination: " + + "[member] %s", memberId)); } - return; + partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); + } else if(monitor instanceof KubernetesClusterMonitor) { + KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; + kubernetesClusterMonitor.handleMemberMaintenanceModeEvent(memberMaintenanceModeEvent); } - monitor.handleMemberMaintenanceModeEvent(maintenanceModeEvent); + } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); + log.error("Error processing event", e); + } finally { + TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); } } }); - - - topologyEventReceiver.addEventListener(new ServiceRemovedEventListener() { - @Override - protected void onEvent(Event event) { - - } - }); } private class ClusterMonitorAdder implements Runnable { @@ -371,4 +855,85 @@ protected synchronized void startClusterMonitor(Cluster cluster) { } } } + + protected synchronized void startApplicationMonitor(String applicationId) { + Thread th = null; + if (!AutoscalerContext.getInstance().appMonitorExist(applicationId)) { + th = new Thread( + new ApplicationMonitorAdder(applicationId)); + } + + if (th != null) { + th.start(); + // try { + // th.join(); + // } catch (InterruptedException ignore) { + + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread has been started successfully: " + + "[application] %s ", applicationId)); + } + } else { + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread already exists: " + + "[application] %s ", applicationId)); + } + } + } + + private class ApplicationMonitorAdder implements Runnable { + private String appId; + + public ApplicationMonitorAdder(String appId) { + this.appId = appId; + } + + public void run() { + ApplicationMonitor applicationMonitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + long start = System.currentTimeMillis(); + if (log.isDebugEnabled()) { + log.debug("application monitor is going to be started for [application] " + + appId); + } + applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); + + long end = System.currentTimeMillis(); + log.info("Time taken to start app monitor: " + (end - start) / 1000); + success = true; + } catch (DependencyBuilderException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } + } while (!success && retries != 0); + + if (applicationMonitor == null) { + String msg = "Application monitor creation failed, even after retrying for 5 times, " + + "for Application: " + appId; + log.error(msg); + throw new RuntimeException(msg); + } + + AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); + + if (log.isInfoEnabled()) { + log.info(String.format("Application monitor has been added successfully: " + + "[application] %s", applicationMonitor.getId())); + } + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index fa8f425f86..8aeae947fa 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -28,10 +28,9 @@ import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.domain.topology.ParentComponent; import java.util.HashMap; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 2bf85a62e0..cf92a18bdd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java similarity index 90% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java index 9cf3709604..bc23dd4dcf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java @@ -16,16 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.application; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.MemberStatsContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; @@ -33,20 +27,16 @@ import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; -import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.VMClusterMonitor; +import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.partition.PartitionGroup; -import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.apache.stratos.messaging.util.Constants; import java.util.Map; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java similarity index 98% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index 030bc53bd0..f043f513ae 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.exception.InvalidArgumentException; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; +import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; @@ -284,4 +285,6 @@ public void setHasFaultyMember(boolean hasFaultyMember) { public boolean isHasFaultyMember() { return hasFaultyMember; } + + public abstract void terminateAllMembers(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index d7238bf251..e2861871cc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import java.util.Map; import java.util.Random; @@ -46,8 +46,6 @@ import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.MemberStatus; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; /* diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java similarity index 98% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java index 02540303dd..39fbd46267 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesClusterMonitor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -507,4 +507,14 @@ private Member getMemberByMemberId(String memberId) { TopologyManager.releaseReadLock(); } } + + @Override + public void terminateAllMembers() { + try { + CloudControllerClient.getInstance().terminateAllContainers(getKubernetesClusterCtxt().getClusterId()); + } catch (TerminationException e) { + log.error(String.format("Could not terminate containers: [cluster-id] %s", + getKubernetesClusterCtxt().getClusterId()), e); + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java similarity index 96% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java index 15b14b6d84..26156516f6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java @@ -16,20 +16,15 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; -import java.util.ArrayList; import java.util.List; -import org.apache.commons.collections.ListUtils; import org.apache.commons.configuration.XMLConfiguration; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.KubernetesClusterContext; import org.apache.stratos.autoscaler.exception.InvalidArgumentException; -import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java similarity index 92% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 38ed1a626a..d4b6a25fb5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import java.util.Map; @@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; @@ -636,4 +637,56 @@ public void addNetworkPartitionCtxt(NetworkPartitionContext ctxt) { public NetworkPartitionContext getPartitionCtxt(String id) { return this.networkPartitionCtxts.get(id); } + + @Override + public void terminateAllMembers() { + + Thread memberTerminator = new Thread(new Runnable(){ + public void run(){ + + for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { + for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { + //if (log.isDebugEnabled()) { + log.info("Starting to terminate all members in Network Partition [ " + + networkPartitionContext.getId() + " ], Partition [ " + + partitionContext.getPartitionId() + " ]"); + // } + // need to terminate active, pending and obsolete members + + // active members + for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) { + log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId()); + terminateMember(activeMemberCtxt.getMemberId()); + } + + // pending members + for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { + log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); + terminateMember(pendingMemberCtxt.getMemberId()); + } + + // obsolete members + for (String obsoleteMemberId : partitionContext.getObsoletedMembers().keySet()) { + log.info("Terminating obsolete member [member id] " + obsoleteMemberId); + terminateMember(obsoleteMemberId); + } + +// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll +// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); + } + } + } + }, "Member Terminator - [cluster id] " + getClusterId()); + + memberTerminator.start(); + } + + private static void terminateMember (String memberId) { + try { + CloudControllerClient.getInstance().terminate(memberId); + + } catch (TerminationException e) { + log.error("Unable to terminate member [member id ] " + memberId, e); + } + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java index 3e6cddc1de..8a0959ce61 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMLbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import java.util.List; import java.util.concurrent.ConcurrentHashMap; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index 9a26b427c6..9d0f134f86 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.monitor; +package org.apache.stratos.autoscaler.monitor.cluster; import java.util.ArrayList; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 5f3b590a5d..73d85f0426 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -24,7 +24,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.VMClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; From e15343080254dc46756804fffd454bbbd6dacced Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 12:06:42 +0530 Subject: [PATCH 328/436] moving Application Strucutre related classes to applications package --- .../autoscaler/grouping/dependency/DependencyBuilder.java | 2 +- .../autoscaler/grouping/dependency/DependencyTree.java | 1 - .../dependency/context/ApplicationContextFactory.java | 5 ++--- .../autoscaler/grouping/topic/StatusEventPublisher.java | 1 + .../topology/AutoscalerTopologyEventReceiver.java | 4 ++++ .../autoscaler/monitor/ApplicationMonitorFactory.java | 2 ++ .../autoscaler/monitor/MonitorStatusEventBuilder.java | 4 ++-- .../autoscaler/monitor/ParentComponentMonitor.java | 6 +----- .../monitor/application/ApplicationMonitor.java | 6 +++--- .../autoscaler/monitor/cluster/ClusterMonitor.java | 4 ++-- .../autoscaler/monitor/events/ApplicationStatusEvent.java | 2 +- .../autoscaler/monitor/events/GroupStatusEvent.java | 2 +- .../stratos/autoscaler/monitor/group/GroupMonitor.java | 7 +++---- .../stratos/autoscaler/status/checker/StatusChecker.java | 1 + .../application/parser/DefaultApplicationParser.java | 5 ++++- .../cloud/controller/application/parser/ParserUtils.java | 2 +- .../cloud/controller/impl/CloudControllerServiceImpl.java | 4 +--- .../cloud/controller/interfaces/ApplicationParser.java | 2 +- .../cloud/controller/topology/TopologyBuilder.java | 1 + .../cloud/controller/topology/TopologyEventPublisher.java | 1 + .../receiver/StratosManagerTopologyEventReceiver.java | 2 +- .../domain/{topology => applications}/Application.java | 3 ++- .../{topology => applications}/ApplicationStatus.java | 2 +- .../{topology => applications}/ClusterDataHolder.java | 2 +- .../{topology => applications}/DependencyOrder.java | 2 +- .../domain/{topology => applications}/Group.java | 3 ++- .../domain/{topology => applications}/GroupStatus.java | 2 +- .../{topology => applications}/ParentComponent.java | 2 +- .../domain/{topology => applications}/StartupOrder.java | 2 +- .../stratos/messaging/domain/topology/Topology.java | 1 + .../status/AppStatusApplicationTerminatedEvent.java | 2 +- .../messaging/event/topology/ApplicationCreatedEvent.java | 2 +- .../event/topology/ApplicationTerminatedEvent.java | 2 +- .../event/topology/ApplicationUndeployedEvent.java | 2 +- .../topology/ApplicationActivatedMessageProcessor.java | 4 ++-- .../topology/ApplicationCreatedMessageProcessor.java | 2 +- .../topology/ApplicationInactivatedMessageProcessor.java | 4 ++-- .../topology/ApplicationTerminatedMessageProcessor.java | 2 +- .../topology/ApplicationTerminatingMessageProcessor.java | 4 ++-- .../topology/ApplicationUndeployedMessageProcessor.java | 3 +++ .../topology/CompleteTopologyMessageProcessor.java | 1 + .../processor/topology/GroupActivatedProcessor.java | 3 +++ .../message/processor/topology/GroupCreatedProcessor.java | 8 +++----- .../processor/topology/GroupInActivateProcessor.java | 7 +++---- .../processor/topology/GroupTerminatedProcessor.java | 6 +++--- .../processor/topology/GroupTerminatingProcessor.java | 6 +++--- .../messaging/topology/locking/TopologyLockingTest.java | 2 ++ .../rest/endpoint/bean/util/converter/PojoConverter.java | 4 ++-- .../stratos/rest/endpoint/services/ServiceUtils.java | 3 +++ 49 files changed, 83 insertions(+), 67 deletions(-) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/Application.java (96%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/ApplicationStatus.java (97%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/ClusterDataHolder.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/DependencyOrder.java (96%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/Group.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/GroupStatus.java (97%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/ParentComponent.java (99%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/{topology => applications}/StartupOrder.java (95%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java index 4e678481ee..bf1233f455 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java @@ -24,7 +24,7 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.applications.*; import java.util.Set; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java index 1ec686b102..05769a6aca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.messaging.domain.topology.Application; import java.util.ArrayList; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java index 631e5d4712..3ea4cd54a7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java @@ -22,9 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.ParentComponent; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.ParentComponent; /** * Factory to create new GroupContext or ClusterContext diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index 9b39a52dd8..eb6e084bb0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -4,6 +4,7 @@ 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.domain.applications.*; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.application.status.*; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 54a1461197..fe4d9dffc2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -37,6 +37,10 @@ import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 2ead896344..debcf93e03 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -44,6 +44,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java index 59bb4c0fab..dac53b42de 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorStatusEventBuilder.java @@ -24,9 +24,9 @@ import org.apache.stratos.autoscaler.monitor.events.ClusterStatusEvent; import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.GroupStatus; /** * This will build the necessary monitor status events to be sent to the parent/child monitor diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 91d5275205..c30402797d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -28,12 +28,8 @@ import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; -import org.apache.stratos.messaging.domain.topology.ParentComponent; +import org.apache.stratos.messaging.domain.applications.ParentComponent; import java.util.HashMap; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java index 4632361efd..dbcbabb30f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitor.java @@ -31,10 +31,10 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; import java.util.Collection; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 988f266f38..22b5e481d3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -33,9 +33,9 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import java.util.ArrayList; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java index d92de77c9b..83c764de0e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/ApplicationStatusEvent.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; /** * This will use to notify observers upon a application activation events received in Topology. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java index 7956914818..7f2176114b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/events/GroupStatusEvent.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.events; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.GroupStatus; /** * This will use to notify observers upon a group activation events received in Topology. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 3623de946f..d48c7aea50 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -24,7 +24,6 @@ import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.EventHandler; -import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.events.GroupStatusEvent; @@ -32,10 +31,10 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index a742b89997..392a0d5bb6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -26,6 +26,7 @@ import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; +import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 06f749a12a..000a06afd0 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -33,7 +33,10 @@ import org.apache.stratos.cloud.controller.pojo.application.*; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.DependencyOrder; +import org.apache.stratos.messaging.domain.applications.Group; import java.util.*; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java index 23b0babb87..e6cdda09cd 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java @@ -22,7 +22,7 @@ import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.pojo.application.GroupContext; import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; -import org.apache.stratos.messaging.domain.topology.StartupOrder; +import org.apache.stratos.messaging.domain.applications.StartupOrder; import java.util.*; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 6e003b1f69..0c2731662b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -39,12 +39,10 @@ import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; -import org.apache.stratos.cloud.controller.topology.TopologyManager; import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Member; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; import org.jclouds.compute.ComputeService; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java index 7bd471df6a..33e98f9cd1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java @@ -22,7 +22,7 @@ import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.applications.Application; import java.util.Set; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 2cf490537a..e31cf3264f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -29,6 +29,7 @@ import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; +import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.application.status.*; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index c9337d216a..f96ba8e4d0 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -26,6 +26,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.broker.publish.EventPublisher; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.instance.status.InstanceStartedEvent; 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 index d4e90cc13c..d6cc395151 100644 --- 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 @@ -26,7 +26,7 @@ import org.apache.stratos.manager.manager.CartridgeSubscriptionManager; import org.apache.stratos.manager.subscription.ApplicationSubscription; import org.apache.stratos.manager.topology.model.TopologyClusterInformationModel; -import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.event.Event; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java similarity index 96% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java index 0e4438b767..e33de3966f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Application.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Application.java @@ -17,9 +17,10 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import org.apache.commons.lang3.RandomStringUtils; +import org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import java.util.*; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java similarity index 97% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java index 2173f86442..38ac01ca16 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ApplicationStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ApplicationStatus.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java index 70eab4c335..6a7e421dad 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ClusterDataHolder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import java.io.Serializable; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java similarity index 96% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java index bdba59ca98..9ece4505de 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/DependencyOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/DependencyOrder.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import java.io.Serializable; import java.util.Set; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java index 79ce4bcba4..1f4d3231e3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java @@ -17,8 +17,9 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; +import org.apache.stratos.messaging.domain.topology.LifeCycleStateTransitionBehavior; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleStateManager; import java.util.Stack; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java similarity index 97% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java index fbbaebcdc0..007947625e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/GroupStatus.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/GroupStatus.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import org.apache.stratos.messaging.domain.topology.lifecycle.LifeCycleState; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java similarity index 99% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java index 86000e9748..3c2814f245 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ParentComponent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import java.io.Serializable; import java.util.*; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java index 4f55b6c325..83d583ea71 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/StartupOrder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/StartupOrder.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.domain.topology; +package org.apache.stratos.messaging.domain.applications; import java.io.Serializable; import java.util.List; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index ddd5ffa81d..0f128fa7d9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java index 3fbb368e64..2dafcdcf5c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.messaging.event.application.status; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import java.io.Serializable; import java.util.Set; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java index 425dd47288..63b64392bc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationCreatedEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.Cluster; import java.util.List; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java index fa0cd269e8..41426856b6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationTerminatedEvent.java @@ -18,7 +18,7 @@ */ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import java.util.Set; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java index ae56bb6196..bd3667a383 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationUndeployedEvent.java @@ -19,7 +19,7 @@ package org.apache.stratos.messaging.event.topology; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import java.util.Set; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java index 064fb9c285..341b40273a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java @@ -20,8 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java index 7d06fd5604..079cb90e66 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java @@ -22,7 +22,7 @@ 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.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java index cda1d73693..8c88324cd5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java @@ -20,8 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java index 3b91e3fc41..2dd3ea7b97 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java @@ -20,8 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java index 6ad43d86c4..032be79964 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java @@ -20,8 +20,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java index 04c69731d1..f368dd1817 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java @@ -21,6 +21,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index f6af30012e..787ac74138 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java index aa050ef975..09b90628df 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java @@ -20,6 +20,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java index b6d2da9ef7..d053f5d09b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java @@ -20,12 +20,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; -import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.event.topology.GroupCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java index d5dcd6587e..add40b4083 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java @@ -20,11 +20,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java index 5a308ba0fc..767ff710e0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java @@ -20,9 +20,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java index 27b5cff43b..5b155323d3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java @@ -20,9 +20,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.Group; -import org.apache.stratos.messaging.domain.topology.GroupStatus; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index 8f25af11bf..b9b8e03889 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -19,6 +19,8 @@ package org.apache.stratos.messaging.topology.locking; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index d5e6882cd9..6c8db77abe 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -32,9 +32,9 @@ import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.subscription.SubscriptionDomain; -import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Group; +import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.rest.endpoint.bean.ApplicationBean; import org.apache.stratos.rest.endpoint.bean.GroupBean; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index b7b5695e87..9037f3376f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -50,6 +50,9 @@ 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.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.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; From f0ba4beb168eb119011aef6c424cc4d60057585b Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 12:22:29 +0530 Subject: [PATCH 329/436] renaming application.status topic to applications --- .../grouping/topic/StatusEventPublisher.java | 54 ++++++++-------- .../status/checker/StatusChecker.java | 62 ++++++++++++++++++- .../AppStatusClusterMaintenanceModeEvent.java | 49 --------------- .../AppStatusClusterReadyToShutdownEvent.java | 47 -------------- .../AppStatusClusterTerminatingEvent.java | 50 --------------- .../AppClusterActivatedEvent.java} | 6 +- .../AppClusterCreatedEvent.java} | 6 +- .../AppClusterInactivateEvent.java} | 6 +- .../AppClusterTerminatedEvent.java} | 6 +- .../AppClusterTerminatingEvent.java | 50 +++++++++++++++ .../AppStatusGroupInactivateEvent.java | 2 +- .../ApplicationActivatedEvent.java} | 6 +- .../ApplicationCreatedEvent.java} | 6 +- .../ApplicationInactivatedEvent.java} | 6 +- .../ApplicationTerminatedEvent.java} | 6 +- .../ApplicationTerminatingEvent.java} | 6 +- .../GroupActivatedEvent.java} | 6 +- .../GroupCreatedEvent.java} | 6 +- .../GroupMaintenanceModeEvent.java} | 6 +- .../GroupReadyToShutdownEvent.java} | 6 +- .../GroupTerminatedEvent.java} | 6 +- .../GroupTerminatingEvent.java} | 6 +- .../status => applications}/StatusEvent.java | 2 +- ...atusApplicationActivatedEventListener.java | 27 -------- ...StatusApplicationCreatedEventListener.java | 27 -------- ...tusApplicationTerminatedEventListener.java | 27 -------- ...usApplicationTerminatingEventListener.java | 27 -------- ...pStatusClusterInactivateEventListener.java | 24 ------- ...pStatusClusterTerminatedEventListener.java | 24 ------- ...StatusClusterTerminatingEventListener.java | 24 ------- ...AppStatusGroupInactivateEventListener.java | 24 ------- ...AppStatusGroupTerminatedEventListener.java | 24 ------- ...ppStatusGroupTerminatingEventListener.java | 24 ------- .../AppClusterActivatedEventListener.java} | 4 +- .../AppClusterCreatedEventListener.java} | 4 +- .../AppClusterInactivateEventListener.java} | 4 +- .../AppClusterTerminatedEventListener.java} | 4 +- .../AppClusterTerminatingEventListener.java | 24 +++++++ .../ApplicationActivatedEventListener.java | 4 +- .../ApplicationCreatedEventListener.java | 7 ++- .../ApplicationInactivatedEventListener.java} | 4 +- .../ApplicationTerminatedEventListener.java | 4 +- .../ApplicationTerminatingEventListener.java | 4 +- .../ApplicationUndeployedEventListener.java | 2 +- .../GroupActivatedEventListener.java | 5 +- .../GroupCreatedEventListener.java | 5 +- .../GroupInactivateEventListener.java | 24 +++++++ .../GroupTerminatedEventListener.java | 5 +- .../GroupTerminatingEventListener.java | 5 +- .../ApplicationInActivateEventListener.java | 27 -------- .../GroupInActivateEventListener.java | 27 -------- .../AppClusterActivatedMessageProcessor.java} | 12 ++-- .../AppClusterCreatedMessageProcessor.java} | 13 ++-- ...AppClusterInactivateMessageProcessor.java} | 14 ++--- ...AppClusterTerminatedMessageProcessor.java} | 14 ++--- ...ppClusterTerminatingMessageProcessor.java} | 14 ++--- .../AppStatusMessageProcessorChain.java | 2 +- ...ApplicationActivatedMessageProcessor.java} | 14 ++--- .../ApplicationCreatedMessageProcessor.java} | 14 ++--- ...plicationInactivatedMessageProcessor.java} | 14 ++--- ...pplicationTerminatedMessageProcessor.java} | 14 ++--- ...plicationTerminatingMessageProcessor.java} | 14 ++--- .../GroupActivatedMessageProcessor.java} | 14 ++--- .../GroupCreatedMessageProcessor.java} | 15 +++-- .../GroupInactivatedMessageProcessor.java} | 8 +-- .../GroupTerminatedMessageProcessor.java} | 14 ++--- .../GroupTerminatingMessageProcessor.java} | 14 ++--- 67 files changed, 359 insertions(+), 666 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusClusterCreatedEvent.java => applications/AppClusterActivatedEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusClusterActivatedEvent.java => applications/AppClusterCreatedEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusClusterInactivateEvent.java => applications/AppClusterInactivateEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusClusterTerminatedEvent.java => applications/AppClusterTerminatedEvent.java} (86%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status => applications}/AppStatusGroupInactivateEvent.java (95%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusApplicationActivatedEvent.java => applications/ApplicationActivatedEvent.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusApplicationCreatedEvent.java => applications/ApplicationCreatedEvent.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusApplicationInactivatedEvent.java => applications/ApplicationInactivatedEvent.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusApplicationTerminatedEvent.java => applications/ApplicationTerminatedEvent.java} (84%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusApplicationTerminatingEvent.java => applications/ApplicationTerminatingEvent.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupCreatedEvent.java => applications/GroupActivatedEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupActivatedEvent.java => applications/GroupCreatedEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupMaintenanceModeEvent.java => applications/GroupMaintenanceModeEvent.java} (84%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupReadyToShutdownEvent.java => applications/GroupReadyToShutdownEvent.java} (84%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupTerminatingEvent.java => applications/GroupTerminatedEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status/AppStatusGroupTerminatedEvent.java => applications/GroupTerminatingEvent.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{application/status => applications}/StatusEvent.java (94%) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{application/status/AppStatusGroupCreatedEventListener.java => applications/AppClusterActivatedEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{application/status/AppStatusClusterCreatedEventListener.java => applications/AppClusterCreatedEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{application/status/AppStatusGroupActivatedEventListener.java => applications/AppClusterInactivateEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{application/status/AppStatusClusterActivatedEventListener.java => applications/AppClusterTerminatedEventListener.java} (85%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/ApplicationActivatedEventListener.java (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/ApplicationCreatedEventListener.java (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{application/status/AppStatusApplicationInactivatedEventListener.java => applications/ApplicationInactivatedEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/ApplicationTerminatedEventListener.java (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/ApplicationTerminatingEventListener.java (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/ApplicationUndeployedEventListener.java (94%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/GroupActivatedEventListener.java (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/GroupCreatedEventListener.java (86%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/GroupTerminatedEventListener.java (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{topology => applications}/GroupTerminatingEventListener.java (86%) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusClusterActivatedMessageProcessor.java => applications/AppClusterActivatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusClusterCreatedMessageProcessor.java => applications/AppClusterCreatedMessageProcessor.java} (77%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusClusterInactivateMessageProcessor.java => applications/AppClusterInactivateMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusClusterTerminatedMessageProcessor.java => applications/AppClusterTerminatedMessageProcessor.java} (78%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusClusterTerminatingMessageProcessor.java => applications/AppClusterTerminatingMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status => applications}/AppStatusMessageProcessorChain.java (99%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusApplicationActivatedMessageProcessor.java => applications/ApplicationActivatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusApplicationCreatedMessageProcessor.java => applications/ApplicationCreatedMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusApplicationInactivatedMessageProcessor.java => applications/ApplicationInactivatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusApplicationTerminatedMessageProcessor.java => applications/ApplicationTerminatedMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusApplicationTerminatingMessageProcessor.java => applications/ApplicationTerminatingMessageProcessor.java} (79%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusGroupActivatedMessageProcessor.java => applications/GroupActivatedMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusGroupCreatedMessageProcessor.java => applications/GroupCreatedMessageProcessor.java} (78%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusGroupInactivatedMessageProcessor.java => applications/GroupInactivatedMessageProcessor.java} (89%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusGroupTerminatedMessageProcessor.java => applications/GroupTerminatedMessageProcessor.java} (80%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{application/status/AppStatusGroupTerminatingMessageProcessor.java => applications/GroupTerminatingMessageProcessor.java} (80%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java index eb6e084bb0..c0e77dee15 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java @@ -7,7 +7,7 @@ import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.event.applications.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; @@ -30,8 +30,8 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str log.info("Publishing Cluster created event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterCreatedEvent clusterCreatedEvent = - new AppStatusClusterCreatedEvent(appId, serviceName, clusterId); + AppClusterCreatedEvent clusterCreatedEvent = + new AppClusterCreatedEvent(appId, serviceName, clusterId); publishEvent(clusterCreatedEvent); } else { @@ -54,8 +54,8 @@ public static void sendClusterActivatedEvent(String appId, String serviceName, S log.info("Publishing Cluster activated event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterActivatedEvent clusterActivatedEvent = - new AppStatusClusterActivatedEvent(appId, serviceName, clusterId); + AppClusterActivatedEvent clusterActivatedEvent = + new AppClusterActivatedEvent(appId, serviceName, clusterId); publishEvent(clusterActivatedEvent); } else { @@ -78,8 +78,8 @@ public static void sendClusterInActivateEvent(String appId, String serviceName, log.info("Publishing Cluster in-activate event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterInactivateEvent clusterInActivateEvent = - new AppStatusClusterInactivateEvent(appId, serviceName, clusterId); + AppClusterInactivateEvent clusterInActivateEvent = + new AppClusterInactivateEvent(appId, serviceName, clusterId); publishEvent(clusterInActivateEvent); } else { @@ -104,8 +104,8 @@ public static void sendClusterTerminatingEvent(String appId, String serviceName, log.info("Publishing Cluster Terminating event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterTerminatingEvent appStatusClusterTerminatingEvent = - new AppStatusClusterTerminatingEvent(appId, serviceName, clusterId); + AppClusterTerminatingEvent appStatusClusterTerminatingEvent = + new AppClusterTerminatingEvent(appId, serviceName, clusterId); publishEvent(appStatusClusterTerminatingEvent); } else { @@ -130,8 +130,8 @@ public static void sendClusterTerminatedEvent(String appId, String serviceName, log.info("Publishing Cluster terminated event for [application]: " + appId + " [cluster]: " + clusterId); } - AppStatusClusterTerminatedEvent appStatusClusterTerminatedEvent = - new AppStatusClusterTerminatedEvent(appId, serviceName, clusterId); + AppClusterTerminatedEvent appStatusClusterTerminatedEvent = + new AppClusterTerminatedEvent(appId, serviceName, clusterId); publishEvent(appStatusClusterTerminatedEvent); } else { @@ -155,8 +155,8 @@ public static void sendGroupCreatedEvent(String appId, String groupId) { log.info("Publishing Group created event for [application]: " + appId + " [group]: " + groupId); } - AppStatusGroupCreatedEvent groupCreatedEvent = - new AppStatusGroupCreatedEvent(appId, groupId); + GroupCreatedEvent groupCreatedEvent = + new GroupCreatedEvent(appId, groupId); publishEvent(groupCreatedEvent); } else { @@ -179,8 +179,8 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { log.info("Publishing Group activated event for [application]: " + appId + " [group]: " + groupId); } - AppStatusGroupActivatedEvent groupActivatedEvent = - new AppStatusGroupActivatedEvent(appId, groupId); + GroupActivatedEvent groupActivatedEvent = + new GroupActivatedEvent(appId, groupId); publishEvent(groupActivatedEvent); } else { @@ -227,8 +227,8 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { log.info("Publishing Group terminating event for [application]: " + appId + " [group]: " + groupId); } - AppStatusGroupTerminatingEvent groupInTerminatingEvent = - new AppStatusGroupTerminatingEvent(appId, groupId); + GroupTerminatingEvent groupInTerminatingEvent = + new GroupTerminatingEvent(appId, groupId); publishEvent(groupInTerminatingEvent); } else { log.warn("Terminating is not in the possible state list of [group] " + groupId); @@ -252,8 +252,8 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Terminated)) { - AppStatusGroupTerminatedEvent groupInTerminatedEvent = - new AppStatusGroupTerminatedEvent(appId, groupId); + GroupTerminatedEvent groupInTerminatedEvent = + new GroupTerminatedEvent(appId, groupId); publishEvent(groupInTerminatedEvent); } else { log.warn("Terminated is not in the possible state list of [group] " + groupId); @@ -275,8 +275,8 @@ public static void sendApplicationActivatedEvent(String appId) { if (log.isInfoEnabled()) { log.info("Publishing Application activated event for [application]: " + appId); } - AppStatusApplicationActivatedEvent applicationActivatedEvent = - new AppStatusApplicationActivatedEvent(appId); + ApplicationActivatedEvent applicationActivatedEvent = + new ApplicationActivatedEvent(appId); publishEvent(applicationActivatedEvent); } else { @@ -298,8 +298,8 @@ public static void sendApplicationInactivatedEvent(String appId) { Application application = TopologyManager.getTopology().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Inactive)) { - AppStatusApplicationInactivatedEvent applicationInActivatedEvent = - new AppStatusApplicationInactivatedEvent(appId); + ApplicationInactivatedEvent applicationInActivatedEvent = + new ApplicationInactivatedEvent(appId); publishEvent(applicationInActivatedEvent); } else { log.warn("Inactive is not in the possible state list of [application] " + appId); @@ -319,8 +319,8 @@ public static void sendApplicationTerminatingEvent(String appId) { if (log.isInfoEnabled()) { log.info("Publishing Application terminated event for [application]: " + appId); } - AppStatusApplicationTerminatingEvent applicationTerminatingEvent = - new AppStatusApplicationTerminatingEvent(appId); + ApplicationTerminatingEvent applicationTerminatingEvent = + new ApplicationTerminatingEvent(appId); publishEvent(applicationTerminatingEvent); } else { log.warn("Terminating is not in the possible state list of [application] " + appId); @@ -340,8 +340,8 @@ public static void sendApplicationTerminatedEvent(String appId, Set gr TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if (groups.isEmpty() && clusterStatus == ClusterStatus.Active || + if (groups.isEmpty() && getClusterAllInSameState(clusterData,ClusterStatus.Active) || clusterData.isEmpty() && groupStatus == GroupStatus.Active || groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) { //send activation event @@ -369,6 +370,65 @@ private boolean updateChildStatus(String appId, String id, Map gr return childFound; } + private boolean getGroupInActive(Map groups) { + boolean groupStat = false; + for (Group group : groups.values()) { + if (group.getStatus() == GroupStatus.Inactive) { + groupStat = true; + return groupStat; + } else { + groupStat = false; + } + } + return groupStat; + } + + private boolean allGroupInSameState(Map groups, GroupStatus status) { + boolean groupStat = false; + for (Group group : groups.values()) { + if (group.getStatus() == status) { + groupStat = true; + } else { + groupStat = false; + return groupStat; + } + } + return groupStat; + } + + + private boolean getClusterInActive(Map clusterData) { + boolean clusterStat = false; + for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { + Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); + Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); + if (cluster.getStatus() == ClusterStatus.Inactive) { + clusterStat = true; + return clusterStat; + } else { + clusterStat = false; + + } + } + return clusterStat; + } + + private boolean getClusterAllInSameState(Map clusterData, + ClusterStatus status) { + boolean clusterStat = false; + for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { + Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); + Cluster cluster = service.getCluster(clusterDataHolderEntry.getValue().getClusterId()); + if (cluster.getStatus() == status) { + clusterStat = true; + } else { + clusterStat = false; + return clusterStat; + } + } + return clusterStat; + } + private GroupStatus getGroupStatus(Map groups) { GroupStatus status = null; boolean groupActive = true; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.java deleted file mode 100644 index 527d86e559..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterMaintenanceModeEvent.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.messaging.event.application.status; - -import java.io.Serializable; - -/** - * This will be fired upon the cluster instability detection by either cep/autoscaler. - */ -public class AppStatusClusterMaintenanceModeEvent extends StatusEvent implements Serializable { - private final String serviceName; - private final String clusterId; - private String appId; - - public AppStatusClusterMaintenanceModeEvent(String appId, String serviceName, String clusterId) { - this.serviceName = serviceName; - this.clusterId = clusterId; - this.appId = appId; - } - - public String getServiceName() { - return serviceName; - } - - public String getClusterId() { - return clusterId; - } - - - public String getAppId() { - return appId; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.java deleted file mode 100644 index 7841d9c70c..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterReadyToShutdownEvent.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.messaging.event.application.status; - -/** - * This event is fired by autoscaler before actually terminate a cluster. - */ -public class AppStatusClusterReadyToShutdownEvent extends StatusEvent { - private final String serviceName; - private final String clusterId; - private String appId; - - public AppStatusClusterReadyToShutdownEvent(String appId, String serviceName, String clusterId) { - this.serviceName = serviceName; - this.clusterId = clusterId; - this.appId = appId; - } - - public String getServiceName() { - return serviceName; - } - - public String getClusterId() { - return clusterId; - } - - - public String getAppId() { - return appId; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.java deleted file mode 100644 index 7a6baf00e8..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatingEvent.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.messaging.event.application.status; - -/** - * This event is fired by cartridge agent when it has started the server and - * applications are ready to serve the incoming requests. - */ -public class AppStatusClusterTerminatingEvent extends StatusEvent { - private static final long serialVersionUID = 2625412714611885089L; - - private final String serviceName; - private final String clusterId; - private String appId; - - public AppStatusClusterTerminatingEvent(String appId, String serviceName, String clusterId) { - this.serviceName = serviceName; - this.clusterId = clusterId; - this.appId = appId; - } - - public String getServiceName() { - return serviceName; - } - - public String getClusterId() { - return clusterId; - } - - public String getAppId() { - return appId; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java index 6480af2e72..688b382f62 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java @@ -17,20 +17,20 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusClusterCreatedEvent extends StatusEvent { +public class AppClusterActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) { + public AppClusterActivatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java index c5737c68f2..3382a349b1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java @@ -17,20 +17,20 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusClusterActivatedEvent extends StatusEvent { +public class AppClusterCreatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) { + public AppClusterCreatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java index 6d8ed46301..bf8926eaab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterInactivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java @@ -17,20 +17,20 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusClusterInactivateEvent extends StatusEvent { +public class AppClusterInactivateEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) { + public AppClusterInactivateEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java index 919d0cac9b..d269d38031 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusClusterTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java @@ -17,20 +17,20 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusClusterTerminatedEvent extends StatusEvent { +public class AppClusterTerminatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppStatusClusterTerminatedEvent(String appId, String serviceName, String clusterId) { + public AppClusterTerminatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java new file mode 100644 index 0000000000..547a681e33 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java @@ -0,0 +1,50 @@ +/* + * 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.messaging.event.applications; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class AppClusterTerminatingEvent extends StatusEvent { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public AppClusterTerminatingEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java similarity index 95% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java index ee26292f51..6eeb2dc630 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupInactivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java index f04ae0217a..7e6a8b47ac 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import java.io.Serializable; /** * This event will be fired upon the application activated is detected. */ -public class AppStatusApplicationActivatedEvent extends StatusEvent implements Serializable { +public class ApplicationActivatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; - public AppStatusApplicationActivatedEvent(String appId) { + public ApplicationActivatedEvent(String appId) { this.appId = appId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java index c432e14b49..5d220fa950 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import java.io.Serializable; /** * This event will be fired upon the application created is detected. */ -public class AppStatusApplicationCreatedEvent extends StatusEvent implements Serializable { +public class ApplicationCreatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; - public AppStatusApplicationCreatedEvent(String appId) { + public ApplicationCreatedEvent(String appId) { this.appId = appId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java index f00a97ad17..8ff0db37fe 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import java.io.Serializable; /** * This event will be fired upon the application inactivated is detected. */ -public class AppStatusApplicationInactivatedEvent extends StatusEvent implements Serializable { +public class ApplicationInactivatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; - public AppStatusApplicationInactivatedEvent(String appId) { + public ApplicationInactivatedEvent(String appId) { this.appId = appId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java index 2dafcdcf5c..024327a7fb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; @@ -26,13 +26,13 @@ /** * This event will be fired upon the application terminated is detected. */ -public class AppStatusApplicationTerminatedEvent extends StatusEvent implements Serializable { +public class ApplicationTerminatedEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; private Set clusterData; - public AppStatusApplicationTerminatedEvent(String appId, Set clusterData) { + public ApplicationTerminatedEvent(String appId, Set clusterData) { this.appId = appId; this.clusterData = clusterData; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java index e2a3a09ddf..e81b988a19 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java @@ -16,19 +16,19 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import java.io.Serializable; /** * This event will be fired upon the application terminating is detected. */ -public class AppStatusApplicationTerminatingEvent extends StatusEvent implements Serializable { +public class ApplicationTerminatingEvent extends StatusEvent implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; - public AppStatusApplicationTerminatingEvent(String appId) { + public ApplicationTerminatingEvent(String appId) { this.appId = appId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java index 04ee30ee91..c200217e56 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java @@ -17,19 +17,19 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusGroupCreatedEvent extends StatusEvent { +public class GroupActivatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public AppStatusGroupCreatedEvent(String appId, String groupId) { + public GroupActivatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java index 3da86675c3..8b622c5792 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java @@ -17,19 +17,19 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusGroupActivatedEvent extends StatusEvent { +public class GroupCreatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public AppStatusGroupActivatedEvent(String appId, String groupId) { + public GroupCreatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java index a1a787c74f..5723305c35 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java @@ -16,16 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event will be fired upon the instability of group detection by autoscaler. */ -public class AppStatusGroupMaintenanceModeEvent extends StatusEvent { +public class GroupMaintenanceModeEvent extends StatusEvent { private String groupId; private String appId; - public AppStatusGroupMaintenanceModeEvent(String appId, String groupId) { + public GroupMaintenanceModeEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java index eaba17d3d4..8099015255 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java @@ -16,16 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by autoscaler before actually terminate a group. */ -public class AppStatusGroupReadyToShutdownEvent extends StatusEvent { +public class GroupReadyToShutdownEvent extends StatusEvent { private String groupId; private String appId; - public AppStatusGroupReadyToShutdownEvent(String appId, String groupId) { + public GroupReadyToShutdownEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java index 52db5fbe17..6cfa88821b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java @@ -17,19 +17,19 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusGroupTerminatingEvent extends StatusEvent { +public class GroupTerminatedEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public AppStatusGroupTerminatingEvent(String appId, String groupId) { + public GroupTerminatedEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java index db31b64004..ba6f979562 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/AppStatusGroupTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java @@ -17,19 +17,19 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusGroupTerminatedEvent extends StatusEvent { +public class GroupTerminatingEvent extends StatusEvent { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public AppStatusGroupTerminatedEvent(String appId, String groupId) { + public GroupTerminatingEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java similarity index 94% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java index 7ffc449a8c..91dbab3212 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/application/status/StatusEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.event.application.status; +package org.apache.stratos.messaging.event.applications; import org.apache.stratos.messaging.event.Event; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.java deleted file mode 100644 index 4dfc8b58ab..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationActivatedEventListener.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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This listener will get triggered upon the application activated event. - */ -public abstract class AppStatusApplicationActivatedEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.java deleted file mode 100644 index 79a7d21961..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationCreatedEventListener.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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This listener will get triggered upon the application created event. - */ -public abstract class AppStatusApplicationCreatedEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.java deleted file mode 100644 index ad1be524c7..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatedEventListener.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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This listener will get triggered upon the application terminated event. - */ -public abstract class AppStatusApplicationTerminatedEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.java deleted file mode 100644 index a454f16fc5..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationTerminatingEventListener.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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This listener will get triggered upon the application terminating event. - */ -public abstract class AppStatusApplicationTerminatingEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java deleted file mode 100644 index 03da7f7363..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterInactivateEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusClusterInactivateEventListener extends EventListener{ -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java deleted file mode 100644 index a47c371d60..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatedEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusClusterTerminatedEventListener extends EventListener{ -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java deleted file mode 100644 index 11bdb97d38..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterTerminatingEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusClusterTerminatingEventListener extends EventListener{ -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java deleted file mode 100644 index 0873a70b75..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupInactivateEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusGroupInactivateEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java deleted file mode 100644 index 785abbd3fe..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatedEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusGroupTerminatedEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java deleted file mode 100644 index 8d56555868..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupTerminatingEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.application.status; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppStatusGroupTerminatingEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java index 82386a3eb7..f99e15b817 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.application.status; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppStatusGroupCreatedEventListener extends EventListener { +public abstract class AppClusterActivatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java index c0c62f9b5a..d43f360549 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.application.status; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppStatusClusterCreatedEventListener extends EventListener{ +public abstract class AppClusterCreatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java index e6381e3674..1adaeef9cb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusGroupActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.application.status; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppStatusGroupActivatedEventListener extends EventListener { +public abstract class AppClusterInactivateEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java index 75da7b85e3..89a66e9721 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusClusterActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.application.status; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppStatusClusterActivatedEventListener extends EventListener{ +public abstract class AppClusterTerminatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java new file mode 100644 index 0000000000..9cd9a5d2e2 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.applications; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class AppClusterTerminatingEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java similarity index 87% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java index f54ab9e442..e244ae92a6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationActivatedEventListener.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; /** - * This listener will be triggered upon the application activated event received. + * This listener will get triggered upon the application activated event. */ public abstract class ApplicationActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java similarity index 87% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java index bbc853f668..8e17c7bdfa 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationCreatedEventListener.java @@ -16,11 +16,12 @@ * specific language governing permissions and limitations * under the License. */ - -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; +/** + * This listener will get triggered upon the application created event. + */ public abstract class ApplicationCreatedEventListener extends EventListener { - } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java index c2a356dd11..d0593fbfb1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/application/status/AppStatusApplicationInactivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationInactivatedEventListener.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.application.status; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; /** * This listener will get triggered upon the application inactivated event. */ -public abstract class AppStatusApplicationInactivatedEventListener extends EventListener { +public abstract class ApplicationInactivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java similarity index 87% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java index 0b6fd597a9..064465c876 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatedEventListener.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; /** - * This listener will be triggered upon the application activated event received. + * This listener will get triggered upon the application terminated event. */ public abstract class ApplicationTerminatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java similarity index 87% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java index cc2645439a..3be2ad2fa7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationTerminatingEventListener.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; /** - * This listener will be triggered upon the application activated event received. + * This listener will get triggered upon the application terminating event. */ public abstract class ApplicationTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java similarity index 94% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java index b28a40dd0e..3abd8232ea 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationUndeployedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/ApplicationUndeployedEventListener.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java index d19d013f26..51455ae38c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupActivatedEventListener.java @@ -16,12 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -/** - * This will get triggered by the groups activation processor after processing the event - */ public abstract class GroupActivatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java index 3fb2d11f16..f13ed103e9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java @@ -16,12 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -/** - * This will get triggered by the groups activation processor after processing the event - */ public abstract class GroupCreatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java new file mode 100644 index 0000000000..aeb58da341 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupInactivateEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.applications; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class GroupInactivateEventListener extends EventListener { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java index af409e786f..ed4bb3a08d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatedEventListener.java @@ -16,12 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -/** - * This will get triggered by the groups activation processor after processing the event - */ public abstract class GroupTerminatedEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java index ab4042fb2d..5168f77aeb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupTerminatingEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupTerminatingEventListener.java @@ -16,12 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.topology; +package org.apache.stratos.messaging.listener.applications; import org.apache.stratos.messaging.listener.EventListener; -/** - * This will get triggered by the groups activation processor after processing the event - */ public abstract class GroupTerminatingEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.java deleted file mode 100644 index d33c0379a7..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationInActivateEventListener.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.messaging.listener.topology; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This listener will be triggered upon the application activated event received. - */ -public abstract class ApplicationInActivateEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.java deleted file mode 100644 index 93a5a60d89..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/GroupInActivateEventListener.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.messaging.listener.topology; - -import org.apache.stratos.messaging.listener.EventListener; - -/** - * This will get triggered by the groups activation processor after processing the event - */ -public abstract class GroupInActivateEventListener extends EventListener { -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java index 3f3c6eb39f..920f94eb59 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; +import org.apache.stratos.messaging.event.applications.AppClusterActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusClusterActivatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppStatusClusterActivatedMessageProcessor.class); +public class AppClusterActivatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppClusterActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,9 +36,9 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusClusterActivatedEvent.class.getName().equals(type)) { + if (AppClusterActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusClusterActivatedEvent event = (AppStatusClusterActivatedEvent) Util.jsonToObject(message, AppStatusClusterActivatedEvent.class); + AppClusterActivatedEvent event = (AppClusterActivatedEvent) Util.jsonToObject(message, AppClusterActivatedEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterActivatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java similarity index 77% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java index a743c43b22..9caa79cd1c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java @@ -16,18 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterCreatedEvent; +import org.apache.stratos.messaging.event.applications.AppClusterCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusClusterCreatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppStatusClusterCreatedMessageProcessor.class); +public class AppClusterCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppClusterCreatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,9 +36,9 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusClusterCreatedEvent.class.getName().equals(type)) { + if (AppClusterCreatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusClusterCreatedEvent event = (AppStatusClusterCreatedEvent) Util.jsonToObject(message, AppStatusClusterCreatedEvent.class); + AppClusterCreatedEvent event = (AppClusterCreatedEvent) Util.jsonToObject(message, AppClusterCreatedEvent.class); if(log.isDebugEnabled()) { log.debug("Received AppStatusClusterCreatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java index 6e289722c1..d9fb0e91a5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterInactivateMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterInactivateEvent; +import org.apache.stratos.messaging.event.applications.AppClusterInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusClusterInactivateMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppStatusClusterInactivateMessageProcessor.class); +public class AppClusterInactivateMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppClusterInactivateMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusClusterInactivateEvent.class.getName().equals(type)) { + if (AppClusterInactivateEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusClusterInactivateEvent event = (AppStatusClusterInactivateEvent) Util. - jsonToObject(message, AppStatusClusterInactivateEvent.class); + AppClusterInactivateEvent event = (AppClusterInactivateEvent) Util. + jsonToObject(message, AppClusterInactivateEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterInActivateEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java similarity index 78% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java index 55cec80f59..843d355b03 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatedEvent; +import org.apache.stratos.messaging.event.applications.AppClusterTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusClusterTerminatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppStatusClusterTerminatedMessageProcessor.class); +public class AppClusterTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppClusterTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusClusterTerminatedEvent.class.getName().equals(type)) { + if (AppClusterTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusClusterTerminatedEvent event = (AppStatusClusterTerminatedEvent) Util. - jsonToObject(message, AppStatusClusterTerminatedEvent.class); + AppClusterTerminatedEvent event = (AppClusterTerminatedEvent) Util. + jsonToObject(message, AppClusterTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java index e387a15fd1..9520f4e731 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusClusterTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusClusterTerminatingEvent; +import org.apache.stratos.messaging.event.applications.AppClusterTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusClusterTerminatingMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppStatusClusterTerminatingMessageProcessor.class); +public class AppClusterTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AppClusterTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusClusterTerminatingEvent.class.getName().equals(type)) { + if (AppClusterTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusClusterTerminatingEvent event = (AppStatusClusterTerminatingEvent) Util. - jsonToObject(message, AppStatusClusterTerminatingEvent.class); + AppClusterTerminatingEvent event = (AppClusterTerminatingEvent) Util. + jsonToObject(message, AppClusterTerminatingEvent.class); if(log.isDebugEnabled()) { log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java similarity index 99% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java index 34cd02b0cc..1524b00e4a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java index 8b88724ac6..71bd50ee23 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationActivatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusApplicationActivatedMessageProcessor extends MessageProcessor { +public class ApplicationActivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusApplicationActivatedMessageProcessor.class); + LogFactory.getLog(ApplicationActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -38,10 +38,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusApplicationActivatedEvent.class.getName().equals(type)) { + if (ApplicationActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusApplicationActivatedEvent event = - (AppStatusApplicationActivatedEvent) Util.jsonToObject(message, AppStatusApplicationActivatedEvent.class); + ApplicationActivatedEvent event = + (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java index 29fce0ab66..db5d77728c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationCreatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusApplicationCreatedMessageProcessor extends MessageProcessor { +public class ApplicationCreatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusApplicationCreatedMessageProcessor.class); + LogFactory.getLog(ApplicationCreatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusApplicationCreatedEvent.class.getName().equals(type)) { + if (ApplicationCreatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusApplicationCreatedEvent event = - (AppStatusApplicationCreatedEvent) Util.jsonToObject(message, AppStatusApplicationCreatedEvent.class); + ApplicationCreatedEvent event = + (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationCreated Event in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java index 972fca39da..d8f2aace98 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusApplicationInactivatedMessageProcessor extends MessageProcessor { +public class ApplicationInactivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusApplicationInactivatedMessageProcessor.class); + LogFactory.getLog(ApplicationInactivatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusApplicationInactivatedEvent.class.getName().equals(type)) { + if (ApplicationInactivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusApplicationInactivatedEvent event = - (AppStatusApplicationInactivatedEvent) Util.jsonToObject(message, AppStatusApplicationInactivatedEvent.class); + ApplicationInactivatedEvent event = + (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java index b639ac019c..a121ffb0bd 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusApplicationTerminatedMessageProcessor extends MessageProcessor { +public class ApplicationTerminatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusApplicationTerminatedMessageProcessor.class); + LogFactory.getLog(ApplicationTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusApplicationTerminatedEvent.class.getName().equals(type)) { + if (ApplicationTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusApplicationTerminatedEvent event = - (AppStatusApplicationTerminatedEvent) Util.jsonToObject(message, AppStatusApplicationTerminatedEvent.class); + ApplicationTerminatedEvent event = + (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java similarity index 79% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java index 143565a2b3..280de2cb9e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusApplicationTerminatingMessageProcessor extends MessageProcessor { +public class ApplicationTerminatingMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusApplicationTerminatingMessageProcessor.class); + LogFactory.getLog(ApplicationTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @@ -39,10 +39,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusApplicationTerminatingEvent.class.getName().equals(type)) { + if (ApplicationTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusApplicationTerminatingEvent event = - (AppStatusApplicationTerminatingEvent) Util.jsonToObject(message, AppStatusApplicationTerminatingEvent.class); + ApplicationTerminatingEvent event = + (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class); if (log.isDebugEnabled()) { log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java index 473726c252..02ddda8035 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; +import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusGroupActivatedMessageProcessor extends MessageProcessor { +public class GroupActivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusGroupActivatedMessageProcessor.class); + LogFactory.getLog(GroupActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusGroupActivatedEvent.class.getName().equals(type)) { + if (GroupActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusGroupActivatedEvent event = - (AppStatusGroupActivatedEvent) Util.jsonToObject(message, AppStatusGroupActivatedEvent.class); + GroupActivatedEvent event = + (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupActivatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java similarity index 78% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java index b9a1c6d6e5..d04d7f9956 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java @@ -16,19 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupActivatedEvent; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupCreatedEvent; +import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusGroupCreatedMessageProcessor extends MessageProcessor { +public class GroupCreatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusGroupCreatedMessageProcessor.class); + LogFactory.getLog(GroupCreatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -38,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusGroupCreatedEvent.class.getName().equals(type)) { + if (GroupCreatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusGroupCreatedEvent event = - (AppStatusGroupCreatedEvent) Util.jsonToObject(message, AppStatusGroupCreatedEvent.class); + GroupCreatedEvent event = + (GroupCreatedEvent) Util.jsonToObject(message, GroupCreatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received AppStatusGroupCreatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java similarity index 89% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java index 714ee88ddb..6cf25874fb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupInactivateEvent; +import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusGroupInactivatedMessageProcessor extends MessageProcessor { +public class GroupInactivatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusGroupInactivatedMessageProcessor.class); + LogFactory.getLog(GroupInactivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java index daa7206ef4..a917a147b8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatedEvent; +import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusGroupTerminatedMessageProcessor extends MessageProcessor { +public class GroupTerminatedMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusGroupTerminatedMessageProcessor.class); + LogFactory.getLog(GroupTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusGroupTerminatedEvent.class.getName().equals(type)) { + if (GroupTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusGroupTerminatedEvent event = - (AppStatusGroupTerminatedEvent) Util.jsonToObject(message, AppStatusGroupTerminatedEvent.class); + GroupTerminatedEvent event = + (GroupTerminatedEvent) Util.jsonToObject(message, GroupTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupTerminatingEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java similarity index 80% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java index 75012e0881..63c055dbfc 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/application/status/AppStatusGroupTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java @@ -16,18 +16,18 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.application.status; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.application.status.AppStatusGroupTerminatingEvent; +import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppStatusGroupTerminatingMessageProcessor extends MessageProcessor { +public class GroupTerminatingMessageProcessor extends MessageProcessor { private static final Log log = - LogFactory.getLog(AppStatusGroupTerminatingMessageProcessor.class); + LogFactory.getLog(GroupTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -37,10 +37,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppStatusGroupTerminatingEvent.class.getName().equals(type)) { + if (GroupTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - AppStatusGroupTerminatingEvent event = - (AppStatusGroupTerminatingEvent) Util.jsonToObject(message, AppStatusGroupTerminatingEvent.class); + GroupTerminatingEvent event = + (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class); if (log.isDebugEnabled()) { log.debug("Received GroupTerminatingEvent: " + event.toString()); From ea9337d36508111c9ad095aadf61e66c43ec4ecf Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 12:23:17 +0530 Subject: [PATCH 330/436] uddating applications topic --- .../AutoscalerTopologyEventReceiver.java | 1 + .../ApplicationStatusTopicReceiver.java | 62 ++++++------ .../controller/topology/TopologyBuilder.java | 45 +++++---- .../AppStatusMessageProcessorChain.java | 94 +++++++++---------- .../TopologyMessageProcessorChain.java | 1 + 5 files changed, 107 insertions(+), 96 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index fe4d9dffc2..97ba3f1ec3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -44,6 +44,7 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; +import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; 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; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index 9db0998889..d83a7d32e3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -22,8 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.application.status.*; -import org.apache.stratos.messaging.listener.application.status.*; +import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.listener.applications.*; import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; public class ApplicationStatusTopicReceiver implements Runnable { @@ -64,74 +64,74 @@ public void run() { private void addEventListeners() { // Listen to topology events that affect clusters - statusEventReceiver.addEventListener(new AppStatusClusterCreatedEventListener() { + statusEventReceiver.addEventListener(new AppClusterCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterCreated((AppStatusClusterCreatedEvent) event); + TopologyBuilder.handleClusterCreated((AppClusterCreatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusClusterActivatedEventListener() { + statusEventReceiver.addEventListener(new AppClusterActivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterActivatedEvent((AppStatusClusterActivatedEvent) event); + TopologyBuilder.handleClusterActivatedEvent((AppClusterActivatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusClusterTerminatedEventListener() { + statusEventReceiver.addEventListener(new AppClusterTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatedEvent((AppStatusClusterTerminatedEvent) event); + TopologyBuilder.handleClusterTerminatedEvent((AppClusterTerminatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusClusterTerminatingEventListener(){ + statusEventReceiver.addEventListener(new AppClusterTerminatingEventListener(){ @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatingEvent((AppStatusClusterTerminatingEvent) event); + TopologyBuilder.handleClusterTerminatingEvent((AppClusterTerminatingEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusClusterInactivateEventListener() { + statusEventReceiver.addEventListener(new AppClusterInactivateEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterInActivateEvent((AppStatusClusterInactivateEvent) event); + TopologyBuilder.handleClusterInActivateEvent((AppClusterInactivateEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusGroupCreatedEventListener() { + statusEventReceiver.addEventListener(new GroupCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupCreated((AppStatusGroupCreatedEvent) event); + TopologyBuilder.handleGroupCreated((GroupCreatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusGroupActivatedEventListener() { + statusEventReceiver.addEventListener(new GroupActivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupActivatedEvent((AppStatusGroupActivatedEvent) event); + TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusGroupTerminatedEventListener() { + statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupTerminatedEvent((AppStatusGroupTerminatedEvent) event); + TopologyBuilder.handleGroupTerminatedEvent((GroupTerminatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusGroupTerminatingEventListener() { + statusEventReceiver.addEventListener(new GroupTerminatingEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleGroupTerminatingEvent((AppStatusGroupTerminatingEvent) event); + TopologyBuilder.handleGroupTerminatingEvent((GroupTerminatingEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusGroupInactivateEventListener() { + statusEventReceiver.addEventListener(new GroupInactivateEventListener() { @Override protected void onEvent(Event event) { TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event); @@ -139,44 +139,44 @@ protected void onEvent(Event event) { } }); - statusEventReceiver.addEventListener(new AppStatusApplicationActivatedEventListener() { + statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleApplicationActivatedEvent((AppStatusApplicationActivatedEvent) event); + TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusApplicationInactivatedEventListener() { + statusEventReceiver.addEventListener(new ApplicationInactivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleApplicationInActivatedEvent((AppStatusApplicationInactivatedEvent) event); + TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusApplicationCreatedEventListener() { + statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleApplicationCreatedEvent((AppStatusApplicationCreatedEvent) event); + TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusApplicationTerminatingEventListener() { + statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleApplicationTerminatingEvent((AppStatusApplicationTerminatingEvent) event); + TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event); } }); - statusEventReceiver.addEventListener(new AppStatusApplicationTerminatedEventListener() { + statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleApplicationTerminatedEvent((AppStatusApplicationTerminatedEvent) event); + TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index e31cf3264f..3bc7b5a502 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -31,7 +31,16 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.application.status.*; +import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; +import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; +import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; +import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -115,7 +124,7 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterCreated (AppStatusClusterCreatedEvent event) { + public static void handleClusterCreated (AppClusterCreatedEvent event) { TopologyManager.acquireWriteLock(); @@ -152,7 +161,7 @@ public static void handleClusterCreated (AppStatusClusterCreatedEvent event) { event.getClusterId()); } - public static void handleGroupCreated (AppStatusGroupCreatedEvent event) { + public static void handleGroupCreated (GroupCreatedEvent event) { TopologyManager.acquireWriteLock(); @@ -186,7 +195,7 @@ public static void handleGroupCreated (AppStatusGroupCreatedEvent event) { TopologyManager.releaseWriteLock(); } - TopologyEventPublisher.sendGroupCreatedEvent(new GroupCreatedEvent(event.getAppId(), event.getGroupId())); + TopologyEventPublisher.sendGroupCreatedEvent(new org.apache.stratos.messaging.event.topology.GroupCreatedEvent(event.getAppId(), event.getGroupId())); } public static void handleClusterCreated(Registrant registrant, boolean isLb) { @@ -713,7 +722,7 @@ public static synchronized void handleApplicationUndeployed(String applicationId } - public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) { + public static void handleClusterActivatedEvent(AppClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterActivatedEvent.getServiceName()); //update the status of the cluster @@ -751,7 +760,7 @@ public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent cl } public static void handleClusterInActivateEvent( - AppStatusClusterInactivateEvent clusterInActivateEvent) { + AppClusterInactivateEvent clusterInActivateEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterInActivateEvent.getServiceName()); //update the status of the cluster @@ -788,7 +797,7 @@ public static void handleClusterInActivateEvent( TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1); } - public static void handleGroupActivatedEvent(AppStatusGroupActivatedEvent groupActivatedEvent) { + public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(groupActivatedEvent.getAppId()); //update the status of the Group @@ -822,7 +831,7 @@ public static void handleGroupActivatedEvent(AppStatusGroupActivatedEvent groupA TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1); } - public static void handleApplicationActivatedEvent(AppStatusApplicationActivatedEvent applicationActivatedEvent) { + public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(applicationActivatedEvent.getAppId()); //update the status of the Group @@ -848,7 +857,7 @@ public static void handleApplicationActivatedEvent(AppStatusApplicationActivated TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); } - public static void handleApplicationInActivatedEvent(AppStatusApplicationInactivatedEvent event) { + public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); //update the status of the Group @@ -874,7 +883,7 @@ public static void handleApplicationInActivatedEvent(AppStatusApplicationInactiv TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent); } - public static void handleApplicationCreatedEvent(AppStatusApplicationCreatedEvent event) { + public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); //update the status of the Group @@ -907,7 +916,7 @@ public static void handleApplicationCreatedEvent(AppStatusApplicationCreatedEven TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent); } - public static void handleApplicationTerminatingEvent(AppStatusApplicationTerminatingEvent event) { + public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) { String applicationId = event.getAppId(); @@ -956,7 +965,7 @@ private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Col } } - public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminatedEvent event) { + public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { Topology topology = TopologyManager.getTopology(); @@ -1018,7 +1027,7 @@ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminat log.info("Removed application [ " + event.getAppId() + " ] from Topology"); - TopologyEventPublisher.sendApplicationTerminatedEvent(new ApplicationTerminatedEvent(event.getAppId(), + TopologyEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(event.getAppId(), clusterData, tenantId, tenantDomain)); } @@ -1027,7 +1036,7 @@ public static void handleApplicationTerminatedEvent(AppStatusApplicationTerminat } } - private static void deleteAppResourcesFromMetadataService(AppStatusApplicationTerminatedEvent event) { + private static void deleteAppResourcesFromMetadataService(ApplicationTerminatedEvent event) { try { MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient(); metadataClient.deleteApplicationProperties(event.getAppId()); @@ -1071,7 +1080,7 @@ public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) } - public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent event) { + public static void handleGroupTerminatedEvent(GroupTerminatedEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); //update the status of the Group @@ -1105,7 +1114,7 @@ public static void handleGroupTerminatedEvent(AppStatusGroupTerminatedEvent even TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent); } - public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent event) { + public static void handleGroupTerminatingEvent(GroupTerminatingEvent event) { Topology topology = TopologyManager.getTopology(); Application application = topology.getApplication(event.getAppId()); //update the status of the Group @@ -1139,7 +1148,7 @@ public static void handleGroupTerminatingEvent(AppStatusGroupTerminatingEvent ev TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); } - public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent event) { + public static void handleClusterTerminatedEvent(AppClusterTerminatedEvent event) { TopologyManager.acquireWriteLock(); @@ -1166,7 +1175,7 @@ public static void handleClusterTerminatedEvent(AppStatusClusterTerminatedEvent TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent); } - public static void handleClusterTerminatingEvent(AppStatusClusterTerminatingEvent event) { + public static void handleClusterTerminatingEvent(AppClusterTerminatingEvent event) { TopologyManager.acquireWriteLock(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java index 1524b00e4a..3705f1e960 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.application.status.*; +import org.apache.stratos.messaging.listener.applications.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; /** @@ -31,68 +31,68 @@ public class AppStatusMessageProcessorChain extends MessageProcessorChain { private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class); - private AppStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor; - private AppStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; - private AppStatusClusterInactivateMessageProcessor clusterInActivateMessageProcessor; - private AppStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; - private AppStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; - private AppStatusGroupCreatedMessageProcessor groupCreatedMessageProcessor; - private AppStatusGroupActivatedMessageProcessor groupActivatedMessageProcessor; - private AppStatusGroupInactivatedMessageProcessor groupInActivateMessageProcessor; - private AppStatusApplicationActivatedMessageProcessor appActivatedMessageProcessor; - private AppStatusApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; - private AppStatusApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; - private AppStatusApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; - private AppStatusApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; - - private AppStatusGroupTerminatedMessageProcessor groupTerminatedMessageProcessor; - private AppStatusGroupTerminatingMessageProcessor groupTerminatingMessageProcessor; + private AppClusterCreatedMessageProcessor clusterCreatedMessageProcessor; + private AppClusterActivatedMessageProcessor clusterActivatedMessageProcessor; + private AppClusterInactivateMessageProcessor clusterInActivateMessageProcessor; + private AppClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; + private AppClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; + private GroupCreatedMessageProcessor groupCreatedMessageProcessor; + private GroupActivatedMessageProcessor groupActivatedMessageProcessor; + private GroupInactivatedMessageProcessor groupInActivateMessageProcessor; + private ApplicationActivatedMessageProcessor appActivatedMessageProcessor; + private ApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; + private ApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; + private ApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; + private ApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; + + private GroupTerminatedMessageProcessor groupTerminatedMessageProcessor; + private GroupTerminatingMessageProcessor groupTerminatingMessageProcessor; public void initialize() { // Add instance notifier event processors - clusterCreatedMessageProcessor= new AppStatusClusterCreatedMessageProcessor(); + clusterCreatedMessageProcessor= new AppClusterCreatedMessageProcessor(); add(clusterCreatedMessageProcessor); - clusterActivatedMessageProcessor = new AppStatusClusterActivatedMessageProcessor(); + clusterActivatedMessageProcessor = new AppClusterActivatedMessageProcessor(); add(clusterActivatedMessageProcessor); - clusterInActivateMessageProcessor = new AppStatusClusterInactivateMessageProcessor(); + clusterInActivateMessageProcessor = new AppClusterInactivateMessageProcessor(); add(clusterInActivateMessageProcessor); - clusterTerminatingMessageProcessor = new AppStatusClusterTerminatingMessageProcessor(); + clusterTerminatingMessageProcessor = new AppClusterTerminatingMessageProcessor(); add(clusterTerminatingMessageProcessor); - clusterTerminatedMessageProcessor = new AppStatusClusterTerminatedMessageProcessor(); + clusterTerminatedMessageProcessor = new AppClusterTerminatedMessageProcessor(); add(clusterTerminatedMessageProcessor); - groupCreatedMessageProcessor = new AppStatusGroupCreatedMessageProcessor(); + groupCreatedMessageProcessor = new GroupCreatedMessageProcessor(); add(groupCreatedMessageProcessor); - groupActivatedMessageProcessor = new AppStatusGroupActivatedMessageProcessor(); + groupActivatedMessageProcessor = new GroupActivatedMessageProcessor(); add(groupActivatedMessageProcessor); - groupInActivateMessageProcessor = new AppStatusGroupInactivatedMessageProcessor(); + groupInActivateMessageProcessor = new GroupInactivatedMessageProcessor(); add(groupInActivateMessageProcessor); - appActivatedMessageProcessor = new AppStatusApplicationActivatedMessageProcessor(); + appActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); add(appActivatedMessageProcessor); - applicationStatusAppCreatedMessageProcessor = new AppStatusApplicationCreatedMessageProcessor(); + applicationStatusAppCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); this.add(applicationStatusAppCreatedMessageProcessor); - applicationStatusAppInActivatedMessageProcessor = new AppStatusApplicationInactivatedMessageProcessor(); + applicationStatusAppInActivatedMessageProcessor = new ApplicationInactivatedMessageProcessor(); this.add(applicationStatusAppInActivatedMessageProcessor); - applicationStatusAppTerminatedMessageProcessor = new AppStatusApplicationTerminatedMessageProcessor(); + applicationStatusAppTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor(); this.add(applicationStatusAppTerminatedMessageProcessor); - applicationStatusAppTerminatingMessageProcessor = new AppStatusApplicationTerminatingMessageProcessor(); + applicationStatusAppTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor(); this.add(applicationStatusAppTerminatingMessageProcessor); - groupTerminatedMessageProcessor = new AppStatusGroupTerminatedMessageProcessor(); + groupTerminatedMessageProcessor = new GroupTerminatedMessageProcessor(); this.add(groupTerminatedMessageProcessor); - groupTerminatingMessageProcessor = new AppStatusGroupTerminatingMessageProcessor(); + groupTerminatingMessageProcessor = new GroupTerminatingMessageProcessor(); this.add(groupTerminatingMessageProcessor); if (log.isDebugEnabled()) { @@ -101,35 +101,35 @@ public void initialize() { } public void addEventListener(EventListener eventListener) { - if(eventListener instanceof AppStatusClusterCreatedEventListener) { + if(eventListener instanceof AppClusterCreatedEventListener) { clusterCreatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusClusterActivatedEventListener) { + } else if (eventListener instanceof AppClusterActivatedEventListener) { clusterActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusClusterInactivateEventListener) { + } else if (eventListener instanceof AppClusterInactivateEventListener) { clusterInActivateMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusGroupCreatedEventListener) { + } else if(eventListener instanceof GroupCreatedEventListener) { groupCreatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusGroupActivatedEventListener) { + } else if (eventListener instanceof GroupActivatedEventListener) { groupActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusClusterTerminatedEventListener){ + } else if(eventListener instanceof AppClusterTerminatedEventListener){ clusterTerminatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusClusterTerminatingEventListener){ + } else if(eventListener instanceof AppClusterTerminatingEventListener){ clusterTerminatingMessageProcessor.addEventListener(eventListener); - }else if (eventListener instanceof AppStatusGroupInactivateEventListener) { + }else if (eventListener instanceof GroupInactivateEventListener) { groupInActivateMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusApplicationActivatedEventListener) { + } else if (eventListener instanceof ApplicationActivatedEventListener) { appActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusApplicationInactivatedEventListener){ + } else if(eventListener instanceof ApplicationInactivatedEventListener){ applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusApplicationCreatedEventListener){ + } else if(eventListener instanceof ApplicationCreatedEventListener){ applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusApplicationTerminatingEventListener){ + } else if(eventListener instanceof ApplicationTerminatingEventListener){ applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppStatusApplicationTerminatedEventListener){ + } else if(eventListener instanceof ApplicationTerminatedEventListener){ applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusGroupTerminatingEventListener){ + } else if (eventListener instanceof GroupTerminatingEventListener){ groupTerminatingMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppStatusGroupTerminatedEventListener){ + } else if (eventListener instanceof GroupTerminatedEventListener){ groupTerminatedMessageProcessor.addEventListener(eventListener); } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 1ed5576d7a..d8d25d99b7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; From 275ba2dd6757a652450246e3843c3c25366a8327 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 13:20:57 +0530 Subject: [PATCH 331/436] removing application status and adding applications, cluster status topic --- ...r.java => ApplicationsEventPublisher.java} | 131 +------------- .../topic/ClusterStatusEventPublisher.java | 171 ++++++++++++++++++ .../AutoscalerTopologyEventReceiver.java | 25 +-- .../monitor/ParentComponentMonitor.java | 11 +- .../monitor/cluster/ClusterMonitor.java | 5 +- .../monitor/group/GroupMonitor.java | 4 +- .../status/checker/StatusChecker.java | 26 +-- .../ApplicationStatusTopicReceiver.java | 112 ++---------- .../internal/CloudControllerDSComponent.java | 1 - .../controller/topology/TopologyBuilder.java | 11 +- .../StratosManagerTopologyEventReceiver.java | 6 +- .../AppClusterTerminatingEvent.java | 50 ----- .../AppStatusGroupInactivateEvent.java | 6 +- .../ApplicationActivatedEvent.java | 4 +- .../applications/ApplicationCreatedEvent.java | 4 +- .../ApplicationInactivatedEvent.java | 4 +- .../ApplicationTerminatedEvent.java | 3 +- .../ApplicationTerminatingEvent.java | 4 +- .../applications/GroupActivatedEvent.java | 6 +- .../event/applications/GroupCreatedEvent.java | 6 +- .../GroupMaintenanceModeEvent.java | 6 +- .../GroupReadyToShutdownEvent.java | 6 +- .../applications/GroupTerminatedEvent.java | 6 +- .../applications/GroupTerminatingEvent.java | 6 +- .../event/applications/StatusEvent.java | 31 ---- .../ClusterStatusClusterActivatedEvent.java} | 8 +- .../ClusterStatusClusterCreatedEvent.java} | 8 +- .../ClusterStatusClusterInactivateEvent.java} | 8 +- .../ClusterStatusClusterTerminatedEvent.java} | 8 +- .../ClusterStatusClusterTerminatingEvent.java | 52 ++++++ .../AppClusterTerminatingEventListener.java | 24 --- ...rStatusClusterActivatedEventListener.java} | 4 +- ...terStatusClusterCreatedEventListener.java} | 4 +- ...StatusClusterInactivateEventListener.java} | 4 +- ...StatusClusterTerminatedEventListener.java} | 4 +- ...StatusClusterTerminatingEventListener.java | 24 +++ .../AppStatusMessageProcessorChain.java | 139 -------------- .../ApplicationActivatedMessageProcessor.java | 68 +++++-- .../ApplicationCreatedMessageProcessor.java | 92 ++++++++-- ...pplicationInactivatedMessageProcessor.java | 67 +++++-- ...ApplicationTerminatedMessageProcessor.java | 99 ++++++++-- ...pplicationTerminatingMessageProcessor.java | 67 +++++-- ...ApplicationUndeployedMessageProcessor.java | 2 +- .../ApplicationsMessageProcessorChain.java | 115 ++++++++++++ .../GroupActivatedMessageProcessor.java | 61 ------- .../GroupActivatedProcessor.java | 2 +- .../GroupCreatedMessageProcessor.java | 61 ------- .../GroupCreatedProcessor.java | 2 +- .../GroupInActivateProcessor.java | 2 +- .../GroupInactivatedMessageProcessor.java | 61 ------- .../GroupTerminatedMessageProcessor.java | 61 ------- .../GroupTerminatedProcessor.java | 2 +- .../GroupTerminatingMessageProcessor.java | 61 ------- .../GroupTerminatingProcessor.java | 2 +- ...atusClusterActivatedMessageProcessor.java} | 13 +- ...StatusClusterCreatedMessageProcessor.java} | 13 +- ...tusClusterInactivateMessageProcessor.java} | 14 +- ...tusClusterTerminatedMessageProcessor.java} | 14 +- ...usClusterTerminatingMessageProcessor.java} | 14 +- .../ClusterStatusMessageProcessorChain.java | 78 ++++++++ .../ApplicationActivatedMessageProcessor.java | 104 ----------- .../ApplicationCreatedMessageProcessor.java | 121 ------------- ...pplicationInactivatedMessageProcessor.java | 104 ----------- ...ApplicationTerminatedMessageProcessor.java | 136 -------------- ...pplicationTerminatingMessageProcessor.java | 104 ----------- .../TopologyMessageProcessorChain.java | 70 +------ .../ApplicationsEventMessageDelegator.java} | 22 +-- .../ApplicationsEventMessageListener.java} | 10 +- .../ApplicationsEventMessageQueue.java} | 4 +- .../ApplicationsEventReceiver.java} | 20 +- .../ClusterStatusEventMessageDelegator.java | 146 +++++++++++++++ .../ClusterStatusEventMessageListener.java | 54 ++++++ .../ClusterStatusEventMessageQueue.java | 26 +++ .../status/ClusterStatusEventReceiver.java | 83 +++++++++ .../stratos/messaging/util/Constants.java | 4 +- 75 files changed, 1290 insertions(+), 1621 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/{StatusEventPublisher.java => ApplicationsEventPublisher.java} (63%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{applications/AppClusterActivatedEvent.java => cluster/status/ClusterStatusClusterActivatedEvent.java} (84%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{applications/AppClusterTerminatedEvent.java => cluster/status/ClusterStatusClusterCreatedEvent.java} (84%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{applications/AppClusterCreatedEvent.java => cluster/status/ClusterStatusClusterInactivateEvent.java} (83%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/{applications/AppClusterInactivateEvent.java => cluster/status/ClusterStatusClusterTerminatedEvent.java} (83%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{applications/AppClusterCreatedEventListener.java => cluster/status/ClusterStatusClusterActivatedEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{applications/AppClusterTerminatedEventListener.java => cluster/status/ClusterStatusClusterCreatedEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{applications/AppClusterInactivateEventListener.java => cluster/status/ClusterStatusClusterInactivateEventListener.java} (85%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/{applications/AppClusterActivatedEventListener.java => cluster/status/ClusterStatusClusterTerminatedEventListener.java} (85%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/ApplicationUndeployedMessageProcessor.java (98%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/GroupActivatedProcessor.java (98%) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/GroupCreatedProcessor.java (98%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/GroupInActivateProcessor.java (98%) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/GroupTerminatedProcessor.java (98%) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{topology => applications}/GroupTerminatingProcessor.java (98%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{applications/AppClusterActivatedMessageProcessor.java => cluster/status/ClusterStatusClusterActivatedMessageProcessor.java} (75%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{applications/AppClusterCreatedMessageProcessor.java => cluster/status/ClusterStatusClusterCreatedMessageProcessor.java} (76%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{applications/AppClusterInactivateMessageProcessor.java => cluster/status/ClusterStatusClusterInactivateMessageProcessor.java} (77%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{applications/AppClusterTerminatedMessageProcessor.java => cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java} (75%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/{applications/AppClusterTerminatingMessageProcessor.java => cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java} (76%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/{application/status/ApplicationStatusEventMessageDelegator.java => applications/ApplicationsEventMessageDelegator.java} (88%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/{application/status/ApplicationStatusEventMessageListener.java => applications/ApplicationsEventMessageListener.java} (86%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/{application/status/ApplicationStatusEventMessageQueue.java => applications/ApplicationsEventMessageQueue.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/{application/status/ApplicationStatusEventReceiver.java => applications/ApplicationsEventReceiver.java} (82%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java similarity index 63% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java index c0e77dee15..1fbc14385a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/StatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java @@ -8,6 +8,7 @@ import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; @@ -16,133 +17,9 @@ /** * This will publish application related events to application status topic. */ -public class StatusEventPublisher { - private static final Log log = LogFactory.getLog(StatusEventPublisher.class); +public class ApplicationsEventPublisher { + private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class); - public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - try { - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - Service service = TopologyManager.getTopology().getService(serviceName); - if (service != null) { - Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Created)) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster created event for [application]: " + appId + - " [cluster]: " + clusterId); - } - AppClusterCreatedEvent clusterCreatedEvent = - new AppClusterCreatedEvent(appId, serviceName, clusterId); - - publishEvent(clusterCreatedEvent); - } else { - log.warn("Created is not in the possible state list of [cluster] " + clusterId); - } - } - } finally { - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - } - } - - public static void sendClusterActivatedEvent(String appId, String serviceName, String clusterId) { - try { - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - Service service = TopologyManager.getTopology().getService(serviceName); - if (service != null) { - Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Active)) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster activated event for [application]: " + appId + - " [cluster]: " + clusterId); - } - AppClusterActivatedEvent clusterActivatedEvent = - new AppClusterActivatedEvent(appId, serviceName, clusterId); - - publishEvent(clusterActivatedEvent); - } else { - log.warn("Active is not in the possible state list of [cluster] " + clusterId); - } - } - } finally { - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - } - } - - public static void sendClusterInActivateEvent(String appId, String serviceName, String clusterId) { - try { - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - Service service = TopologyManager.getTopology().getService(serviceName); - if (service != null) { - Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Inactive)) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster in-activate event for [application]: " + appId + - " [cluster]: " + clusterId); - } - AppClusterInactivateEvent clusterInActivateEvent = - new AppClusterInactivateEvent(appId, serviceName, clusterId); - - publishEvent(clusterInActivateEvent); - } else { - log.warn("In-active is not in the possible state list of [cluster] " + clusterId); - } - } - } finally { - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - - } - } - - public static void sendClusterTerminatingEvent(String appId, String serviceName, String clusterId) { - - try { - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - Service service = TopologyManager.getTopology().getService(serviceName); - if (service != null) { - Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Terminating)) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster Terminating event for [application]: " + appId + - " [cluster]: " + clusterId); - } - AppClusterTerminatingEvent appStatusClusterTerminatingEvent = - new AppClusterTerminatingEvent(appId, serviceName, clusterId); - - publishEvent(appStatusClusterTerminatingEvent); - } else { - log.warn("Terminating is not in the possible state list of [cluster] " + clusterId); - } - } - } finally { - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - - } - - } - - public static void sendClusterTerminatedEvent(String appId, String serviceName, String clusterId) { - try { - TopologyManager.acquireReadLockForCluster(serviceName, clusterId); - Service service = TopologyManager.getTopology().getService(serviceName); - if (service != null) { - Cluster cluster = service.getCluster(clusterId); - if (cluster.isStateTransitionValid(ClusterStatus.Terminated)) { - if (log.isInfoEnabled()) { - log.info("Publishing Cluster terminated event for [application]: " + appId + - " [cluster]: " + clusterId); - } - AppClusterTerminatedEvent appStatusClusterTerminatedEvent = - new AppClusterTerminatedEvent(appId, serviceName, clusterId); - - publishEvent(appStatusClusterTerminatedEvent); - } else { - log.warn("Terminated is not in the possible state list of [cluster] " + clusterId); - } - } - } finally { - TopologyManager.releaseReadLockForCluster(serviceName, clusterId); - - } - } public static void sendGroupCreatedEvent(String appId, String groupId) { try { @@ -354,7 +231,7 @@ public static void sendApplicationTerminatedEvent(String appId, Set gr if (parent instanceof Application) { //send application activated event log.info("sending app activate: " + appId); - StatusEventPublisher.sendApplicationActivatedEvent(appId); + ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group activate: " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationsEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); } } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || @@ -312,7 +312,7 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (parent instanceof Group) { //send activation to the parent log.info("sending group in-active: " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); + ApplicationsEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); } } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || @@ -322,7 +322,7 @@ private boolean updateChildStatus(String appId, String id, Map gr //validating the life cycle if (application.getStatus().equals(ApplicationStatus.Terminating)) { log.info("sending app terminated: " + appId); - StatusEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); } else { log.info("[Application] " + appId + " is in the [status] " + application.getStatus().toString() + ". Hence not sending terminated event"); @@ -331,7 +331,7 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (parent instanceof Group) { //send activation to the parent log.info("sending group created : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); } /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || @@ -352,7 +352,7 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (parent instanceof Group) { //send activation to the parent log.info("sending group created : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); } } else { log.warn("Clusters/groups not found in this [component] " + appId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index d83a7d32e3..fe97f99be2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -23,17 +23,19 @@ import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.listener.applications.*; -import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; +import org.apache.stratos.messaging.listener.cluster.status.*; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver; public class ApplicationStatusTopicReceiver implements Runnable { private static final Log log = LogFactory.getLog(ApplicationStatusTopicReceiver.class); - private ApplicationStatusEventReceiver statusEventReceiver; + private ApplicationsEventReceiver statusEventReceiver; private boolean terminated; public ApplicationStatusTopicReceiver() { - this.statusEventReceiver = new ApplicationStatusEventReceiver(); + this.statusEventReceiver = new ApplicationsEventReceiver(); addEventListeners(); } @@ -64,124 +66,40 @@ public void run() { private void addEventListeners() { // Listen to topology events that affect clusters - statusEventReceiver.addEventListener(new AppClusterCreatedEventListener() { + statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterCreated((AppClusterCreatedEvent) event); + TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppClusterActivatedEventListener() { + statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterActivatedEvent((AppClusterActivatedEvent) event); + TopologyBuilder.handleClusterActivatedEvent((ClusterStatusClusterActivatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppClusterTerminatedEventListener() { + statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatedEvent((AppClusterTerminatedEvent) event); + TopologyBuilder.handleClusterTerminatedEvent((ClusterStatusClusterTerminatedEvent) event); } }); - statusEventReceiver.addEventListener(new AppClusterTerminatingEventListener(){ + statusEventReceiver.addEventListener(new ClusterStatusClusterTerminatingEventListener(){ @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterTerminatingEvent((AppClusterTerminatingEvent) event); + TopologyBuilder.handleClusterTerminatingEvent((ClusterStatusClusterTerminatingEvent) event); } }); - statusEventReceiver.addEventListener(new AppClusterInactivateEventListener() { + statusEventReceiver.addEventListener(new ClusterStatusClusterInactivateEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterInActivateEvent((AppClusterInactivateEvent) event); + TopologyBuilder.handleClusterInActivateEvent((ClusterStatusClusterInactivateEvent) event); } }); - - - statusEventReceiver.addEventListener(new GroupCreatedEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleGroupCreated((GroupCreatedEvent) event); - } - }); - - statusEventReceiver.addEventListener(new GroupActivatedEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleGroupActivatedEvent((GroupActivatedEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new GroupTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleGroupTerminatedEvent((GroupTerminatedEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new GroupTerminatingEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleGroupTerminatingEvent((GroupTerminatingEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new GroupInactivateEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleGroupInActiveEvent((AppStatusGroupInactivateEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new ApplicationActivatedEventListener() { - - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleApplicationActivatedEvent((ApplicationActivatedEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new ApplicationInactivatedEventListener() { - - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleApplicationInActivatedEvent((ApplicationInactivatedEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new ApplicationCreatedEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleApplicationCreatedEvent((ApplicationCreatedEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleApplicationTerminatingEvent((ApplicationTerminatingEvent) event); - - } - }); - - statusEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - TopologyBuilder.handleApplicationTerminatedEvent((ApplicationTerminatedEvent) event); - - } - }); - - } public void setTerminated(boolean terminated) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 5831948c06..222cc154e4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -34,7 +34,6 @@ import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber; -import org.apache.stratos.messaging.message.receiver.application.status.ApplicationStatusEventReceiver; import org.apache.stratos.messaging.util.Constants; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 3bc7b5a502..294102765f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -41,6 +41,7 @@ import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; +import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; import org.apache.stratos.messaging.event.instance.status.InstanceReadyToShutdownEvent; @@ -124,7 +125,7 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterCreated (AppClusterCreatedEvent event) { + public static void handleClusterCreated (ClusterStatusClusterCreatedEvent event) { TopologyManager.acquireWriteLock(); @@ -722,7 +723,7 @@ public static synchronized void handleApplicationUndeployed(String applicationId } - public static void handleClusterActivatedEvent(AppClusterActivatedEvent clusterActivatedEvent) { + public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterActivatedEvent.getServiceName()); //update the status of the cluster @@ -760,7 +761,7 @@ public static void handleClusterActivatedEvent(AppClusterActivatedEvent clusterA } public static void handleClusterInActivateEvent( - AppClusterInactivateEvent clusterInActivateEvent) { + ClusterStatusClusterInactivateEvent clusterInActivateEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterInActivateEvent.getServiceName()); //update the status of the cluster @@ -1148,7 +1149,7 @@ public static void handleGroupTerminatingEvent(GroupTerminatingEvent event) { TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); } - public static void handleClusterTerminatedEvent(AppClusterTerminatedEvent event) { + public static void handleClusterTerminatedEvent(ClusterStatusClusterTerminatedEvent event) { TopologyManager.acquireWriteLock(); @@ -1175,7 +1176,7 @@ public static void handleClusterTerminatedEvent(AppClusterTerminatedEvent event) TopologyEventPublisher.sendClusterTerminatedEvent(clusterTerminatedEvent); } - public static void handleClusterTerminatingEvent(AppClusterTerminatingEvent event) { + public static void handleClusterTerminatingEvent(ClusterStatusClusterTerminatingEvent event) { TopologyManager.acquireWriteLock(); 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 index d6cc395151..a0856645e7 100644 --- 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 @@ -310,6 +310,7 @@ protected void onEvent(Event event) { }); //add listner to Complete Topology Event +/* topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() { @Override protected void onEvent(Event event) { @@ -367,8 +368,10 @@ protected void onEvent(Event event) { } } }); - +*/ + //add listener +/* topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { @Override protected void onEvent(Event event) { @@ -412,6 +415,7 @@ protected void onEvent(Event event) { } } }); +*/ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.java deleted file mode 100644 index 547a681e33..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatingEvent.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.messaging.event.applications; - -/** - * This event is fired by cartridge agent when it has started the server and - * applications are ready to serve the incoming requests. - */ -public class AppClusterTerminatingEvent extends StatusEvent { - private static final long serialVersionUID = 2625412714611885089L; - - private final String serviceName; - private final String clusterId; - private String appId; - - public AppClusterTerminatingEvent(String appId, String serviceName, String clusterId) { - this.serviceName = serviceName; - this.clusterId = clusterId; - this.appId = appId; - } - - public String getServiceName() { - return serviceName; - } - - public String getClusterId() { - return clusterId; - } - - public String getAppId() { - return appId; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java index 6eeb2dc630..07eb6743b8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppStatusGroupInactivateEvent.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppStatusGroupInactivateEvent extends StatusEvent { +public class AppStatusGroupInactivateEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java index 7e6a8b47ac..7825850baf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationActivatedEvent.java @@ -18,12 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + import java.io.Serializable; /** * This event will be fired upon the application activated is detected. */ -public class ApplicationActivatedEvent extends StatusEvent implements Serializable { +public class ApplicationActivatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java index 5d220fa950..dfb90f296e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java @@ -18,12 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + import java.io.Serializable; /** * This event will be fired upon the application created is detected. */ -public class ApplicationCreatedEvent extends StatusEvent implements Serializable { +public class ApplicationCreatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java index 8ff0db37fe..3006225352 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationInactivatedEvent.java @@ -18,12 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + import java.io.Serializable; /** * This event will be fired upon the application inactivated is detected. */ -public class ApplicationInactivatedEvent extends StatusEvent implements Serializable { +public class ApplicationInactivatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java index 024327a7fb..eaa54e3170 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatedEvent.java @@ -19,6 +19,7 @@ package org.apache.stratos.messaging.event.applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.event.Event; import java.io.Serializable; import java.util.Set; @@ -26,7 +27,7 @@ /** * This event will be fired upon the application terminated is detected. */ -public class ApplicationTerminatedEvent extends StatusEvent implements Serializable { +public class ApplicationTerminatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java index e81b988a19..2a434a42e0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationTerminatingEvent.java @@ -18,12 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + import java.io.Serializable; /** * This event will be fired upon the application terminating is detected. */ -public class ApplicationTerminatingEvent extends StatusEvent implements Serializable { +public class ApplicationTerminatingEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java index c200217e56..a587befb99 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupActivatedEvent.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupActivatedEvent extends StatusEvent { +public class GroupActivatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java index 8b622c5792..77336d2924 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupCreatedEvent extends StatusEvent { +public class GroupCreatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java index 5723305c35..4c1e2f0acf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupMaintenanceModeEvent.java @@ -18,10 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event will be fired upon the instability of group detection by autoscaler. */ -public class GroupMaintenanceModeEvent extends StatusEvent { +public class GroupMaintenanceModeEvent extends Event implements Serializable { private String groupId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java index 8099015255..b2d5d5786f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupReadyToShutdownEvent.java @@ -18,10 +18,14 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by autoscaler before actually terminate a group. */ -public class GroupReadyToShutdownEvent extends StatusEvent { +public class GroupReadyToShutdownEvent extends Event implements Serializable { private String groupId; private String appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java index 6cfa88821b..2a38caff1c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatedEvent.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupTerminatedEvent extends StatusEvent { +public class GroupTerminatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java index ba6f979562..c526a35e2c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupTerminatingEvent.java @@ -19,11 +19,15 @@ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.event.Event; + +import java.io.Serializable; + /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupTerminatingEvent extends StatusEvent { +public class GroupTerminatingEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java deleted file mode 100644 index 91dbab3212..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/StatusEvent.java +++ /dev/null @@ -1,31 +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.messaging.event.applications; - -import org.apache.stratos.messaging.event.Event; - -import java.io.Serializable; - -/** - * Represents all instance status events. - */ -public abstract class StatusEvent extends Event implements Serializable { - private static final long serialVersionUID = -4790128084271867615L; -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java index 688b382f62..1e00bd5e29 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterActivatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterActivatedEvent.java @@ -17,20 +17,22 @@ * under the License. */ -package org.apache.stratos.messaging.event.applications; +package org.apache.stratos.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppClusterActivatedEvent extends StatusEvent { +public class ClusterStatusClusterActivatedEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppClusterActivatedEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterActivatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java index d269d38031..d28cca1169 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterTerminatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java @@ -17,20 +17,22 @@ * under the License. */ -package org.apache.stratos.messaging.event.applications; +package org.apache.stratos.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppClusterTerminatedEvent extends StatusEvent { +public class ClusterStatusClusterCreatedEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppClusterTerminatedEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java index 3382a349b1..34fad5aaa0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterInactivateEvent.java @@ -17,20 +17,22 @@ * under the License. */ -package org.apache.stratos.messaging.event.applications; +package org.apache.stratos.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppClusterCreatedEvent extends StatusEvent { +public class ClusterStatusClusterInactivateEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppClusterCreatedEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterInactivateEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java index bf8926eaab..48ecb6823e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/AppClusterInactivateEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatedEvent.java @@ -17,20 +17,22 @@ * under the License. */ -package org.apache.stratos.messaging.event.applications; +package org.apache.stratos.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; /** * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class AppClusterInactivateEvent extends StatusEvent { +public class ClusterStatusClusterTerminatedEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public AppClusterInactivateEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterTerminatedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.java new file mode 100644 index 0000000000..df6eba9fe7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterTerminatingEvent.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.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class ClusterStatusClusterTerminatingEvent extends Event { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterStatusClusterTerminatingEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java deleted file mode 100644 index 9cd9a5d2e2..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatingEventListener.java +++ /dev/null @@ -1,24 +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.messaging.listener.applications; - -import org.apache.stratos.messaging.listener.EventListener; - -public abstract class AppClusterTerminatingEventListener extends EventListener{ -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java index d43f360549..c2a1eef91b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterActivatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.applications; +package org.apache.stratos.messaging.listener.cluster.status; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppClusterCreatedEventListener extends EventListener{ +public abstract class ClusterStatusClusterActivatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java index 89a66e9721..6ca547686a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterTerminatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.applications; +package org.apache.stratos.messaging.listener.cluster.status; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppClusterTerminatedEventListener extends EventListener{ +public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java index 1adaeef9cb..3af6d9dfe5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterInactivateEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterInactivateEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.applications; +package org.apache.stratos.messaging.listener.cluster.status; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppClusterInactivateEventListener extends EventListener{ +public abstract class ClusterStatusClusterInactivateEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java similarity index 85% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java index f99e15b817..04b54bab0f 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/AppClusterActivatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatedEventListener.java @@ -16,9 +16,9 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.listener.applications; +package org.apache.stratos.messaging.listener.cluster.status; import org.apache.stratos.messaging.listener.EventListener; -public abstract class AppClusterActivatedEventListener extends EventListener{ +public abstract class ClusterStatusClusterTerminatedEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java new file mode 100644 index 0000000000..d007d7fe7c --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterTerminatingEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.cluster.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterStatusClusterTerminatingEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.java deleted file mode 100644 index 3705f1e960..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppStatusMessageProcessorChain.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.messaging.message.processor.applications; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.applications.*; -import org.apache.stratos.messaging.message.processor.MessageProcessorChain; - -/** - * Application Status processor chain is to handle the list processors to parse the application - * status. - */ -public class AppStatusMessageProcessorChain extends MessageProcessorChain { - private static final Log log = LogFactory.getLog(AppStatusMessageProcessorChain.class); - - private AppClusterCreatedMessageProcessor clusterCreatedMessageProcessor; - private AppClusterActivatedMessageProcessor clusterActivatedMessageProcessor; - private AppClusterInactivateMessageProcessor clusterInActivateMessageProcessor; - private AppClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; - private AppClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; - private GroupCreatedMessageProcessor groupCreatedMessageProcessor; - private GroupActivatedMessageProcessor groupActivatedMessageProcessor; - private GroupInactivatedMessageProcessor groupInActivateMessageProcessor; - private ApplicationActivatedMessageProcessor appActivatedMessageProcessor; - private ApplicationCreatedMessageProcessor applicationStatusAppCreatedMessageProcessor; - private ApplicationInactivatedMessageProcessor applicationStatusAppInActivatedMessageProcessor; - private ApplicationTerminatedMessageProcessor applicationStatusAppTerminatedMessageProcessor; - private ApplicationTerminatingMessageProcessor applicationStatusAppTerminatingMessageProcessor; - - private GroupTerminatedMessageProcessor groupTerminatedMessageProcessor; - private GroupTerminatingMessageProcessor groupTerminatingMessageProcessor; - - public void initialize() { - // Add instance notifier event processors - clusterCreatedMessageProcessor= new AppClusterCreatedMessageProcessor(); - add(clusterCreatedMessageProcessor); - - clusterActivatedMessageProcessor = new AppClusterActivatedMessageProcessor(); - add(clusterActivatedMessageProcessor); - - clusterInActivateMessageProcessor = new AppClusterInactivateMessageProcessor(); - add(clusterInActivateMessageProcessor); - - clusterTerminatingMessageProcessor = new AppClusterTerminatingMessageProcessor(); - add(clusterTerminatingMessageProcessor); - - clusterTerminatedMessageProcessor = new AppClusterTerminatedMessageProcessor(); - add(clusterTerminatedMessageProcessor); - - groupCreatedMessageProcessor = new GroupCreatedMessageProcessor(); - add(groupCreatedMessageProcessor); - - groupActivatedMessageProcessor = new GroupActivatedMessageProcessor(); - add(groupActivatedMessageProcessor); - - groupInActivateMessageProcessor = new GroupInactivatedMessageProcessor(); - add(groupInActivateMessageProcessor); - - appActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); - add(appActivatedMessageProcessor); - - applicationStatusAppCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); - this.add(applicationStatusAppCreatedMessageProcessor); - - applicationStatusAppInActivatedMessageProcessor = new ApplicationInactivatedMessageProcessor(); - this.add(applicationStatusAppInActivatedMessageProcessor); - - applicationStatusAppTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor(); - this.add(applicationStatusAppTerminatedMessageProcessor); - - applicationStatusAppTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor(); - this.add(applicationStatusAppTerminatingMessageProcessor); - - groupTerminatedMessageProcessor = new GroupTerminatedMessageProcessor(); - this.add(groupTerminatedMessageProcessor); - - groupTerminatingMessageProcessor = new GroupTerminatingMessageProcessor(); - this.add(groupTerminatingMessageProcessor); - - if (log.isDebugEnabled()) { - log.debug("Instance notifier message processor chain initialized"); - } - } - - public void addEventListener(EventListener eventListener) { - if(eventListener instanceof AppClusterCreatedEventListener) { - clusterCreatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppClusterActivatedEventListener) { - clusterActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof AppClusterInactivateEventListener) { - clusterInActivateMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof GroupCreatedEventListener) { - groupCreatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupActivatedEventListener) { - groupActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppClusterTerminatedEventListener){ - clusterTerminatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof AppClusterTerminatingEventListener){ - clusterTerminatingMessageProcessor.addEventListener(eventListener); - }else if (eventListener instanceof GroupInactivateEventListener) { - groupInActivateMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationActivatedEventListener) { - appActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationInactivatedEventListener){ - applicationStatusAppInActivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationCreatedEventListener){ - applicationStatusAppCreatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatingEventListener){ - applicationStatusAppTerminatingMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatedEventListener){ - applicationStatusAppTerminatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatingEventListener){ - groupTerminatingMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatedEventListener){ - groupTerminatedMessageProcessor.addEventListener(eventListener); - } else - { - throw new RuntimeException("Unknown event listener " + eventListener.toString()); - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java index 71bd50ee23..6c82925e17 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java @@ -20,43 +20,85 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; +/** + * This processor responsible to process the application activation even and update the Topology. + */ public class ApplicationActivatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationActivatedMessageProcessor.class); private MessageProcessor nextProcessor; + @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; - } + @Override public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + if (ApplicationActivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + // Parse complete message and build event - ApplicationActivatedEvent event = - (ApplicationActivatedEvent) Util.jsonToObject(message, ApplicationActivatedEvent.class); + ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. + jsonToObject(message, ApplicationActivatedEvent.class); + + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); - if (log.isDebugEnabled()) { - log.debug("Received ApplicationActivatedEvent in application status topic: " + event.toString()); + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); } - // Notify event listeners - notifyEventListeners(event); - return true; + } else { if (nextProcessor != null) { - return nextProcessor.process(type, message, object); + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } + + private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); + } + return false; + } else { + // Apply changes to the topology + if (!application.isStateTransitionValid(ApplicationStatus.Active)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Active + " ]"); + } + application.setStatus(ApplicationStatus.Active); + + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java index db5d77728c..92d61bad8b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java @@ -16,48 +16,106 @@ * specific language governing permissions and limitations * under the License. */ + package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; -public class ApplicationCreatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(ApplicationCreatedMessageProcessor.class); +import java.util.Set; +public class ApplicationCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; - } @Override public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + if (ApplicationCreatedEvent.class.getName().equals(type)) { - // Parse complete message and build event - ApplicationCreatedEvent event = - (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + if (!topology.isInitialized()) { + return false; + } - if (log.isDebugEnabled()) { - log.debug("Received ApplicationCreated Event in application status topic: " + event.toString()); + ApplicationCreatedEvent event = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); + if (event == null) { + log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); + return false; } - // Notify event listeners - notifyEventListeners(event); - return true; + + TopologyUpdater.acquireWriteLockForApplications(); + // since the Clusters will also get modified, acquire write locks for each Service Type + Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); + } + } + + try { + return doProcess(event, topology); + + } finally { + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); + } + } + TopologyUpdater.releaseWriteLockForApplications(); + } + } else { if (nextProcessor != null) { - return nextProcessor.process(type, message, object); + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } + + private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { + + // check if required properties are available + if (event.getApplication() == null) { + String errorMsg = "Application object of application created event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (event.getApplication().getUniqueIdentifier() == null || event.getApplication().getUniqueIdentifier().isEmpty()) { + String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getUniqueIdentifier() + " ]"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) { + log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology"); + + } else { + // add application and the clusters to Topology + for(Cluster cluster: event.getClusterList()) { + topology.getService(cluster.getServiceName()).addCluster(cluster); + } + topology.addApplication(event.getApplication()); + } + + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java index d8f2aace98..91eae8cf06 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java @@ -20,10 +20,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ public class ApplicationInactivatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationInactivatedMessageProcessor.class); @@ -34,30 +41,64 @@ public class ApplicationInactivatedMessageProcessor extends MessageProcessor { @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; - } + @Override public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + if (ApplicationInactivatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + // Parse complete message and build event - ApplicationInactivatedEvent event = - (ApplicationInactivatedEvent) Util.jsonToObject(message, ApplicationInactivatedEvent.class); + ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. + jsonToObject(message, ApplicationInactivatedEvent.class); - if (log.isDebugEnabled()) { - log.debug("Received ApplicationInActivatedEvent in application status topic: " + event.toString()); + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); } - // Notify event listeners - notifyEventListeners(event); - return true; + } else { if (nextProcessor != null) { - return nextProcessor.process(type, message, object); + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); } + return false; + } else { + // Apply changes to the topology + if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Inactive + " ]"); + } + application.setStatus(ApplicationStatus.Inactive); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java index a121ffb0bd..8cd21826a6 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java @@ -20,10 +20,18 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; +import java.util.Set; + +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ public class ApplicationTerminatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationTerminatedMessageProcessor.class); @@ -34,30 +42,95 @@ public class ApplicationTerminatedMessageProcessor extends MessageProcessor { @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; - } + @Override public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + if (ApplicationTerminatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + // Parse complete message and build event - ApplicationTerminatedEvent event = - (ApplicationTerminatedEvent) Util.jsonToObject(message, ApplicationTerminatedEvent.class); + ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util. + jsonToObject(message, ApplicationTerminatedEvent.class); - if (log.isDebugEnabled()) { - log.debug("Received ApplicationTerminatedEvent in application status topic: " + event.toString()); + TopologyUpdater.acquireWriteLockForApplications(); + Set clusterDataHolders = event.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); + } } - // Notify event listeners - notifyEventListeners(event); - return true; + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplications(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterData : clusterDataHolders) { + TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); + } + } + } + } else { if (nextProcessor != null) { - return nextProcessor.process(type, message, object); + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } + + private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) { + + // check if required properties are available + if (event.getAppId() == null) { + String errorMsg = "Application Id of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + if (event.getTenantDomain()== null) { + String errorMsg = "Application tenant domain of application removed event is invalid"; + log.error(errorMsg); + throw new RuntimeException(errorMsg); + } + + // check if an Application with same name exists in topology + String appId = event.getAppId(); + if (topology.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); + topology.removeApplication(appId); + } + + if (event.getClusterData() != null) { + // remove the Clusters from the Topology + for (ClusterDataHolder clusterData : event.getClusterData()) { + Service service = topology.getService(clusterData.getServiceType()); + if (service != null) { + service.removeCluster(clusterData.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); + } + } else { + log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); + } + } + } + + if (log.isDebugEnabled()) { + log.debug("ApplicationRemovedMessageProcessor notifying listener "); + } + + notifyEventListeners(event); + return true; + + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java index 280de2cb9e..057d013278 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java @@ -20,10 +20,17 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; +/** + * This processor responsible to process the application Inactivation even and update the Topology. + */ public class ApplicationTerminatingMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationTerminatingMessageProcessor.class); @@ -34,30 +41,64 @@ public class ApplicationTerminatingMessageProcessor extends MessageProcessor { @Override public void setNext(MessageProcessor nextProcessor) { this.nextProcessor = nextProcessor; - } + @Override public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + if (ApplicationTerminatingEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) + return false; + // Parse complete message and build event - ApplicationTerminatingEvent event = - (ApplicationTerminatingEvent) Util.jsonToObject(message, ApplicationTerminatingEvent.class); + ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util. + jsonToObject(message, ApplicationTerminatingEvent.class); - if (log.isDebugEnabled()) { - log.debug("Received ApplicationTerminatingEvent in application status topic: " + event.toString()); + TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); } - // Notify event listeners - notifyEventListeners(event); - return true; + } else { if (nextProcessor != null) { - return nextProcessor.process(type, message, object); + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) { + + // Validate event against the existing topology + Application application = topology.getApplication(event.getAppId()); + if (application == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Application does not exist: [service] %s", + event.getAppId())); } + return false; + } else { + // Apply changes to the topology + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid State transfer from [ " + application.getStatus() + + " ] to [ " + ApplicationStatus.Terminating + " ]"); + } + application.setStatus(ApplicationStatus.Terminating); + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java index f368dd1817..7e91ab8a42 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java new file mode 100644 index 0000000000..e75b6048f4 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java @@ -0,0 +1,115 @@ +/* + * 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.messaging.message.processor.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.applications.*; +import org.apache.stratos.messaging.message.processor.MessageProcessorChain; + +/** + * Application Status processor chain is to handle the list processors to parse the application + * status. + */ +public class ApplicationsMessageProcessorChain extends MessageProcessorChain { + private static final Log log = LogFactory.getLog(ApplicationsMessageProcessorChain.class); + + private GroupCreatedProcessor groupCreatedMessageProcessor; + private GroupActivatedProcessor groupActivatedMessageProcessor; + private GroupInActivateProcessor groupInActivateMessageProcessor; + private GroupTerminatedProcessor groupTerminatedProcessor; + private GroupTerminatingProcessor groupTerminatingProcessor; + private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; + private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; + private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor; + private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor; + private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor; + private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor; + + public void initialize() { + // Add instance notifier event processors + + groupCreatedMessageProcessor = new GroupCreatedProcessor(); + add(groupCreatedMessageProcessor); + + groupActivatedMessageProcessor = new GroupActivatedProcessor(); + add(groupActivatedMessageProcessor); + + groupInActivateMessageProcessor = new GroupInActivateProcessor(); + add(groupInActivateMessageProcessor); + + groupTerminatedProcessor = new GroupTerminatedProcessor(); + add(groupTerminatedProcessor); + + groupTerminatingProcessor = new GroupTerminatingProcessor(); + add(groupTerminatingProcessor); + + applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); + add(applicationActivatedMessageProcessor); + + applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); + add(applicationCreatedMessageProcessor); + + applicationInactivatedMessageProcessor = new ApplicationInactivatedMessageProcessor(); + add(applicationInactivatedMessageProcessor); + + applicationTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor(); + add(applicationTerminatingMessageProcessor); + + applicationTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor(); + add(applicationTerminatedMessageProcessor); + + applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor(); + add(applicationUndeployedMessageProcessor); + + if (log.isDebugEnabled()) { + log.debug("Instance notifier message processor chain initialized"); + } + } + + public void addEventListener(EventListener eventListener) { + + if(eventListener instanceof GroupCreatedEventListener) { + groupCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupInactivateEventListener) { + groupInActivateMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupActivatedEventListener) { + groupActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupTerminatingEventListener) { + groupTerminatingProcessor.addEventListener(eventListener); + } else if (eventListener instanceof GroupTerminatedEventListener) { + groupTerminatedProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationCreatedEventListener) { + applicationCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationActivatedEventListener) { + applicationActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationInactivatedEventListener) { + applicationInactivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationTerminatingEventListener) { + applicationTerminatingMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationTerminatedEventListener) { + applicationTerminatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationUndeployedEventListener) { + applicationUndeployedMessageProcessor.addEventListener(eventListener); + } else { + throw new RuntimeException("Unknown event listener " + eventListener.toString()); + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java deleted file mode 100644 index 02ddda8035..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedMessageProcessor.java +++ /dev/null @@ -1,61 +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.messaging.message.processor.applications; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -public class GroupActivatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(GroupActivatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (GroupActivatedEvent.class.getName().equals(type)) { - // Parse complete message and build event - GroupActivatedEvent event = - (GroupActivatedEvent) Util.jsonToObject(message, GroupActivatedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("Received GroupActivatedEvent: " + event.toString()); - } - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - return nextProcessor.process(type, message, object); - } else { - throw new RuntimeException( - String.format("Failed to process group activated message " + - "using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java index 09b90628df..845e933d1e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java deleted file mode 100644 index d04d7f9956..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedMessageProcessor.java +++ /dev/null @@ -1,61 +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.messaging.message.processor.applications; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -public class GroupCreatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(GroupCreatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (GroupCreatedEvent.class.getName().equals(type)) { - // Parse complete message and build event - GroupCreatedEvent event = - (GroupCreatedEvent) Util.jsonToObject(message, GroupCreatedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("Received AppStatusGroupCreatedEvent: " + event.toString()); - } - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - return nextProcessor.process(type, message, object); - } else { - throw new RuntimeException( - String.format("Failed to process group created message " + - "using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java index d053f5d09b..47d445737b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupCreatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java index add40b4083..063a3de382 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java deleted file mode 100644 index 6cf25874fb..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInactivatedMessageProcessor.java +++ /dev/null @@ -1,61 +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.messaging.message.processor.applications; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -public class GroupInactivatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(GroupInactivatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (AppStatusGroupInactivateEvent.class.getName().equals(type)) { - // Parse complete message and build event - AppStatusGroupInactivateEvent event = - (AppStatusGroupInactivateEvent) Util.jsonToObject(message, AppStatusGroupInactivateEvent.class); - - if (log.isDebugEnabled()) { - log.debug("Received GroupInActivateEvent: " + event.toString()); - } - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - return nextProcessor.process(type, message, object); - } else { - throw new RuntimeException( - String.format("Failed to process group in activated message " + - "using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java deleted file mode 100644 index a917a147b8..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedMessageProcessor.java +++ /dev/null @@ -1,61 +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.messaging.message.processor.applications; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -public class GroupTerminatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(GroupTerminatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (GroupTerminatedEvent.class.getName().equals(type)) { - // Parse complete message and build event - GroupTerminatedEvent event = - (GroupTerminatedEvent) Util.jsonToObject(message, GroupTerminatedEvent.class); - - if (log.isDebugEnabled()) { - log.debug("Received GroupTerminatingEvent: " + event.toString()); - } - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - return nextProcessor.process(type, message, object); - } else { - throw new RuntimeException( - String.format("Failed to process group in GroupTerminatingEvent message " + - "using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java index 767ff710e0..3de09146e9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java deleted file mode 100644 index 63c055dbfc..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingMessageProcessor.java +++ /dev/null @@ -1,61 +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.messaging.message.processor.applications; - - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -public class GroupTerminatingMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(GroupTerminatingMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (GroupTerminatingEvent.class.getName().equals(type)) { - // Parse complete message and build event - GroupTerminatingEvent event = - (GroupTerminatingEvent) Util.jsonToObject(message, GroupTerminatingEvent.class); - - if (log.isDebugEnabled()) { - log.debug("Received GroupTerminatingEvent: " + event.toString()); - } - // Notify event listeners - notifyEventListeners(event); - return true; - } else { - if (nextProcessor != null) { - return nextProcessor.process(type, message, object); - } else { - throw new RuntimeException( - String.format("Failed to process group in GroupTerminatingEvent message " + - "using available message processors: [type] %s [body] %s", type, message)); - } - } - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java similarity index 98% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java index 5b155323d3..e124b7b602 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.topology; +package org.apache.stratos.messaging.message.processor.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java similarity index 75% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java index 920f94eb59..694c3f3ba4 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.applications; +package org.apache.stratos.messaging.message.processor.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppClusterActivatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppClusterActivatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppClusterActivatedMessageProcessor.class); +public class ClusterStatusClusterActivatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterActivatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,9 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppClusterActivatedEvent.class.getName().equals(type)) { + if (ClusterStatusClusterActivatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppClusterActivatedEvent event = (AppClusterActivatedEvent) Util.jsonToObject(message, AppClusterActivatedEvent.class); + ClusterStatusClusterActivatedEvent event = (ClusterStatusClusterActivatedEvent) Util. + jsonToObject(message, ClusterStatusClusterActivatedEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterActivatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java similarity index 76% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java index 9caa79cd1c..9b4780b76c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.applications; +package org.apache.stratos.messaging.message.processor.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppClusterCreatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppClusterCreatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppClusterCreatedMessageProcessor.class); +public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,9 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppClusterCreatedEvent.class.getName().equals(type)) { + if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppClusterCreatedEvent event = (AppClusterCreatedEvent) Util.jsonToObject(message, AppClusterCreatedEvent.class); + ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util. + jsonToObject(message, ClusterStatusClusterCreatedEvent.class); if(log.isDebugEnabled()) { log.debug("Received AppStatusClusterCreatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java similarity index 77% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java index d9fb0e91a5..69918e24f9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterInactivateMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.applications; +package org.apache.stratos.messaging.message.processor.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppClusterInactivateEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppClusterInactivateMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppClusterInactivateMessageProcessor.class); +public class ClusterStatusClusterInactivateMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterInactivateMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppClusterInactivateEvent.class.getName().equals(type)) { + if (ClusterStatusClusterInactivateEvent.class.getName().equals(type)) { // Parse complete message and build event - AppClusterInactivateEvent event = (AppClusterInactivateEvent) Util. - jsonToObject(message, AppClusterInactivateEvent.class); + ClusterStatusClusterInactivateEvent event = (ClusterStatusClusterInactivateEvent) Util. + jsonToObject(message, ClusterStatusClusterInactivateEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterInActivateEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java similarity index 75% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java index 843d355b03..64b6c7bbee 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.applications; +package org.apache.stratos.messaging.message.processor.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppClusterTerminatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppClusterTerminatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppClusterTerminatedMessageProcessor.class); +public class ClusterStatusClusterTerminatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterTerminatedMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppClusterTerminatedEvent.class.getName().equals(type)) { + if (ClusterStatusClusterTerminatedEvent.class.getName().equals(type)) { // Parse complete message and build event - AppClusterTerminatedEvent event = (AppClusterTerminatedEvent) Util. - jsonToObject(message, AppClusterTerminatedEvent.class); + ClusterStatusClusterTerminatedEvent event = (ClusterStatusClusterTerminatedEvent) Util. + jsonToObject(message, ClusterStatusClusterTerminatedEvent.class); if (log.isDebugEnabled()) { log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java similarity index 76% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java index 9520f4e731..c161dd5f60 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/AppClusterTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java @@ -16,17 +16,17 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.processor.applications; +package org.apache.stratos.messaging.message.processor.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.applications.AppClusterTerminatingEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class AppClusterTerminatingMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AppClusterTerminatingMessageProcessor.class); +public class ClusterStatusClusterTerminatingMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterTerminatingMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (AppClusterTerminatingEvent.class.getName().equals(type)) { + if (ClusterStatusClusterTerminatingEvent.class.getName().equals(type)) { // Parse complete message and build event - AppClusterTerminatingEvent event = (AppClusterTerminatingEvent) Util. - jsonToObject(message, AppClusterTerminatingEvent.class); + ClusterStatusClusterTerminatingEvent event = (ClusterStatusClusterTerminatingEvent) Util. + jsonToObject(message, ClusterStatusClusterTerminatingEvent.class); if(log.isDebugEnabled()) { log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java new file mode 100644 index 0000000000..29556ecbcf --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java @@ -0,0 +1,78 @@ +/* + * 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.messaging.message.processor.cluster.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.listener.cluster.status.*; +import org.apache.stratos.messaging.message.processor.MessageProcessorChain; + +/** + * This is to keep track of the processors for the cluster status topic. + */ +public class ClusterStatusMessageProcessorChain extends MessageProcessorChain { + private static final Log log = LogFactory.getLog(ClusterStatusMessageProcessorChain.class); + + + private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; + private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor; + private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor; + private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; + private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; + @Override + protected void initialize() { + clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor(); + add(clusterCreatedMessageProcessor); + + clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor(); + add(clusterActivatedMessageProcessor); + + clusterInactivateMessageProcessor = new ClusterStatusClusterInactivateMessageProcessor(); + add(clusterInactivateMessageProcessor); + + clusterTerminatedMessageProcessor = new ClusterStatusClusterTerminatedMessageProcessor(); + add(clusterTerminatedMessageProcessor); + + clusterTerminatingMessageProcessor = new ClusterStatusClusterTerminatingMessageProcessor(); + add(clusterTerminatingMessageProcessor); + + if (log.isDebugEnabled()) { + log.debug("Cluster status message processor chain initialized"); + } + } + + @Override + public void addEventListener(EventListener eventListener) { + if(eventListener instanceof ClusterStatusClusterCreatedEventListener) { + clusterCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) { + clusterInactivateMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterStatusClusterActivatedEventListener) { + clusterActivatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterStatusClusterTerminatingEventListener) { + clusterTerminatingMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ClusterStatusClusterTerminatedEventListener) { + clusterTerminatedMessageProcessor.addEventListener(eventListener); + } else { + throw new RuntimeException("Unknown event listener " + eventListener.toString()); + } + + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java deleted file mode 100644 index 341b40273a..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationActivatedMessageProcessor.java +++ /dev/null @@ -1,104 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -/** - * This processor responsible to process the application activation even and update the Topology. - */ -public class ApplicationActivatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(ApplicationActivatedMessageProcessor.class); - - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (ApplicationActivatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) - return false; - - // Parse complete message and build event - ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. - jsonToObject(message, ApplicationActivatedEvent.class); - - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); - - try { - return doProcess(event, topology); - - } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { - - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } else { - // Apply changes to the topology - if (!application.isStateTransitionValid(ApplicationStatus.Active)) { - log.error("Invalid State transfer from [ " + application.getStatus() + - " ] to [ " + ApplicationStatus.Active + " ]"); - } - application.setStatus(ApplicationStatus.Active); - - } - - // Notify event listeners - notifyEventListeners(event); - return true; - - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.java deleted file mode 100644 index 079cb90e66..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationCreatedMessageProcessor.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.messaging.message.processor.topology; - -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.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -import java.util.Set; - -public class ApplicationCreatedMessageProcessor extends MessageProcessor { - - private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - - Topology topology = (Topology) object; - - if (ApplicationCreatedEvent.class.getName().equals(type)) { - if (!topology.isInitialized()) { - return false; - } - - ApplicationCreatedEvent event = (ApplicationCreatedEvent) Util.jsonToObject(message, ApplicationCreatedEvent.class); - if (event == null) { - log.error("Unable to convert the JSON message to ApplicationCreatedEvent"); - return false; - } - - TopologyUpdater.acquireWriteLockForApplications(); - // since the Clusters will also get modified, acquire write locks for each Service Type - Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); - } - } - - try { - return doProcess(event, topology); - - } finally { - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); - } - } - TopologyUpdater.releaseWriteLockForApplications(); - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { - - // check if required properties are available - if (event.getApplication() == null) { - String errorMsg = "Application object of application created event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - if (event.getApplication().getUniqueIdentifier() == null || event.getApplication().getUniqueIdentifier().isEmpty()) { - String errorMsg = "App id of application created event is invalid: [ " + event.getApplication().getUniqueIdentifier() + " ]"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - // check if an Application with same name exists in topology - if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) { - log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology"); - - } else { - // add application and the clusters to Topology - for(Cluster cluster: event.getClusterList()) { - topology.getService(cluster.getServiceName()).addCluster(cluster); - } - topology.addApplication(event.getApplication()); - } - - notifyEventListeners(event); - return true; - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java deleted file mode 100644 index 8c88324cd5..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationInactivatedMessageProcessor.java +++ /dev/null @@ -1,104 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -/** - * This processor responsible to process the application Inactivation even and update the Topology. - */ -public class ApplicationInactivatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(ApplicationInactivatedMessageProcessor.class); - - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (ApplicationInactivatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) - return false; - - // Parse complete message and build event - ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. - jsonToObject(message, ApplicationInactivatedEvent.class); - - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); - - try { - return doProcess(event, topology); - - } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { - - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } else { - // Apply changes to the topology - if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) { - log.error("Invalid State transfer from [ " + application.getStatus() + - " ] to [ " + ApplicationStatus.Inactive + " ]"); - } - application.setStatus(ApplicationStatus.Inactive); - - } - - // Notify event listeners - notifyEventListeners(event); - return true; - - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java deleted file mode 100644 index 2dd3ea7b97..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatedMessageProcessor.java +++ /dev/null @@ -1,136 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -import java.util.Set; - -/** - * This processor responsible to process the application Inactivation even and update the Topology. - */ -public class ApplicationTerminatedMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(ApplicationTerminatedMessageProcessor.class); - - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (ApplicationTerminatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) - return false; - - // Parse complete message and build event - ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util. - jsonToObject(message, ApplicationTerminatedEvent.class); - - TopologyUpdater.acquireWriteLockForApplications(); - Set clusterDataHolders = event.getClusterData(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); - } - } - - try { - return doProcess(event, topology); - - } finally { - TopologyUpdater.releaseWriteLockForApplications(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); - } - } - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) { - - // check if required properties are available - if (event.getAppId() == null) { - String errorMsg = "Application Id of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - if (event.getTenantDomain()== null) { - String errorMsg = "Application tenant domain of application removed event is invalid"; - log.error(errorMsg); - throw new RuntimeException(errorMsg); - } - - // check if an Application with same name exists in topology - String appId = event.getAppId(); - if (topology.applicationExists(appId)) { - log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); - topology.removeApplication(appId); - } - - if (event.getClusterData() != null) { - // remove the Clusters from the Topology - for (ClusterDataHolder clusterData : event.getClusterData()) { - Service service = topology.getService(clusterData.getServiceType()); - if (service != null) { - service.removeCluster(clusterData.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); - } - } else { - log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); - } - } - } - - if (log.isDebugEnabled()) { - log.debug("ApplicationRemovedMessageProcessor notifying listener "); - } - - notifyEventListeners(event); - return true; - - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java deleted file mode 100644 index 032be79964..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationTerminatingMessageProcessor.java +++ /dev/null @@ -1,104 +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.messaging.message.processor.topology; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; -import org.apache.stratos.messaging.util.Util; - -/** - * This processor responsible to process the application Inactivation even and update the Topology. - */ -public class ApplicationTerminatingMessageProcessor extends MessageProcessor { - private static final Log log = - LogFactory.getLog(ApplicationTerminatingMessageProcessor.class); - - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - - @Override - public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; - - if (ApplicationTerminatingEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) - return false; - - // Parse complete message and build event - ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util. - jsonToObject(message, ApplicationTerminatingEvent.class); - - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); - - try { - return doProcess(event, topology); - - } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); - } - - } else { - if (nextProcessor != null) { - // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); - } else { - throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) { - - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - if (log.isWarnEnabled()) { - log.warn(String.format("Application does not exist: [service] %s", - event.getAppId())); - } - return false; - } else { - // Apply changes to the topology - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid State transfer from [ " + application.getStatus() + - " ] to [ " + ApplicationStatus.Terminating + " ]"); - } - application.setStatus(ApplicationStatus.Terminating); - - } - - // Notify event listeners - notifyEventListeners(event); - return true; - - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index d8d25d99b7..048e9a3416 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; -import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; import org.apache.stratos.messaging.listener.topology.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; @@ -47,17 +46,6 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private MemberMaintenanceModeProcessor memberMaintenanceModeProcessor; private MemberSuspendedMessageProcessor memberSuspendedMessageProcessor; private MemberTerminatedMessageProcessor memberTerminatedMessageProcessor; - private GroupCreatedProcessor groupCreatedProcessor; - private GroupActivatedProcessor groupActivatedProcessor; - private GroupInActivateProcessor groupInActivateProcessor; - private ApplicationCreatedMessageProcessor applicationCreatedMessageProcessor; - private ApplicationUndeployedMessageProcessor applicationUndeployedMessageProcessor; - private ApplicationActivatedMessageProcessor applicationActivatedMessageProcessor; - private ApplicationInactivatedMessageProcessor applicationInactivatedMessageProcessor; - private ApplicationTerminatedMessageProcessor applicationTerminatedMessageProcessor; - private ApplicationTerminatingMessageProcessor applicationTerminatingMessageProcessor; - private GroupTerminatingProcessor groupTerminatingProcessor; - private GroupTerminatedProcessor groupTerminatedProcessor; private ClusterTerminatingProcessor clusterTerminatingProcessor; private ClusterTerminatedProcessor clusterTerminatedProcessor; @@ -111,39 +99,6 @@ public void initialize() { memberTerminatedMessageProcessor = new MemberTerminatedMessageProcessor(); add(memberTerminatedMessageProcessor); - groupCreatedProcessor = new GroupCreatedProcessor(); - add(groupCreatedProcessor); - - groupActivatedProcessor = new GroupActivatedProcessor(); - add(groupActivatedProcessor); - - groupInActivateProcessor = new GroupInActivateProcessor(); - add(groupInActivateProcessor); - - groupTerminatingProcessor = new GroupTerminatingProcessor(); - add(groupTerminatingProcessor); - - groupTerminatedProcessor = new GroupTerminatedProcessor(); - add(groupTerminatedProcessor); - - applicationCreatedMessageProcessor = new ApplicationCreatedMessageProcessor(); - add(applicationCreatedMessageProcessor); - - applicationUndeployedMessageProcessor = new ApplicationUndeployedMessageProcessor(); - add(applicationUndeployedMessageProcessor); - - applicationActivatedMessageProcessor = new ApplicationActivatedMessageProcessor(); - add(applicationActivatedMessageProcessor); - - applicationInactivatedMessageProcessor = new ApplicationInactivatedMessageProcessor(); - add(applicationInactivatedMessageProcessor); - - applicationTerminatedMessageProcessor = new ApplicationTerminatedMessageProcessor(); - add(applicationTerminatedMessageProcessor); - - applicationTerminatingMessageProcessor = new ApplicationTerminatingMessageProcessor(); - add(applicationTerminatingMessageProcessor); - if (log.isDebugEnabled()) { log.debug("Topology message processor chain initialized X1"); } @@ -182,30 +137,7 @@ public void addEventListener(EventListener eventListener) { serviceRemovedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof MemberMaintenanceListener) { memberMaintenanceModeProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupActivatedEventListener) { - groupActivatedProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupCreatedEventListener) { - groupCreatedProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupInActivateEventListener) { - groupInActivateProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatedEventListener){ - groupTerminatedProcessor.addEventListener(eventListener); - } else if (eventListener instanceof GroupTerminatingEventListener){ - groupTerminatingProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationCreatedEventListener) { - applicationCreatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationUndeployedEventListener) { - applicationUndeployedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationActivatedEventListener) { - applicationActivatedMessageProcessor.addEventListener(eventListener); - } else if (eventListener instanceof ApplicationInActivateEventListener){ - applicationInactivatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatedEventListener){ - applicationTerminatedMessageProcessor.addEventListener(eventListener); - } else if(eventListener instanceof ApplicationTerminatingEventListener){ - applicationTerminatingMessageProcessor.addEventListener(eventListener); - } - else { + } else { throw new RuntimeException("Unknown event listener"); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java similarity index 88% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java index 9eda9e00e8..68d44b0296 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageDelegator.java @@ -16,27 +16,27 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.receiver.application.status; +package org.apache.stratos.messaging.message.receiver.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; -import org.apache.stratos.messaging.message.processor.application.status.AppStatusMessageProcessorChain; +import org.apache.stratos.messaging.message.processor.applications.ApplicationsMessageProcessorChain; import org.apache.stratos.messaging.util.Constants; import javax.jms.TextMessage; -public class ApplicationStatusEventMessageDelegator implements Runnable { - private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageDelegator.class); +public class ApplicationsEventMessageDelegator implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationsEventMessageDelegator.class); - private ApplicationStatusEventMessageQueue messageQueue; + private ApplicationsEventMessageQueue messageQueue; private MessageProcessorChain processorChain; private boolean terminated; - public ApplicationStatusEventMessageDelegator(ApplicationStatusEventMessageQueue messageQueue) { + public ApplicationsEventMessageDelegator(ApplicationsEventMessageQueue messageQueue) { this.messageQueue = messageQueue; - this.processorChain = new AppStatusMessageProcessorChain(); + this.processorChain = new ApplicationsMessageProcessorChain(); } public void addEventListener(EventListener eventListener) { @@ -99,7 +99,7 @@ private EventMessage jsonToEventMessage(String json) { String eventType = MessageParts[0].trim(); eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\"")); - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug(String.format("Extracted [event type] %s", eventType)); } @@ -107,13 +107,13 @@ private EventMessage jsonToEventMessage(String json) { String messageTag = MessageParts[1]; messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\"")); - if("message".equals(messageTag)){ + if ("message".equals(messageTag)) { message = MessageParts[2].trim(); //Remove trailing bracket twice to get the message message = message.substring(0, message.lastIndexOf("}")).trim(); message = message.substring(0, message.lastIndexOf("}")).trim(); - if(message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1){ - if(log.isDebugEnabled()) { + if (message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1) { + if (log.isDebugEnabled()) { log.debug(String.format("[Extracted message] %s ", message)); } event.setMessage(message); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java similarity index 86% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java index 93eeb542fc..936c1743a0 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.receiver.application.status; +package org.apache.stratos.messaging.message.receiver.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -26,12 +26,12 @@ import javax.jms.MessageListener; import javax.jms.TextMessage; -public class ApplicationStatusEventMessageListener implements MessageListener { - private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class); +public class ApplicationsEventMessageListener implements MessageListener { + private static final Log log = LogFactory.getLog(ApplicationsEventMessageListener.class); - private ApplicationStatusEventMessageQueue messageQueue; + private ApplicationsEventMessageQueue messageQueue; - public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue messageQueue) { + public ApplicationsEventMessageListener(ApplicationsEventMessageQueue messageQueue) { this.messageQueue = messageQueue; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java index ba455c9cbd..604513e992 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventMessageQueue.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageQueue.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.receiver.application.status; +package org.apache.stratos.messaging.message.receiver.applications; import javax.jms.TextMessage; import java.util.concurrent.LinkedBlockingQueue; -public class ApplicationStatusEventMessageQueue extends LinkedBlockingQueue { +public class ApplicationsEventMessageQueue extends LinkedBlockingQueue { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java similarity index 82% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java index 0b6cada6c6..b7577bd39d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/application/status/ApplicationStatusEventReceiver.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventReceiver.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.receiver.application.status; +package org.apache.stratos.messaging.message.receiver.applications; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -24,18 +24,18 @@ import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.util.Constants; -public class ApplicationStatusEventReceiver implements Runnable { - private static final Log log = LogFactory.getLog(ApplicationStatusEventReceiver.class); +public class ApplicationsEventReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationsEventReceiver.class); - private ApplicationStatusEventMessageDelegator messageDelegator; - private ApplicationStatusEventMessageListener messageListener; + private ApplicationsEventMessageDelegator messageDelegator; + private ApplicationsEventMessageListener messageListener; private TopicSubscriber topicSubscriber; private boolean terminated; - public ApplicationStatusEventReceiver() { - ApplicationStatusEventMessageQueue messageQueue = new ApplicationStatusEventMessageQueue(); - this.messageDelegator = new ApplicationStatusEventMessageDelegator(messageQueue); - this.messageListener = new ApplicationStatusEventMessageListener(messageQueue); + public ApplicationsEventReceiver() { + ApplicationsEventMessageQueue messageQueue = new ApplicationsEventMessageQueue(); + this.messageDelegator = new ApplicationsEventMessageDelegator(messageQueue); + this.messageListener = new ApplicationsEventMessageListener(messageQueue); } public void addEventListener(EventListener eventListener) { @@ -46,7 +46,7 @@ public void addEventListener(EventListener eventListener) { public void run() { try { // Start topic subscriber thread - topicSubscriber = new TopicSubscriber(Constants.APPLICATION_STATUS_TOPIC); + topicSubscriber = new TopicSubscriber(Constants.APPLICATIONS_TOPIC); topicSubscriber.setMessageListener(messageListener); Thread subscriberThread = new Thread(topicSubscriber); subscriberThread.start(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java new file mode 100644 index 0000000000..a2fed87ad7 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageDelegator.java @@ -0,0 +1,146 @@ +/* + * 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.messaging.message.receiver.cluster.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.message.processor.MessageProcessorChain; +import org.apache.stratos.messaging.message.processor.cluster.status.ClusterStatusMessageProcessorChain; +import org.apache.stratos.messaging.util.Constants; + +import javax.jms.TextMessage; + +public class ClusterStatusEventMessageDelegator implements Runnable { + private static final Log log = LogFactory.getLog(ClusterStatusEventMessageDelegator.class); + + private ClusterStatusEventMessageQueue messageQueue; + private MessageProcessorChain processorChain; + private boolean terminated; + + public ClusterStatusEventMessageDelegator(ClusterStatusEventMessageQueue messageQueue) { + this.messageQueue = messageQueue; + this.processorChain = new ClusterStatusMessageProcessorChain(); + } + + public void addEventListener(EventListener eventListener) { + processorChain.addEventListener(eventListener); + } + + @Override + public void run() { + try { + if (log.isInfoEnabled()) { + log.info("Application status event message delegator started"); + } + + while (!terminated) { + try { + TextMessage message = messageQueue.take(); + + // Retrieve the header + String type = message.getStringProperty(Constants.EVENT_CLASS_NAME); + + // Retrieve the actual message + String json = message.getText(); + + if (log.isDebugEnabled()) { + log.debug(String.format("Application status event message received from queue: %s", type)); + } + + // Delegate message to message processor chain + if (log.isDebugEnabled()) { + log.debug(String.format("Delegating application status event message: %s", type)); + } + processorChain.process(type, json, null); + } catch (Exception e) { + log.error("Failed to retrieve application status event message", e); + } + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Application status event message delegator failed", e); + } + } + } + + /** + * Terminate topology event message delegator thread. + */ + public void terminate() { + terminated = true; + } + + + private EventMessage jsonToEventMessage(String json) { + + EventMessage event = new EventMessage(); + String message; + + //split the message to 3 parts using ':' first is class name, second contains the text 'message' and the third contains + //message + String[] MessageParts = json.split(":", 3); + + String eventType = MessageParts[0].trim(); + eventType = eventType.substring(eventType.indexOf("\"") + 1, eventType.lastIndexOf("\"")); + if (log.isDebugEnabled()) { + log.debug(String.format("Extracted [event type] %s", eventType)); + } + + event.setEventName(eventType); + String messageTag = MessageParts[1]; + messageTag = messageTag.substring(messageTag.indexOf("\"") + 1, messageTag.lastIndexOf("\"")); + + if ("message".equals(messageTag)) { + message = MessageParts[2].trim(); + //Remove trailing bracket twice to get the message + message = message.substring(0, message.lastIndexOf("}")).trim(); + message = message.substring(0, message.lastIndexOf("}")).trim(); + if (message.indexOf('{') == 0 && message.indexOf('}') == message.length() - 1) { + if (log.isDebugEnabled()) { + log.debug(String.format("[Extracted message] %s ", message)); + } + event.setMessage(message); + return event; + } + } + return null; + } + + private class EventMessage { + private String eventName; + private String message; + + private String getEventName() { + return eventName; + } + + private void setEventName(String eventName) { + this.eventName = eventName; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java new file mode 100644 index 0000000000..12c7800208 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java @@ -0,0 +1,54 @@ +/* + * 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.messaging.message.receiver.cluster.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageListener; +import javax.jms.TextMessage; + +public class ClusterStatusEventMessageListener implements MessageListener { + private static final Log log = LogFactory.getLog(ClusterStatusEventMessageListener.class); + + private ClusterStatusEventMessageQueue messageQueue; + + public ClusterStatusEventMessageListener(ClusterStatusEventMessageQueue messageQueue) { + this.messageQueue = messageQueue; + } + + @Override + public void onMessage(Message message) { + if (message instanceof TextMessage) { + TextMessage receivedMessage = (TextMessage) message; + try { + if (log.isDebugEnabled()) { + log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText())); + } + // Add received message to the queue + messageQueue.add(receivedMessage); + + } catch (JMSException e) { + log.error(e.getMessage(), e); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java new file mode 100644 index 0000000000..96568009d9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageQueue.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.message.receiver.cluster.status; + + +import javax.jms.TextMessage; +import java.util.concurrent.LinkedBlockingQueue; + +public class ClusterStatusEventMessageQueue extends LinkedBlockingQueue { +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.java new file mode 100644 index 0000000000..72ccaed33e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventReceiver.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.messaging.message.receiver.cluster.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.broker.subscribe.TopicSubscriber; +import org.apache.stratos.messaging.listener.EventListener; +import org.apache.stratos.messaging.util.Constants; + +public class ClusterStatusEventReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ClusterStatusEventReceiver.class); + + private ClusterStatusEventMessageDelegator messageDelegator; + private ClusterStatusEventMessageListener messageListener; + private TopicSubscriber topicSubscriber; + private boolean terminated; + + public ClusterStatusEventReceiver() { + ClusterStatusEventMessageQueue messageQueue = new ClusterStatusEventMessageQueue(); + this.messageDelegator = new ClusterStatusEventMessageDelegator(messageQueue); + this.messageListener = new ClusterStatusEventMessageListener(messageQueue); + } + + public void addEventListener(EventListener eventListener) { + messageDelegator.addEventListener(eventListener); + } + + @Override + public void run() { + try { + // Start topic subscriber thread + topicSubscriber = new TopicSubscriber(Constants.CLUSTER_STATUS_TOPIC); + topicSubscriber.setMessageListener(messageListener); + Thread subscriberThread = new Thread(topicSubscriber); + subscriberThread.start(); + if (log.isDebugEnabled()) { + log.debug("Application status event message receiver thread started"); + } + + // Start Application status event message delegator thread + Thread receiverThread = new Thread(messageDelegator); + receiverThread.start(); + if (log.isDebugEnabled()) { + log.debug("Application status event message delegator thread started"); + } + + // Keep the thread live until terminated + while (!terminated) { + try { + Thread.sleep(1000); + } catch (InterruptedException ignore) { + } + } + } catch (Exception e) { + if (log.isErrorEnabled()) { + log.error("Application status failed", e); + } + } + } + + public void terminate() { + topicSubscriber.terminate(); + messageDelegator.terminate(); + terminated = true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index 33f2f22206..2d2d532858 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -24,7 +24,9 @@ public class Constants { public static final String HEALTH_STAT_TOPIC = "summarized-health-stats"; public static final String INSTANCE_STATUS_TOPIC = "instance-status"; public static final String INSTANCE_NOTIFIER_TOPIC = "instance-notifier"; - public static final String APPLICATION_STATUS_TOPIC = "application-status"; + public static final String APPLICATIONS_TOPIC = "applications"; + public static final String CLUSTER_STATUS_TOPIC = "applications"; + public static final String PING_TOPIC = "ping"; public static final String TENANT_TOPIC = "tenant"; public static final String TENANT_RANGE_ALL = "*"; From 18f16549c953f5355afd34c10882c2723e78d9de Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 13:34:23 +0530 Subject: [PATCH 332/436] adding Application locks, Application Holder and persisting in Autoscaler --- .../applications/ApplicationHolder.java | 113 ++++++++++++++++++ .../autoscaler/registry/RegistryManager.java | 42 +++++++ .../autoscaler/util/AutoScalerConstants.java | 2 +- .../autoscaler/util/AutoscalerUtil.java | 49 +++++--- .../domain/applications/Applications.java | 46 +++++++ .../applications/locking/ApplicationLock.java | 59 +++++++++ .../locking/ApplicationLockHierarchy.java | 88 ++++++++++++++ 7 files changed, 382 insertions(+), 17 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java new file mode 100644 index 0000000000..e147d1bfa5 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java @@ -0,0 +1,113 @@ +/* + * 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.autoscaler.applications; + +import com.google.gson.Gson; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.util.AutoscalerUtil; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; + +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class ApplicationHolder { + + private static final Log log = LogFactory.getLog(ApplicationHolder.class); + + private static volatile ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true); + private static volatile ReentrantReadWriteLock.ReadLock readLock = lock.readLock(); + private static volatile ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock(); + private static volatile Applications applications; + + private ApplicationHolder () {} + + public static void acquireReadLock() { + if(log.isDebugEnabled()) { + log.debug("Read lock acquired"); + } + readLock.lock(); + } + + public static void releaseReadLock() { + if(log.isDebugEnabled()) { + log.debug("Read lock released"); + } + readLock.unlock(); + } + + public static void acquireWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired"); + } + writeLock.lock(); + } + + public static void releaseWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock released"); + } + writeLock.unlock(); + } + + public static Applications getApplications () { + + if (applications == null) { + synchronized (ApplicationHolder.class) { + if (applications == null) { + // retrieve from registry + applications = AutoscalerUtil.getApplications(); + if (log.isDebugEnabled()) { + log.debug("Trying to retrieve Applications from registry"); + } + if (applications == null) { + if (log.isDebugEnabled()) { + log.debug("No applications found in Registry"); + } + // create a new Applications object + applications = new Applications(); + } + } + } + } + + return applications; + } + + public static void persistApplication (Application application) { + + synchronized (ApplicationHolder.class) { + if (log.isDebugEnabled()) { + log.debug("Updating topology"); + } + applications.addApplication(application); + AutoscalerUtil.persistApplication(application); + if (log.isDebugEnabled()) { + log.debug(String.format("Topology updated: %s", toJson(applications))); + } + } + + } + + private static String toJson(Object object) { + Gson gson = new Gson(); + return gson.toJson(object); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 7b3413e652..25caf0ebfe 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -32,6 +32,8 @@ import org.apache.stratos.autoscaler.util.Serializer; import org.apache.stratos.autoscaler.util.ServiceReferenceHolder; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Resource; import org.wso2.carbon.registry.core.exceptions.RegistryException; @@ -139,6 +141,46 @@ public void persistDeploymentPolicy(DeploymentPolicy deploymentPolicy) { log.debug(deploymentPolicy.toString()); } } + + public void persistApplication (Application application) { + + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + + "/" + application.getUniqueIdentifier(); + persist(application, resourcePath); + if(log.isDebugEnabled()) { + log.debug("Application [ " + application.getUniqueIdentifier() + + " ] persisted successfully in the Autoscaler Registry"); + } + } + + public String [] getApplicationResourcePaths () { + Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + + AutoScalerConstants.APPLICATIONS_RESOURCE); + + if (obj != null) { + if (obj instanceof String []) { + return (String []) obj; + } else { + log.warn("Expected object type not found for Applications in Registry"); + return null; + } + } + return null; + } + + public Application getApplication (String applicationResourcePath) { + Object obj = retrieve(applicationResourcePath); + + if (obj != null) { + if (obj instanceof Application) { + return (Application) obj; + } else { + log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry"); + return null; + } + } + return null; + } private Object retrieve(String resourcePath) { try { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java index 03cf861a29..b30e0e64c5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java @@ -38,7 +38,7 @@ public final class AutoScalerConstants { public static final String NETWORK_PARTITION_LB_HOLDER_RESOURCE = "/network-partitions"; public static final String AS_POLICY_RESOURCE = "/policies/autoscalingPolicies"; public static final String DEPLOYMENT_POLICY_RESOURCE = "/policies/deploymentPolicies"; - + public static final String APPLICATIONS_RESOURCE = "/applications"; /** * Configs diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 59dda9f24a..4b95118c58 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -22,24 +22,12 @@ import org.apache.axiom.om.OMElement; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.MemberStatsContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; -import org.apache.stratos.autoscaler.monitor.cluster.LbClusterMonitor; -import org.apache.stratos.autoscaler.partition.PartitionGroup; -import org.apache.stratos.autoscaler.partition.PartitionManager; -import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; + import javax.xml.namespace.QName; import java.util.*; @@ -55,6 +43,35 @@ private AutoscalerUtil() { } + public static Applications getApplications () { + + Applications applications; + String [] appResourcePaths = RegistryManager.getInstance().getApplicationResourcePaths(); + if (appResourcePaths != null) { + applications = new Applications(); + for (String appResourcePath : appResourcePaths) { + applications.addApplication(getApplicationFromPath(appResourcePath)); + } + + return applications; + } + + return null; + } + + public static Application getApplication (String appId) { + return getApplicationFromPath(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + + "/" + appId); + } + + public static void persistApplication (Application application) { + RegistryManager.getInstance().persistApplication(application); + } + + private static Application getApplicationFromPath (String appResourcePath) { + return RegistryManager.getInstance().getApplication(appResourcePath); + } + /*public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { // FIXME fix the following code to correctly update // AutoscalerContext context = AutoscalerContext.getInstance(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java new file mode 100644 index 0000000000..9455a4c118 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java @@ -0,0 +1,46 @@ +/* + * 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.messaging.domain.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +public class Applications implements Serializable { + + private static Log log = LogFactory.getLog(Applications.class); + + private Map applicationMap; + + public Applications () { + this.applicationMap = new HashMap(); + } + + public void addApplication (Application application) { + this.applicationMap.put(application.getUniqueIdentifier(), application); + } + + public Application getApplication (String appId) { + return this.applicationMap.get(appId); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.java new file mode 100644 index 0000000000..5d01e362ef --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLock.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.messaging.domain.applications.locking; + +import java.util.concurrent.locks.ReentrantReadWriteLock; + +public class ApplicationLock { + + private final ReentrantReadWriteLock lock; + + public ApplicationLock () { + lock = new ReentrantReadWriteLock(true); + } + + /** + * acquires write lock + */ + public void acquireWriteLock() { + lock.writeLock().lock(); + } + + /** + * releases write lock + */ + public void releaseWritelock() { + lock.writeLock().unlock(); + } + + /** + * acquires read lock + */ + public void acquireReadLock() { + lock.readLock().lock(); + } + + /** + * releases read lock + */ + public void releaseReadLock() { + lock.readLock().unlock(); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java new file mode 100644 index 0000000000..71bfe031ae --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java @@ -0,0 +1,88 @@ +/* + * 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.messaging.domain.applications.locking; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.HashMap; +import java.util.Map; + +public class ApplicationLockHierarchy { + + private static final Log log = LogFactory.getLog(ApplicationLockHierarchy.class); + + // lock for Applications + private final ApplicationLock applicationLock; + + // key = Application.id + private final Map appIdToApplicationLockMap; + + private static volatile ApplicationLockHierarchy applicationLockHierarchy; + + private ApplicationLockHierarchy () { + this.applicationLock = new ApplicationLock(); + this.appIdToApplicationLockMap = new HashMap(); + } + + public static ApplicationLockHierarchy getInstance () { + + if (applicationLockHierarchy == null) { + synchronized (ApplicationLockHierarchy.class) { + if (applicationLockHierarchy == null) { + applicationLockHierarchy = new ApplicationLockHierarchy(); + } + } + } + + return applicationLockHierarchy; + } + + public void addApplicationLock (String appId, final ApplicationLock appLock) { + + if (!appIdToApplicationLockMap.containsKey(appId)) { + synchronized (appIdToApplicationLockMap) { + if (!appIdToApplicationLockMap.containsKey(appId)) { + appIdToApplicationLockMap.put(appId, appLock); + log.info("Added lock for Application " + appId); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("Topology Lock for Application " + appId + " already exists"); + } + } + } + + public ApplicationLock getLock (String appId) { + return appIdToApplicationLockMap.get(appId); + } + + public void removeLock (String appId) { + if (appIdToApplicationLockMap.remove(appId) != null) { + log.info("Removed lock for Application " + appId); + } else { + if (log.isDebugEnabled()) { + log.debug("Lock already removed for Application " + appId); + } + } + } + +} From 7f05298c3680ad1eb72e19cde334fc2df8217514 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 14:33:56 +0530 Subject: [PATCH 333/436] adding app id to Group --- .../org.apache.stratos.autoscaler/pom.xml | 5 +++ .../ApplicationSynchronizerTask.java | 43 +++++++++++++++++++ .../parser/DefaultApplicationParser.java | 2 +- .../messaging/domain/applications/Group.java | 9 +++- 4 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml index 35d03da13e..5ba1ebabcc 100644 --- a/components/org.apache.stratos.autoscaler/pom.xml +++ b/components/org.apache.stratos.autoscaler/pom.xml @@ -170,6 +170,11 @@ ${project.version} provided + + org.wso2.carbon + org.wso2.carbon.ntask.core + 4.2.0 + diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java new file mode 100644 index 0000000000..571e7a8957 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java @@ -0,0 +1,43 @@ +/* + * 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.autoscaler.applications; + +import org.wso2.carbon.ntask.core.Task; + +import java.util.Map; + +public class ApplicationSynchronizerTask implements Task { + + @Override + public void setProperties(Map stringStringMap) { + + } + + @Override + public void init() { + + } + + @Override + public void execute() { + + + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 000a06afd0..c75e883db4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -416,7 +416,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g groupCtxt.getAlias() + " is not found in the all Group Definitions collection"); } - Group group = new Group(groupCtxt.getName(), groupCtxt.getAlias()); + Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias()); group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy()); group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java index 1f4d3231e3..da52e9934a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Group.java @@ -39,11 +39,14 @@ public class Group extends ParentComponent implements LifeCycleStateTransitionBe private String deploymentPolicy; // Group level autoscaling policy private String autoscalingPolicy; + // application id + private String applicationId; // Life cycle state manager protected LifeCycleStateManager groupStateManager; - public Group (String name, String alias) { + public Group (String applicationId, String name, String alias) { super(); + this.applicationId = applicationId; this.name = name; this.alias = alias; this.groupStateManager = new LifeCycleStateManager(GroupStatus.Created, alias); @@ -109,4 +112,8 @@ public boolean equals(Object other) { public int hashCode () { return name.hashCode() + alias.hashCode(); } + + public String getApplicationId() { + return applicationId; + } } From 0f7d7b0d0db9f643fd232f0ef2689cf62553dee7 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 14:53:49 +0530 Subject: [PATCH 334/436] adding complete applications --- .../domain/applications/Applications.java | 22 ++- .../locking/ApplicationLockHierarchy.java | 3 + .../applications/ApplicationCreatedEvent.java | 11 +- .../CompleteApplicationsEvent.java | 44 ++++++ ...=> ClusterStatusClusterResettedEvent.java} | 4 +- .../event/topology/ClusterCreatedEvent.java | 26 +--- .../event/topology/ClusterResetEvent.java | 56 +++++++ .../CompleteApplicationsEventListener.java | 26 ++++ ...usterStatusClusterResetEventListener.java} | 2 +- .../ApplicationCreatedMessageProcessor.java | 32 +--- .../CompleteApplicationsMessageProcessor.java | 111 +++++++++++++ .../updater/ApplicationsUpdater.java | 140 +++++++++++++++++ ...erStatusClusterResetMessageProcessor.java} | 12 +- .../ClusterStatusMessageProcessorChain.java | 6 +- .../ClusterCreatedMessageProcessor.java | 35 ++--- .../ClusterResetMessageProcessor.java | 146 ++++++++++++++++++ 16 files changed, 596 insertions(+), 80 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/{ClusterStatusClusterCreatedEvent.java => ClusterStatusClusterResettedEvent.java} (90%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/{ClusterStatusClusterCreatedEventListener.java => ClusterStatusClusterResetEventListener.java} (91%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/{ClusterStatusClusterCreatedMessageProcessor.java => ClusterStatusClusterResetMessageProcessor.java} (83%) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java index 9455a4c118..9e8cf3ea33 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java @@ -32,15 +32,33 @@ public class Applications implements Serializable { private Map applicationMap; + private boolean initialized; + public Applications () { this.applicationMap = new HashMap(); } public void addApplication (Application application) { - this.applicationMap.put(application.getUniqueIdentifier(), application); + this.getApplications().put(application.getUniqueIdentifier(), application); } public Application getApplication (String appId) { - return this.applicationMap.get(appId); + return this.getApplications().get(appId); + } + + public boolean isInitialized() { + return initialized; + } + + public void setInitialized(boolean initialized) { + this.initialized = initialized; + } + + public boolean applicationExists(String appId) { + return this.getApplications().containsKey(appId); + } + + public Map getApplications() { + return applicationMap; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java index 71bfe031ae..cc31892165 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java @@ -85,4 +85,7 @@ public void removeLock (String appId) { } } + public ApplicationLock getApplicationLock() { + return applicationLock; + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java index dfb90f296e..26ba7f26b7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/ApplicationCreatedEvent.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.messaging.event.applications; +import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.event.Event; import java.io.Serializable; @@ -28,13 +29,13 @@ public class ApplicationCreatedEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; - private String appId; + private Application application; - public ApplicationCreatedEvent(String appId) { - this.appId = appId; + public ApplicationCreatedEvent(Application application) { + this.application = application; } - public String getAppId() { - return appId; + public Application getApplication() { + return application; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java new file mode 100644 index 0000000000..25035ab08b --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/CompleteApplicationsEvent.java @@ -0,0 +1,44 @@ +/* + * 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.messaging.event.applications; + +import org.apache.stratos.messaging.domain.applications.Applications; +import org.apache.stratos.messaging.event.topology.TopologyEvent; + +import java.io.Serializable; + +/** + * This event is fired periodically with the complete topology. It would be a + * starting point for subscribers to initialize the current state of the topology + * before receiving other topology events. + */ +public class CompleteApplicationsEvent extends TopologyEvent implements Serializable { + private static final long serialVersionUID = 8580862188444892004L; + + private final Applications applications; + + public CompleteApplicationsEvent(Applications applications) { + this.applications = applications; + } + + public Applications getApplications() { + return applications; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java index d28cca1169..68c8e7fadf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java @@ -25,14 +25,14 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class ClusterStatusClusterCreatedEvent extends Event { +public class ClusterStatusClusterResettedEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterResettedEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java index 70452ab6c4..4c06f3bb71 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterCreatedEvent.java @@ -28,31 +28,19 @@ public class ClusterCreatedEvent extends TopologyEvent implements Serializable { private static final long serialVersionUID = 2080623816272047762L; - private final String appId; - private final String serviceName; - private final String clusterId; + private final Cluster cluster; - - public ClusterCreatedEvent(String appId, String serviceName, String clusterId) { - this.appId = appId; - this.serviceName = serviceName; - this.clusterId = clusterId; + public ClusterCreatedEvent(Cluster cluster) { + this.cluster = cluster; } - public String getServiceName() { - return serviceName; - } - @Override public String toString() { - return "ClusterCreatedEvent [serviceName=" + serviceName + ", application=" + appId + "]"; - } - - public String getClusterId() { - return clusterId; + return "ClusterCreatedEvent [serviceName=" + cluster.getServiceName() + ", " + + "application=" + cluster.getAppId() + " , cluster= " + cluster.getClusterId() + " ]"; } - public String getAppId() { - return appId; + public Cluster getCluster() { + return cluster; } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java new file mode 100644 index 0000000000..d4d6622331 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ClusterResetEvent.java @@ -0,0 +1,56 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.event.Event; + +/** + * Cluster activated event will be sent by Autoscaler + */ +public class ClusterResetEvent extends Event { + + private final String serviceName; + private final String clusterId; + private String appId; + + public ClusterResetEvent(String appId, String serviceName, String clusterId) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + } + + public String getServiceName() { + return serviceName; + } + + @Override + public String toString() { + return "ClusterActivatedEvent [serviceName=" + serviceName + ", clusterStatus=" + + "]"; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java new file mode 100644 index 0000000000..cd1bb24471 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/CompleteApplicationsEventListener.java @@ -0,0 +1,26 @@ +/* + * 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.messaging.listener.applications; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class CompleteApplicationsEventListener extends EventListener { + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java index 6ca547686a..375ae3247e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterResetEventListener.java @@ -20,5 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{ +public abstract class ClusterStatusClusterResetEventListener extends EventListener{ } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java index 92d61bad8b..db8e3c85a9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java @@ -21,10 +21,10 @@ 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.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -44,10 +44,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationCreatedEvent.class.getName().equals(type)) { - if (!topology.isInitialized()) { + if (!applications.isInitialized()) { return false; } @@ -58,37 +58,24 @@ public boolean process(String type, String message, Object object) { } TopologyUpdater.acquireWriteLockForApplications(); - // since the Clusters will also get modified, acquire write locks for each Service Type - Set clusterDataHolders = event.getApplication().getClusterDataRecursively(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); - } - } - try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterData : clusterDataHolders) { - TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); - } - } TopologyUpdater.releaseWriteLockForApplications(); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { + private boolean doProcess(ApplicationCreatedEvent event, Applications topology) { // check if required properties are available if (event.getApplication() == null) { @@ -109,9 +96,6 @@ private boolean doProcess (ApplicationCreatedEvent event,Topology topology) { } else { // add application and the clusters to Topology - for(Cluster cluster: event.getClusterList()) { - topology.getService(cluster.getServiceName()).addCluster(cluster); - } topology.addApplication(event.getApplication()); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java new file mode 100644 index 0000000000..53c469b265 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java @@ -0,0 +1,111 @@ +/* + * 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.messaging.message.processor.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Member; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; +import org.apache.stratos.messaging.event.applications.CompleteApplicationsEvent; +import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class CompleteApplicationsMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(CompleteApplicationsMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Applications applications = (Applications) object; + + if (CompleteApplicationsEvent.class.getName().equals(type)) { + // Parse complete message and build event + CompleteApplicationsEvent event = (CompleteApplicationsEvent) Util. + jsonToObject(message, CompleteApplicationsEvent.class); + + if (!applications.isInitialized()) { + ApplicationsUpdater.acquireWriteLock(); + + try { + doProcess(event, applications); + + } finally { + ApplicationsUpdater.releaseWriteLock(); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, applications); + } + return false; + } + } + + private void doProcess (CompleteApplicationsEvent event, Applications applications) { + // add existing Applications to Topology + Collection applicationsList = event.getApplications().getApplications().values(); + if (applicationsList != null && !applicationsList.isEmpty()) { + for (Application application : applicationsList) { + applications.addApplication(application); + if (log.isDebugEnabled()) { + log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology"); + } + } + } else { + if (log.isDebugEnabled()) { + log.debug("No Application information found in Complete Topology event"); + } + } + + if (log.isInfoEnabled()) { + log.info("Topology initialized"); + } + + // Set topology initialized + applications.setInitialized(true); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java new file mode 100644 index 0000000000..bbbfbf5c0a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java @@ -0,0 +1,140 @@ +/* + * 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.messaging.message.processor.applications.updater; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; +import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; + +/** + * Used to lock the Topology for writes by messaging component + * + * Acquire a write lock: + * + * From root level, acquire read lock, and acquire a write lock only for the + * relevant sub tree. + * + * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - + * acquiring: + * public static void acquireWriteLockForCluster (String serviceName, String clusterId) + * + * releasing: + * public static void releaseWriteLockForCluster (String serviceName, String clusterId) + * + * Example 2: Acquiring write lock to add a new Cluster object - + * acquiring: + * public static void acquireWriteLockForService (String serviceName) + * + * releasing: + * public static void releaseWriteLockForService (String serviceName) + * + * Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service) + * acquire: + * public static void acquireWriteLockForServices() + * + * release: + * public static void releaseWriteLockForServices() + */ + +public class ApplicationsUpdater { + + private static final Log log = LogFactory.getLog(ApplicationsUpdater.class); + + private static volatile ApplicationLockHierarchy applicationLockHierarchy = + ApplicationLockHierarchy.getInstance(); + + // Top level locks - should be used to lock the entire Topology + + /** + * Acquires write lock for the Complete Topology + */ + public static void acquireWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Topology"); + } + applicationLockHierarchy.getApplicationLock().acquireWriteLock(); + } + + /** + * Releases write lock for the Complete Topology + */ + public static void releaseWriteLock() { + if(log.isDebugEnabled()) { + log.debug("Write lock released for Topology"); + } + applicationLockHierarchy.getApplicationLock().releaseWritelock(); + } + + /** + * Acquires write lock for the Application + * + * @param appId Application id + */ + public static void acquireWriteLockForApplication (String appId) { + + // acquire read lock for all Applications + TopologyManager.acquireReadLockForApplications(); + + ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId); + if (applicationLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // now, lock Application + applicationLock.acquireWriteLock(); + if(log.isDebugEnabled()) { + log.debug("Write lock acquired for Application " + appId); + } + } + } + + /** + * Releases write lock for the Application + * + * @param appId Application id + */ + public static void releaseWriteLockForApplication (String appId) { + + ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId); + if (applicationLock == null) { + handleLockNotFound("Topology lock not found for Application " + appId); + + } else { + // release App lock + applicationLock.releaseWritelock(); + if(log.isDebugEnabled()) { + log.debug("Write lock released for Application " + appId); + } + } + + // release read lock for all Applications + TopologyManager.releaseReadLockForApplications(); + } + + private static void handleLockNotFound (String errorMsg) { + log.warn(errorMsg); + //throw new RuntimeException(errorMsg); + } + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java similarity index 83% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java index 9b4780b76c..b5bf30112e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java @@ -20,13 +20,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; -public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class); +public class ClusterStatusClusterResetMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterResetMessageProcessor.class); private MessageProcessor nextProcessor; @Override @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) { + if (ClusterStatusClusterResettedEvent.class.getName().equals(type)) { // Parse complete message and build event - ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util. - jsonToObject(message, ClusterStatusClusterCreatedEvent.class); + ClusterStatusClusterResettedEvent event = (ClusterStatusClusterResettedEvent) Util. + jsonToObject(message, ClusterStatusClusterResettedEvent.class); if(log.isDebugEnabled()) { log.debug("Received AppStatusClusterCreatedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java index 29556ecbcf..42092bcc61 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java @@ -32,13 +32,13 @@ public class ClusterStatusMessageProcessorChain extends MessageProcessorChain { private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; - private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor; + private ClusterStatusClusterResetMessageProcessor clusterCreatedMessageProcessor; private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor; private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; @Override protected void initialize() { - clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor(); + clusterCreatedMessageProcessor = new ClusterStatusClusterResetMessageProcessor(); add(clusterCreatedMessageProcessor); clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor(); @@ -60,7 +60,7 @@ protected void initialize() { @Override public void addEventListener(EventListener eventListener) { - if(eventListener instanceof ClusterStatusClusterCreatedEventListener) { + if(eventListener instanceof ClusterStatusClusterResetEventListener) { clusterCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) { clusterInactivateMessageProcessor.addEventListener(eventListener); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java index b8cd80f796..0ff303c99d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterCreatedMessageProcessor.java @@ -50,13 +50,13 @@ public boolean process(String type, String message, Object object) { // Parse complete message and build event ClusterCreatedEvent event = (ClusterCreatedEvent) Util.jsonToObject(message, ClusterCreatedEvent.class); - - TopologyUpdater.acquireWriteLockForService(event.getServiceName()); + String serviceName = event.getCluster().getServiceName(); + TopologyUpdater.acquireWriteLockForService(serviceName); try { return doProcess(event, topology); } finally { - TopologyUpdater.releaseWriteLockForService(event.getServiceName()); + TopologyUpdater.releaseWriteLockForService(serviceName); } } else { @@ -70,13 +70,15 @@ public boolean process(String type, String message, Object object) { } private boolean doProcess (ClusterCreatedEvent event,Topology topology) { - + Cluster cluster = event.getCluster(); + String serviceName = cluster.getServiceName(); + String clusterId = cluster.getClusterId(); // Apply service filter if (TopologyServiceFilter.getInstance().isActive()) { - if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(serviceName)) { // Service is excluded, do not update topology or fire event if (log.isDebugEnabled()) { - log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + log.debug(String.format("Service is excluded: [service] %s", serviceName)); } return false; } @@ -84,10 +86,10 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { // Apply cluster filter if (TopologyClusterFilter.getInstance().isActive()) { - if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(clusterId)) { // Cluster is excluded, do not update topology or fire event if (log.isDebugEnabled()) { - log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + log.debug(String.format("Cluster is excluded: [cluster] %s", clusterId)); } return false; } @@ -105,27 +107,24 @@ private boolean doProcess (ClusterCreatedEvent event,Topology topology) { throw new RuntimeException("Host name/s not found in cluster created event"); }*/ // Validate event against the existing topology - Service service = topology.getService(event.getServiceName()); + Service service = topology.getService(serviceName); if (service == null) { if (log.isWarnEnabled()) { log.warn(String.format("Service does not exist: [service] %s", - event.getServiceName())); + serviceName)); } return false; } - if (service.clusterExists(event.getClusterId())) { + if (service.clusterExists(clusterId)) { if (log.isWarnEnabled()) { - log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(), - event.getClusterId())); + log.warn(String.format("Cluster already exists in service: [service] %s " + + "[cluster] %s",serviceName , + clusterId)); } } else { // Apply changes to the topology - Cluster cluster = service.getCluster(event.getClusterId()); - if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { - log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " + - "for cluster " + cluster.getClusterId()); - } + service.addCluster(cluster); cluster.setStatus(ClusterStatus.Created); if (log.isInfoEnabled()) { log.info(String.format("Cluster created: %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java new file mode 100644 index 0000000000..3cfb2dcdb5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ClusterResetMessageProcessor.java @@ -0,0 +1,146 @@ +/* + * 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.messaging.message.processor.topology; + +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.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; +import org.apache.stratos.messaging.event.topology.ClusterResetEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.util.Util; + +public class ClusterResetMessageProcessor extends MessageProcessor { + + private static final Log log = LogFactory.getLog(ClusterResetMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + + Topology topology = (Topology) object; + if (ClusterResetEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + return false; + } + + // Parse complete message and build event + ClusterResetEvent event = (ClusterResetEvent) Util. + jsonToObject(message, ClusterResetEvent.class); + + TopologyUpdater.acquireWriteLockForService(event.getServiceName()); + try { + return doProcess(event, topology); + + } finally { + TopologyUpdater.releaseWriteLockForService(event.getServiceName()); + } + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ClusterResetEvent event,Topology topology) { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(event.getServiceName())) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", event.getServiceName())); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(event.getClusterId())) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", event.getClusterId())); + } + return false; + } + } + + // Validate event properties + /*Cluster cluster = event.getCluster(); + + if(cluster == null) { + String msg = "Cluster object of cluster created event is null."; + log.error(msg); + throw new RuntimeException(msg); + } + if (cluster.getHostNames().isEmpty()) { + throw new RuntimeException("Host name/s not found in cluster created event"); + }*/ + // Validate event against the existing topology + Service service = topology.getService(event.getServiceName()); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + event.getServiceName())); + } + return false; + } + if (service.clusterExists(event.getClusterId())) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster already exists in service: [service] %s [cluster] %s", event.getServiceName(), + event.getClusterId())); + } + } else { + + // Apply changes to the topology + Cluster cluster = service.getCluster(event.getClusterId()); + if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { + log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Created + " " + + "for cluster " + cluster.getClusterId()); + } + cluster.setStatus(ClusterStatus.Created); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster reset as Created: %s", + cluster.toString())); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} From 696bc0d24d25bf70a0bbcf8c1303fab7ad7e66d8 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 14:54:25 +0530 Subject: [PATCH 335/436] adding complete applications support --- .../grouping/topic/ClusterStatusEventPublisher.java | 4 ++-- .../status/receiver/ApplicationStatusTopicReceiver.java | 6 ++---- .../stratos/cloud/controller/topology/TopologyBuilder.java | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java index 2a05b2e226..9a43418544 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java @@ -48,8 +48,8 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str log.info("Publishing Cluster created event for [application]: " + appId + " [cluster]: " + clusterId); } - ClusterStatusClusterCreatedEvent clusterCreatedEvent = - new ClusterStatusClusterCreatedEvent(appId, serviceName, clusterId); + ClusterStatusClusterResettedEvent clusterCreatedEvent = + new ClusterStatusClusterResettedEvent(appId, serviceName, clusterId); publishEvent(clusterCreatedEvent); } else { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index fe97f99be2..d75039d592 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -22,9 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.topology.TopologyBuilder; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.applications.*; import org.apache.stratos.messaging.event.cluster.status.*; -import org.apache.stratos.messaging.listener.applications.*; import org.apache.stratos.messaging.listener.cluster.status.*; import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver; @@ -66,10 +64,10 @@ public void run() { private void addEventListeners() { // Listen to topology events that affect clusters - statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() { + statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event); + TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 294102765f..dcbeb4861f 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -125,7 +125,7 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterCreated (ClusterStatusClusterCreatedEvent event) { + public static void handleClusterCreated (ClusterStatusClusterResettedEvent event) { TopologyManager.acquireWriteLock(); From 4de85b55bcce498cffcf3aa89a2d01c9215783d6 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 14:59:14 +0530 Subject: [PATCH 336/436] adding cluster reset processor support --- .../AutoscalerTopologyEventReceiver.java | 16 +++++++++++-- .../topology/ClusterResetEventListener.java | 24 +++++++++++++++++++ .../TopologyMessageProcessorChain.java | 6 +++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index aacc31c47e..467825003e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -168,13 +168,13 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { + topologyEventReceiver.addEventListener(new ClusterResetEventListener() { @Override protected void onEvent(Event event) { log.info("[ClusterCreatedEvent] Received: " + event.getClass()); - ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; + ClusterResetEvent clusterCreatedEvent = (ClusterResetEvent) event; String clusterId = clusterCreatedEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); @@ -186,6 +186,18 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ClusterCreatedEvent] Received: " + event.getClass()); + + ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; + //TODO notify the monitor about cluster creation + + } + }); + topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java new file mode 100644 index 0000000000..15165901ca --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ClusterResetEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterResetEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index 048e9a3416..f5ada8959b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -36,6 +36,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private ServiceCreatedMessageProcessor serviceCreatedMessageProcessor; private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor; private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor; + private ClusterResetMessageProcessor clusterResetMessageProcessor; private ClusterActivatedProcessor clusterActivatedProcessor; private ClusterInActivateProcessor clusterInActivateProcessor; private ClusterRemovedMessageProcessor clusterRemovedMessageProcessor; @@ -75,6 +76,9 @@ public void initialize() { clusterTerminatedProcessor = new ClusterTerminatedProcessor(); add(clusterTerminatedProcessor); + clusterResetMessageProcessor = new ClusterResetMessageProcessor(); + add(clusterResetMessageProcessor); + clusterTerminatingProcessor = new ClusterTerminatingProcessor(); add(clusterTerminatingProcessor); @@ -117,6 +121,8 @@ public void addEventListener(EventListener eventListener) { clusterRemovedMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ClusterTerminatedEventListener){ clusterTerminatedProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ClusterResetEventListener){ + clusterResetMessageProcessor.addEventListener(eventListener); } else if(eventListener instanceof ClusterTerminatingEventListener){ clusterTerminatingProcessor.addEventListener(eventListener); }else if (eventListener instanceof InstanceSpawnedEventListener) { From 686d0e063be8926447a7eef7e636622c2be55863 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 15:55:14 +0530 Subject: [PATCH 337/436] adding application builder --- .../dependency/DependencyBuilder.java | 6 +- .../dependency/DependencyTree.java | 4 +- .../context/ApplicationContext.java | 2 +- .../context/ApplicationContextFactory.java | 4 +- .../dependency/context/ClusterContext.java | 2 +- .../dependency/context/GroupContext.java | 2 +- .../topic/ApplicationBuilder.java | 478 ++++++++++++++++++ .../topic/ApplicationsEventPublisher.java | 4 +- .../AutoscalerTopologyEventReceiver.java | 4 +- .../monitor/ApplicationMonitorFactory.java | 6 +- .../monitor/ParentComponentMonitor.java | 8 +- .../monitor/cluster/ClusterMonitor.java | 1 - .../monitor/group/GroupMonitor.java | 5 +- .../status/checker/StatusChecker.java | 78 ++- .../impl/CloudControllerServiceImpl.java | 6 +- .../controller/topology/TopologyBuilder.java | 421 +-------------- 16 files changed, 554 insertions(+), 477 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/DependencyBuilder.java (96%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/DependencyTree.java (98%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/context/ApplicationContext.java (97%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/context/ApplicationContextFactory.java (96%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/context/ClusterContext.java (94%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/dependency/context/GroupContext.java (93%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping => applications}/topic/ApplicationsEventPublisher.java (98%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java similarity index 96% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java index bf1233f455..48c22fd56e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyBuilder.java @@ -16,14 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency; +package org.apache.stratos.autoscaler.applications.dependency; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContextFactory; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContextFactory; import org.apache.stratos.messaging.domain.applications.*; import java.util.Set; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java similarity index 98% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java index 05769a6aca..0cb9aa4c40 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/DependencyTree.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/DependencyTree.java @@ -16,11 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency; +package org.apache.stratos.autoscaler.applications.dependency; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; import java.util.ArrayList; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java similarity index 97% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java index 3197fb99bb..45d154452d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContext.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency.context; +package org.apache.stratos.autoscaler.applications.dependency.context; import org.apache.stratos.messaging.domain.topology.ClusterStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java similarity index 96% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java index 3ea4cd54a7..b4d7740c51 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ApplicationContextFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ApplicationContextFactory.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency.context; +package org.apache.stratos.autoscaler.applications.dependency.context; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; -import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; +import org.apache.stratos.autoscaler.applications.dependency.DependencyTree; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.applications.ParentComponent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java similarity index 94% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java index d11389d3bf..6de38d4bc4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/ClusterContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/ClusterContext.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency.context; +package org.apache.stratos.autoscaler.applications.dependency.context; /** * ClusterContext to keep cluster level context information diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java similarity index 93% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java index 408272aec2..3f546c5876 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/dependency/context/GroupContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/dependency/context/GroupContext.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.dependency.context; +package org.apache.stratos.autoscaler.applications.dependency.context; public class GroupContext extends ApplicationContext { public GroupContext(String id, boolean killDependent) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java new file mode 100644 index 0000000000..5aa05a2a09 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -0,0 +1,478 @@ +/* + * 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.autoscaler.applications.topic; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.ApplicationHolder; +import org.apache.stratos.messaging.domain.applications.*; +import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; +import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; +import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; +import org.apache.stratos.messaging.event.topology.*; + +import java.util.Collection; +import java.util.Set; + +/** + * This will build the application. + */ +public class ApplicationBuilder { + private static final Log log = LogFactory.getLog(ApplicationBuilder.class); + + + /*public static synchronized void handleApplicationDeployed(Application application, + Set applicationClusterContexts, + Set metaDataHolders) { + + + Applications applications = Appcation.getApplications(); + try { + ApplicationHolder.acquireWriteLock(); + + if (applications.applicationExists(application.getUniqueIdentifier())) { + log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); + return; + } + List clusters = new ArrayList(); + for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { + Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), + applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), + applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); + //cluster.setStatus(Status.Created); + cluster.addHostName(applicationClusterContext.getHostName()); + cluster.setTenantRange(applicationClusterContext.getTenantRange()); + clusters.add(cluster); + + Service service = applications.getService(applicationClusterContext.getCartridgeType()); + if (service != null) { + service.addCluster(cluster); + log.info("Added Cluster " + cluster.toString() + " to Applications for Application with id: " + application.getUniqueIdentifier()); + } else { + log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); + return; + } + } + + // add to Applications and update + applications.addApplication(application); + ApplicationHolder.persistApplication(applications); + + log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Applications successfully"); + org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent(application, clusters); + ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); + + } finally { + ApplicationHolder.releaseWriteLock(); + } + }*/ + + /*public static synchronized void handleApplicationUndeployed(String applicationId) { + + Set clusterData; + + // update the Application and Cluster Statuses as 'Terminating' + ApplicationHolder.acquireWriteLock(); + + try { + + Applications applications = ApplicationHolder.getApplications(); + + if (!applications.applicationExists(applicationId)) { + log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications"); + return; + } + + Application application = applications.getApplication(applicationId); + // check and update application status to 'Terminating' + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully + application.setStatus(ApplicationStatus.Terminating); + + // update all the Clusters' statuses to 'Terminating' + clusterData = application.getClusterDataRecursively(); + for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = applications.getService(clusterDataHolder.getServiceType()); + if (service != null) { + Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); + if (aCluster != null) { + // validate state transition + if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { + log.error("Invalid state transfer from " + aCluster.getStatus() + " to " + + ClusterStatus.Terminating); + } + // for now anyway update the status forcefully + aCluster.setStatus(ClusterStatus.Terminating); + + } else { + log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + + " in Applications"); + } + + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); + } + } + + // update all Group's statuses to 'Terminating' + if (application.getGroups() != null) { + updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); + } + + ApplicationHolder.persistApplication(applications); + + } finally { + ApplicationHolder.releaseWriteLock(); + } + + ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); + }*/ + + public static void handleGroupTerminatedEvent(String appId, String groupId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + Group group = application.getGroupRecursively(groupId); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + group.setStatus(GroupStatus.Terminated); + log.info("Group terminated adding status started for " + group.getUniqueIdentifier()); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendGroupTerminatedEvent(appId, groupId); + } + + public static void handleGroupActivatedEvent(String appId, String groupId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + Group group = application.getGroupRecursively(groupId); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + group.setStatus(GroupStatus.Active); + log.info("Group activated adding status started for " + group.getUniqueIdentifier()); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendGroupActivatedEvent(application.getUniqueIdentifier(), + group.getUniqueIdentifier()); + } + + public static void handleGroupCreatedEvent(String appId, String groupId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + Group group = application.getGroupRecursively(groupId); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + group.setStatus(GroupStatus.Created); + log.info("Group created adding status started for " + group.getUniqueIdentifier()); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendGroupCreatedEvent(appId, groupId); + } + + public static void handleGroupInActivateEvent(String appId, String groupId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + Group group = application.getGroupRecursively(groupId); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + group.setStatus(GroupStatus.Inactive); + log.info("Group in-active adding status started for " + group.getUniqueIdentifier()); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendGroupInActivateEvent(appId, groupId); + } + + public static void handleGroupTerminatingEvent(String appId, String groupId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + Group group = application.getGroupRecursively(groupId); + if (group == null) { + log.warn(String.format("Group %s does not exist", + groupId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + group.setStatus(GroupStatus.Terminating); + log.info("Group terminating adding status started for " + group.getUniqueIdentifier()); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, groupId); + } + + public static void handleApplicationActivatedEvent(String appId) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + + try { + ApplicationHolder.acquireWriteLock(); + application.setStatus(ApplicationStatus.Active); + log.info("Application activated adding status started for Applications"); + + ApplicationHolder.persistApplication(application); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); + } + + /*public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(event.getAppId()); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + event.getAppId())); + return; + } + List clusters = new ArrayList(); + Set allClusters = application.getClusterDataRecursively(); + + for (ClusterDataHolder clusterDataHolder : allClusters) { + String clusterId = clusterDataHolder.getClusterId(); + String serviceName = clusterDataHolder.getServiceType(); + clusters.add(ApplicationHolder.getApplications().getService(serviceName).getCluster(clusterId)); + } + org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationActivatedEvent = + new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent( + application, clusters); + try { + ApplicationHolder.acquireWriteLock(); + application.setStatus(ApplicationStatus.Created); + log.info("Application created adding status started for Applications"); + + ApplicationHolder.persistApplication(applications); + } finally { + ApplicationHolder.releaseWriteLock(); + } + //publishing data + ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent); + }*/ + + public static void handleApplicationTerminatingEvent(String appId) { + + String applicationId = appId; + + // update the Application Status as 'Terminating' + ApplicationHolder.acquireWriteLock(); + + try { + + Applications applications = ApplicationHolder.getApplications(); + + if (!applications.applicationExists(applicationId)) { + log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications"); + return; + } + + Application application = applications.getApplication(applicationId); + // check and update application status to 'Terminating' + if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully + application.setStatus(ApplicationStatus.Terminating); + log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); + + } finally { + ApplicationHolder.releaseWriteLock(); + } + + ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); + } + + private static void updateGroupStatusesRecursively(GroupStatus groupStatus, Collection groups) { + + for (Group group : groups) { + if (!group.isStateTransitionValid(groupStatus)) { + log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus); + } + // force update for now + group.setStatus(groupStatus); + + // go recursively and update + if (group.getGroups() != null) { + updateGroupStatusesRecursively(groupStatus, group.getGroups()); + } + } + } + + public static void handleApplicationTerminatedEvent(String appId) { + + Applications applications = ApplicationHolder.getApplications(); + + try { + ApplicationHolder.acquireWriteLock(); + + if (!applications.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] doesn't exist in Applications"); + //ApplicationsEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); + + } else { + Application application = applications.getApplication(appId); + + if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { + log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated); + } + // forcefully set status for now + application.setStatus(ApplicationStatus.Terminated); + + int tenantId = application.getTenantId(); + String tenantDomain = application.getTenantDomain(); + Set clusterData = application.getClusterDataRecursively(); + // remove clusters + /*for (ClusterDataHolder clusterDataHolder : clusterData) { + Service service = applications.getService(clusterDataHolder.getServiceType()); + if (service != null) { + // remove Cluster + service.removeCluster(clusterDataHolder.getClusterId()); + + if (log.isDebugEnabled()) { + log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); + } + } else { + log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " + + " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); + } + + // remove runtime data + FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); + dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); + if (log.isDebugEnabled()) { + log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); + } + + try { + RegistryManager.getInstance().persist(dataHolder); + } catch (RegistryException e) { + log.error("Unable to persist data in Registry", e); + } + } + + + // remove application + applications.removeApplication(event.getAppId()); + ApplicationHolder.persistApplication(applications); + + deleteAppResourcesFromMetadataService(event); + + log.info("Removed application [ " + event.getAppId() + " ] from Applications"); + + ApplicationsEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent(event.getAppId(), + clusterData, tenantId, tenantDomain))*/ + ; + } + + } finally { + ApplicationHolder.releaseWriteLock(); + } + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java similarity index 98% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index 1fbc14385a..f8d989f806 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -1,14 +1,12 @@ -package org.apache.stratos.autoscaler.grouping.topic; +package org.apache.stratos.autoscaler.applications.topic; 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.domain.applications.*; -import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.applications.*; -import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 467825003e..18929edb25 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -27,21 +27,19 @@ import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index debcf93e03..1e64d78589 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -30,9 +30,9 @@ import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index c8f9d9c0d9..593807789f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -24,10 +24,10 @@ import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.dependency.DependencyBuilder; -import org.apache.stratos.autoscaler.grouping.dependency.DependencyTree; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher; +import org.apache.stratos.autoscaler.applications.dependency.DependencyBuilder; +import org.apache.stratos.autoscaler.applications.dependency.DependencyTree; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.ParentComponent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java index 02c1b1858c..560300c6ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java @@ -25,7 +25,6 @@ import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.TerminationException; -import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java index 5ee7f84415..1648402067 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/group/GroupMonitor.java @@ -20,9 +20,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.monitor.EventHandler; import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; @@ -104,7 +105,7 @@ public void onParentEvent(MonitorStatusEvent statusEvent) { // send the ClusterTerminating event if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) { - ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, id); + ApplicationBuilder.handleGroupTerminatingEvent(appId, id); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 629667a945..eafa269786 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -23,7 +23,8 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.grouping.topic.ApplicationsEventPublisher; +import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; @@ -288,41 +289,30 @@ private boolean updateChildStatus(String appId, String id, Map gr TopologyManager.acquireReadLockForApplication(appId); Application application = TopologyManager.getTopology().getApplication(appId); - if (groups.isEmpty() && getClusterAllInSameState(clusterData,ClusterStatus.Active) || - clusterData.isEmpty() && groupStatus == GroupStatus.Active || - groupStatus == GroupStatus.Active && clusterStatus == ClusterStatus.Active) { + if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) || + clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) || + getAllClusterInSameState(clusterData,ClusterStatus.Active) && + getAllGroupInSameState(groups, GroupStatus.Active)) { //send activation event if (parent instanceof Application) { //send application activated event log.info("sending app activate: " + appId); - ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); + ApplicationBuilder.handleApplicationActivatedEvent(appId); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group activate: " + parent.getUniqueIdentifier()); - ApplicationsEventPublisher.sendGroupActivatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationBuilder.handleGroupActivatedEvent(appId, parent.getUniqueIdentifier()); } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Inactive || - clusterData.isEmpty() && groupStatus == GroupStatus.Inactive || - groupStatus == GroupStatus.Inactive && clusterStatus == ClusterStatus.Inactive) { - //send the in activation event - if (parent instanceof Application) { - //send application activated event - log.warn("Application can't be in in-active : " + appId); - //StatusEventPublisher.sendApplicationInactivatedEvent(appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group in-active: " + parent.getUniqueIdentifier()); - ApplicationsEventPublisher.sendGroupInActivateEvent(appId, parent.getUniqueIdentifier()); - } - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminated || - clusterData.isEmpty() && groupStatus == GroupStatus.Terminated || - groupStatus == GroupStatus.Terminated && clusterStatus == ClusterStatus.Terminated) { + } else if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Terminated) || + clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Terminated) || + getAllClusterInSameState(clusterData, ClusterStatus.Terminated) && + getAllGroupInSameState(groups, GroupStatus.Terminated)) { //send the terminated event if (parent instanceof Application) { //validating the life cycle if (application.getStatus().equals(ApplicationStatus.Terminating)) { log.info("sending app terminated: " + appId); - ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId, parent.getClusterDataRecursively()); + ApplicationBuilder.handleApplicationTerminatedEvent(appId); } else { log.info("[Application] " + appId + " is in the [status] " + application.getStatus().toString() + ". Hence not sending terminated event"); @@ -331,28 +321,32 @@ private boolean updateChildStatus(String appId, String id, Map gr } else if (parent instanceof Group) { //send activation to the parent log.info("sending group created : " + parent.getUniqueIdentifier()); - ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationBuilder.handleGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); } - /*} else if (groups.isEmpty() && clusterStatus == ClusterStatus.Terminating || - clusterData.isEmpty() && groupStatus == GroupStatus.Terminating || - groupStatus == GroupStatus.Terminating && clusterStatus == ClusterStatus.Terminating) { - if (parent instanceof Application) { - log.info("Application can't be in terminating: " + appId); - } else if (parent instanceof Group) { - //send activation to the parent - log.info("sending group terminating : " + parent.getUniqueIdentifier()); - StatusEventPublisher.sendGroupTerminatingEvent(appId, parent.getUniqueIdentifier()); - }*/ - } else if (groups.isEmpty() && clusterStatus == ClusterStatus.Created || - clusterData.isEmpty() && groupStatus == GroupStatus.Created || - groupStatus == GroupStatus.Created && clusterStatus == ClusterStatus.Created) { + } else if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Created) || + clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Created) || + getAllClusterInSameState(clusterData,ClusterStatus.Created) && + getAllGroupInSameState(groups, GroupStatus.Created)) { if (parent instanceof Application) { log.info("[Application] " + appId + "couldn't change to Created, since it is" + "already in " + application.getStatus().toString()); } else if (parent instanceof Group) { //send activation to the parent log.info("sending group created : " + parent.getUniqueIdentifier()); - ApplicationsEventPublisher.sendGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + ApplicationBuilder.handleGroupCreatedEvent(appId, parent.getUniqueIdentifier()); + } + } else if (groups.isEmpty() && getAllClusterInActive(clusterData) || + clusterData.isEmpty() && getAllGroupInActive(groups) || + getAllClusterInActive(clusterData) && getAllGroupInActive(groups)) { + //send the in activation event + if (parent instanceof Application) { + //send application activated event + log.warn("Application can't be in in-active : " + appId); + //StatusEventPublisher.sendApplicationInactivatedEvent(appId); + } else if (parent instanceof Group) { + //send activation to the parent + log.info("sending group in-active: " + parent.getUniqueIdentifier()); + ApplicationBuilder.handleGroupInActivateEvent(appId, parent.getUniqueIdentifier()); } } else { log.warn("Clusters/groups not found in this [component] " + appId); @@ -370,7 +364,7 @@ private boolean updateChildStatus(String appId, String id, Map gr return childFound; } - private boolean getGroupInActive(Map groups) { + private boolean getAllGroupInActive(Map groups) { boolean groupStat = false; for (Group group : groups.values()) { if (group.getStatus() == GroupStatus.Inactive) { @@ -383,7 +377,7 @@ private boolean getGroupInActive(Map groups) { return groupStat; } - private boolean allGroupInSameState(Map groups, GroupStatus status) { + private boolean getAllGroupInSameState(Map groups, GroupStatus status) { boolean groupStat = false; for (Group group : groups.values()) { if (group.getStatus() == status) { @@ -397,7 +391,7 @@ private boolean allGroupInSameState(Map groups, GroupStatus statu } - private boolean getClusterInActive(Map clusterData) { + private boolean getAllClusterInActive(Map clusterData) { boolean clusterStat = false; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { Service service = TopologyManager.getTopology().getService(clusterDataHolderEntry.getValue().getServiceType()); @@ -413,7 +407,7 @@ private boolean getClusterInActive(Map clusterData) { return clusterStat; } - private boolean getClusterAllInSameState(Map clusterData, + private boolean getAllClusterInSameState(Map clusterData, ClusterStatus status) { boolean clusterStat = false; for (Map.Entry clusterDataHolderEntry : clusterData.entrySet()) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 0c2731662b..ca2cc1e3b4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1403,16 +1403,16 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); } - TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), + /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), applicationParser.getPayloadData()); - +*/ persist(); } @Override public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - TopologyBuilder.handleApplicationUndeployed(applicationId); + //TopologyBuilder.handleApplicationUndeployed(applicationId); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index dcbeb4861f..7ee342e127 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -22,23 +22,17 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; +import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; -import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; -import org.apache.stratos.messaging.domain.applications.*; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.applications.*; -import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; -import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; +import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent; import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.applications.ApplicationTerminatingEvent; -import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; -import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; import org.apache.stratos.messaging.event.cluster.status.*; @@ -49,9 +43,9 @@ import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient; import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient; -import org.wso2.carbon.registry.core.exceptions.RegistryException; -import java.util.*; +import java.util.List; +import java.util.Map; import java.util.Properties; /** @@ -69,7 +63,7 @@ public static void handleServiceCreated(List cartridgeList) { log.warn(String.format("Cartridge list is empty")); return; } - + try { TopologyManager.acquireWriteLock(); @@ -104,7 +98,7 @@ public static void handleServiceCreated(List cartridgeList) { public static void handleServiceRemoved(List cartridgeList) { Topology topology = TopologyManager.getTopology(); - for (Cartridge cartridge : cartridgeList) { + for (Cartridge cartridge : cartridgeList) { if (topology.getService(cartridge.getType()).getClusters().size() == 0) { if (topology.serviceExists(cartridge.getType())) { try { @@ -125,7 +119,7 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterCreated (ClusterStatusClusterResettedEvent event) { + public static void handleClusterCreated(ClusterStatusClusterResettedEvent event) { TopologyManager.acquireWriteLock(); @@ -146,9 +140,9 @@ public static void handleClusterCreated (ClusterStatusClusterResettedEvent event } // update the cluster status to Created - if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { - log.error("Invalid state transition from " + cluster.getStatus() + " to " + - ClusterStatus.Created + " for cluster id " + event.getClusterId()); + if (!cluster.isStateTransitionValid(ClusterStatus.Created)) { + log.error("Invalid state transition from " + cluster.getStatus() + " to " + + ClusterStatus.Created + " for cluster id " + event.getClusterId()); } // forcefully update the status cluster.setStatus(ClusterStatus.Created); @@ -162,42 +156,6 @@ public static void handleClusterCreated (ClusterStatusClusterResettedEvent event event.getClusterId()); } - public static void handleGroupCreated (GroupCreatedEvent event) { - - TopologyManager.acquireWriteLock(); - - try { - Topology topology = TopologyManager.getTopology(); - - Application application = topology.getApplication(event.getAppId()); - if (application == null) { - log.error("Application " + event.getAppId() + - " not found in Topology, unable to update the Group status to Created"); - return; - } - - Group group = application.getGroupRecursively(event.getGroupId()); - if (group == null) { - log.error("Group " + event.getGroupId() + - " not found in Topology, unable to update the Group status to Created"); - return; - } - - // update the cluster status to Created - if (!group.isStateTransitionValid(GroupStatus.Created)) { - log.error("Invalid state transition from " + group.getStatus() + " to " + - GroupStatus.Created + " for group " + event.getGroupId()); - } - // forcefully update the status - group.setStatus(GroupStatus.Created); - TopologyManager.updateTopology(topology); - - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendGroupCreatedEvent(new org.apache.stratos.messaging.event.topology.GroupCreatedEvent(event.getAppId(), event.getGroupId())); - } public static void handleClusterCreated(Registrant registrant, boolean isLb) { /*Topology topology = TopologyManager.getTopology(); @@ -478,7 +436,7 @@ public static void handleMemberReadyToShutdown(InstanceReadyToShutdownEvent inst return; } - + Member member = cluster.getMember(instanceReadyToShutdownEvent.getMemberId()); if (member == null) { log.warn(String.format("Member %s does not exist", @@ -612,117 +570,6 @@ public static void handleMemberSuspended() { } } - public static synchronized void handleApplicationDeployed(Application application, - Set applicationClusterContexts, - Set metaDataHolders) { - - - Topology topology = TopologyManager.getTopology(); - try { - TopologyManager.acquireWriteLock(); - - if (topology.applicationExists(application.getUniqueIdentifier())) { - log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology"); - return; - } - List clusters = new ArrayList(); - for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { - Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), - applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); - //cluster.setStatus(Status.Created); - cluster.addHostName(applicationClusterContext.getHostName()); - cluster.setTenantRange(applicationClusterContext.getTenantRange()); - clusters.add(cluster); - - Service service = topology.getService(applicationClusterContext.getCartridgeType()); - if (service != null) { - service.addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier()); - } else { - log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); - return; - } - } - - // add to Topology and update - topology.addApplication(application); - TopologyManager.updateTopology(topology); - - log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully"); - org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters); - TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); - - } finally { - TopologyManager.releaseWriteLock(); - } - } - - public static synchronized void handleApplicationUndeployed(String applicationId) { - - Set clusterData; - - // update the Application and Cluster Statuses as 'Terminating' - TopologyManager.acquireWriteLock(); - - try { - - Topology topology = TopologyManager.getTopology(); - - if (!topology.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - return; - } - - Application application = topology.getApplication(applicationId); - // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); - - // update all the Clusters' statuses to 'Terminating' - clusterData = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Topology"); - } - - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); - } - } - - // update all Group's statuses to 'Terminating' - if (application.getGroups() != null) { - updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); - } - - TopologyManager.updateTopology(topology); - - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); - } - - public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterActivatedEvent.getServiceName()); @@ -798,251 +645,13 @@ public static void handleClusterInActivateEvent( TopologyEventPublisher.sendClusterInActivateEvent(clusterActivatedEvent1); } - public static void handleGroupActivatedEvent(GroupActivatedEvent groupActivatedEvent) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(groupActivatedEvent.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - groupActivatedEvent.getAppId())); - return; - } - - Group group = application.getGroupRecursively(groupActivatedEvent.getGroupId()); - if (group == null) { - log.warn(String.format("Group %s does not exist", - groupActivatedEvent.getGroupId())); - return; - } - - org.apache.stratos.messaging.event.topology.GroupActivatedEvent groupActivatedEvent1 = - new org.apache.stratos.messaging.event.topology.GroupActivatedEvent( - groupActivatedEvent.getAppId(), - groupActivatedEvent.getGroupId()); - try { - TopologyManager.acquireWriteLock(); - group.setStatus(GroupStatus.Active); - log.info("Group activated adding status started for " + group.getUniqueIdentifier()); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendGroupActivatedEvent(groupActivatedEvent1); - } - - public static void handleApplicationActivatedEvent(ApplicationActivatedEvent applicationActivatedEvent) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(applicationActivatedEvent.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - applicationActivatedEvent.getAppId())); - return; - } - - org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent applicationActivatedEvent1 = - new org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent( - applicationActivatedEvent.getAppId()); - try { - TopologyManager.acquireWriteLock(); - application.setStatus(ApplicationStatus.Active); - log.info("Application activated adding status started for Topology"); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendApplicationActivatedEvent(applicationActivatedEvent1); - } - - public static void handleApplicationInActivatedEvent(ApplicationInactivatedEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - - org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent applicationActivatedEvent = - new org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent( - event.getAppId()); - try { - TopologyManager.acquireWriteLock(); - application.setStatus(ApplicationStatus.Inactive); - log.info("Application inactivated adding status started for Topology"); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendApplicationInactivatedEvent(applicationActivatedEvent); - } - - public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - List clusters = new ArrayList(); - Set allClusters = application.getClusterDataRecursively(); - - for(ClusterDataHolder clusterDataHolder : allClusters){ - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); - clusters.add(TopologyManager.getTopology().getService(serviceName).getCluster(clusterId)); - } - org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationActivatedEvent = - new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent( - application, clusters); - try { - TopologyManager.acquireWriteLock(); - application.setStatus(ApplicationStatus.Created); - log.info("Application created adding status started for Topology"); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent); - } - - public static void handleApplicationTerminatingEvent(ApplicationTerminatingEvent event) { - - String applicationId = event.getAppId(); - - // update the Application Status as 'Terminating' - TopologyManager.acquireWriteLock(); - - try { - - Topology topology = TopologyManager.getTopology(); - - if (!topology.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - return; - } - - Application application = topology.getApplication(applicationId); - // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); - log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); - - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendApplicationTerminatingEvent( - new org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent(applicationId)); - } - - private static void updateGroupStatusesRecursively (GroupStatus groupStatus, Collection groups) { - - for (Group group : groups) { - if (!group.isStateTransitionValid(groupStatus)) { - log.error("Invalid state transfer from " + group.getStatus() + " to " + groupStatus); - } - // force update for now - group.setStatus(groupStatus); - - // go recursively and update - if (group.getGroups() != null) { - updateGroupStatusesRecursively(groupStatus, group.getGroups()); - } - } - } - - public static void handleApplicationTerminatedEvent(ApplicationTerminatedEvent event) { - - Topology topology = TopologyManager.getTopology(); - - try { - TopologyManager.acquireWriteLock(); - - if (!topology.applicationExists(event.getAppId())) { - log.warn("Application with id [ " + event.getAppId() + " ] doesn't exist in Topology"); - //TopologyEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); - - } else { - Application application = topology.getApplication(event.getAppId()); - - if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { - log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated); - } - // forcefully set status for now - application.setStatus(ApplicationStatus.Terminated); - - int tenantId = application.getTenantId(); - String tenantDomain = application.getTenantDomain(); - Set clusterData = application.getClusterDataRecursively(); - // remove clusters - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - // remove Cluster - service.removeCluster(clusterDataHolder.getClusterId()); - - if (log.isDebugEnabled()) { - log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); - } - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); - } - - // remove runtime data - FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); - dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); - if(log.isDebugEnabled()) { - log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); - } - - try { - RegistryManager.getInstance().persist(dataHolder); - } catch (RegistryException e) { - log.error("Unable to persist data in Registry", e); - } - } - - - - // remove application - topology.removeApplication(event.getAppId()); - TopologyManager.updateTopology(topology); - - deleteAppResourcesFromMetadataService(event); - - log.info("Removed application [ " + event.getAppId() + " ] from Topology"); - - TopologyEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent(event.getAppId(), - clusterData, tenantId, tenantDomain)); - } - - } finally { - TopologyManager.releaseWriteLock(); - } - } private static void deleteAppResourcesFromMetadataService(ApplicationTerminatedEvent event) { try { MetaDataServiceClient metadataClient = new DefaultMetaDataServiceClient(); metadataClient.deleteApplicationProperties(event.getAppId()); } catch (Exception e) { - log.error("Error occurred while deleting the application resources frm metadata service " , e); + log.error("Error occurred while deleting the application resources frm metadata service ", e); } } From 836b71fd7a0d4258cf4b397d5cc43228c477ffa0 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Fri, 31 Oct 2014 15:36:45 +0530 Subject: [PATCH 338/436] adding service group deployment to auto scaler --- .../autoscaler/api/AutoScalerServiceImpl.java | 78 +- .../InvalidServiceGroupException.java | 46 + .../stratos/autoscaler/pojo/Dependencies.java | 46 + .../stratos/autoscaler/pojo/ServiceGroup.java | 67 ++ .../autoscaler/registry/RegistryManager.java | 47 +- .../autoscaler/util/AutoScalerConstants.java | 3 +- .../stratos/autoscaler/util/Deserializer.java | 10 +- .../client/AutoscalerServiceClient.java | 20 +- .../deployer/DefaultServiceGroupDeployer.java | 39 +- .../pom.xml | 3 +- .../src/main/resources/AutoScalerService.wsdl | 892 +++++++++++------- 11 files changed, 846 insertions(+), 405 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 897fd4e113..d710bf7655 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -18,22 +18,25 @@ */ package org.apache.stratos.autoscaler.api; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.InvalidPartitionException; -import org.apache.stratos.autoscaler.exception.InvalidPolicyException; -import org.apache.stratos.autoscaler.exception.NonExistingLBException; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; +import org.apache.stratos.autoscaler.exception.*; import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.partition.PartitionManager; +import org.apache.stratos.autoscaler.pojo.Dependencies; +import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; +import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; +import org.wso2.carbon.registry.api.RegistryException; +import java.text.MessageFormat; import java.util.ArrayList; /** @@ -268,5 +271,72 @@ public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String dep } + public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException { + + if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) { + String msg = "Service group can not be null service name can not be empty."; + log.error(msg); + throw new IllegalArgumentException(msg); + + } + String name = servicegroup.getName(); + + if(RegistryManager.getInstance().serviceGroupExist(name)){ + throw new InvalidServiceGroupException("Service group with the name " + name + " already exist."); + } + + if(log.isDebugEnabled()) { + log.debug(MessageFormat.format("Deploying service group {0}", servicegroup.getName())); + } + + String [] subGroups = servicegroup.getCartridges(); + + if(log.isDebugEnabled()) { + log.debug("SubGroups" + subGroups); + if (subGroups != null) { + log.debug("subGroups:size" + subGroups.length); + } else { + log.debug("subGroups: are null"); + } + } + + + Dependencies dependencies = servicegroup.getDependencies(); + + if(log.isDebugEnabled()) { + log.debug("Dependencies" + dependencies); + } + + if (dependencies != null) { + String [] startupOrders = dependencies.getStartupOrders(); + + if(log.isDebugEnabled()) { + log.debug("StartupOrders" + startupOrders); + + if (startupOrders != null) { + log.debug("StartupOrder:size" + startupOrders.length); + } else { + log.debug("StartupOrder: is null"); + } + } + } + + RegistryManager.getInstance().persistServiceGroup(servicegroup); + } + + public ServiceGroup getServiceGroup(String name){ + if(StringUtils.isEmpty(name)){ + return null; + } + try { + return RegistryManager.getInstance().getServiceGroup(name); + } catch (Exception e) { + throw new AutoScalerException("Error occurred while retrieving service groups", e); + } + } + public boolean serviceGroupExist(String serviceName){ + return false; + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java new file mode 100644 index 0000000000..d18c274d1e --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/InvalidServiceGroupException.java @@ -0,0 +1,46 @@ +/* + * 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.autoscaler.exception; + +public class InvalidServiceGroupException extends Exception { + + + private static final long serialVersionUID = 2651280146514042590L; + + private String message; + + public InvalidServiceGroupException(String msg) { + super(msg); + this.setMessage(msg); + } + + public InvalidServiceGroupException(String msg, Exception ex) { + super(msg, ex); + this.setMessage(msg); + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java new file mode 100644 index 0000000000..4403e6c2fd --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/Dependencies.java @@ -0,0 +1,46 @@ +/* + * 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.autoscaler.pojo; + +import java.io.Serializable; + +public class Dependencies implements Serializable { + + private static final long serialVersionUID = 4187267350546153680L; + + private String [] startupOrders; + + private String killBehaviour; + + public String getKillBehaviour() { + return killBehaviour; + } + + public void setKillBehaviour(String killBehaviour) { + this.killBehaviour = killBehaviour; + } + + public String[] getStartupOrders() { + return startupOrders; + } + + public void setStartupOrders(String[] startupOrders) { + this.startupOrders = startupOrders; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.java new file mode 100644 index 0000000000..4de6e0c543 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/pojo/ServiceGroup.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.autoscaler.pojo; + +import java.io.Serializable; + +public class ServiceGroup implements Serializable { + + + private static final long serialVersionUID = -7413745300105885793L; + + private String name; + + private String [] subGroups; + + private String [] cartridges; + + private Dependencies dependencies; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String [] getSubGroups() { + return subGroups; + } + + public void setSubGroups(String [] subGroups) { + this.subGroups = subGroups; + } + + public String [] getCartridges() { + return cartridges; + } + + public void setCartridges(String [] cartridges) { + this.cartridges = cartridges; + } + + public Dependencies getDependencies() { + return dependencies; + } + + public void setDependencies(Dependencies dependencies) { + this.dependencies = dependencies; + } +} \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 25caf0ebfe..ee8e4114f4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -21,11 +21,13 @@ */ +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; +import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.Deserializer; @@ -142,6 +144,7 @@ public void persistDeploymentPolicy(DeploymentPolicy deploymentPolicy) { } } + public void persistApplication (Application application) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + @@ -181,13 +184,27 @@ public Application getApplication (String applicationResourcePath) { } return null; } + + public void persistServiceGroup(ServiceGroup servicegroup) { + if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){ + throw new IllegalArgumentException("Service group or group name can not be null"); + } + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + servicegroup.getName(); + persist(servicegroup, resourcePath); + if(log.isDebugEnabled()) { + log.debug(String.format("Persisted service group %s at path %s", servicegroup.getName(), resourcePath)); + } + } + + public boolean serviceGroupExist(String serviceGroupName){ + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + serviceGroupName; + return this.resourceExist(resourcePath); + } private Object retrieve(String resourcePath) { try { Resource resource = registryService.get(resourcePath); - return resource.getContent(); - } catch (ResourceNotFoundException ignore) { // this means, we've never persisted info in registry return null; @@ -198,6 +215,10 @@ private Object retrieve(String resourcePath) { } } + private boolean resourceExist(String resourcePath){ + return this.retrieve(resourcePath) != null; + } + public List retrievePartitions() { List partitionList = new ArrayList(); RegistryManager registryManager = RegistryManager.getInstance(); @@ -327,6 +348,26 @@ public List retrieveDeploymentPolicies() { return depPolicyList; } + public ServiceGroup getServiceGroup(String name) throws Exception{ + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + name; + Object serializedObj = registryManager.retrieve(resourcePath); + ServiceGroup group = null; + if (serializedObj != null) { + + Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); + if (dataObj instanceof ServiceGroup) { + group = (ServiceGroup) dataObj; + if(log.isDebugEnabled()) { + log.debug(group.toString()); + } + } else { + return null; + } + } + + return group; + } + public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId(); this.delete(resourcePath); @@ -372,6 +413,6 @@ private void delete(String resourcePath) { log.error("Could not delete resource at "+ resourcePath); throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e); } - + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java index b30e0e64c5..3587afe66e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoScalerConstants.java @@ -44,5 +44,6 @@ public final class AutoScalerConstants { * Configs */ public static final String AUTOSCALER_MONITOR_INTERVAL = "autoscaler.monitorInterval"; - + + public static final String SERVICE_GROUP = "/groups"; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java index 5c9714392b..af1c6eae87 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/Deserializer.java @@ -18,15 +18,11 @@ */ package org.apache.stratos.autoscaler.util; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectInputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import java.io.*; + public class Deserializer { private static final Log log = LogFactory.getLog(Deserializer.class); @@ -75,7 +71,7 @@ public static Object deserialize(String filePath) throws Exception { * @return the deserialized {@link Object} * @throws Exception if the deserialization is failed. */ - public static Object deserializeFromByteArray(byte[] bytes) throws Exception { + public static Object deserializeFromByteArray(byte[] bytes) throws IOException, ClassNotFoundException { ByteArrayInputStream bis = new ByteArrayInputStream(bytes); ObjectInput in = null; 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 b87d0f219a..731c80fd92 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 @@ -24,15 +24,13 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; +import org.apache.stratos.autoscaler.stub.*; +import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; -import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; -import org.apache.stratos.autoscaler.stub.AutoScalerServiceNonExistingLBExceptionException; -import org.apache.stratos.autoscaler.stub.AutoScalerServiceStub; import java.rmi.RemoteException; @@ -211,5 +209,13 @@ public String getDefaultLBClusterId (String deploymentPolicy) throws RemoteExcep public String getServiceLBClusterId (String serviceType, String deploymentPolicy) throws RemoteException { return stub.getServiceLBClusterId(serviceType, deploymentPolicy); } - + + + public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws RemoteException { + return stub.getServiceGroup(serviceGroupDefinitionName); + } + + public void deployServiceGroup(ServiceGroup serviceGroup) throws AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException { + stub.deployServiceGroup(serviceGroup); + } } 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 index be0c4ee5a6..7244de402e 100644 --- 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 @@ -22,23 +22,21 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.stub.pojo.Dependencies; +import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; +import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; +import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +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.ServiceGroupDefinition; import org.apache.stratos.manager.grouping.definitions.DependencyDefinitions; -import org.apache.stratos.cloud.controller.stub.pojo.ServiceGroup; -import org.apache.stratos.cloud.controller.stub.pojo.Dependencies; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; -import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class DefaultServiceGroupDeployer implements ServiceGroupDeployer { @@ -155,23 +153,23 @@ public void deployServiceGroupDefinition (Object serviceGroupDefinitionObj) thro } } - CloudControllerServiceClient ccServiceClient = null; + AutoscalerServiceClient asServiceClient = null; try { - ccServiceClient = CloudControllerServiceClient.getServiceClient(); + asServiceClient = AutoscalerServiceClient.getServiceClient(); if (log.isDebugEnabled()) { log.debug("deplying to cloud controller service group " + serviceGroupDefinition.getName()); } - - ccServiceClient.deployServiceGroup(serviceGroup); + + asServiceClient.deployServiceGroup(serviceGroup); } catch (AxisFault axisFault) { throw new ADCException(axisFault); }catch (RemoteException e) { throw new ADCException(e); - } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) { - throw new ADCException(e); + } catch (AutoScalerServiceInvalidServiceGroupExceptionException e) { + e.printStackTrace(); } } @@ -181,16 +179,16 @@ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefi log.debug("getting service group from cloud controller " + serviceGroupDefinitionName); } - CloudControllerServiceClient ccServiceClient = null; + AutoscalerServiceClient asServiceClient = null; try { - ccServiceClient = CloudControllerServiceClient.getServiceClient(); + asServiceClient = AutoscalerServiceClient.getServiceClient(); if (log.isDebugEnabled()) { log.debug("deploying to cloud controller service group " + serviceGroupDefinitionName); } - ServiceGroup serviceGroup = ccServiceClient.getServiceGroup(serviceGroupDefinitionName); + ServiceGroup serviceGroup = asServiceClient.getServiceGroup(serviceGroupDefinitionName); ServiceGroupDefinition serviceGroupDef = populateServiceGroupDefinitionPojo(serviceGroup); return serviceGroupDef; @@ -199,10 +197,7 @@ public ServiceGroupDefinition getServiceGroupDefinition (String serviceGroupDefi throw new ADCException(axisFault); } catch (RemoteException e) { throw new ADCException(e); - } catch (CloudControllerServiceInvalidServiceGroupExceptionException e) { - throw new ADCException(e); } - } diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 60683cce6c..0df790347e 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -47,7 +47,7 @@ - + @@ -93,6 +93,7 @@ org.apache.stratos.autoscaler.exception.*; version=${project.version}, org.apache.stratos.autoscaler.partition.*; version=${project.version}, org.apache.stratos.autoscaler.api.*; version=${project.version} + org.apache.stratos.autoscaler.pojo.*; version=${project.version} diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index 23b4099033..d0665cf9a5 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,1155 +1,1327 @@ - + AutoScalerService + + + + + - + - + - + - - + + - - - - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + - + - - - + + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - + - - - - - - - - - - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - - + + - - + + - - + + - - + + - - + + + + + + - - - + + + + + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + + + + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + \ No newline at end of file From d4f90be212976c529b6970c673b4eddf6461e0a4 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 14:55:36 +0530 Subject: [PATCH 339/436] removing Application from Topology - I --- .../domain/applications/Applications.java | 13 +- .../messaging/domain/topology/Topology.java | 111 ------------------ 2 files changed, 11 insertions(+), 113 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java index 9e8cf3ea33..e5a79216bf 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java @@ -21,6 +21,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy; import java.io.Serializable; import java.util.HashMap; @@ -38,8 +40,10 @@ public Applications () { this.applicationMap = new HashMap(); } - public void addApplication (Application application) { - this.getApplications().put(application.getUniqueIdentifier(), application); + public synchronized void addApplication (Application application) { + this.applicationMap.put(application.getUniqueIdentifier(), application); + ApplicationLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(), + new ApplicationLock()); } public Application getApplication (String appId) { @@ -61,4 +65,9 @@ public boolean applicationExists(String appId) { public Map getApplications() { return applicationMap; } + + public synchronized void removeApplication (String appId) { + this.applicationMap.remove(appId); + ApplicationLockHierarchy.getInstance().removeLock(appId); + } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java index 0f128fa7d9..a5780bb46c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Topology.java @@ -37,42 +37,12 @@ public class Topology implements Serializable { private static final long serialVersionUID = -2453583548027402122L; // Key: Service.serviceName private Map serviceMap; - //Grouping - private Map compositeApplicationMap; - // grouping_poc private Map configCompositeApplicationMap; - // Key: Application.id - private Map applicationMap; private boolean initialized; private static Log log = LogFactory.getLog(Topology.class); public Topology() { this.serviceMap = new HashMap(); - this.compositeApplicationMap = new HashMap(); - // grouping_poc this.configCompositeApplicationMap = new HashMap(); - this.applicationMap = new HashMap(); - } - - public void addApplication (Application application) { - this.applicationMap.put(application.getUniqueIdentifier(), application); - TopologyLockHierarchy.getInstance().addApplicationLock(application.getUniqueIdentifier(), new TopologyLock()); - } - - public Application getApplication (String applicationId) { - return applicationMap.get(applicationId); - } - - public void removeApplication (String applicationId) { - applicationMap.remove(applicationId); - TopologyLockHierarchy.getInstance().removeTopologyLockForApplication(applicationId); - } - - public Collection getApplications () { - return applicationMap.values(); - } - - public boolean applicationExists (String applicationId) { - return this.applicationMap.containsKey(applicationId); } public Collection getServices() { @@ -111,87 +81,6 @@ public boolean serviceExists(String serviceName) { public void clear() { this.serviceMap.clear(); } - - // Grouping - public Collection getCompositeApplication() { - return this.compositeApplicationMap.values(); - } - - public void addCompositeApplication(String alias, CompositeApplication app) { - this.compositeApplicationMap.put(alias, app); - } - - public void removeCompositeApplication(String alias) { - this.compositeApplicationMap.remove(alias); - } - - /* grouping_poc - public Collection getConfigCompositeApplication() { - - if (this.configCompositeApplicationMap == null) { - log.info("adding new config comp in topology while retrieving it, ConfigCompositeApplication is null"); - this.configCompositeApplicationMap = new HashMap(); - } - return this.configCompositeApplicationMap.values(); - } - - public void addConfigCompositeApplication(String alias, ConfigCompositeApplication configApp) { - log.info("adding config comp in topology" + alias + " / " + configApp); - if (this.configCompositeApplicationMap != null) { - log.info("adding config comp in topology, ConfigCompositeApplication is not null"); - this.configCompositeApplicationMap.put(alias, configApp); - log.info("successful config comp in topology, ConfigCompositeApplication is not null"); - } else { - log.info("adding config comp in topology, ConfigCompositeApplication is null, adding one"); - this.configCompositeApplicationMap = new HashMap(); - this.configCompositeApplicationMap.put(alias, configApp); - } - } - - public void removeConfigCompositeApplication(String alias) { - this.configCompositeApplicationMap.remove(alias); - } - - public void removeAllCompositeApplication() { - java.util.Set keys = this.compositeApplicationMap.keySet(); - for (String key : keys) { - compositeApplicationMap.remove(key); - } - } - - public void removeAllConfigCompositeApplication() { - java.util.Set keys = this.configCompositeApplicationMap.keySet(); - for (String key : keys) { - configCompositeApplicationMap.remove(key); - } - } - - public CompositeApplication getCompositeApplication(String appAlias) { - return this.compositeApplicationMap.get(appAlias); - } - - public boolean compositeApplicationExists(String appAlias) { - return this.compositeApplicationMap.containsKey(appAlias); - } - - public ConfigCompositeApplication getConfigCompositeApplication(String appAlias) { - return this.configCompositeApplicationMap.get(appAlias); - } - - public boolean configCompositeApplicationExists(String appAlias) { - return this.configCompositeApplicationMap.containsKey(appAlias); - } - - - public Map getConfigCompositeApplicationMap() { - return configCompositeApplicationMap; - } - - public void setConfigCompositeApplicationMap(Map configCompositeApplicationMap) { - this.configCompositeApplicationMap = configCompositeApplicationMap; - } - - */ public void setInitialized(boolean initialized) { this.initialized = initialized; From c42d7c1dc232256e4bbb7a10bda7e8f110ddb795 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 15:55:27 +0530 Subject: [PATCH 340/436] moving applications stuff to autoscaler - II --- .../topic/ApplicationsEventPublisher.java | 56 ++++----- .../AutoscalerTopologyEventReceiver.java | 7 +- .../monitor/ApplicationMonitorFactory.java | 13 +- .../status/checker/StatusChecker.java | 21 ++-- .../topology/TopologyEventPublisher.java | 2 +- .../domain/applications/Applications.java | 2 +- .../locking/ApplicationLockHierarchy.java | 4 +- .../locking/TopologyLockHierarchy.java | 42 ------- .../ApplicationActivatedMessageProcessor.java | 24 ++-- .../ApplicationCreatedMessageProcessor.java | 18 ++- ...pplicationInactivatedMessageProcessor.java | 24 ++-- ...ApplicationTerminatedMessageProcessor.java | 43 ++++--- ...pplicationTerminatingMessageProcessor.java | 24 ++-- ...ApplicationUndeployedMessageProcessor.java | 61 ++++----- .../CompleteApplicationsMessageProcessor.java | 17 +-- .../applications/GroupActivatedProcessor.java | 20 +-- .../applications/GroupCreatedProcessor.java | 24 ++-- .../GroupInActivateProcessor.java | 22 ++-- .../GroupTerminatedProcessor.java | 24 ++-- .../GroupTerminatingProcessor.java | 24 ++-- .../updater/ApplicationsUpdater.java | 23 ++-- .../CompleteTopologyMessageProcessor.java | 15 --- .../topology/updater/TopologyUpdater.java | 68 +--------- .../applications/ApplicationManager.java | 119 ++++++++++++++++++ .../receiver/topology/TopologyManager.java | 67 +--------- 25 files changed, 351 insertions(+), 413 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index f8d989f806..bdbffc0154 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -7,7 +7,7 @@ import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.applications.*; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.util.Constants; import java.util.Set; @@ -21,8 +21,8 @@ public class ApplicationsEventPublisher { public static void sendGroupCreatedEvent(String appId, String groupId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Created)) { @@ -39,14 +39,14 @@ public static void sendGroupCreatedEvent(String appId, String groupId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } public static void sendGroupActivatedEvent(String appId, String groupId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Active)) { @@ -63,14 +63,14 @@ public static void sendGroupActivatedEvent(String appId, String groupId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } public static void sendGroupInActivateEvent(String appId, String groupId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Inactive)) { @@ -87,14 +87,14 @@ public static void sendGroupInActivateEvent(String appId, String groupId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } public static void sendGroupTerminatingEvent(String appId, String groupId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Terminating)) { @@ -110,7 +110,7 @@ public static void sendGroupTerminatingEvent(String appId, String groupId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } @@ -122,8 +122,8 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { } try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { Group group = application.getGroupRecursively(groupId); if (group.isStateTransitionValid(GroupStatus.Terminated)) { @@ -135,7 +135,7 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } @@ -143,8 +143,8 @@ public static void sendGroupTerminatedEvent(String appId, String groupId) { public static void sendApplicationActivatedEvent(String appId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Active)) { if (log.isInfoEnabled()) { @@ -159,7 +159,7 @@ public static void sendApplicationActivatedEvent(String appId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } @@ -169,8 +169,8 @@ public static void sendApplicationInactivatedEvent(String appId) { } try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Inactive)) { ApplicationInactivatedEvent applicationInActivatedEvent = @@ -181,14 +181,14 @@ public static void sendApplicationInactivatedEvent(String appId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } public static void sendApplicationTerminatingEvent(String appId) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Terminating)) { if (log.isInfoEnabled()) { @@ -202,14 +202,14 @@ public static void sendApplicationTerminatingEvent(String appId) { } } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } } public static void sendApplicationTerminatedEvent(String appId, Set clusterData) { try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (application != null) { if (application.isStateTransitionValid(ApplicationStatus.Terminated)) { if (log.isInfoEnabled()) { @@ -223,7 +223,7 @@ public static void sendApplicationTerminatedEvent(String appId, Set clusterIds = component.getClusterDataMap(); Map groups = component.getAliasToGroupMap(); updateChildStatus(appId, idOfChild, groups, clusterIds, component); } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } @@ -286,8 +287,8 @@ private boolean updateChildStatus(String appId, String id, Map gr clusterStatus = getClusterStatus(clusterData); groupStatus = getGroupStatus(groups); try { - TopologyManager.acquireReadLockForApplication(appId); - Application application = TopologyManager.getTopology().getApplication(appId); + ApplicationManager.acquireReadLockForApplication(appId); + Application application = ApplicationManager.getApplications().getApplication(appId); if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) || clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) || @@ -352,7 +353,7 @@ private boolean updateChildStatus(String appId, String id, Map gr log.warn("Clusters/groups not found in this [component] " + appId); } } finally { - TopologyManager.releaseReadLockForApplication(appId); + ApplicationManager.releaseReadLockForApplication(appId); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index f96ba8e4d0..2e0883b421 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -78,7 +78,7 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId,serviceName, clusterId); + ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster()); if(log.isInfoEnabled()) { log.info("Publishing cluster created event: " +clusterId); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java index e5a79216bf..e1feb825eb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/Applications.java @@ -68,6 +68,6 @@ public Map getApplications() { public synchronized void removeApplication (String appId) { this.applicationMap.remove(appId); - ApplicationLockHierarchy.getInstance().removeLock(appId); + ApplicationLockHierarchy.getInstance().removeLockForApplication(appId); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java index cc31892165..2b457d719b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/locking/ApplicationLockHierarchy.java @@ -71,11 +71,11 @@ public void addApplicationLock (String appId, final ApplicationLock appLock) { } } - public ApplicationLock getLock (String appId) { + public ApplicationLock getLockForApplication(String appId) { return appIdToApplicationLockMap.get(appId); } - public void removeLock (String appId) { + public void removeLockForApplication (String appId) { if (appIdToApplicationLockMap.remove(appId) != null) { log.info("Removed lock for Application " + appId); } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java index bb6b8fa7b9..e89df3ad3e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/locking/TopologyLockHierarchy.java @@ -35,15 +35,9 @@ public class TopologyLockHierarchy { // lock for Services private final TopologyLock serviceLock; - // lock for Applications - private final TopologyLock applicatioLock; - // key = Service.name private final Map serviceNameToTopologyLockMap; - // key = Application.id - private final Map applicationIdToTopologyLockMap; - // key = Cluster.id private final Map clusterIdToTopologyLockMap; @@ -53,9 +47,7 @@ private TopologyLockHierarchy () { this.completeTopologyLock = new TopologyLock(); this.serviceLock = new TopologyLock(); - this.applicatioLock = new TopologyLock(); this.serviceNameToTopologyLockMap = new ConcurrentHashMap(); - this.applicationIdToTopologyLockMap = new ConcurrentHashMap(); this.clusterIdToTopologyLockMap = new ConcurrentHashMap(); } @@ -72,26 +64,6 @@ public static TopologyLockHierarchy getInstance () { return topologyLockHierarchy; } - public void addApplicationLock (String appId, final TopologyLock topologyLock) { - - if (!applicationIdToTopologyLockMap.containsKey(appId)) { - synchronized (applicationIdToTopologyLockMap) { - if (!applicationIdToTopologyLockMap.containsKey(appId)) { - applicationIdToTopologyLockMap.put(appId, topologyLock); - log.info("Added lock for Application " + appId); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("Topology Lock for Application " + appId + " already exists"); - } - } - } - - public TopologyLock getTopologyLockForApplication (String appId) { - return applicationIdToTopologyLockMap.get(appId); - } - public void addServiceLock (String serviceName, final TopologyLock topologyLock) { if (!serviceNameToTopologyLockMap.containsKey(serviceName)) { @@ -132,16 +104,6 @@ public TopologyLock getTopologyLockForCluster (String clusterId) { return clusterIdToTopologyLockMap.get(clusterId); } - public void removeTopologyLockForApplication (String appId) { - if (applicationIdToTopologyLockMap.remove(appId) != null) { - log.info("Removed lock for Application " + appId); - } else { - if (log.isDebugEnabled()) { - log.debug("Lock already removed for Application " + appId); - } - } - } - public void removeTopologyLockForService (String serviceName) { if (serviceNameToTopologyLockMap.remove(serviceName) != null) { log.info("Removed lock for Service " + serviceName); @@ -166,10 +128,6 @@ public TopologyLock getServiceLock() { return serviceLock; } - public TopologyLock getApplicatioLock() { - return applicatioLock; - } - public TopologyLock getCompleteTopologyLock() { return completeTopologyLock; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java index 6c82925e17..da75265a50 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java @@ -22,9 +22,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -46,40 +48,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationActivatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event ApplicationActivatedEvent event = (ApplicationActivatedEvent) Util. jsonToObject(message, ApplicationActivatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { + private boolean doProcess(ApplicationActivatedEvent event, Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -87,7 +89,7 @@ private boolean doProcess(ApplicationActivatedEvent event, Topology topology) { } return false; } else { - // Apply changes to the topology + // Apply changes to the applications if (!application.isStateTransitionValid(ApplicationStatus.Active)) { log.error("Invalid State transfer from [ " + application.getStatus() + " ] to [ " + ApplicationStatus.Active + " ]"); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java index db8e3c85a9..cfe850032a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationCreatedMessageProcessor.java @@ -22,15 +22,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.util.Util; -import java.util.Set; - public class ApplicationCreatedMessageProcessor extends MessageProcessor { private static final Log log = LogFactory.getLog(ApplicationCreatedMessageProcessor.class); @@ -57,12 +53,12 @@ public boolean process(String type, String message, Object object) { return false; } - TopologyUpdater.acquireWriteLockForApplications(); + ApplicationsUpdater.acquireWriteLockForApplications(); try { return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplications(); + ApplicationsUpdater.releaseWriteLockForApplications(); } } else { @@ -75,7 +71,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess(ApplicationCreatedEvent event, Applications topology) { + private boolean doProcess(ApplicationCreatedEvent event, Applications applications) { // check if required properties are available if (event.getApplication() == null) { @@ -90,13 +86,13 @@ private boolean doProcess(ApplicationCreatedEvent event, Applications topology) throw new RuntimeException(errorMsg); } - // check if an Application with same name exists in topology - if (topology.applicationExists(event.getApplication().getUniqueIdentifier())) { + // check if an Application with same name exists in applications + if (applications.applicationExists(event.getApplication().getUniqueIdentifier())) { log.warn("Application with id [ " + event.getApplication().getUniqueIdentifier() + " ] already exists in Topology"); } else { // add application and the clusters to Topology - topology.addApplication(event.getApplication()); + applications.addApplication(event.getApplication()); } notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java index 91eae8cf06..e97e3fcea1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java @@ -22,9 +22,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -46,40 +48,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationInactivatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event ApplicationInactivatedEvent event = (ApplicationInactivatedEvent) Util. jsonToObject(message, ApplicationInactivatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) { + private boolean doProcess (ApplicationInactivatedEvent event, Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -87,7 +89,7 @@ private boolean doProcess (ApplicationInactivatedEvent event, Topology topology) } return false; } else { - // Apply changes to the topology + // Apply changes to the applications if (!application.isStateTransitionValid(ApplicationStatus.Inactive)) { log.error("Invalid State transfer from [ " + application.getStatus() + " ] to [ " + ApplicationStatus.Inactive + " ]"); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java index 8cd21826a6..99d08fe67a 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java @@ -20,10 +20,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -47,18 +49,18 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationTerminatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event ApplicationTerminatedEvent event = (ApplicationTerminatedEvent) Util. jsonToObject(message, ApplicationTerminatedEvent.class); - TopologyUpdater.acquireWriteLockForApplications(); + ApplicationsUpdater.acquireWriteLockForApplications(); Set clusterDataHolders = event.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { @@ -67,10 +69,10 @@ public boolean process(String type, String message, Object object) { } try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplications(); + ApplicationsUpdater.releaseWriteLockForApplications(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { TopologyUpdater.releaseWriteLockForService(clusterData.getServiceType()); @@ -81,14 +83,14 @@ public boolean process(String type, String message, Object object) { } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) { + private boolean doProcess (ApplicationTerminatedEvent event, Applications applications) { // check if required properties are available if (event.getAppId() == null) { @@ -103,25 +105,26 @@ private boolean doProcess (ApplicationTerminatedEvent event, Topology topology) throw new RuntimeException(errorMsg); } - // check if an Application with same name exists in topology + // check if an Application with same name exists in applications String appId = event.getAppId(); - if (topology.applicationExists(appId)) { + if (applications.applicationExists(appId)) { log.warn("Application with id [ " + appId + " ] still exists in Topology, removing it"); - topology.removeApplication(appId); + applications.removeApplication(appId); } if (event.getClusterData() != null) { // remove the Clusters from the Topology for (ClusterDataHolder clusterData : event.getClusterData()) { - Service service = topology.getService(clusterData.getServiceType()); - if (service != null) { - service.removeCluster(clusterData.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); - } - } else { - log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); - } + log.info("################################ TODO ################################"); +// Service service = applications.getService(clusterData.getServiceType()); +// if (service != null) { +// service.removeCluster(clusterData.getClusterId()); +// if (log.isDebugEnabled()) { +// log.debug("Removed the Cluster " + clusterData.getClusterId() + " from Topology"); +// } +// } else { +// log.warn("Service " + clusterData.getServiceType() + " not found in Topology!"); +// } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java index 057d013278..633e080443 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java @@ -22,9 +22,11 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -46,40 +48,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationTerminatingEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event ApplicationTerminatingEvent event = (ApplicationTerminatingEvent) Util. jsonToObject(message, ApplicationTerminatingEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) { + private boolean doProcess (ApplicationTerminatingEvent event, Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -87,7 +89,7 @@ private boolean doProcess (ApplicationTerminatingEvent event, Topology topology) } return false; } else { - // Apply changes to the topology + // Apply changes to the applications if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { log.error("Invalid State transfer from [ " + application.getStatus() + " ] to [ " + ApplicationStatus.Terminating + " ]"); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java index 7e91ab8a42..e911b7776e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java @@ -23,10 +23,12 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -46,10 +48,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (ApplicationUndeployedEvent.class.getName().equals(type)) { - if (!topology.isInitialized()) { + if (!applications.isInitialized()) { return false; } @@ -61,7 +63,7 @@ public boolean process(String type, String message, Object object) { } // get write lock for the application and relevant Clusters - TopologyUpdater.acquireWriteLockForApplication(event.getApplicationId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getApplicationId()); Set clusterDataHolders = event.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { @@ -71,7 +73,7 @@ public boolean process(String type, String message, Object object) { } try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { // remove locks @@ -81,13 +83,13 @@ public boolean process(String type, String message, Object object) { clusterData.getClusterId()); } } - TopologyUpdater.releaseWriteLockForApplication(event.getApplicationId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getApplicationId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format ("Failed to process message using available message processors: [type] %s [body] %s", type, message)); @@ -95,10 +97,10 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) { + private boolean doProcess (ApplicationUndeployedEvent event, Applications applications) { // update the application status to Terminating - Application application = topology.getApplication(event.getApplicationId()); + Application application = applications.getApplication(event.getApplicationId()); // check and update application status to 'Terminating' if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); @@ -110,27 +112,28 @@ private boolean doProcess (ApplicationUndeployedEvent event, Topology topology) Set clusterData = application.getClusterDataRecursively(); // update the Cluster statuses to Terminating for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Topology"); - } - - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); - } + log.info("############################### TODO ###############################"); +// Service service = applications.getService(clusterDataHolder.getServiceType()); +// if (service != null) { +// Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); +// if (aCluster != null) { +// // validate state transition +// if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { +// log.error("Invalid state transfer from " + aCluster.getStatus() + " to " +// + ClusterStatus.Terminating); +// } +// // for now anyway update the status forcefully +// aCluster.setStatus(ClusterStatus.Terminating); +// +// } else { +// log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + +// " in Topology"); +// } +// +// } else { +// log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + +// " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); +// } } notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java index 53c469b265..c9af67a1e7 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java @@ -22,25 +22,12 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.Member; -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; -import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; import org.apache.stratos.messaging.event.applications.CompleteApplicationsEvent; -import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent; -import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; -import org.apache.stratos.messaging.message.filter.topology.TopologyMemberFilter; -import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; public class CompleteApplicationsMessageProcessor extends MessageProcessor { @@ -62,13 +49,13 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, CompleteApplicationsEvent.class); if (!applications.isInitialized()) { - ApplicationsUpdater.acquireWriteLock(); + ApplicationsUpdater.acquireWriteLockForApplications(); try { doProcess(event, applications); } finally { - ApplicationsUpdater.releaseWriteLock(); + ApplicationsUpdater.releaseWriteLockForApplications(); } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java index 845e933d1e..5c8d477435 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java @@ -21,11 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -43,40 +45,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (GroupActivatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event GroupActivatedEvent event = (GroupActivatedEvent) Util. jsonToObject(message, GroupActivatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (GroupActivatedEvent event,Topology topology) { + private boolean doProcess (GroupActivatedEvent event, Applications applications) { // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java index 47d445737b..67861e4984 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java @@ -21,11 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupCreatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -43,40 +45,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (GroupCreatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event GroupCreatedEvent event = (GroupCreatedEvent) Util. jsonToObject(message, GroupCreatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (GroupCreatedEvent event,Topology topology) { + private boolean doProcess (GroupCreatedEvent event,Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -92,7 +94,7 @@ private boolean doProcess (GroupCreatedEvent event,Topology topology) { event.getGroupId())); } } else { - // Apply changes to the topology + // Apply changes to the applications if (!group.isStateTransitionValid(GroupStatus.Created)) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " + "for Group " + group.getAlias()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java index 063a3de382..4f2e581bca 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java @@ -21,11 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -43,40 +45,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (GroupInactivateEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event GroupInactivateEvent event = (GroupInactivateEvent) Util. jsonToObject(message, GroupInactivateEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess(GroupInactivateEvent event, Topology topology) { + private boolean doProcess(GroupInactivateEvent event, Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java index 3de09146e9..6e985b7575 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java @@ -21,11 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -43,40 +45,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (GroupTerminatedEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event GroupTerminatedEvent event = (GroupTerminatedEvent) Util. jsonToObject(message, GroupTerminatedEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (GroupTerminatedEvent event,Topology topology) { + private boolean doProcess (GroupTerminatedEvent event, Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -92,7 +94,7 @@ private boolean doProcess (GroupTerminatedEvent event,Topology topology) { event.getGroupId())); } } else { - // Apply changes to the topology + // Apply changes to the applications if (!group.isStateTransitionValid(GroupStatus.Terminated)) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Terminated); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java index e124b7b602..c9a136f863 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java @@ -21,11 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; @@ -43,40 +45,40 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - Topology topology = (Topology) object; + Applications applications = (Applications) object; if (GroupTerminatingEvent.class.getName().equals(type)) { - // Return if topology has not been initialized - if (!topology.isInitialized()) + // Return if applications has not been initialized + if (!applications.isInitialized()) return false; // Parse complete message and build event GroupTerminatingEvent event = (GroupTerminatingEvent) Util. jsonToObject(message, GroupTerminatingEvent.class); - TopologyUpdater.acquireWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); try { - return doProcess(event, topology); + return doProcess(event, applications); } finally { - TopologyUpdater.releaseWriteLockForApplication(event.getAppId()); + ApplicationsUpdater.releaseWriteLockForApplication(event.getAppId()); } } else { if (nextProcessor != null) { // ask the next processor to take care of the message. - return nextProcessor.process(type, message, topology); + return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (GroupTerminatingEvent event,Topology topology) { + private boolean doProcess (GroupTerminatingEvent event,Applications applications) { - // Validate event against the existing topology - Application application = topology.getApplication(event.getAppId()); + // Validate event against the existing applications + Application application = applications.getApplication(event.getAppId()); if (application == null) { if (log.isWarnEnabled()) { log.warn(String.format("Application does not exist: [service] %s", @@ -92,7 +94,7 @@ private boolean doProcess (GroupTerminatingEvent event,Topology topology) { event.getGroupId())); } } else { - // Apply changes to the topology + // Apply changes to the applications if (!group.isStateTransitionValid(GroupStatus.Terminating)) { log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Active); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java index bbbfbf5c0a..e987abfebb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java @@ -23,8 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock; import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy; -import org.apache.stratos.messaging.domain.topology.locking.TopologyLock; -import org.apache.stratos.messaging.domain.topology.locking.TopologyLockHierarchy; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; /** @@ -67,21 +66,21 @@ public class ApplicationsUpdater { // Top level locks - should be used to lock the entire Topology /** - * Acquires write lock for the Complete Topology + * Acquires write lock for all Applications */ - public static void acquireWriteLock() { + public static void acquireWriteLockForApplications() { if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Topology"); + log.debug("Write lock acquired for Applications"); } applicationLockHierarchy.getApplicationLock().acquireWriteLock(); } /** - * Releases write lock for the Complete Topology + * Releases write lock for all Applications */ - public static void releaseWriteLock() { + public static void releaseWriteLockForApplications() { if(log.isDebugEnabled()) { - log.debug("Write lock released for Topology"); + log.debug("Write lock released for Applications"); } applicationLockHierarchy.getApplicationLock().releaseWritelock(); } @@ -94,9 +93,9 @@ public static void releaseWriteLock() { public static void acquireWriteLockForApplication (String appId) { // acquire read lock for all Applications - TopologyManager.acquireReadLockForApplications(); + ApplicationManager.acquireReadLockForApplications(); - ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId); + ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId); if (applicationLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); @@ -116,7 +115,7 @@ public static void acquireWriteLockForApplication (String appId) { */ public static void releaseWriteLockForApplication (String appId) { - ApplicationLock applicationLock = applicationLockHierarchy.getLock(appId); + ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId); if (applicationLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); @@ -129,7 +128,7 @@ public static void releaseWriteLockForApplication (String appId) { } // release read lock for all Applications - TopologyManager.releaseReadLockForApplications(); + ApplicationManager.releaseReadLockForApplications(); } private static void handleLockNotFound (String errorMsg) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java index 787ac74138..ea1f83b3c1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/CompleteTopologyMessageProcessor.java @@ -149,21 +149,6 @@ private void doProcess (CompleteTopologyEvent event, Topology topology) { } } - // add existing Applications to Topology - Collection applications = event.getTopology().getApplications(); - if (applications != null && !applications.isEmpty()) { - for (Application application : applications) { - topology.addApplication(application); - if (log.isDebugEnabled()) { - log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology"); - } - } - } else { - if (log.isDebugEnabled()) { - log.debug("No Application information found in Complete Topology event"); - } - } - if (log.isInfoEnabled()) { log.info("Topology initialized"); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java index 9867223f06..e4b1c6657b 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/updater/TopologyUpdater.java @@ -83,27 +83,7 @@ public static void releaseWriteLock() { topologyLockHierarchy.getCompleteTopologyLock().releaseWritelock(); } - // Application and Service write locks - /** - * Acquires write lock for the all Applications - */ - public static void acquireWriteLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Applications"); - } - topologyLockHierarchy.getApplicatioLock().acquireWriteLock(); - } - - /** - * Releases write lock for the all Applications - */ - public static void releaseWriteLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Write lock released for Applications"); - } - topologyLockHierarchy.getApplicatioLock().releaseWritelock(); - } - + // Service write locks /** * Acquires write lock for the all Services */ @@ -218,52 +198,6 @@ public static void releaseWriteLockForCluster (String serviceName, String cluste TopologyManager.releaseReadLockForService(serviceName); } - /** - * Acquires write lock for the Application - * - * @param appId Application id - */ - public static void acquireWriteLockForApplication (String appId) { - - // acquire read lock for all Applications - TopologyManager.acquireReadLockForApplications(); - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // now, lock Application - topologyAppLock.acquireWriteLock(); - if(log.isDebugEnabled()) { - log.debug("Write lock acquired for Application " + appId); - } - } - } - - /** - * Releases write lock for the Application - * - * @param appId Application id - */ - public static void releaseWriteLockForApplication (String appId) { - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // release App lock - topologyAppLock.releaseWritelock(); - if(log.isDebugEnabled()) { - log.debug("Write lock released for Application " + appId); - } - } - - // release read lock for all Applications - TopologyManager.releaseReadLockForApplications(); - } - private static void handleLockNotFound (String errorMsg) { log.warn(errorMsg); //throw new RuntimeException(errorMsg); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.java new file mode 100644 index 0000000000..0c3aa0e23e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationManager.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.messaging.message.receiver.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.domain.applications.Applications; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock; +import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy; + +public class ApplicationManager { + + private static final Log log = LogFactory.getLog(ApplicationManager.class); + + private static volatile Applications applications; + private static volatile ApplicationLockHierarchy applicationLockHierarchy = + ApplicationLockHierarchy.getInstance(); + + public static Applications getApplications () { + + if (applications == null) { + synchronized (ApplicationManager.class){ + if (applications == null) { + applications = new Applications(); + if(log.isDebugEnabled()) { + log.debug("Applications object created"); + } + } + } + } + return applications; + } + + /** + * Acquires read lock for all Applications + */ + public static void acquireReadLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Applications"); + } + applicationLockHierarchy.getApplicationLock().acquireReadLock(); + } + + /** + * Releases read lock for all Applications + */ + public static void releaseReadLockForApplications() { + if(log.isDebugEnabled()) { + log.debug("Read lock released for Applications"); + } + applicationLockHierarchy.getApplicationLock().releaseReadLock(); + } + + /** + * Acquires read lock for an Application + * + * @param applicationId Application Id to acquire read lock + */ + public static void acquireReadLockForApplication(String applicationId) { + + // acquire read lock for all Applications + acquireReadLockForApplications(); + + ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId); + if (applicationLock == null) { + handleLockNotFound("Application lock not found for Application " + applicationId); + + } else { + applicationLock.acquireReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock acquired for Application " + applicationId); + } + } + } + + /** + * Releases read lock for an Application + * + * @param applicationId Application Id to release read lock + */ + public static void releaseReadLockForApplication(String applicationId) { + + ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(applicationId); + if (applicationLock == null) { + handleLockNotFound("Application lock not found for Application " + applicationId); + + } else { + applicationLock.releaseReadLock(); + if(log.isDebugEnabled()) { + log.debug("Read lock released for Application " + applicationId); + } + } + + // release read lock for all Applications + releaseReadLockForApplications(); + } + + private static void handleLockNotFound (String errorMsg) { + log.warn(errorMsg); + //throw new RuntimeException(errorMsg); + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java index 1d74616f70..159e128973 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/topology/TopologyManager.java @@ -85,26 +85,7 @@ public static void releaseReadLock() { topologyLockHierarchy.getCompleteTopologyLock().releaseReadLock(); } - // Application and Service read locks - /** - * Acquires read lock for the all Applications - */ - public static void acquireReadLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Read lock acquired for Applications"); - } - topologyLockHierarchy.getApplicatioLock().acquireReadLock(); - } - - /** - * Releases read lock for the all Applications - */ - public static void releaseReadLockForApplications() { - if(log.isDebugEnabled()) { - log.debug("Read lock released for Applications"); - } - topologyLockHierarchy.getApplicatioLock().releaseReadLock(); - } + // Service read locks /** * Acquires read lock for the all Services @@ -222,52 +203,6 @@ public static void releaseReadLockForCluster (String serviceName, String cluster releaseReadLockForService(serviceName); } - /** - * Acquires read lock for the Application - * - * @param appId Application id - */ - public static void acquireReadLockForApplication (String appId) { - - // acquire read lock for all Applications - acquireReadLockForApplications(); - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // now, lock Application - topologyAppLock.acquireReadLock(); - if(log.isDebugEnabled()) { - log.debug("Read lock acquired for Application " + appId); - } - } - } - - /** - * Releases read lock for the Application - * - * @param appId Application id - */ - public static void releaseReadLockForApplication (String appId) { - - TopologyLock topologyAppLock = topologyLockHierarchy.getTopologyLockForApplication(appId); - if (topologyAppLock == null) { - handleLockNotFound("Topology lock not found for Application " + appId); - - } else { - // release App lock - topologyAppLock.releaseReadLock(); - if(log.isDebugEnabled()) { - log.debug("Read lock released for Application " + appId); - } - } - - // release read lock for all Applications - releaseReadLockForApplications(); - } - private static void handleLockNotFound (String errorMsg) { log.warn(errorMsg); //throw new RuntimeException(errorMsg); From 226b8709e09e91c3f2f86eb679d7f1adbb0ce108 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 16:05:28 +0530 Subject: [PATCH 341/436] moving application stuff to Autoscaler --- .../controller/topology/TopologyBuilder.java | 103 ------------------ .../topology/TopologyEventPublisher.java | 12 +- .../StratosManagerTopologyEventReceiver.java | 13 ++- .../rest/endpoint/services/ServiceUtils.java | 7 +- 4 files changed, 17 insertions(+), 118 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 7ee342e127..5c25297bbd 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -655,109 +655,6 @@ private static void deleteAppResourcesFromMetadataService(ApplicationTerminatedE } } - public static void handleGroupInActiveEvent(AppStatusGroupInactivateEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - - Group group = application.getGroupRecursively(event.getGroupId()); - if (group == null) { - log.warn(String.format("Group %s does not exist", - event.getGroupId())); - return; - } - - org.apache.stratos.messaging.event.topology.GroupInactivateEvent groupInActivateEvent = - new org.apache.stratos.messaging.event.topology.GroupInactivateEvent( - event.getAppId(), - event.getGroupId()); - try { - TopologyManager.acquireWriteLock(); - group.setStatus(GroupStatus.Inactive); - log.info("Group in-active adding status started for" + group.getUniqueIdentifier()); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendGroupInActiveEvent(groupInActivateEvent); - } - - - public static void handleGroupTerminatedEvent(GroupTerminatedEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - - Group group = application.getGroupRecursively(event.getGroupId()); - if (group == null) { - log.warn(String.format("Group %s does not exist", - event.getGroupId())); - return; - } - - org.apache.stratos.messaging.event.topology.GroupTerminatedEvent groupTerminatedTopologyEvent = - new org.apache.stratos.messaging.event.topology.GroupTerminatedEvent( - event.getAppId(), - event.getGroupId()); - try { - TopologyManager.acquireWriteLock(); - group.setStatus(GroupStatus.Terminated); - log.info("Group Terminated adding status started for" + group.getUniqueIdentifier()); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendGroupTerminatedEvent(groupTerminatedTopologyEvent); - } - - public static void handleGroupTerminatingEvent(GroupTerminatingEvent event) { - Topology topology = TopologyManager.getTopology(); - Application application = topology.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - - Group group = application.getGroupRecursively(event.getGroupId()); - if (group == null) { - log.warn(String.format("Group %s does not exist", - event.getGroupId())); - return; - } - - org.apache.stratos.messaging.event.topology.GroupTerminatingEvent groupTerminatingTopologyEvent = - new org.apache.stratos.messaging.event.topology.GroupTerminatingEvent( - event.getAppId(), - event.getGroupId()); - try { - TopologyManager.acquireWriteLock(); - group.setStatus(GroupStatus.Terminating); - log.info("Group Terminating adding status started for " + group.getUniqueIdentifier()); - - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - //publishing data - TopologyEventPublisher.sendGroupTerminatingEvent(groupTerminatingTopologyEvent); - } - public static void handleClusterTerminatedEvent(ClusterStatusClusterTerminatedEvent event) { TopologyManager.acquireWriteLock(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 2e0883b421..eb1fb7f70b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -78,12 +78,12 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster()); - - if(log.isInfoEnabled()) { - log.info("Publishing cluster created event: " +clusterId); - } - publishEvent(clusterCreatedEvent); +// ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster()); +// +// if(log.isInfoEnabled()) { +// log.info("Publishing cluster created event: " +clusterId); +// } +// publishEvent(clusterCreatedEvent); } public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) { 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 index a0856645e7..d4446c477a 100644 --- 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 @@ -92,21 +92,22 @@ protected void onEvent(Event event) { ClusterCreatedEvent clustercreatedEvent = (ClusterCreatedEvent) event; - String serviceType = clustercreatedEvent.getServiceName(); + String serviceType = clustercreatedEvent.getCluster().getServiceName(); //acquire read lock //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getServiceName(), - clustercreatedEvent.getClusterId()); + TopologyManager.acquireReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(), + clustercreatedEvent.getCluster().getClusterId()); try { - Cluster cluster = TopologyManager.getTopology().getService(serviceType).getCluster(clustercreatedEvent.getClusterId()); + Cluster cluster = TopologyManager.getTopology().getService(serviceType). + getCluster(clustercreatedEvent.getCluster().getClusterId()); TopologyClusterInformationModel.getInstance().addCluster(cluster); } finally { //release read lock //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getServiceName(), - clustercreatedEvent.getClusterId()); + TopologyManager.releaseReadLockForCluster(clustercreatedEvent.getCluster().getServiceName(), + clustercreatedEvent.getCluster().getClusterId()); } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 9037f3376f..2b99f1412f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -54,6 +54,7 @@ import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.messaging.util.Constants; import org.apache.stratos.rest.endpoint.bean.ApplicationBean; @@ -1449,8 +1450,8 @@ static void undeployServiceGroupDefinition (String serviceGroupDefinitionName) t public static ApplicationBean getApplicationInfo(String applicationId, ConfigurationContext configContext) { ApplicationBean applicationBean = null; try{ - TopologyManager.acquireReadLockForApplication(applicationId); - Application application = TopologyManager.getTopology().getApplication(applicationId); + ApplicationManager.acquireReadLockForApplication(applicationId); + Application application = ApplicationManager.getApplications().getApplication(applicationId); if(application == null){ return null; } @@ -1480,7 +1481,7 @@ public static ApplicationBean getApplicationInfo(String applicationId, Configura applicationBean.addGroup(groupBean); } }finally { - TopologyManager.releaseReadLockForApplication(applicationId); + ApplicationManager.releaseReadLockForApplication(applicationId); } From ff2e971d6dfad83fbc29d5d5380bf3af6fe4d98c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 16:21:22 +0530 Subject: [PATCH 342/436] ApplicationSynchronizerTask initial impl. --- .../applications/ApplicationSynchronizerTask.java | 9 ++++++++- .../applications/topic/ApplicationsEventPublisher.java | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java index 571e7a8957..a8ce042120 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java @@ -19,6 +19,9 @@ package org.apache.stratos.autoscaler.applications; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; +import org.apache.stratos.messaging.domain.applications.Applications; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.wso2.carbon.ntask.core.Task; import java.util.Map; @@ -38,6 +41,10 @@ public void init() { @Override public void execute() { - + Applications applications = ApplicationManager.getApplications(); + if (applications != null) { + // publish complete Applications event + ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications); + } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index bdbffc0154..0a0b2616ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -18,6 +18,10 @@ public class ApplicationsEventPublisher { private static final Log log = LogFactory.getLog(ApplicationsEventPublisher.class); + public static void sendCompleteApplicationsEvent (Applications completeApplications) { + + publishEvent(new CompleteApplicationsEvent(completeApplications)); + } public static void sendGroupCreatedEvent(String appId, String groupId) { try { From 746c37ae022c5771b406b92e249cc4cb23f5515a Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 16:25:24 +0530 Subject: [PATCH 343/436] fixing merge issue --- .../ApplicationStatusTopicReceiver.java | 7 ++ .../controller/topology/TopologyBuilder.java | 71 ++++++++-------- .../topology/TopologyEventPublisher.java | 23 +++-- .../messaging/domain/topology/Cluster.java | 6 +- .../ClusterStatusClusterCreatedEvent.java | 85 +++++++++++++++++++ ...sterStatusClusterCreatedEventListener.java | 24 ++++++ ...tatusClusterActivatedMessageProcessor.java | 2 +- ...rStatusClusterCreatedMessageProcessor.java | 59 +++++++++++++ ...atusClusterInactivateMessageProcessor.java | 2 +- ...terStatusClusterResetMessageProcessor.java | 2 +- ...atusClusterTerminatedMessageProcessor.java | 2 +- ...tusClusterTerminatingMessageProcessor.java | 2 +- .../ClusterStatusMessageProcessorChain.java | 16 ++-- 13 files changed, 249 insertions(+), 52 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java index d75039d592..1fe14fdef4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java @@ -71,6 +71,13 @@ protected void onEvent(Event event) { } }); + statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() { + @Override + protected void onEvent(Event event) { + TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event); + } + }); + statusEventReceiver.addEventListener(new ClusterStatusClusterActivatedEventListener() { @Override protected void onEvent(Event event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 5c25297bbd..e70d1824d2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -119,7 +119,42 @@ public static void handleServiceRemoved(List cartridgeList) { } } - public static void handleClusterCreated(ClusterStatusClusterResettedEvent event) { + public static void handleClusterCreated(ClusterStatusClusterCreatedEvent event) { + TopologyManager.acquireWriteLock(); + Cluster cluster; + + try { + Topology topology = TopologyManager.getTopology(); + Service service = topology.getService(event.getServiceName()); + if (service == null) { + log.error("Service " + event.getServiceName() + + " not found in Topology, unable to update the cluster status to Created"); + return; + } + + if (service.clusterExists(event.getClusterId())) { + log.warn("Cluster " + event.getClusterId() + " is already in the Topology "); + return; + } else { + cluster = new Cluster(event.getServiceName(), + event.getClusterId(), event.getDeploymentPolicyName(), + event.getAutosScalePolicyName(), event.getAppId()); + //cluster.setStatus(Status.Created); + cluster.setHostNames(event.getHostNames()); + cluster.setTenantRange(event.getTenantRange()); + cluster.setStatus(ClusterStatus.Created); + service.addCluster(cluster); + TopologyManager.updateTopology(topology); + } + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendClusterCreatedEvent(cluster); + } + + + public static void handleClusterReset(ClusterStatusClusterResettedEvent event) { TopologyManager.acquireWriteLock(); @@ -152,7 +187,7 @@ public static void handleClusterCreated(ClusterStatusClusterResettedEvent event) TopologyManager.releaseWriteLock(); } - TopologyEventPublisher.sendClusterCreatedEvent(event.getAppId(), event.getServiceName(), + TopologyEventPublisher.sendClusterResetEvent(event.getAppId(), event.getServiceName(), event.getClusterId()); } @@ -231,38 +266,6 @@ public static void handleClusterRemoved(ClusterContext ctxt) { TopologyEventPublisher.sendClusterRemovedEvent(ctxt, deploymentPolicy); } - /*public static void handleClusterMaintenanceMode(ClusterContext ctxt) { - - Topology topology = TopologyManager.getTopology(); - Service service = topology.getService(ctxt.getCartridgeType()); - if (service == null) { - log.warn(String.format("Service %s does not exist", - ctxt.getCartridgeType())); - return; - } - - if (!service.clusterExists(ctxt.getClusterId())) { - log.warn(String.format("Cluster %s does not exist for service %s", - ctxt.getClusterId(), - ctxt.getCartridgeType())); - return; - } - - try { - TopologyManager.acquireWriteLock(); - Cluster cluster = service.getCluster(ctxt.getClusterId()); - if (!cluster.isStateTransitionValid(ClusterStatus.Inactive)) { - log.error("Invalid State Transition from " + cluster.getStatus() + " to " + ClusterStatus.Inactive); - } - cluster.setStatus(ClusterStatus.Inactive); - TopologyManager.updateTopology(topology); - } finally { - TopologyManager.releaseWriteLock(); - } - TopologyEventPublisher.sendClusterMaintenanceModeEvent(ctxt); - }*/ - - public static void handleMemberSpawned(String serviceName, String clusterId, String partitionId, String privateIp, String publicIp, MemberContext context) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index eb1fb7f70b..3f580804fb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -77,13 +77,22 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } } - public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { -// ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(new Cluster()); -// -// if(log.isInfoEnabled()) { -// log.info("Publishing cluster created event: " +clusterId); -// } -// publishEvent(clusterCreatedEvent); + public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) { + ClusterResetEvent clusterResetEvent = new ClusterResetEvent(appId,serviceName, clusterId); + + if(log.isInfoEnabled()) { + log.info("Publishing cluster reset event: " + clusterId); + } + publishEvent(clusterResetEvent); + } + + public static void sendClusterCreatedEvent(Cluster cluster) { + ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(cluster); + + if(log.isInfoEnabled()) { + log.info("Publishing cluster created event: " + cluster.getClusterId()); + } + publishEvent(clusterCreatedEvent); } public static void sendApplicationCreatedEvent (ApplicationCreatedEvent applicationCreatedEvent) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java index 1f69fd65c3..eef5a761cb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/Cluster.java @@ -65,7 +65,7 @@ public Cluster(String serviceName, String clusterId, String deploymentPolicyName this.clusterId = clusterId; this.deploymentPolicyName = deploymentPolicyName; this.autoscalePolicyName = autoscalePolicyName; - this.hostNames = new ArrayList(); + this.setHostNames(new ArrayList()); this.memberMap = new HashMap(); this.appId = appId; this.clusterStateManager = new LifeCycleStateManager(ClusterStatus.Created, clusterId); @@ -250,6 +250,10 @@ public String getAppId() { return appId; } + public void setHostNames(List hostNames) { + this.hostNames = hostNames; + } + // public ClusterStatus getTempStatus() { // return status; // } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.java new file mode 100644 index 0000000000..5004cd8eb2 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterCreatedEvent.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.messaging.event.cluster.status; + +import org.apache.stratos.messaging.event.Event; + +import java.util.List; + +/** + * This event is fired by cartridge agent when it has started the server and + * applications are ready to serve the incoming requests. + */ +public class ClusterStatusClusterCreatedEvent extends Event { + private static final long serialVersionUID = 2625412714611885089L; + + private final String serviceName; + private final String clusterId; + private String appId; + private String autosScalePolicyName; + private String deploymentPolicyName; + private List hostNames; + private String tenantRange; + + public ClusterStatusClusterCreatedEvent(String appId, String serviceName, String clusterId, + String autosScalePolicyName, String deploymentPolicyName) { + this.serviceName = serviceName; + this.clusterId = clusterId; + this.appId = appId; + this.deploymentPolicyName = deploymentPolicyName; + this.autosScalePolicyName = autosScalePolicyName; + } + + public String getServiceName() { + return serviceName; + } + + public String getClusterId() { + return clusterId; + } + + public String getAppId() { + return appId; + } + + public String getAutosScalePolicyName() { + return autosScalePolicyName; + } + + public String getDeploymentPolicyName() { + return deploymentPolicyName; + } + + public List getHostNames() { + return hostNames; + } + + public void setHostNames(List hostNames) { + this.hostNames = hostNames; + } + + public String getTenantRange() { + return tenantRange; + } + + public void setTenantRange(String tenantRange) { + this.tenantRange = tenantRange; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java new file mode 100644 index 0000000000..6ca547686a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/cluster/status/ClusterStatusClusterCreatedEventListener.java @@ -0,0 +1,24 @@ +/* + * 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.messaging.listener.cluster.status; + +import org.apache.stratos.messaging.listener.EventListener; + +public abstract class ClusterStatusClusterCreatedEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java index 694c3f3ba4..92fe910bac 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterActivatedMessageProcessor.java @@ -42,7 +42,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ClusterStatusClusterActivatedEvent.class); if(log.isDebugEnabled()) { - log.debug("Received ClusterActivatedEvent: " + event.toString()); + log.debug("Received ClusterStatusClusterActivatedEvent: " + event.toString()); } // Notify event listeners notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java new file mode 100644 index 0000000000..d6bdcd7570 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.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.messaging.message.processor.cluster.status; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + + +public class ClusterStatusClusterCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ClusterStatusClusterCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (ClusterStatusClusterCreatedEvent.class.getName().equals(type)) { + // Parse complete message and build event + ClusterStatusClusterCreatedEvent event = (ClusterStatusClusterCreatedEvent) Util. + jsonToObject(message, ClusterStatusClusterCreatedEvent.class); + + if(log.isDebugEnabled()) { + log.debug("Received ClusterStatusClusterCreatedEvent: " + event.toString()); + } + // Notify event listeners + notifyEventListeners(event); + return true; + } else { + if (nextProcessor != null) { + return nextProcessor.process(type, message, object); + } else { + throw new RuntimeException(String.format("Failed to process cluster created message using available message processors: [type] %s [body] %s", type, message)); + } + } + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java index 69918e24f9..f169fa2128 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterInactivateMessageProcessor.java @@ -42,7 +42,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ClusterStatusClusterInactivateEvent.class); if(log.isDebugEnabled()) { - log.debug("Received ClusterInActivateEvent: " + event.toString()); + log.debug("Received ClusterStatusClusterInactivateEvent: " + event.toString()); } // Notify event listeners notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java index b5bf30112e..75bc0070d8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java @@ -42,7 +42,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ClusterStatusClusterResettedEvent.class); if(log.isDebugEnabled()) { - log.debug("Received AppStatusClusterCreatedEvent: " + event.toString()); + log.debug("Received ClusterStatusClusterResettedEvent: " + event.toString()); } // Notify event listeners notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java index 64b6c7bbee..04c09dbbee 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatedMessageProcessor.java @@ -42,7 +42,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ClusterStatusClusterTerminatedEvent.class); if (log.isDebugEnabled()) { - log.debug("Received AppStatusClusterTerminatedEvent: " + event.toString()); + log.debug("Received ClusterStatusClusterTerminatedEvent: " + event.toString()); } // Notify event listeners notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java index c161dd5f60..0db1896d09 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterTerminatingMessageProcessor.java @@ -42,7 +42,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ClusterStatusClusterTerminatingEvent.class); if(log.isDebugEnabled()) { - log.debug("Received AppStatusClusterTerminatingEvent: " + event.toString()); + log.debug("Received ClusterStatusClusterTerminatingEvent: " + event.toString()); } // Notify event listeners notifyEventListeners(event); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java index 42092bcc61..28689fb7d3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusMessageProcessorChain.java @@ -20,6 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent; import org.apache.stratos.messaging.listener.EventListener; import org.apache.stratos.messaging.listener.cluster.status.*; import org.apache.stratos.messaging.message.processor.MessageProcessorChain; @@ -30,17 +31,20 @@ public class ClusterStatusMessageProcessorChain extends MessageProcessorChain { private static final Log log = LogFactory.getLog(ClusterStatusMessageProcessorChain.class); - + private ClusterStatusClusterCreatedMessageProcessor clusterCreatedMessageProcessor; private ClusterStatusClusterActivatedMessageProcessor clusterActivatedMessageProcessor; - private ClusterStatusClusterResetMessageProcessor clusterCreatedMessageProcessor; + private ClusterStatusClusterResetMessageProcessor clusterResetMessageProcessor; private ClusterStatusClusterInactivateMessageProcessor clusterInactivateMessageProcessor; private ClusterStatusClusterTerminatedMessageProcessor clusterTerminatedMessageProcessor; private ClusterStatusClusterTerminatingMessageProcessor clusterTerminatingMessageProcessor; @Override protected void initialize() { - clusterCreatedMessageProcessor = new ClusterStatusClusterResetMessageProcessor(); + clusterCreatedMessageProcessor = new ClusterStatusClusterCreatedMessageProcessor(); add(clusterCreatedMessageProcessor); + clusterResetMessageProcessor = new ClusterStatusClusterResetMessageProcessor(); + add(clusterResetMessageProcessor); + clusterActivatedMessageProcessor = new ClusterStatusClusterActivatedMessageProcessor(); add(clusterActivatedMessageProcessor); @@ -60,8 +64,10 @@ protected void initialize() { @Override public void addEventListener(EventListener eventListener) { - if(eventListener instanceof ClusterStatusClusterResetEventListener) { - clusterCreatedMessageProcessor.addEventListener(eventListener); + if(eventListener instanceof ClusterStatusClusterCreatedEventListener) { + clusterResetMessageProcessor.addEventListener(eventListener); + } else if(eventListener instanceof ClusterStatusClusterResetEventListener) { + clusterResetMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterStatusClusterInactivateEventListener) { clusterInactivateMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterStatusClusterActivatedEventListener) { From 262f3635ab4d742538445d374e1fae5fd994b185 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Fri, 31 Oct 2014 16:28:32 +0530 Subject: [PATCH 344/436] Fixing merge issue in CloudControllerServiceImpl.deployCartridgeDefinition() method --- .../impl/CloudControllerServiceImpl.java | 36 +++++++++---------- .../domain/topology/ParentComponent.java | 2 +- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 34a611fea5..901082c86d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -155,25 +155,25 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In List iaases = cartridge.getIaases(); if (!StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType())) { - if (iaases == null || iaases.isEmpty()) { - String msg = "Invalid Cartridge Definition: Cartridge Type: " - + cartridgeConfig.getType() - + ". Cause: Iaases of this Cartridge is null or empty."; - LOG.error(msg); - throw new InvalidCartridgeDefinitionException(msg); - } + if (iaases == null || iaases.isEmpty()) { + String msg = "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType() + + ". Cause: Iaases of this Cartridge is null or empty."; + LOG.error(msg); + throw new InvalidCartridgeDefinitionException(msg); + } - if (iaases == null || iaases.isEmpty()) { - String msg = - "Invalid Cartridge Definition: Cartridge Type: " + - cartridgeConfig.getType()+ - ". Cause: Iaases of this Cartridge is null or empty."; - LOG.error(msg); - throw new InvalidCartridgeDefinitionException(msg); - } + if (iaases == null || iaases.isEmpty()) { + String msg = "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType() + + ". Cause: Iaases of this Cartridge is null or empty."; + LOG.error(msg); + throw new InvalidCartridgeDefinitionException(msg); + } - for (IaasProvider iaasProvider : iaases) { - CloudControllerUtil.getIaas(iaasProvider); + for (IaasProvider iaasProvider : iaases) { + CloudControllerUtil.getIaas(iaasProvider); + } } // TODO transaction begins @@ -201,8 +201,6 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In // transaction ends LOG.info("Successfully deployed the Cartridge definition: " + cartridgeType); - - } } private void populateNewCartridge(Cartridge cartridge, diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java index 86000e9748..1a80341153 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/topology/ParentComponent.java @@ -24,7 +24,7 @@ /** * Abstraction for a an entity that can have child entities - * in an Application withing the Topology + * in an Application within the Topology */ public abstract class ParentComponent implements Serializable { From eb523d79e9e25539ab8448de7c3079e7e1e8f5d4 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 16:42:09 +0530 Subject: [PATCH 345/436] updaing cluster status topic and refactoring --- .../topic/ApplicationBuilder.java | 7 -- .../topic/ApplicationsEventPublisher.java | 4 +- .../topic/ClusterStatusEventPublisher.java | 28 +++++++- .../status/checker/StatusChecker.java | 2 +- ...r.java => ClusterStatusTopicReceiver.java} | 16 ++--- .../internal/CloudControllerDSComponent.java | 13 ++-- .../controller/topology/TopologyBuilder.java | 8 +-- ...CreatedEvent.java => GroupResetEvent.java} | 4 +- ...va => ClusterStatusClusterResetEvent.java} | 4 +- ...ener.java => GroupResetEventListener.java} | 2 +- .../ApplicationActivatedMessageProcessor.java | 2 - ...pplicationInactivatedMessageProcessor.java | 4 +- ...ApplicationTerminatedMessageProcessor.java | 7 +- ...pplicationTerminatingMessageProcessor.java | 4 +- ...ApplicationUndeployedMessageProcessor.java | 5 +- .../ApplicationsMessageProcessorChain.java | 6 +- .../CompleteApplicationsMessageProcessor.java | 8 +-- .../applications/GroupActivatedProcessor.java | 4 +- .../GroupInActivateProcessor.java | 2 - ...rocessor.java => GroupResetProcessor.java} | 18 +++-- .../GroupTerminatedProcessor.java | 4 +- .../GroupTerminatingProcessor.java | 4 +- .../updater/ApplicationsUpdater.java | 71 +++++++++---------- ...rStatusClusterCreatedMessageProcessor.java | 1 - ...terStatusClusterResetMessageProcessor.java | 8 +-- .../topology/locking/TopologyLockingTest.java | 4 +- 26 files changed, 116 insertions(+), 124 deletions(-) rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/{ApplicationStatusTopicReceiver.java => ClusterStatusTopicReceiver.java} (87%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/{GroupCreatedEvent.java => GroupResetEvent.java} (91%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/{ClusterStatusClusterResettedEvent.java => ClusterStatusClusterResetEvent.java} (90%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/{GroupCreatedEventListener.java => GroupResetEventListener.java} (92%) rename components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/{GroupCreatedProcessor.java => GroupResetProcessor.java} (84%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 5aa05a2a09..9d4db75b7e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -22,13 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.messaging.domain.applications.*; -import org.apache.stratos.messaging.event.applications.*; -import org.apache.stratos.messaging.event.applications.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.applications.ApplicationInactivatedEvent; -import org.apache.stratos.messaging.event.applications.GroupActivatedEvent; -import org.apache.stratos.messaging.event.applications.GroupCreatedEvent; -import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; -import org.apache.stratos.messaging.event.topology.*; import java.util.Collection; import java.util.Set; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index 0a0b2616ca..bbeeca4787 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -34,8 +34,8 @@ public static void sendGroupCreatedEvent(String appId, String groupId) { log.info("Publishing Group created event for [application]: " + appId + " [group]: " + groupId); } - GroupCreatedEvent groupCreatedEvent = - new GroupCreatedEvent(appId, groupId); + GroupResetEvent groupCreatedEvent = + new GroupResetEvent(appId, groupId); publishEvent(groupCreatedEvent); } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java index 9a43418544..631a999fd5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java @@ -48,8 +48,32 @@ public static void sendClusterCreatedEvent(String appId, String serviceName, Str log.info("Publishing Cluster created event for [application]: " + appId + " [cluster]: " + clusterId); } - ClusterStatusClusterResettedEvent clusterCreatedEvent = - new ClusterStatusClusterResettedEvent(appId, serviceName, clusterId); + /*ClusterStatusClusterCreatedEvent clusterCreatedEvent = + new ClusterStatusClusterCreatedEvent(appId, serviceName, clusterId); + + publishEvent(clusterCreatedEvent);*/ + } else { + log.warn("Created is not in the possible state list of [cluster] " + clusterId); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(serviceName, clusterId); + } + } + + public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) { + try { + TopologyManager.acquireReadLockForCluster(serviceName, clusterId); + Service service = TopologyManager.getTopology().getService(serviceName); + if (service != null) { + Cluster cluster = service.getCluster(clusterId); + if (cluster.isStateTransitionValid(ClusterStatus.Created)) { + if (log.isInfoEnabled()) { + log.info("Publishing Cluster created event for [application]: " + appId + + " [cluster]: " + clusterId); + } + ClusterStatusClusterResetEvent clusterCreatedEvent = + new ClusterStatusClusterResetEvent(appId, serviceName, clusterId); publishEvent(clusterCreatedEvent); } else { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 5468f6d749..35864207eb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -107,7 +107,7 @@ public void run() { ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(), monitor.getClusterId()); } else { - ClusterStatusEventPublisher.sendClusterCreatedEvent(appId, monitor.getServiceId(), + ClusterStatusEventPublisher.sendClusterResetEvent(appId, monitor.getServiceId(), monitor.getClusterId()); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java similarity index 87% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java index 1fe14fdef4..4cc7599c7d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ApplicationStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java @@ -24,16 +24,16 @@ import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.listener.cluster.status.*; -import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver; +import org.apache.stratos.messaging.message.receiver.cluster.status.ClusterStatusEventReceiver; -public class ApplicationStatusTopicReceiver implements Runnable { - private static final Log log = LogFactory.getLog(ApplicationStatusTopicReceiver.class); +public class ClusterStatusTopicReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ClusterStatusTopicReceiver.class); - private ApplicationsEventReceiver statusEventReceiver; + private ClusterStatusEventReceiver statusEventReceiver; private boolean terminated; - public ApplicationStatusTopicReceiver() { - this.statusEventReceiver = new ApplicationsEventReceiver(); + public ClusterStatusTopicReceiver() { + this.statusEventReceiver = new ClusterStatusEventReceiver(); addEventListeners(); } @@ -67,14 +67,14 @@ private void addEventListeners() { statusEventReceiver.addEventListener(new ClusterStatusClusterResetEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event); + TopologyBuilder.handleClusterReset((ClusterStatusClusterResetEvent) event); } }); statusEventReceiver.addEventListener(new ClusterStatusClusterCreatedEventListener() { @Override protected void onEvent(Event event) { - TopologyBuilder.handleClusterCreated((ClusterStatusClusterResettedEvent) event); + TopologyBuilder.handleClusterCreated((ClusterStatusClusterCreatedEvent) event); } }); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 222cc154e4..8aa3d4fda3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.status.receiver.ApplicationStatusTopicReceiver; +import org.apache.stratos.cloud.controller.application.status.receiver.ClusterStatusTopicReceiver; import org.apache.stratos.cloud.controller.exception.CloudControllerException; import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; @@ -64,7 +64,7 @@ public class CloudControllerDSComponent { private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class); - private ApplicationStatusTopicReceiver applicationStatusTopicReceiver; + private ClusterStatusTopicReceiver clusterStatusTopicReceiver; protected void activate(ComponentContext context) { try { @@ -79,17 +79,18 @@ protected void activate(ComponentContext context) { Thread tdelegator = new Thread(delegator); tdelegator.start(); - applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver(); - Thread appThread = new Thread(applicationStatusTopicReceiver); + clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); + Thread appThread = new Thread(clusterStatusTopicReceiver); appThread.start(); if (log.isDebugEnabled()) { - log.debug("Application status Receiver thread started"); + log.debug("Cluster status Receiver thread started"); } // Register cloud controller service BundleContext bundleContext = context.getBundleContext(); - bundleContext.registerService(CloudControllerService.class.getName(), new CloudControllerServiceImpl(), null); + bundleContext.registerService(CloudControllerService.class.getName(), + new CloudControllerServiceImpl(), null); if(log.isInfoEnabled()) { log.info("Scheduling tasks"); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index e70d1824d2..0ec8f01d2e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -27,14 +27,8 @@ import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; -import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.Group; -import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.event.applications.AppStatusGroupInactivateEvent; import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.applications.GroupTerminatedEvent; -import org.apache.stratos.messaging.event.applications.GroupTerminatingEvent; import org.apache.stratos.messaging.event.cluster.status.*; import org.apache.stratos.messaging.event.instance.status.InstanceActivatedEvent; import org.apache.stratos.messaging.event.instance.status.InstanceMaintenanceModeEvent; @@ -154,7 +148,7 @@ public static void handleClusterCreated(ClusterStatusClusterCreatedEvent event) } - public static void handleClusterReset(ClusterStatusClusterResettedEvent event) { + public static void handleClusterReset(ClusterStatusClusterResetEvent event) { TopologyManager.acquireWriteLock(); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java similarity index 91% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java index 77336d2924..e0e7a910f1 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupCreatedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/applications/GroupResetEvent.java @@ -27,13 +27,13 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class GroupCreatedEvent extends Event implements Serializable { +public class GroupResetEvent extends Event implements Serializable { private static final long serialVersionUID = 2625412714611885089L; private String groupId; private String appId; - public GroupCreatedEvent(String appId, String groupId) { + public GroupResetEvent(String appId, String groupId) { this.appId = appId; this.groupId = groupId; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java similarity index 90% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java index 68c8e7fadf..eada57ea2d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResettedEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/cluster/status/ClusterStatusClusterResetEvent.java @@ -25,14 +25,14 @@ * This event is fired by cartridge agent when it has started the server and * applications are ready to serve the incoming requests. */ -public class ClusterStatusClusterResettedEvent extends Event { +public class ClusterStatusClusterResetEvent extends Event { private static final long serialVersionUID = 2625412714611885089L; private final String serviceName; private final String clusterId; private String appId; - public ClusterStatusClusterResettedEvent(String appId, String serviceName, String clusterId) { + public ClusterStatusClusterResetEvent(String appId, String serviceName, String clusterId) { this.serviceName = serviceName; this.clusterId = clusterId; this.appId = appId; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java similarity index 92% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java index f13ed103e9..b4b67ed839 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupCreatedEventListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/applications/GroupResetEventListener.java @@ -20,5 +20,5 @@ import org.apache.stratos.messaging.listener.EventListener; -public abstract class GroupCreatedEventListener extends EventListener { +public abstract class GroupResetEventListener extends EventListener { } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java index da75265a50..0fd16b33be 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationActivatedMessageProcessor.java @@ -23,11 +23,9 @@ import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java index e97e3fcea1..21a59061a8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationInactivatedMessageProcessor.java @@ -23,11 +23,9 @@ import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationInactivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -78,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationInactivatedEvent event, Applications applications) { + private boolean doProcess(ApplicationInactivatedEvent event, Applications applications) { // Validate event against the existing applications Application application = applications.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java index 99d08fe67a..9ffe785763 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatedMessageProcessor.java @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; @@ -61,7 +60,7 @@ public boolean process(String type, String message, Object object) { jsonToObject(message, ApplicationTerminatedEvent.class); ApplicationsUpdater.acquireWriteLockForApplications(); - Set clusterDataHolders = event.getClusterData(); + Set clusterDataHolders = event.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterData : clusterDataHolders) { TopologyUpdater.acquireWriteLockForService(clusterData.getServiceType()); @@ -90,7 +89,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationTerminatedEvent event, Applications applications) { + private boolean doProcess(ApplicationTerminatedEvent event, Applications applications) { // check if required properties are available if (event.getAppId() == null) { @@ -99,7 +98,7 @@ private boolean doProcess (ApplicationTerminatedEvent event, Applications applic throw new RuntimeException(errorMsg); } - if (event.getTenantDomain()== null) { + if (event.getTenantDomain() == null) { String errorMsg = "Application tenant domain of application removed event is invalid"; log.error(errorMsg); throw new RuntimeException(errorMsg); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java index 633e080443..9b69182215 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationTerminatingMessageProcessor.java @@ -23,11 +23,9 @@ import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -78,7 +76,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (ApplicationTerminatingEvent event, Applications applications) { + private boolean doProcess(ApplicationTerminatingEvent event, Applications applications) { // Validate event against the existing applications Application application = applications.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java index e911b7776e..5bf0d9f1fb 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationUndeployedMessageProcessor.java @@ -25,7 +25,6 @@ import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; @@ -92,12 +91,12 @@ public boolean process(String type, String message, Object object) { return nextProcessor.process(type, message, applications); } else { throw new RuntimeException(String.format - ("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + ("Failed to process message using available message processors: [type] %s [body] %s", type, message)); } } } - private boolean doProcess (ApplicationUndeployedEvent event, Applications applications) { + private boolean doProcess(ApplicationUndeployedEvent event, Applications applications) { // update the application status to Terminating Application application = applications.getApplication(event.getApplicationId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java index e75b6048f4..fb9858bcfe 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/ApplicationsMessageProcessorChain.java @@ -31,7 +31,7 @@ public class ApplicationsMessageProcessorChain extends MessageProcessorChain { private static final Log log = LogFactory.getLog(ApplicationsMessageProcessorChain.class); - private GroupCreatedProcessor groupCreatedMessageProcessor; + private GroupResetProcessor groupCreatedMessageProcessor; private GroupActivatedProcessor groupActivatedMessageProcessor; private GroupInActivateProcessor groupInActivateMessageProcessor; private GroupTerminatedProcessor groupTerminatedProcessor; @@ -46,7 +46,7 @@ public class ApplicationsMessageProcessorChain extends MessageProcessorChain { public void initialize() { // Add instance notifier event processors - groupCreatedMessageProcessor = new GroupCreatedProcessor(); + groupCreatedMessageProcessor = new GroupResetProcessor(); add(groupCreatedMessageProcessor); groupActivatedMessageProcessor = new GroupActivatedProcessor(); @@ -86,7 +86,7 @@ public void initialize() { public void addEventListener(EventListener eventListener) { - if(eventListener instanceof GroupCreatedEventListener) { + if (eventListener instanceof GroupResetEventListener) { groupCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GroupInactivateEventListener) { groupInActivateMessageProcessor.addEventListener(eventListener); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java index c9af67a1e7..190188e117 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/CompleteApplicationsMessageProcessor.java @@ -44,7 +44,7 @@ public boolean process(String type, String message, Object object) { Applications applications = (Applications) object; if (CompleteApplicationsEvent.class.getName().equals(type)) { - // Parse complete message and build event + // Parse complete message and build event CompleteApplicationsEvent event = (CompleteApplicationsEvent) Util. jsonToObject(message, CompleteApplicationsEvent.class); @@ -72,14 +72,14 @@ public boolean process(String type, String message, Object object) { } } - private void doProcess (CompleteApplicationsEvent event, Applications applications) { - // add existing Applications to Topology + private void doProcess(CompleteApplicationsEvent event, Applications applications) { + // add existing Applications to Topology Collection applicationsList = event.getApplications().getApplications().values(); if (applicationsList != null && !applicationsList.isEmpty()) { for (Application application : applicationsList) { applications.addApplication(application); if (log.isDebugEnabled()) { - log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology"); + log.debug("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology"); } } } else { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java index 5c8d477435..b73f703886 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupActivatedProcessor.java @@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; -import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -75,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (GroupActivatedEvent event, Applications applications) { + private boolean doProcess(GroupActivatedEvent event, Applications applications) { // Validate event against the existing topology Application application = applications.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java index 4f2e581bca..5df4a629df 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupInActivateProcessor.java @@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java similarity index 84% rename from components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java rename to components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java index 67861e4984..5c50e0b83d 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupCreatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupResetProcessor.java @@ -24,18 +24,16 @@ import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; -import org.apache.stratos.messaging.domain.topology.Topology; -import org.apache.stratos.messaging.event.topology.GroupCreatedEvent; +import org.apache.stratos.messaging.event.applications.GroupResetEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** * This processor will act upon the Group activation events */ -public class GroupCreatedProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(GroupCreatedProcessor.class); +public class GroupResetProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(GroupResetProcessor.class); private MessageProcessor nextProcessor; @Override @@ -47,14 +45,14 @@ public void setNext(MessageProcessor nextProcessor) { public boolean process(String type, String message, Object object) { Applications applications = (Applications) object; - if (GroupCreatedEvent.class.getName().equals(type)) { + if (GroupResetEvent.class.getName().equals(type)) { // Return if applications has not been initialized if (!applications.isInitialized()) return false; // Parse complete message and build event - GroupCreatedEvent event = (GroupCreatedEvent) Util. - jsonToObject(message, GroupCreatedEvent.class); + GroupResetEvent event = (GroupResetEvent) Util. + jsonToObject(message, GroupResetEvent.class); ApplicationsUpdater.acquireWriteLockForApplication(event.getAppId()); @@ -75,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (GroupCreatedEvent event,Applications applications) { + private boolean doProcess(GroupResetEvent event, Applications applications) { // Validate event against the existing applications Application application = applications.getApplication(event.getAppId()); @@ -96,7 +94,7 @@ private boolean doProcess (GroupCreatedEvent event,Applications applications) { } else { // Apply changes to the applications if (!group.isStateTransitionValid(GroupStatus.Created)) { - log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " + + log.error("Invalid State Transition from " + group.getStatus() + " to " + GroupStatus.Created + " " + "for Group " + group.getAlias()); } group.setStatus(GroupStatus.Created); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java index 6e985b7575..f03c21ec32 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatedProcessor.java @@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -75,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (GroupTerminatedEvent event, Applications applications) { + private boolean doProcess(GroupTerminatedEvent event, Applications applications) { // Validate event against the existing applications Application application = applications.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java index c9a136f863..ccc7b8f0f2 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/GroupTerminatingProcessor.java @@ -24,11 +24,9 @@ import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.applications.GroupStatus; -import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.message.processor.applications.updater.ApplicationsUpdater; -import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; import org.apache.stratos.messaging.util.Util; /** @@ -75,7 +73,7 @@ public boolean process(String type, String message, Object object) { } } - private boolean doProcess (GroupTerminatingEvent event,Applications applications) { + private boolean doProcess(GroupTerminatingEvent event, Applications applications) { // Validate event against the existing applications Application application = applications.getApplication(event.getAppId()); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java index e987abfebb..5a45ff00ff 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/applications/updater/ApplicationsUpdater.java @@ -24,36 +24,35 @@ import org.apache.stratos.messaging.domain.applications.locking.ApplicationLock; import org.apache.stratos.messaging.domain.applications.locking.ApplicationLockHierarchy; import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; /** * Used to lock the Topology for writes by messaging component - * - * Acquire a write lock: - * - * From root level, acquire read lock, and acquire a write lock only for the - * relevant sub tree. - * - * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - - * acquiring: - * public static void acquireWriteLockForCluster (String serviceName, String clusterId) - * - * releasing: - * public static void releaseWriteLockForCluster (String serviceName, String clusterId) - * - * Example 2: Acquiring write lock to add a new Cluster object - - * acquiring: - * public static void acquireWriteLockForService (String serviceName) - * - * releasing: - * public static void releaseWriteLockForService (String serviceName) - * - * Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service) - * acquire: - * public static void acquireWriteLockForServices() - * - * release: - * public static void releaseWriteLockForServices() + *

+ * Acquire a write lock: + *

+ * From root level, acquire read lock, and acquire a write lock only for the + * relevant sub tree. + *

+ * Example 1: Acquiring write lock for a Cluster to modify the Cluster object - + * acquiring: + * public static void acquireWriteLockForCluster (String serviceName, String clusterId) + *

+ * releasing: + * public static void releaseWriteLockForCluster (String serviceName, String clusterId) + *

+ * Example 2: Acquiring write lock to add a new Cluster object - + * acquiring: + * public static void acquireWriteLockForService (String serviceName) + *

+ * releasing: + * public static void releaseWriteLockForService (String serviceName) + *

+ * Example 3: Acquiring the write lock to add a deploy a Cartridge (add a new Service) + * acquire: + * public static void acquireWriteLockForServices() + *

+ * release: + * public static void releaseWriteLockForServices() */ public class ApplicationsUpdater { @@ -69,7 +68,7 @@ public class ApplicationsUpdater { * Acquires write lock for all Applications */ public static void acquireWriteLockForApplications() { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Write lock acquired for Applications"); } applicationLockHierarchy.getApplicationLock().acquireWriteLock(); @@ -79,7 +78,7 @@ public static void acquireWriteLockForApplications() { * Releases write lock for all Applications */ public static void releaseWriteLockForApplications() { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Write lock released for Applications"); } applicationLockHierarchy.getApplicationLock().releaseWritelock(); @@ -90,19 +89,19 @@ public static void releaseWriteLockForApplications() { * * @param appId Application id */ - public static void acquireWriteLockForApplication (String appId) { + public static void acquireWriteLockForApplication(String appId) { // acquire read lock for all Applications ApplicationManager.acquireReadLockForApplications(); ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId); - if (applicationLock == null) { + if (applicationLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); } else { // now, lock Application applicationLock.acquireWriteLock(); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Write lock acquired for Application " + appId); } } @@ -113,16 +112,16 @@ public static void acquireWriteLockForApplication (String appId) { * * @param appId Application id */ - public static void releaseWriteLockForApplication (String appId) { + public static void releaseWriteLockForApplication(String appId) { ApplicationLock applicationLock = applicationLockHierarchy.getLockForApplication(appId); - if (applicationLock == null) { + if (applicationLock == null) { handleLockNotFound("Topology lock not found for Application " + appId); } else { // release App lock applicationLock.releaseWritelock(); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Write lock released for Application " + appId); } } @@ -131,7 +130,7 @@ public static void releaseWriteLockForApplication (String appId) { ApplicationManager.releaseReadLockForApplications(); } - private static void handleLockNotFound (String errorMsg) { + private static void handleLockNotFound(String errorMsg) { log.warn(errorMsg); //throw new RuntimeException(errorMsg); } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java index d6bdcd7570..cae1e1baf3 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterCreatedMessageProcessor.java @@ -21,7 +21,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterCreatedEvent; -import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java index 75bc0070d8..668493e441 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/cluster/status/ClusterStatusClusterResetMessageProcessor.java @@ -20,7 +20,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResettedEvent; +import org.apache.stratos.messaging.event.cluster.status.ClusterStatusClusterResetEvent; import org.apache.stratos.messaging.message.processor.MessageProcessor; import org.apache.stratos.messaging.util.Util; @@ -36,10 +36,10 @@ public void setNext(MessageProcessor nextProcessor) { @Override public boolean process(String type, String message, Object object) { - if (ClusterStatusClusterResettedEvent.class.getName().equals(type)) { + if (ClusterStatusClusterResetEvent.class.getName().equals(type)) { // Parse complete message and build event - ClusterStatusClusterResettedEvent event = (ClusterStatusClusterResettedEvent) Util. - jsonToObject(message, ClusterStatusClusterResettedEvent.class); + ClusterStatusClusterResetEvent event = (ClusterStatusClusterResetEvent) Util. + jsonToObject(message, ClusterStatusClusterResetEvent.class); if(log.isDebugEnabled()) { log.debug("Received ClusterStatusClusterResettedEvent: " + event.toString()); diff --git a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java index b9b8e03889..63633078f7 100644 --- a/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java +++ b/components/org.apache.stratos.messaging/src/test/java/org/apache/stratos/messaging/topology/locking/TopologyLockingTest.java @@ -33,7 +33,7 @@ public class TopologyLockingTest { private static Topology topology; - @BeforeClass + /*@BeforeClass public static void setUpBeforeClass() { System.out.println("Setting up TopologyLockingTest"); topology = TopologyManager.getTopology(); @@ -206,5 +206,5 @@ public void testAcquireAndReleaseWriteLockForApp2 () { public static void tearDownAfterClass() { System.out.println("Cleaning up TopologyLockingTest"); topology = null; - } + }*/ } From 0d726c8fe2ebc43576ed60d78997df2a5f921d9f Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 17:00:03 +0530 Subject: [PATCH 346/436] adding complete application publisher task --- .../apache/stratos/autoscaler/Constants.java | 4 + ...k.java => ApplicationSynchronizeTask.java} | 27 +++--- .../ApplicationSynchronizerTaskScheduler.java | 87 +++++++++++++++++++ .../topic/ApplicationsEventPublisher.java | 9 ++ .../internal/AutoscalerServerComponent.java | 41 +++++++-- .../util/ServiceReferenceHolder.java | 12 ++- 6 files changed, 159 insertions(+), 21 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/{ApplicationSynchronizerTask.java => ApplicationSynchronizeTask.java} (62%) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java index 3e9e5e2fcd..ef7be70cc9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java @@ -34,6 +34,10 @@ public class Constants { public static final int SCHEDULE_DEFAULT_INITIAL_DELAY = 30; public static final int SCHEDULE_DEFAULT_PERIOD = 15; + public static final String APPLICATION_SYNC_CRON = "1 * * * * ? *"; + public static final String APPLICATION_SYNC_TASK_NAME = "TOPOLOGY_SYNC_TASK"; + public static final String APPLICATION_SYNC_TASK_TYPE = "TOPOLOGY_SYNC_TASK_TYPE"; + public static final String AUTOSCALER_CONFIG_FILE_NAME = "autoscaler.xml"; public static final String CLOUD_CONTROLLER_SERVICE_SFX = "services/CloudControllerService"; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java similarity index 62% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java index a8ce042120..e18cd12143 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTask.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java @@ -19,32 +19,33 @@ package org.apache.stratos.autoscaler.applications; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; -import org.apache.stratos.messaging.domain.applications.Applications; -import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.wso2.carbon.ntask.core.Task; import java.util.Map; -public class ApplicationSynchronizerTask implements Task { +public class ApplicationSynchronizeTask implements Task { + private static final Log log = LogFactory.getLog(ApplicationSynchronizeTask.class); @Override - public void setProperties(Map stringStringMap) { - + public void execute() { + if (log.isDebugEnabled()) { + log.debug("Executing topology synchronization task"); + } + // publish to the topic + if (ApplicationHolder.getApplications() != null) { + ApplicationsEventPublisher.sendCompleteTopologyEvent(ApplicationHolder.getApplications()); + } } @Override public void init() { + log.info("Applications Complete Event publisher task has been started..."); } @Override - public void execute() { - - Applications applications = ApplicationManager.getApplications(); - if (applications != null) { - // publish complete Applications event - ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications); - } - } + public void setProperties(Map arg0) {} } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.java new file mode 100644 index 0000000000..7d9eb1c1c0 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizerTaskScheduler.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.autoscaler.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.Constants; +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; + +/** + * Topology synchronizer task scheduler for scheduling the topology synchronizer task + * using carbon task service. + */ +public class ApplicationSynchronizerTaskScheduler { + + private static final Log log = LogFactory.getLog(ApplicationSynchronizerTaskScheduler.class); + + public static void schedule(TaskService taskService) { + TaskManager taskManager = null; + try { + + //if (!taskService.getRegisteredTaskTypes().contains(CloudControllerConstants.TOPOLOGY_SYNC_TASK_TYPE)) { + // Register task type + taskService.registerTaskType(Constants.APPLICATION_SYNC_TASK_TYPE); + + /*// Register task + taskManager = taskService.getTaskManager(CloudControllerConstants.TOPOLOGY_SYNC_TASK_TYPE); + String cronProp = dataHolder.getTopologyConfig().getProperty(CloudControllerConstants.CRON_PROPERTY); + String cron = cronProp != null ? cronProp :CloudControllerConstants.TOPOLOGY_SYNC_CRON ; + TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(cron); + TaskInfo taskInfo = new TaskInfo(CloudControllerConstants.TOPOLOGY_SYNC_TASK_NAME, + TopologySynchronizerTask.class.getName(), + new HashMap(), triggerInfo); + taskManager.registerTask(taskInfo);*/ + + taskManager = taskService.getTaskManager(Constants.APPLICATION_SYNC_TASK_TYPE); + String cronProp = Constants.APPLICATION_SYNC_CRON; + TaskInfo.TriggerInfo triggerInfo = new TaskInfo.TriggerInfo(cronProp); + TaskInfo taskInfo = new TaskInfo(Constants.APPLICATION_SYNC_TASK_NAME, + ApplicationSynchronizeTask.class.getName(), + new HashMap(), triggerInfo); + taskManager.registerTask(taskInfo); + if (log.isDebugEnabled()) { + log.debug(String.format("Topology synchronization task scheduled: %s", Constants.APPLICATION_SYNC_TASK_NAME)); + } + //} + + } catch (Exception e) { + if (taskManager != null) { + try { + taskManager.deleteTask(Constants.APPLICATION_SYNC_TASK_NAME); + } catch (TaskException te) { + if (log.isErrorEnabled()) { + log.error(te); + } + } + } + + String msg = String.format("Could not schedule topology synchronization task: %s", + Constants.APPLICATION_SYNC_TASK_NAME); + log.error(msg, e); + throw new RuntimeException(msg, e); + } + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index bbeeca4787..7a1203a534 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -23,6 +23,15 @@ public static void sendCompleteApplicationsEvent (Applications completeApplicati publishEvent(new CompleteApplicationsEvent(completeApplications)); } + public static void sendCompleteTopologyEvent(Applications applications) { + CompleteApplicationsEvent applicationsEvent = new CompleteApplicationsEvent(applications); + + if(log.isDebugEnabled()) { + log.debug(String.format("Publishing complete Applications event")); + } + publishEvent(applicationsEvent); + } + public static void sendGroupCreatedEvent(String appId, String groupId) { try { ApplicationManager.acquireReadLockForApplication(appId); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java index 4823057500..5ada0b7d4e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; +import org.apache.stratos.autoscaler.applications.ApplicationSynchronizerTaskScheduler; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.message.receiver.health.AutoscalerHealthStatEventReceiver; @@ -32,6 +33,7 @@ import org.apache.stratos.autoscaler.util.ServiceReferenceHolder; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.registry.api.RegistryException; import org.wso2.carbon.registry.core.service.RegistryService; @@ -41,6 +43,9 @@ /** * @scr.component name=org.apache.stratos.autoscaler.internal.AutoscalerServerComponent" * immediate="true" + * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService" + * cardinality="1..1" policy="dynamic" bind="setTaskService" + * unbind="unsetTaskService" * @scr.reference name="registry.service" * interface= * "org.wso2.carbon.registry.core.service.RegistryService" @@ -52,13 +57,13 @@ public class AutoscalerServerComponent { private static final Log log = LogFactory.getLog(AutoscalerServerComponent.class); AutoscalerTopologyEventReceiver asTopologyReceiver; -// TopicSubscriber healthStatTopicSubscriber; + // TopicSubscriber healthStatTopicSubscriber; AutoscalerHealthStatEventReceiver autoscalerHealthStatEventReceiver; protected void activate(ComponentContext componentContext) throws Exception { try { // Start topology receiver - asTopologyReceiver = new AutoscalerTopologyEventReceiver(); + asTopologyReceiver = new AutoscalerTopologyEventReceiver(); Thread topologyTopicSubscriberThread = new Thread(asTopologyReceiver); topologyTopicSubscriberThread.start(); if (log.isDebugEnabled()) { @@ -88,7 +93,7 @@ protected void activate(ComponentContext componentContext) throws Exception { Partition partition = partitionIterator.next(); PartitionManager.getInstance().addPartitionToInformationModel(partition); } - + // Adding the network partitions stored in registry to the information model List nwPartitionHolders = RegistryManager.getInstance().retrieveNetworkPartitionLbHolders(); Iterator nwPartitionIterator = nwPartitionHolders.iterator(); @@ -96,7 +101,7 @@ protected void activate(ComponentContext componentContext) throws Exception { NetworkPartitionLbHolder nwPartition = nwPartitionIterator.next(); PartitionManager.getInstance().addNetworkPartitionLbHolder(nwPartition); } - + List asPolicies = RegistryManager.getInstance().retrieveASPolicies(); Iterator asPolicyIterator = asPolicies.iterator(); while (asPolicyIterator.hasNext()) { @@ -111,6 +116,14 @@ protected void activate(ComponentContext componentContext) throws Exception { PolicyManager.getInstance().addDeploymentPolicyToInformationModel(depPolicy); } + if (log.isInfoEnabled()) { + log.info("Scheduling tasks to publish applications"); + } + + ApplicationSynchronizerTaskScheduler + .schedule(ServiceReferenceHolder.getInstance() + .getTaskService()); + if (log.isInfoEnabled()) { log.info("Autoscaler Server Component activated"); } @@ -120,10 +133,10 @@ protected void activate(ComponentContext componentContext) throws Exception { } protected void deactivate(ComponentContext context) { - asTopologyReceiver.terminate(); - autoscalerHealthStatEventReceiver.terminate(); + asTopologyReceiver.terminate(); + autoscalerHealthStatEventReceiver.terminate(); } - + protected void setRegistryService(RegistryService registryService) { if (log.isDebugEnabled()) { log.debug("Setting the Registry Service"); @@ -143,4 +156,18 @@ protected void unsetRegistryService(RegistryService registryService) { } ServiceReferenceHolder.getInstance().setRegistry(null); } + + 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("Unsetting the Task Service"); + } + ServiceReferenceHolder.getInstance().setTaskService(null); + } } \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java index 00629dcb9c..9040f74a5f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/ServiceReferenceHolder.java @@ -21,13 +21,15 @@ */ +import org.wso2.carbon.ntask.core.service.TaskService; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.session.UserRegistry; public class ServiceReferenceHolder { private static ServiceReferenceHolder instance; - private Registry registry; + private Registry registry; + private TaskService taskService; private ServiceReferenceHolder() { } @@ -46,4 +48,12 @@ public void setRegistry(UserRegistry governanceSystemRegistry) { public Registry getRegistry() { return registry; } + + public TaskService getTaskService() { + return taskService; + } + + public void setTaskService(TaskService taskService) { + this.taskService = taskService; + } } From 828269f28a31a2a1a525988d2cdcc7a9f0a9fb4f Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 18:13:42 +0530 Subject: [PATCH 347/436] adding service undeployment --- .../autoscaler/api/AutoScalerServiceImpl.java | 11 +++++++++- .../autoscaler/registry/RegistryManager.java | 20 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index d710bf7655..8c4bf2e483 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -324,7 +324,7 @@ public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceG RegistryManager.getInstance().persistServiceGroup(servicegroup); } - public ServiceGroup getServiceGroup(String name){ + public ServiceGroup getServiceGroup(String name) { if(StringUtils.isEmpty(name)){ return null; } @@ -338,5 +338,14 @@ public boolean serviceGroupExist(String serviceName){ return false; } + public void undeployServiceGroup(String name) throws AutoScalerException { + try { + RegistryManager.getInstance().removeServiceGroup(name); + } catch (Exception e) { + throw new AutoScalerException("Error occurred while removing the service groups", e); + } + + } + } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index ee8e4114f4..0e1417e80d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -368,6 +368,26 @@ public ServiceGroup getServiceGroup(String name) throws Exception{ return group; } + public ServiceGroup removeServiceGroup(String name) throws Exception{ + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + + AutoScalerConstants.SERVICE_GROUP + "/" + name; + Object serializedObj = registryManager.retrieve(resourcePath); + ServiceGroup group = null; + if (serializedObj != null) { + Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); + if (dataObj instanceof ServiceGroup) { + group = (ServiceGroup) dataObj; + if(log.isDebugEnabled()) { + log.debug(group.toString()); + } + } else { + return null; + } + } + + return group; + } + public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId(); this.delete(resourcePath); From 7d7cd50d23cb78af9411c1680a4ddc48d7631500 Mon Sep 17 00:00:00 2001 From: reka Date: Fri, 31 Oct 2014 18:19:48 +0530 Subject: [PATCH 348/436] adding undeploy service group --- .../src/main/resources/AutoScalerService.wsdl | 885 ++++++++++-------- 1 file changed, 470 insertions(+), 415 deletions(-) diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index d0665cf9a5..b76e02a1cb 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,369 +1,390 @@ - + AutoScalerService + + + + + + + - + - + - + - + - - + + - - - - + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - - + + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + @@ -371,957 +392,991 @@ - - - - + + + + - - + + - - + + - - - + + + - - - - + + + + - - - + + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - - - - - - - - - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - + + + + + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file From b9aabfdcaca069ae77b3977c361215da80c53265 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 18:47:32 +0530 Subject: [PATCH 349/436] moving Application Parsing to Autoscaler --- .../autoscaler/api/AutoScalerServiceImpl.java | 27 +- .../applications/ApplicationHolder.java | 15 +- .../ApplicationSynchronizeTask.java | 2 +- .../applications/ApplicationUtils.java | 289 ++++++++ .../applications/ClusterInformation.java | 27 + .../applications/MTClusterInformation.java | 47 ++ .../applications/STClusterInformation.java | 57 ++ .../parser/ApplicationParser.java | 51 ++ .../parser/DefaultApplicationParser.java | 657 ++++++++++++++++++ .../applications/parser/ParserUtils.java | 142 ++++ .../ApplicationCartridgePayloadData.java | 27 + .../payload/BasicPayloadData.java | 311 +++++++++ .../payload/DataCartridgePayloadData.java | 27 + .../FrameworkCartridgePayloadData.java | 27 + .../LoadBalancerCartridgePayloadData.java | 27 + .../applications/payload/PayloadData.java | 69 ++ .../applications/payload/PayloadFactory.java | 59 ++ .../pojo/ApplicationClusterContext.java | 137 ++++ .../applications/pojo/ApplicationContext.java | 93 +++ .../applications/pojo/ComponentContext.java | 54 ++ .../applications/pojo/DependencyContext.java | 44 ++ .../applications/pojo/GroupContext.java | 84 +++ .../pojo/SubscribableContext.java | 44 ++ .../pojo/SubscribableInfoContext.java | 103 +++ .../topic/ApplicationBuilder.java | 44 ++ .../topic/ApplicationsEventPublisher.java | 14 +- .../controller/CloudControllerClient.java | 16 + .../ApplicationDefinitionException.java | 48 ++ .../CartridgeInformationException.java | 47 ++ .../AutoScalerServiceInterface.java | 18 + .../autoscaler/registry/RegistryManager.java | 5 + .../autoscaler/util/AutoscalerUtil.java | 4 + 32 files changed, 2603 insertions(+), 13 deletions(-) create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java create mode 100755 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java create mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 8c4bf2e483..4938b4c1ef 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -22,6 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; +import org.apache.stratos.autoscaler.applications.parser.ApplicationParser; +import org.apache.stratos.autoscaler.applications.parser.DefaultApplicationParser; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; +import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.*; @@ -34,7 +38,7 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.wso2.carbon.registry.api.RegistryException; +import org.apache.stratos.messaging.domain.applications.Application; import java.text.MessageFormat; import java.util.ArrayList; @@ -248,8 +252,25 @@ public String getServiceLBClusterId (String serviceType, String deploymentPolicy return null; } - - public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) { + + @Override + public void deployApplicationDefinition(ApplicationContext applicationContext) + throws ApplicationDefinitionException { + + ApplicationParser applicationParser = new DefaultApplicationParser(); + Application application = applicationParser.parse(applicationContext); + ApplicationBuilder.handleApplicationCreated(application, + applicationParser.getApplicationClusterContexts()); + } + + @Override + public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) + throws ApplicationDefinitionException { + + ApplicationBuilder.handleApplicationUndeployed(applicationId); + } + + public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) { for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java index e147d1bfa5..6d16677f98 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationHolder.java @@ -94,9 +94,6 @@ public static Applications getApplications () { public static void persistApplication (Application application) { synchronized (ApplicationHolder.class) { - if (log.isDebugEnabled()) { - log.debug("Updating topology"); - } applications.addApplication(application); AutoscalerUtil.persistApplication(application); if (log.isDebugEnabled()) { @@ -106,6 +103,18 @@ public static void persistApplication (Application application) { } + public static void removeApplication (String applicationId) { + + synchronized (ApplicationHolder.class) { + applications.removeApplication(applicationId); + AutoscalerUtil.removeApplication(applicationId); + if (log.isDebugEnabled()) { + log.debug("Application [ " + applicationId + " ] removed from Applications"); + } + } + + } + private static String toJson(Object object) { Gson gson = new Gson(); return gson.toJson(object); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java index e18cd12143..9f0ca8c73f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java @@ -36,7 +36,7 @@ public void execute() { } // publish to the topic if (ApplicationHolder.getApplications() != null) { - ApplicationsEventPublisher.sendCompleteTopologyEvent(ApplicationHolder.getApplications()); + ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications()); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java new file mode 100644 index 0000000000..e82882c6ca --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java @@ -0,0 +1,289 @@ +/* + * 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.autoscaler.applications; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.payload.BasicPayloadData; +import org.apache.stratos.autoscaler.applications.payload.PayloadData; +import org.apache.stratos.autoscaler.applications.payload.PayloadFactory; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.PortMapping; +import org.apache.stratos.cloud.controller.stub.pojo.Property; + +import java.util.*; +import java.util.regex.Pattern; + +public class ApplicationUtils { + private static final Log log = LogFactory.getLog(ApplicationUtils.class); + + public static boolean isAliasValid (String alias) { + + String patternString = "([a-z0-9]+([-][a-z0-9])*)+"; + Pattern pattern = Pattern.compile(patternString); + + return pattern.matcher(alias).matches(); + } + + public static boolean isValid (String arg) { + + if (arg == null || arg.isEmpty()) { + return false; + } else { + return true; + } + } + + public static Properties getGlobalPayloadData () { + + Properties globalProperties = new Properties(); + + if (System.getProperty("puppet.ip") != null) { + globalProperties.setProperty("PUPPET_IP", System.getProperty("puppet.ip")); + } + if (System.getProperty("puppet.hostname") != null) { + globalProperties.setProperty("PUPPET_HOSTNAME", System.getProperty("puppet.hostname")); + } + if (System.getProperty("puppet.env") != null) { + globalProperties.setProperty("PUPPET_ENV", System.getProperty("puppet.env")); + } + if (System.getProperty("puppet.dns.available") != null) { + globalProperties.setProperty("PUPPET_DNS_AVAILABLE", System.getProperty("puppet.dns.available")); + } + + return globalProperties; + } + +// public static MetaDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key, +// String hostname, String tenantRange, String clusterId, +// SubscribableContext subscribableCtxt, +// SubscribableInfoContext subscribableInfoCtxt, +// Cartridge cartridge) { +// +// MetaDataHolder metaDataHolder; +// if (groupName != null) { +// metaDataHolder = new MetaDataHolder(appId, groupName, clusterId); +// } else { +// metaDataHolder = new MetaDataHolder(appId, clusterId); +// } +// +// Properties clusterLevelPayloadProperties = new Properties(); +// // app id +// clusterLevelPayloadProperties.setProperty("APP_ID", appId); +// // group name +// if (groupName != null) { +// clusterLevelPayloadProperties.setProperty("GROUP_NAME", groupName); +// } +// // service name +// if (subscribableCtxt.getType() != null) { +// clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType()); +// } +// // host name +// if (hostname != null) { +// clusterLevelPayloadProperties.put("HOST_NAME", hostname); +// } +// // multi tenant +// clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant())); +// // tenant range +// if (tenantRange != null) { +// clusterLevelPayloadProperties.put("TENANT_RANGE", tenantRange); +// } +// // cartridge alias +// if (subscribableCtxt.getAlias() != null) { +// clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias()); +// } +// // cluster id +// if (clusterId != null) { +// clusterLevelPayloadProperties.put("CLUSTER_ID", clusterId); +// } +// // repo url +// if (subscribableInfoCtxt.getRepoUrl() != null) { +// clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl()); +// } +// // ports +//// if (createPortMappingPayloadString(cartridge) != null) { +//// clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge)); +//// } +// // provider +// if (cartridge.getProvider() != null) { +// clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider()); +// } +// // tenant id +// clusterLevelPayloadProperties.setProperty("TENANT_ID", String.valueOf(tenantId)); +// // cartridge key +// clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key); +// // get global payload params +// //clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); +// +// metaDataHolder.setProperties(clusterLevelPayloadProperties); +// return metaDataHolder; +// } + + private static String createPortMappingPayloadString (CartridgeInfo cartridge) { + + // port mappings + StringBuilder portMapBuilder = new StringBuilder(); + PortMapping[] portMappings = cartridge.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 StringBuilder getTextPayload (String appId, String groupName, String clusterId) { + + StringBuilder payloadBuilder = new StringBuilder(); + payloadBuilder.append("APP_ID=" + appId); + if (groupName != null) { + payloadBuilder.append(","); + payloadBuilder.append("GROUP_NAME=" + groupName); + } + payloadBuilder.append(","); + payloadBuilder.append("CLUSTER_ID=" + clusterId); + // puppet related + if (System.getProperty("puppet.ip") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip")); + } + if (System.getProperty("puppet.hostname") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); + } + if (System.getProperty("puppet.env") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.env")); + } + if (System.getProperty("puppet.dns.available") != null) { + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.dns.available")); + } + // meta data endpoint + // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { + // TODO + //payloadBuilder.append(","); + //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); + // } + payloadBuilder.append(","); + + return payloadBuilder; + } + + public static PayloadData createPayload(String appId, String groupName, CartridgeInfo cartridgeInfo, String subscriptionKey, int tenantId, String clusterId, + String hostName, String repoUrl, String alias, Map customPayloadEntries, String[] dependencyAliases) + throws ApplicationDefinitionException { + + //Create the payload + BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridgeInfo, subscriptionKey, + clusterId, hostName, repoUrl, alias, tenantId, dependencyAliases); + //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 cartridgeInfo definition file for this cartridgeInfo type + if (cartridgeInfo.getProperties() != null && cartridgeInfo.getProperties().length != 0) { + + for (Property propertyEntry : 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 (propertyEntry.getName() + .startsWith("payload_parameter.")) { + String payloadParamName = propertyEntry.getName(); + String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1); + if("DEPLOYMENT".equals(payloadParamSubstring)) { + isDeploymentParam = true; + } + payloadData.add(payloadParamSubstring, propertyEntry.getValue()); + } + } + } + + // DEPLOYMENT payload param must be set because its used by puppet agent + // to generate the hostname. Therefore, if DEPLOYMENT is not set in cartridgeInfo 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> entrySet = customPayloadEntries.entrySet(); + for (Map.Entry entry : entrySet) { + payloadData.add(entry.getKey(), entry.getValue()); + } + } + + return payloadData; + } + + private static BasicPayloadData createBasicPayload(String appId, String groupName, CartridgeInfo cartridge, + String subscriptionKey, String clusterId, + String hostName, String repoUrl, String alias, + int tenantId, String[] dependencyAliases) { + + BasicPayloadData basicPayloadData = new BasicPayloadData(); + basicPayloadData.setAppId(appId); + basicPayloadData.setGroupName(groupName); + basicPayloadData.setApplicationPath(cartridge.getBaseDir()); + basicPayloadData.setSubscriptionKey(subscriptionKey); + //basicPayloadData.setDeployment("default");//currently hard coded to default + basicPayloadData.setMultitenant(String.valueOf(cartridge.getMultiTenant())); + basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridge)); + basicPayloadData.setServiceName(cartridge.getType()); + basicPayloadData.setProvider(cartridge.getProvider()); + + if(repoUrl != null) { + basicPayloadData.setGitRepositoryUrl(repoUrl); + } + + if (clusterId != null) { + basicPayloadData.setClusterId(clusterId); + } + + if (hostName != null) { + basicPayloadData.setHostName(hostName); + } + + if (alias != null) { + basicPayloadData.setSubscriptionAlias(alias); + } + + basicPayloadData.setTenantId(tenantId); + + basicPayloadData.setTenantRange("*"); + basicPayloadData.setDependencyAliases(dependencyAliases); +// if(cartridge.getExportingProperties() != null){ +// basicPayloadData.setExportingProperties(cartridge.getExportingProperties()); +// log.info("testing1 getExportingProperties " + cartridge.getExportingProperties()); +// +// } + + return basicPayloadData; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java new file mode 100644 index 0000000000..5fd6d571bc --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.application; + +public interface ClusterInformation { + + public String getClusterId (String alias, String cartridgeType); + + public String getHostName (String alias, String cartridgeDefinitionHostName); +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java new file mode 100644 index 0000000000..a0a59d420b --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.autoscaler.applications; + +import org.apache.stratos.cloud.controller.application.ClusterInformation; + +public class MTClusterInformation implements ClusterInformation { + + @Override + public String getClusterId(String alias, String cartridgeType) { + + if (!ApplicationUtils.isValid(cartridgeType)) { + // cannot happen + throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); + } + + return cartridgeType + ".domain"; + } + + @Override + public String getHostName(String alias, String cartridgeDefinitionHostName) { + + if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { + // cannot happen + throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); + } + + return cartridgeDefinitionHostName; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java new file mode 100644 index 0000000000..9a5bea88ef --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java @@ -0,0 +1,57 @@ +/* + * 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.autoscaler.applications; + +import org.apache.stratos.cloud.controller.application.ClusterInformation; + +public class STClusterInformation implements ClusterInformation { + + @Override + public String getClusterId(String alias, String cartridgeType) { + + if (!ApplicationUtils.isValid(alias)) { + // cannot happen + throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); + } + + if (!ApplicationUtils.isValid(cartridgeType)) { + // cannot happen + throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); + } + + return alias + "." + cartridgeType + ".domain"; + } + + @Override + public String getHostName(String alias, String cartridgeDefinitionHostName) { + + if (!ApplicationUtils.isValid(alias)) { + // cannot happen + throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); + } + + if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { + // cannot happen + throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); + } + + return alias + "." + cartridgeDefinitionHostName; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java new file mode 100644 index 0000000000..529c1f8eb6 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.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.autoscaler.applications.parser; + + +import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; +import org.apache.stratos.messaging.domain.applications.Application; + +import java.util.Set; + + +public interface ApplicationParser { + + /** + * Parses the Application Definition + * + * @param obj Object with the Application Definition. An Object is used here since there can be + * significant changes between the way composite Applications are defined in different + * conventions + * @return Application structure denoting the parsed Application + * @throws ApplicationDefinitionException If the Application Definition is invalid + */ + public Application parse (Object obj) throws ApplicationDefinitionException; + + /** + * Returns a set of ApplicationClusterContext which will comprise of cluster related information + * extracted from the Application definition + * + * @return Set of ApplicationClusterContext objects + * @throws ApplicationDefinitionException if any error occurs + */ + public Set getApplicationClusterContexts() throws ApplicationDefinitionException; +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java new file mode 100644 index 0000000000..8184743c50 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -0,0 +1,657 @@ +/* + * 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.autoscaler.applications.parser; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.ApplicationUtils; +import org.apache.stratos.autoscaler.applications.MTClusterInformation; +import org.apache.stratos.autoscaler.applications.STClusterInformation; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; +import org.apache.stratos.autoscaler.applications.pojo.GroupContext; +import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext; +import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext; +import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; +import org.apache.stratos.autoscaler.exception.CartridgeInformationException; +import org.apache.stratos.autoscaler.pojo.ServiceGroup; +import org.apache.stratos.autoscaler.registry.RegistryManager; +import org.apache.stratos.cloud.controller.application.ClusterInformation; +import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext; +import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.DependencyOrder; +import org.apache.stratos.messaging.domain.applications.Group; + +import java.util.*; + +public class DefaultApplicationParser implements ApplicationParser { + + private static Log log = LogFactory.getLog(DefaultApplicationParser.class); + +// private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); + + private Set applicationClusterContexts; + + public DefaultApplicationParser () { + + this.applicationClusterContexts = new HashSet(); + } + + @Override + public Application parse(Object obj) throws ApplicationDefinitionException { + + ApplicationContext applicationCtxt = (ApplicationContext) obj; + + if (applicationCtxt == null) { + handleError("Invalid Composite Application Definition"); + } + + assert applicationCtxt != null; + if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) { + handleError("Invalid alias specified"); + } + + if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) { + handleError("Invalid Composite App id specified"); + } + + // get the defined groups + Map definedGroups = getDefinedGroups(applicationCtxt); + if (log.isDebugEnabled()) { + if (definedGroups != null) { + Set> groupEntries = definedGroups.entrySet(); + log.debug("Defined Groups: [ "); + for (Map.Entry groupEntry : groupEntries) { + log.debug("Group alias: " + groupEntry.getKey()); + } + log.debug(" ]"); + } else { + log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId()); + } + } + + // get the Subscribables Information + Map subscribablesInfo = getSubscribableInformation(applicationCtxt); + if (log.isDebugEnabled()) { + Set> subscribableInfoCtxtEntries = subscribablesInfo.entrySet(); + log.debug("Defined Subscribable Information: [ "); + for (Map.Entry subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) { + log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey()); + } + log.debug(" ]"); + } + + if (subscribablesInfo == null) { + handleError("Invalid Composite Application Definition, no Subscribable Information specified"); + } + + return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); + } + + @Override + public Set getApplicationClusterContexts() throws ApplicationDefinitionException { + return applicationClusterContexts; + } + + /** + * Extract Group information from Application Definition + * + * @param appCtxt ApplicationContext object with Application information + * @return Map [group alias -> Group] + * + * @throws ApplicationDefinitionException if the Group information is invalid + */ + private Map getDefinedGroups (ApplicationContext appCtxt) throws + ApplicationDefinitionException { + + // map [group alias -> Group Definition] + Map definedGroups = null; + + if (appCtxt.getComponents() != null) { + if (appCtxt.getComponents().getGroupContexts() != null) { + definedGroups = new HashMap(); + + for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) { + + // check validity of group name + if (StringUtils.isEmpty(groupContext.getName())) { + handleError("Invalid Group name specified"); + } + + // check if group is deployed + if(!isGroupDeployed(groupContext.getName())) { + handleError("Group with name " + groupContext.getName() + " not deployed"); + } + + // check validity of group alias + + if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { + handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); + } + + // check if a group is already defined under the same alias + if(definedGroups.get(groupContext.getAlias()) != null) { + // a group with same alias already exists, can't continue + handleError("A Group with alias " + groupContext.getAlias() + " already exists"); + } + + definedGroups.put(groupContext.getAlias(), groupContext); + if (log.isDebugEnabled()) { + log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]"); + } + } + } + } + + return definedGroups; + } + + /** + * Extract Subscription Information from the Application Definition + * + * @param appCtxt ApplicationContext object with Application information + * @return Map [cartridge alias -> Group] + * + * @throws ApplicationDefinitionException if the Subscription information is invalid + */ + private Map getSubscribableInformation (ApplicationContext appCtxt) throws + ApplicationDefinitionException { + + // map [cartridge alias -> Subscribable Information] + Map subscribableInformation = null; + + if (appCtxt.getSubscribableInfoContext() != null) { + subscribableInformation = new HashMap(); + + for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) { + + if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) || + !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) { + handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); + } + + // check if a group is already defined under the same alias + if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) { + // a group with same alias already exists, can't continue + handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists"); + } + + subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt); + if (log.isDebugEnabled()) { + log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]"); + } + } + } + + return subscribableInformation; + } + + /** + * Check if a Group Definition is deployed + * + * @param serviceGroupName Group name + * @return true if the Group is deployed, else false + * + * @throws ApplicationDefinitionException + */ + private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException { + + try { + return RegistryManager.getInstance().getServiceGroup(serviceGroupName) != null; + } catch (Exception e) { + String errorMsg = "Error in checking if Service Group Definition [ " + serviceGroupName + + " ] already exists"; + log.error(errorMsg, e); + throw new ApplicationDefinitionException(errorMsg, e); + } + } + + /** + * Builds the Application structure + * + * @param appCtxt ApplicationContext object with Application information + * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @return Application Application object denoting the Application structure + * + * @throws ApplicationDefinitionException If an error occurs in building the Application structure + */ + private Application buildCompositeAppStructure (ApplicationContext appCtxt, + Map definedGroupCtxts, + Map subscribableInfoCtxts) + throws ApplicationDefinitionException { + + Application application = new Application(appCtxt.getApplicationId()); + + // set tenant related information + application.setTenantId(appCtxt.getTenantId()); + application.setTenantDomain(appCtxt.getTenantDomain()); + application.setTenantAdminUserName(appCtxt.getTeantAdminUsername()); + + // following keeps track of all Clusters created for this application + //Set clusters = new HashSet(); + //ClusterDataHolder clusterDataHolder = null; + Map clusterDataMap; + + if (appCtxt.getComponents() != null) { + // get top level Subscribables + if (appCtxt.getComponents().getSubscribableContexts() != null) { + clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), + application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), + subscribableInfoCtxts); + application.setClusterData(clusterDataMap); + //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); + } + + // get Groups + if (appCtxt.getComponents().getGroupContexts() != null) { + application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(), + application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()), + subscribableInfoCtxts, definedGroupCtxts)); + } + + // get top level Dependency definitions + if (appCtxt.getComponents().getDependencyContext() != null) { + DependencyOrder appDependencyOrder = new DependencyOrder(); + String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts(); + if (startupOrders != null) { + if (log.isDebugEnabled()) { + log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + + appCtxt.getAlias() + " #: " + startupOrders.length); + } + appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders)); + } else { + if (log.isDebugEnabled()) { + log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias()); + } + } + String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour(); + validateTerminationBehavior(terminationBehavior); + appDependencyOrder.setTerminationBehaviour(terminationBehavior); + + application.setDependencyOrder(appDependencyOrder); + } + } + + log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); + + return application; + } + + /** + * Validates terminationBehavior. The terminationBehavior should be one of the following: + * 1. terminate-none + * 2. terminate-dependents + * 3. terminate-all + * + * @throws ApplicationDefinitionException if terminationBehavior is different to what is + * listed above + */ + private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException { + + if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) || + "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) { + throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " + + terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " + + " 'terminate-all' "); + } + } + + /** + * Parse Group information + * + * @param appId Application id + * @param tenantId tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupCtxts Group information + * @param subscribableInformation Subscribable Information + * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information + * @return Map [alias -> Group] + * + * @throws ApplicationDefinitionException if an error occurs in parsing Group Information + */ + private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, + Map subscribableInformation, + Map definedGroupCtxts) + throws ApplicationDefinitionException { + + Map groupAliasToGroup = new HashMap(); + + for (GroupContext groupCtxt : groupCtxts) { + Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts); + groupAliasToGroup.put(group.getAlias(), group); + } + + //Set topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup); + Set nestedGroups = new HashSet(); + getNestedGroupContexts(nestedGroups, groupAliasToGroup.values()); + filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups); + + return groupAliasToGroup; + } + + /** + * Extracts nested Group information recursively + * + * @param nestedGroups Nested Groups set to be populated recursively + * @param groups Collection of Groups + */ + private void getNestedGroupContexts (Set nestedGroups, Collection groups) { + + if (groups != null) { + for (Group group : groups) { + if (group.getGroups() != null) { + nestedGroups.addAll(group.getGroups()); + getNestedGroupContexts(nestedGroups, group.getGroups()); + } + } + } + } + + /** + * Filters duplicated Groups from top level + * + * @param topLevelGroups Top level Groups + * @param nestedGroups nested Groups + */ + private void filterDuplicatedGroupContexts (Collection topLevelGroups, Set nestedGroups) { + + for (Group nestedGroup : nestedGroups) { + filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup); + } + } + + private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Group nestedGroup) { + + Iterator parentIterator = topLevelGroups.iterator(); + while (parentIterator.hasNext()) { + Group parentGroup = parentIterator.next(); + // if there is an exactly similar nested Group Context and a top level Group Context + // it implies that they are duplicates. Should be removed from top level. + if (parentGroup.equals(nestedGroup)) { + parentIterator.remove(); + } + } + } + + /** + * Parses an individual Group + * + * @param appId Application id + * @param tenantId tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupCtxt Group definition information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information + * @return Group object + * + * @throws ApplicationDefinitionException if unable to parse + */ + private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, + Map subscribableInfoCtxts, + Map definedGroupCtxts) + throws ApplicationDefinitionException { + + // check if are in the defined Group set + GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias()); + if (definedGroupDef == null) { + handleError("Group Definition with name: " + groupCtxt.getName() + ", alias: " + + groupCtxt.getAlias() + " is not found in the all Group Definitions collection"); + } + + Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias()); + + group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy()); + group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); + DependencyOrder dependencyOrder = new DependencyOrder(); + // create the Dependency Ordering + String [] startupOrders = getStartupOrderForGroup(groupCtxt); + if (startupOrders != null) { + dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt)); + } + dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName())); + group.setDependencyOrder(dependencyOrder); + + Map clusterDataMap; + + // get group level Subscribables + if (groupCtxt.getSubscribableContexts() != null) { + clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), + Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); + group.setClusterData(clusterDataMap); + } + + // get nested groups + if (groupCtxt.getGroupContexts() != null) { + Map nestedGroups = new HashMap(); + // check sub groups + for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) { + // get the complete Group Definition + subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); + Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, + subscribableInfoCtxts, + definedGroupCtxts); + nestedGroups.put(nestedGroup.getAlias(), nestedGroup); + } + + group.setGroups(nestedGroups); + } + + return group; + } + + /** + * Find the startup order + * + * @param groupContext GroupContext with Group defintion information + * @return Set of Startup Orders which are defined in the Group + * + * @throws ApplicationDefinitionException + */ + private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { + + ServiceGroup serviceGroup = null; + try { + serviceGroup = RegistryManager.getInstance().getServiceGroup(groupContext.getName()); + } catch (Exception e) { + String errorMsg = "Error in getting Service Group Definition for [ " + groupContext.getName() + + " ] from Registry"; + log.error(errorMsg, e); + throw new ApplicationDefinitionException(errorMsg, e); + } + + if (serviceGroup == null) { + handleError("Service Group Definition not found for name " + groupContext.getName()); + } + + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName()); + } + + assert serviceGroup != null; + if (serviceGroup.getDependencies() != null) { + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " ); + } + if (serviceGroup.getDependencies().getStartupOrders() != null) { + + String [] startupOrders = serviceGroup.getDependencies().getStartupOrders(); + if (log.isDebugEnabled()) { + log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " + startupOrders.length); + } + return startupOrders; + } + } + + return null; + } + + /** + * Get kill behaviour related to a Group + * + * @param serviceGroupName Group name + * @return String indicating the kill behavior + * + * @throws ApplicationDefinitionException if an error occurs + */ + private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException { + + ServiceGroup serviceGroup = null; + try { + serviceGroup = RegistryManager.getInstance().getServiceGroup(serviceGroupName); + } catch (Exception e) { + String errorMsg = "Error in getting Service Group Definition for [ " + serviceGroupName + + " ] from Registry"; + log.error(errorMsg, e); + throw new ApplicationDefinitionException(errorMsg, e); + } + + if (serviceGroup == null) { + handleError("Service Group Definition not found for name " + serviceGroupName); + } + + assert serviceGroup != null; + if (serviceGroup.getDependencies() != null) { + return serviceGroup.getDependencies().getKillBehaviour(); + } + + return null; + + } + + /** + * Parse Subscription Information + * + * @param appId Application id + * @param tenantId Tenant id of tenant which deployed the Application + * @param key Generated key for the Application + * @param groupName Group name (if relevant) + * @param subscribableCtxts Subscribable Information + * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information + * @return Map [subscription alias -> ClusterDataHolder] + * + * @throws ApplicationDefinitionException + */ + private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, + List subscribableCtxts, + Map subscribableInfoCtxts) + throws ApplicationDefinitionException { + + Map clusterDataMap = new HashMap(); + + for (SubscribableContext subscribableCtxt : subscribableCtxts) { + + // check is there is a related Subscribable Information + SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); + if (subscribableInfoCtxt == null) { + handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: " + + subscribableCtxt.getAlias()); + } + + // check if Cartridge Type is valid + if (StringUtils.isEmpty(subscribableCtxt.getType())) { + handleError("Invalid Cartridge Type specified : [ " + + subscribableCtxt.getType() + " ]"); + } + + // check if a cartridgeInfo with relevant type is already deployed. else, can't continue + CartridgeInfo cartridgeInfo = getCartridge(subscribableCtxt.getType()); + if (cartridgeInfo == null) { + handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + + " ] for Composite Application"); + } + + // get hostname and cluster id + ClusterInformation clusterInfo; + assert cartridgeInfo != null; + if (cartridgeInfo.getMultiTenant()) { + clusterInfo = new MTClusterInformation(); + } else { + clusterInfo = new STClusterInformation(); + } + + String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridgeInfo.getHostName()); + String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); + + // create and collect this cluster's information + assert subscribableInfoCtxt != null; + ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridgeInfo, + key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), + clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases()); + + appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); + this.applicationClusterContexts.add(appClusterCtxt); + + // add relevant information to the map + clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId)); + } + + return clusterDataMap; + } + + /** + * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application + * + * @param appId Application id + * @param groupName Group name + * @param cartridgeInfo Cartridge information + * @param subscriptionKey Generated key for the Application + * @param tenantId Tenant Id of the tenant which deployed the Application + * @param repoUrl Repository URL + * @param alias alias specified for this Subscribable in the Application Definition + * @param clusterId Cluster id + * @param hostname Hostname + * @param deploymentPolicy Deployment policy used + * @param isLB if this cluster is an LB + * @return ApplicationClusterContext object with relevant information + * + * @throws ApplicationDefinitionException If any error occurs + */ + private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, CartridgeInfo cartridgeInfo, + String subscriptionKey, int tenantId, String repoUrl, + String alias, String clusterId, String hostname, + String deploymentPolicy, boolean isLB, String[] dependencyAliases) + throws ApplicationDefinitionException { + + // Create text payload + String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridgeInfo, subscriptionKey, tenantId, clusterId, + hostname, repoUrl, alias, null, dependencyAliases).toString(); + + return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); + } + + private CartridgeInfo getCartridge (String cartridgeType) throws ApplicationDefinitionException { + + try { + return CloudControllerClient.getInstance().getCartrdgeInformation(cartridgeType); + } catch (CartridgeInformationException e) { + throw new ApplicationDefinitionException(e); + } + } + + private void handleError (String errorMsg) throws ApplicationDefinitionException { + log.error(errorMsg); + throw new ApplicationDefinitionException(errorMsg); + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java new file mode 100644 index 0000000000..162ead793e --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ParserUtils.java @@ -0,0 +1,142 @@ +/* + * 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.autoscaler.applications.parser; + +import org.apache.stratos.autoscaler.applications.pojo.GroupContext; +import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; +import org.apache.stratos.messaging.domain.applications.StartupOrder; + +import java.util.*; + +public class ParserUtils { + + public static Set convert (String [] startupOrderArr) throws ApplicationDefinitionException { + + Set startupOrders = new HashSet(); + + if (startupOrderArr == null) { + return startupOrders; + } + + for (String commaSeparatedStartupOrder : startupOrderArr) { + startupOrders.add(getStartupOrder(commaSeparatedStartupOrder)); + } + + return startupOrders; + } + + private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) throws ApplicationDefinitionException{ + + List startupOrders = new ArrayList(); + + for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) { + startupOrder = startupOrder.trim(); + if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group.")) { + throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.' or 'group.'"); + } + + startupOrders.add(startupOrder); + } + + return new StartupOrder(startupOrders); + } + + public static Set convert (String [] startupOrderArr, GroupContext groupContext) + throws ApplicationDefinitionException { + + Set startupOrders = new HashSet(); + + if (startupOrderArr == null) { + return startupOrders; + } + + + for (String commaSeparatedStartupOrder : startupOrderArr) { + // convert all Startup Orders to aliases-based + List components = Arrays.asList(commaSeparatedStartupOrder.split(",")); + startupOrders.add(getStartupOrder(components, groupContext)); + } + + return startupOrders; + } + + private static StartupOrder getStartupOrder (List components, GroupContext groupContext) + throws ApplicationDefinitionException { + + List aliasBasedComponents = new ArrayList(); + + for (String component : components) { + component = component.trim(); + + String aliasBasedComponent; + if (component.startsWith("cartridge.")) { + String cartridgeType = component.substring(10); + aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext); + if (aliasBasedComponent == null) { + throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Service type " + cartridgeType); + } + + aliasBasedComponent = "cartridge.".concat(aliasBasedComponent); + + } else if (component.startsWith("group.")) { + String groupName = component.substring(6); + aliasBasedComponent = getAliasForGroupName(groupName, groupContext); + if (aliasBasedComponent == null) { + throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + + "cannot find the matching alias for Group name " + groupName); + } + + aliasBasedComponent = "group.".concat(aliasBasedComponent); + + } else { + throw new ApplicationDefinitionException("Incorrect Startup Order specified, " + + "should start with 'cartridge.' or 'group.'"); + } + aliasBasedComponents.add(aliasBasedComponent); + } + + return new StartupOrder(aliasBasedComponents); + } + + private static String getAliasForGroupName (String groupName, GroupContext groupContext) { + + for (GroupContext groupCtxt : groupContext.getGroupContexts()) { + if (groupName.equals(groupCtxt.getName())) { + return groupCtxt.getAlias(); + } + } + + return null; + } + + + private static String getAliasForServiceType (String serviceType, GroupContext groupContext) { + + for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) { + if (serviceType.equals(subCtxt.getType())) { + return subCtxt.getAlias(); + } + } + + return null; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java new file mode 100644 index 0000000000..d80894af66 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/ApplicationCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * 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.autoscaler.applications.payload; + +public class ApplicationCartridgePayloadData extends PayloadData { + + public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java new file mode 100644 index 0000000000..b0e4588676 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/BasicPayloadData.java @@ -0,0 +1,311 @@ +/* + * 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.autoscaler.applications.payload; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.io.Serializable; + +/** + * Contains basic payload data fields + */ +public class BasicPayloadData implements Serializable { + + private static Log log = LogFactory.getLog(BasicPayloadData.class); + + private String appId; + private String groupName; + 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; + private String[] dependencyAliases; + private String[] exportingProperties; + + protected StringBuilder payloadBuilder; + + public BasicPayloadData() { + + } + + public void populatePayload () { + + payloadBuilder = new StringBuilder(); + + payloadBuilder.append("APP_ID=" + getAppId()); + payloadBuilder.append(","); + payloadBuilder.append("GROUP_NAME=" + getGroupName()); + payloadBuilder.append(","); + 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("puppet.ip")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env")); + payloadBuilder.append(","); + payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available")); + payloadBuilder.append(","); + if(getDependencyAliasesPayloadString() != null){ + payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString()); + } + payloadBuilder.append(","); + if(getExportingPropertiesPayloadString() != null){ + payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString()); + } + + } + + 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; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public String[] getDependencyAliases() { + return dependencyAliases; + } + + public void setDependencyAliases(String[] dependencyAliases) { + this.dependencyAliases = dependencyAliases; + } + + private String getDependencyAliasesPayloadString(){ + if(dependencyAliases == null){ + return null; + } + + StringBuilder dependencyAliasesPayload = new StringBuilder(); + for(int i=0; i< dependencyAliases.length; i++){ + dependencyAliasesPayload.append(dependencyAliases[i]); + if(i != dependencyAliases.length -1){ + dependencyAliasesPayload.append("|"); + } + } + log.info("testing1 getDependencyAliasesPayloadString " + dependencyAliasesPayload); + return dependencyAliasesPayload.toString(); + } + + private String getExportingPropertiesPayloadString(){ + if(exportingProperties == null){ + return null; + } + + StringBuilder exportingPropertiesPayload = new StringBuilder(); + for(int i=0; i< exportingProperties.length; i++){ + exportingPropertiesPayload.append(exportingProperties[i]); + if(i != exportingProperties.length -1){ + exportingPropertiesPayload.append("|"); + } + } + log.info("testing1 getExportingPropertiesPayloadString " + exportingPropertiesPayload); + return exportingPropertiesPayload.toString(); + } + + public String[] getExportingProperties() { + return exportingProperties; + } + + public void setExportingProperties(String[] exportingProperties) { + this.exportingProperties = exportingProperties; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java new file mode 100644 index 0000000000..84ef25a225 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/DataCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * 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.autoscaler.applications.payload; + +public class DataCartridgePayloadData extends PayloadData { + + public DataCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java new file mode 100644 index 0000000000..03b2ed1e74 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/FrameworkCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * 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.autoscaler.applications.payload; + +public class FrameworkCartridgePayloadData extends PayloadData { + + public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java new file mode 100644 index 0000000000..d4949ccf1f --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/LoadBalancerCartridgePayloadData.java @@ -0,0 +1,27 @@ +/* + * 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.autoscaler.applications.payload; + +public class LoadBalancerCartridgePayloadData extends PayloadData { + + public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) { + super(basicPayloadData); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java new file mode 100644 index 0000000000..963e88b1db --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadData.java @@ -0,0 +1,69 @@ +/* + * 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.autoscaler.applications.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 completePayloadMap; + public PayloadData(BasicPayloadData basicPayloadData) { + + this.setBasicPayloadData(basicPayloadData); + completePayloadMap = new HashMap(); + } + + 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(); + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.java new file mode 100755 index 0000000000..53bac968f2 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/payload/PayloadFactory.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.autoscaler.applications.payload; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; + + +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 + */ + public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType, + BasicPayloadData basicPayloadData) + throws ApplicationDefinitionException { + + PayloadData payloadData = null; + + //TODO: fix after adding the property Category to Cartridge Definition + if (cartridgeProvider.equals("data")) { + payloadData = new DataCartridgePayloadData(basicPayloadData); + } else { + payloadData = new FrameworkCartridgePayloadData(basicPayloadData); + } + + if(payloadData == null) { + throw new ApplicationDefinitionException("Unable to find matching payload for cartridge type " + cartridgeType + + ", provider " + cartridgeProvider); + } + + return payloadData; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java new file mode 100644 index 0000000000..39b8214219 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationClusterContext.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.autoscaler.applications.pojo; + +public class ApplicationClusterContext { + + // cluster id + private String clusterId; + // cartridge type + private String cartridgeType; + // payload as a String + private String textPayload; + // host name + private String hostName; + // flag to indicate LB cluster + private boolean isLbCluster; + // autoscaling policy + private String autoscalePolicyName; + // deployment policy + private String deploymentPolicyName; + // tenant rance + private String tenantRange; + + public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName, + String textPayload, String deploymentPolicyName, boolean isLbCluster) { + + this.cartridgeType = cartridgeType; + this.clusterId = clusterId; + this.hostName = hostName; + this.textPayload = textPayload; + this.deploymentPolicyName = deploymentPolicyName; + this.isLbCluster = isLbCluster; + this.tenantRange = "*"; + } + + public String getClusterId() { + return clusterId; + } + + public void setClusterId(String clusterId) { + this.clusterId = clusterId; + } + + public String getCartridgeType() { + return cartridgeType; + } + + public void setCartridgeType(String cartridgeType) { + this.cartridgeType = cartridgeType; + } + + public String getTextPayload() { + return textPayload; + } + + public void setTextPayload(String textPayload) { + this.textPayload = textPayload; + } + + public String getHostName() { + return hostName; + } + + public void setHostName(String hostName) { + this.hostName = hostName; + } + + public boolean isLbCluster() { + return isLbCluster; + } + + public void setLbCluster(boolean lbCluster) { + isLbCluster = lbCluster; + } + + public String getAutoscalePolicyName() { + return autoscalePolicyName; + } + + public void setAutoscalePolicyName(String autoscalePolicyName) { + this.autoscalePolicyName = autoscalePolicyName; + } + + public String getDeploymentPolicyName() { + return deploymentPolicyName; + } + + public void setDeploymentPolicyName(String deploymentPolicyName) { + this.deploymentPolicyName = deploymentPolicyName; + } + + public String getTenantRange() { + return tenantRange; + } + + public void setTenantRange(String tenantRange) { + this.tenantRange = tenantRange; + } + + public boolean equals(Object other) { + + if(other == null || !(other instanceof ApplicationClusterContext)) { + return false; + } + + if(this == other) { + return true; + } + + ApplicationClusterContext that = (ApplicationClusterContext)other; + + return this.cartridgeType.equals(that.cartridgeType) && + this.clusterId.equals(that.clusterId); + } + + public int hashCode () { + return this.cartridgeType.hashCode() + this.clusterId.hashCode(); + } + +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java new file mode 100644 index 0000000000..1b9c5161aa --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java @@ -0,0 +1,93 @@ +/* + * 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.autoscaler.applications.pojo; + +public class ApplicationContext { + + private int tenantId; + + private String tenantDomain; + + private String teantAdminUsername; + + private String applicationId; + + private String alias; + + private ComponentContext componentContext; + + private SubscribableInfoContext[] subscribableInfoContexts; + + public String getApplicationId() { + return applicationId; + } + + public void setApplicationId(String applicationId) { + this.applicationId = applicationId; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public ComponentContext getComponents() { + return componentContext; + } + + public void setComponents(ComponentContext componentContext) { + this.componentContext = componentContext; + } + + public SubscribableInfoContext[] getSubscribableInfoContext() { + return subscribableInfoContexts; + } + + public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) { + this.subscribableInfoContexts = subscribableInfoContexts; + } + + 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; + } + + public String getTeantAdminUsername() { + return teantAdminUsername; + } + + public void setTeantAdminUsername(String teantAdminUsername) { + this.teantAdminUsername = teantAdminUsername; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java new file mode 100644 index 0000000000..b39b07f3c9 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ComponentContext.java @@ -0,0 +1,54 @@ +/* + * 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.autoscaler.applications.pojo; + +public class ComponentContext { + + private GroupContext[] groupContexts; + + private SubscribableContext[] subscribableContexts; + + private DependencyContext dependencyContext; + + + public GroupContext[] getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(GroupContext[] groupContexts) { + this.groupContexts = groupContexts; + } + + public SubscribableContext[] getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public DependencyContext getDependencyContext() { + return dependencyContext; + } + + public void setDependencyContext(DependencyContext dependencyContext) { + this.dependencyContext = dependencyContext; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java new file mode 100644 index 0000000000..ccb17f0f49 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/DependencyContext.java @@ -0,0 +1,44 @@ +/* + * 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.autoscaler.applications.pojo; + + +public class DependencyContext { + + private String [] startupOrdersContexts; + + private String terminationBehaviour; + + public String getTerminationBehaviour() { + return terminationBehaviour; + } + + public void setTerminationBehaviour(String terminationBehaviour) { + this.terminationBehaviour = terminationBehaviour; + } + + public String [] getStartupOrdersContexts() { + return startupOrdersContexts; + } + + public void setStartupOrdersContexts(String [] startupOrdersContexts) { + this.startupOrdersContexts = startupOrdersContexts; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java new file mode 100644 index 0000000000..c05a5d506b --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/GroupContext.java @@ -0,0 +1,84 @@ +/* + * 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.autoscaler.applications.pojo; + +public class GroupContext { + + private String name; + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private SubscribableContext[] subscribableContexts; + + private GroupContext[] groupContexts; + + + 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 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 SubscribableContext[] getSubscribableContexts() { + return subscribableContexts; + } + + public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { + this.subscribableContexts = subscribableContexts; + } + + public GroupContext[] getGroupContexts() { + return groupContexts; + } + + public void setGroupContexts(GroupContext[] groupContexts) { + this.groupContexts = groupContexts; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java new file mode 100644 index 0000000000..7ae4864857 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableContext.java @@ -0,0 +1,44 @@ +/* + * 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.autoscaler.applications.pojo; + +public class SubscribableContext { + + 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; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java new file mode 100644 index 0000000000..62d32df3b4 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/SubscribableInfoContext.java @@ -0,0 +1,103 @@ +/* + * 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.autoscaler.applications.pojo; + +public class SubscribableInfoContext { + + private String alias; + + private String deploymentPolicy; + + private String autoscalingPolicy; + + private String repoUrl; + + private boolean privateRepo; + + private String repoUsername; + + private String repoPassword; + + private String[] dependencyAliases; + + 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; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 9d4db75b7e..07ddfb6ed9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.applications.ApplicationHolder; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; import org.apache.stratos.messaging.domain.applications.*; import java.util.Collection; @@ -142,6 +143,49 @@ public class ApplicationBuilder { ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); }*/ + public static void handleApplicationCreated (Application application, + Set appClusterCtxts) { + + Applications applications = ApplicationHolder.getApplications(); + + ApplicationHolder.acquireWriteLock(); + + try { + if (applications.getApplication(application.getUniqueIdentifier()) != null) { + ApplicationHolder.persistApplication(application); + } else { + log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); + } + + } finally { + ApplicationHolder.releaseWriteLock(); + } + + ApplicationsEventPublisher.sendApplicationCreatedEvent(application); + } + + public static void handleApplicationUndeployed (String applicationId) { + + Applications applications = ApplicationHolder.getApplications(); + + ApplicationHolder.acquireWriteLock(); + Application applicationToRemove = applications.getApplication(applicationId); + Set clusterData = null; + + try { + if (applicationToRemove != null) { + clusterData = applicationToRemove.getClusterDataRecursively(); + ApplicationHolder.removeApplication(applicationId); + } else { + log.warn("Application [ " + applicationId + " ] not found among existing Applications"); + } + + } finally { + ApplicationHolder.releaseWriteLock(); + } + + ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); + } public static void handleGroupTerminatedEvent(String appId, String groupId) { Applications applications = ApplicationHolder.getApplications(); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index 7a1203a534..7ca224e6b8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -7,6 +7,7 @@ import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.applications.*; +import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.util.Constants; @@ -23,13 +24,14 @@ public static void sendCompleteApplicationsEvent (Applications completeApplicati publishEvent(new CompleteApplicationsEvent(completeApplications)); } - public static void sendCompleteTopologyEvent(Applications applications) { - CompleteApplicationsEvent applicationsEvent = new CompleteApplicationsEvent(applications); + public static void sendApplicationCreatedEvent (Application application) { - if(log.isDebugEnabled()) { - log.debug(String.format("Publishing complete Applications event")); - } - publishEvent(applicationsEvent); + publishEvent(new ApplicationCreatedEvent(application)); + } + + public static void sendApplicationUndeployedEvent (String appId, Set clusterData) { + + publishEvent(new ApplicationUndeployedEvent(appId, clusterData)); } public static void sendGroupCreatedEvent(String appId, String groupId) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index dff493d969..b13465f8f6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -25,12 +25,14 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.CartridgeInformationException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.SpawningException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; +import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; @@ -226,6 +228,20 @@ public synchronized void terminate(String memberId) throws TerminationException } } + public CartridgeInfo getCartrdgeInformation (String cartridgeType) throws CartridgeInformationException { + try { + return stub.getCartridgeInfo(cartridgeType); + + } catch (RemoteException e) { + String msg = e.getMessage(); + log.error(msg, e); + throw new CartridgeInformationException(msg, e); + } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) { + String msg = e.getMessage(); + log.error(msg, e); + throw new CartridgeInformationException(msg, e); + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.java new file mode 100644 index 0000000000..d904e8d662 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/ApplicationDefinitionException.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.autoscaler.exception; + +public class ApplicationDefinitionException extends Exception { + + private String message; + + public ApplicationDefinitionException () { + super(); + } + + public ApplicationDefinitionException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public ApplicationDefinitionException (String message) { + super(message); + this.message = message; + } + + public ApplicationDefinitionException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} + diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java new file mode 100644 index 0000000000..53bea79368 --- /dev/null +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/exception/CartridgeInformationException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.autoscaler.exception; + +public class CartridgeInformationException extends Exception { + + private String message; + + public CartridgeInformationException () { + super(); + } + + public CartridgeInformationException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public CartridgeInformationException (String message) { + super(message); + this.message = message; + } + + public CartridgeInformationException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 9f289abf9a..74cbb5664c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -21,7 +21,9 @@ */ +import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.autoscaler.exception.InvalidPartitionException; import org.apache.stratos.autoscaler.exception.InvalidPolicyException; import org.apache.stratos.autoscaler.exception.NonExistingLBException; @@ -86,4 +88,20 @@ public interface AutoScalerServiceInterface { public String getDefaultLBClusterId (String deploymentPolicyName); public String getServiceLBClusterId (String serviceType, String deploymentPolicyName); + + /** + * deploys an Application Definition + * + * @param applicationContext {@link org.apache.stratos.autoscaler.applications.pojo.ApplicationContext} object + * @throws ApplicationDefinitionException if an error is encountered + */ + public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException; + + /** + * undeploys an Application Definition + * + * @param applicationId Id of the Application to be undeployed + * @throws ApplicationDefinitionException if an error is encountered + */ + public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 0e1417e80d..5e995dacd2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -185,6 +185,11 @@ public Application getApplication (String applicationResourcePath) { return null; } + public void removeApplication (String applicationId) { + delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + + "/" + applicationId); + } + public void persistServiceGroup(ServiceGroup servicegroup) { if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){ throw new IllegalArgumentException("Service group or group name can not be null"); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 4b95118c58..835e2848b5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -72,6 +72,10 @@ private static Application getApplicationFromPath (String appResourcePath) { return RegistryManager.getInstance().getApplication(appResourcePath); } + public static void removeApplication (String applicationId) { + RegistryManager.getInstance().removeApplication(applicationId); + } + /*public static LbClusterMonitor getLBClusterMonitor(Cluster cluster) throws PolicyValidationException, PartitionValidationException { // FIXME fix the following code to correctly update // AutoscalerContext context = AutoscalerContext.getInstance(); From fe674def54161db3f82e12b62eb0db81776456d7 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Fri, 31 Oct 2014 19:28:45 +0530 Subject: [PATCH 350/436] Updating cloud controller service stub bundle exports --- .../interfaces/CloudControllerService.java | 24 +- .../pojo/ApplicationClusterContext.java | 6 +- .../pojo/application/ApplicationContext.java | 6 +- .../pojo/application/ComponentContext.java | 6 +- .../pojo/application/DependencyContext.java | 8 +- .../pojo/application/GroupContext.java | 6 +- .../pojo/application/SubscribableContext.java | 7 +- .../application/SubscribableInfoContext.java | 6 +- .../pojo/payload/MetaDataHolder.java | 5 +- .../pom.xml | 3 +- .../resources/CloudControllerService.wsdl | 1460 ++++++++--------- 11 files changed, 778 insertions(+), 759 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 835cc094a1..1ea57e4d23 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -19,15 +19,6 @@ package org.apache.stratos.cloud.controller.interfaces; import org.apache.stratos.cloud.controller.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.exception.InvalidCartridgeDefinitionException; -import org.apache.stratos.cloud.controller.exception.InvalidCartridgeTypeException; -import org.apache.stratos.cloud.controller.exception.InvalidClusterException; -import org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException; -import org.apache.stratos.cloud.controller.exception.InvalidMemberException; -import org.apache.stratos.cloud.controller.exception.InvalidPartitionException; -import org.apache.stratos.cloud.controller.exception.MemberTerminationFailedException; -import org.apache.stratos.cloud.controller.exception.UnregisteredCartridgeException; -import org.apache.stratos.cloud.controller.exception.UnregisteredClusterException; import org.apache.stratos.cloud.controller.exception.*; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; @@ -46,7 +37,7 @@ public interface CloudControllerService { * @throws InvalidIaasProviderException if the iaas providers configured are not valid. * @throws IllegalArgumentException if the provided argument is not valid. */ - void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) + void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, InvalidIaasProviderException; /** @@ -77,9 +68,9 @@ void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) boolean validatePartition(Partition partition) throws InvalidPartitionException; /** - * Validate a given {@link DeploymentPolicy} against a Cartridge. - * @param cartridgeType type of the cartridge that this policy is going to be attached to. - * @param deploymentPolicy policy to be validated. + * Validate a given deployment policy. + * @param cartridgeType type of the cartridge + * @param partitions partitions * @return whether the policy is a valid one against the given Cartridge. * @throws InvalidPartitionException if the policy contains at least one invalid partition. * @throws InvalidCartridgeTypeException if the given Cartridge type is not a valid one. @@ -93,7 +84,7 @@ boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) * present service cluster, if there is any. A service cluster is uniquely identified by its * domain and sub domain combination. *

- * @param clusterContext information about the new subscription. + * @param registrant information about the new subscription. * @return whether the registration is successful or not. * * @throws UnregisteredCartridgeException @@ -107,7 +98,7 @@ boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) * to the provided Cluster ID. Also note that the instance that is starting up * belongs to the group whose name is derived from its Cluster ID, replacing . * by a hyphen (-). - * @param Member Context with cluster id, partition etc. + * @param member Context with cluster id, partition etc. * @return updated {@link MemberContext} * @throws UnregisteredCartridgeException if the requested Cartridge type is not a registered one. * @throws InvalidIaasProviderException if the iaas requested is not valid. @@ -127,9 +118,6 @@ boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) * * @param memberId * member ID of the instance to be terminated. - * @param partition - * It contains the region, zone, network and host of a IaaS where - * an instance need to be terminated.. * @return whether an instance terminated successfully or not. */ void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java index 8fa9feef95..030a38a4be 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -19,7 +19,11 @@ package org.apache.stratos.cloud.controller.pojo; -public class ApplicationClusterContext { +import java.io.Serializable; + +public class ApplicationClusterContext implements Serializable { + + private static final long serialVersionUID = 9040883765827407542L; // cluster id private String clusterId; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java index 3a8af441d3..804babf96a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java @@ -19,7 +19,11 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class ApplicationContext { +import java.io.Serializable; + +public class ApplicationContext implements Serializable { + + private static final long serialVersionUID = 6704036501869668646L; private int tenantId; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java index d1a13a5d9d..3831b2683e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java @@ -19,7 +19,11 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class ComponentContext { +import java.io.Serializable; + +public class ComponentContext implements Serializable { + + private static final long serialVersionUID = -3841830873207967496L; private GroupContext[] groupContexts; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java index 0459f36b5e..bf79f5334c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java @@ -20,8 +20,12 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class DependencyContext { - +import java.io.Serializable; + +public class DependencyContext implements Serializable { + + private static final long serialVersionUID = 6211713487242343226L; + private String [] startupOrdersContexts; private String killBehaviour; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java index fda4becbec..e0504af696 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java @@ -19,7 +19,11 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class GroupContext { +import java.io.Serializable; + +public class GroupContext implements Serializable{ + + private static final long serialVersionUID = 1595266728968445926L; private String name; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java index 6f7f4bc8ed..88d8f754e5 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java @@ -19,13 +19,16 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class SubscribableContext { +import java.io.Serializable; + +public class SubscribableContext implements Serializable { + + private static final long serialVersionUID = 3853456523070318925L; private String type; private String alias; - public String getType() { return type; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java index 5f75a7c155..5c6bda854a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java @@ -19,7 +19,11 @@ package org.apache.stratos.cloud.controller.pojo.application; -public class SubscribableInfoContext { +import java.io.Serializable; + +public class SubscribableInfoContext implements Serializable { + + private static final long serialVersionUID = -6874644941002783034L; private String alias; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java index 3db9f71b50..662e4810e4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java @@ -19,13 +19,16 @@ package org.apache.stratos.cloud.controller.pojo.payload; +import java.io.Serializable; import java.util.Properties; /** * Holds payload/meta data related to a cluster */ -public class MetaDataHolder { +public class MetaDataHolder implements Serializable { + + private static final long serialVersionUID = -3015788285718847360L; private String appId; diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml index 8576d093e2..6f61083836 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml @@ -92,7 +92,8 @@ org.apache.stratos.cloud.controller.stub.deployment.partition.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.pojo.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.impl.*; version=${project.version}, - org.apache.stratos.cloud.controller.stub.*; version=${project.version} + org.apache.stratos.cloud.controller.stub.*; version=${project.version}, + org.apache.stratos.cloud.controller.pojo.application.xsd.*; version=${project.version}, *;resolution:=optional diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index a72d88d646..c0d195510c 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,1777 +1,1777 @@ - + CloudControllerService - + - - - - - - - + + + + + + + - - - + + + - - + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - + + + + + + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + + + - + - + - + - + - + - + + - + - + - + - + - + - + - + - + - + - + - - - - + + + - + + + + + + + - + + + + + - - + + + + + + + + + - + - - - - - - - - - - - - - + + - + - - + + + + + + + + - + - - - - - - - - - + - + - - + + - + - - - - - - - - + + + + + + + + + + + + + - - + + - - - - + + + + - + - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - + + + - + - - + + + + + + + + + + + - + - - + - + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - + + - + - - - + + + - + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - + - + + - + - - - + + + + + + + + + - - - - + - - - - - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - - + + + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + + + + - - + + - + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + + + + - - + + - + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - + - + - + - + - + - + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file From 16f9ec30c20424875becc7cf2a8ab63d9408a9c5 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Fri, 31 Oct 2014 19:44:44 +0530 Subject: [PATCH 351/436] moving app deployment to Autoscaler --- .../parser/DefaultApplicationParser.java | 6 +- .../client/AutoscalerServiceClient.java | 11 + .../bean/util/converter/PojoConverter.java | 16 +- .../rest/endpoint/services/ServiceUtils.java | 31 +- .../pom.xml | 7 +- .../src/main/resources/AutoScalerService.wsdl | 342 +++++++++++++----- 6 files changed, 292 insertions(+), 121 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index 8184743c50..a2c8ce53fa 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -25,17 +25,13 @@ import org.apache.stratos.autoscaler.applications.ApplicationUtils; import org.apache.stratos.autoscaler.applications.MTClusterInformation; import org.apache.stratos.autoscaler.applications.STClusterInformation; -import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; -import org.apache.stratos.autoscaler.applications.pojo.GroupContext; -import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext; -import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext; +import org.apache.stratos.autoscaler.applications.pojo.*; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.autoscaler.exception.CartridgeInformationException; import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.application.ClusterInformation; -import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; 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 731c80fd92..7e33897cad 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 @@ -24,6 +24,7 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.stub.*; @@ -218,4 +219,14 @@ public ServiceGroup getServiceGroup(String serviceGroupDefinitionName) throws Re public void deployServiceGroup(ServiceGroup serviceGroup) throws AutoScalerServiceInvalidServiceGroupExceptionException, RemoteException { stub.deployServiceGroup(serviceGroup); } + + public void deployApplication (ApplicationContext applicationContext) throws + AutoScalerServiceApplicationDefinitionExceptionException, RemoteException { + stub.deployApplicationDefinition(applicationContext); + } + + public void undeployApplication (String applicationId, int tenantId, String tenantDomain) throws + AutoScalerServiceApplicationDefinitionExceptionException, RemoteException { + stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain); + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 6c8db77abe..cb7d9b355e 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -22,8 +22,11 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.pojo.stub.DependencyContext; +import org.apache.stratos.autoscaler.applications.pojo.stub.GroupContext; +import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext; +import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableInfoContext; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.cloud.controller.stub.pojo.application.*; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; @@ -680,15 +683,16 @@ public static List convertToServiceDefinitionBeans (Colle private static Log log = LogFactory.getLog(PojoConverter.class); - public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) { + public static org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext + convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) { - ApplicationContext applicationContext = new ApplicationContext(); + org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext(); applicationContext.setApplicationId(compositeAppDefinition.getApplicationId()); applicationContext.setAlias(compositeAppDefinition.getAlias()); // convert and set components if (compositeAppDefinition.getComponents() != null) { - ComponentContext componentContext = new ComponentContext(); + org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext componentContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext(); // top level subscribables if (compositeAppDefinition.getComponents().getSubscribables() != null) { componentContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions( @@ -736,7 +740,7 @@ private static SubscribableInfoContext[] getSubscribableInfoContextArrFromSubscr private static DependencyContext getDependencyContextFromDependencyDefinition (DependencyDefinitions dependencyDefinitions) { DependencyContext dependencyContext = new DependencyContext(); - dependencyContext.setKillBehaviour(dependencyDefinitions.getTerminationBehaviour()); + dependencyContext.setTerminationBehaviour(dependencyDefinitions.getTerminationBehaviour()); if (dependencyDefinitions != null && dependencyDefinitions.getStartupOrders() != null) { String [] startupOrders = new String [dependencyDefinitions.getStartupOrders().size()]; @@ -771,7 +775,7 @@ private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List subscribableDefinitions) { + private static org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext [] getSubscribableContextArrayFromSubscribableDefinitions(List subscribableDefinitions) { SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()]; int i = 0; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 2b99f1412f..012611fa93 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.*; @@ -148,19 +149,28 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co throw new RestAPIException(e1); } - ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition); + org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = + PojoConverter.convertApplicationBeanToApplicationContext(appDefinition); applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); - try { - CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); +// try { +// CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); +// +// } catch (RemoteException e) { +// throw new RestAPIException(e); +// } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { +// throw new RestAPIException(e); +// } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { +// throw new RestAPIException(e); +// } - } catch (RemoteException e) { - throw new RestAPIException(e); - } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { + try { + AutoscalerServiceClient.getServiceClient().deployApplication(applicationContext); + } catch (AutoScalerServiceApplicationDefinitionExceptionException e) { throw new RestAPIException(e); - } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { + } catch (RemoteException e) { throw new RestAPIException(e); } } @@ -179,12 +189,13 @@ static void unDeployApplication(String appId, ConfigurationContext ctxt, try { int tenantId = ApplicationManagementUtil.getTenantId(ctxt); - CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain); + //CloudControllerServiceClient.getServiceClient().undeployApplicationDefinition(appId, tenantId, tenantDomain); + AutoscalerServiceClient.getServiceClient().undeployApplication(appId, tenantId, tenantDomain); - } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { - throw new RestAPIException(e); } catch (RemoteException e) { throw new RestAPIException(e); + } catch (AutoScalerServiceApplicationDefinitionExceptionException e) { + throw new RestAPIException(e); } } diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 0df790347e..05f3d50a06 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -47,7 +47,7 @@ - + @@ -92,8 +92,9 @@ org.apache.stratos.autoscaler.policy.model.*; version=${project.version}, org.apache.stratos.autoscaler.exception.*; version=${project.version}, org.apache.stratos.autoscaler.partition.*; version=${project.version}, - org.apache.stratos.autoscaler.api.*; version=${project.version} - org.apache.stratos.autoscaler.pojo.*; version=${project.version} + org.apache.stratos.autoscaler.api.*; version=${project.version}, + org.apache.stratos.autoscaler.pojo.*; version=${project.version}, + org.apache.stratos.autoscaler.applications.pojo.*; version=${project.version} diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index b76e02a1cb..5d64615674 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,58 +1,157 @@ - + AutoScalerService - - - - - - - + + + + + + + + + - + + + - + + + + + + + - + - + + + - + - + + - + - + + + + + + - - - + - - + + - + + + + + + + + + + + + + + + + + - - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -67,6 +166,22 @@ + + + + + + + + + + + + + + + + @@ -273,6 +388,13 @@ + + + + + + + @@ -389,92 +511,53 @@ - - - - - - - - - - + + - - + + - - - - + - - - + + + + - - - - - - - - - - - - - - - + + + + + + + - + - - + - + - - + - + - - + - - - - - + - - - + - - - - + - - - - - - - - - - + @@ -524,6 +607,12 @@ + + + + + + @@ -554,6 +643,9 @@ + + + @@ -653,6 +745,10 @@ + + + + @@ -673,6 +769,10 @@ + + + + @@ -788,6 +888,15 @@ + + + + + + + + + @@ -833,6 +942,15 @@ + + + + + + + + + @@ -1007,6 +1125,15 @@ + + + + + + + + + @@ -1052,6 +1179,15 @@ + + + + + + + + + @@ -1223,6 +1359,12 @@ + + + + + + @@ -1265,6 +1407,12 @@ + + + + + + @@ -1361,22 +1509,22 @@ - + - + - + - + - + - + \ No newline at end of file From 47b31d08608c9f0dcf7c2c3f4485629746769b04 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Fri, 31 Oct 2014 20:17:10 +0530 Subject: [PATCH 352/436] Adding missing application status message receiver in cloud controller --- .../internal/CloudControllerDSComponent.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 797f2998f6..604aed88ba 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -79,7 +79,17 @@ protected void activate(ComponentContext context) { InstanceStatusEventMessageDelegator delegator = new InstanceStatusEventMessageDelegator(); Thread tdelegator = new Thread(delegator); tdelegator.start(); - + if(log.isInfoEnabled()) { + log.info("Instance status message receiver thread started"); + } + + ApplicationStatusTopicReceiver applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver(); + Thread appThread = new Thread(applicationStatusTopicReceiver); + appThread.start(); + if(log.isInfoEnabled()) { + log.info("Application status message receiver thread started"); + } + // Register cloud controller service BundleContext bundleContext = context.getBundleContext(); bundleContext.registerService(CloudControllerService.class.getName(), new CloudControllerServiceImpl(), null); From ef4df6d66397d12fb84e9867bf4f5e934af58158 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Sat, 1 Nov 2014 10:20:01 +0530 Subject: [PATCH 353/436] Removing subscribe method from REST API and refining code/error logs --- ...actAuthenticationAuthorizationHandler.java | 4 +- .../handlers/CustomExceptionMapper.java | 2 +- .../CustomThrowableExceptionMapper.java | 4 +- .../StratosAuthenticationHandler.java | 22 +++-- .../rest/endpoint/services/StratosAdmin.java | 92 ++++++------------- 5 files changed, 45 insertions(+), 79 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/AbstractAuthenticationAuthorizationHandler.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/AbstractAuthenticationAuthorizationHandler.java index b3328414a8..12098608e5 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/AbstractAuthenticationAuthorizationHandler.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/AbstractAuthenticationAuthorizationHandler.java @@ -33,8 +33,6 @@ public abstract class AbstractAuthenticationAuthorizationHandler implements RequestHandler { private Log log = LogFactory.getLog(AbstractAuthenticationAuthorizationHandler.class); - - public Response handleRequest(Message message, ClassResourceInfo classResourceInfo) { HttpHeaders headers = new HttpHeadersImpl(message); List authHeader = headers.getRequestHeader(HttpHeaders.AUTHORIZATION); @@ -47,9 +45,9 @@ public Response handleRequest(Message message, ClassResourceInfo classResourceIn } // give the control to the next handler return null; - } protected abstract boolean canHandle(String authHeaderPrefix); + protected abstract Response handle(Message message,ClassResourceInfo classResourceInfo); } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java index bc6941dd5b..8682b7db06 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomExceptionMapper.java @@ -40,7 +40,7 @@ public Response toResponse(RestAPIException restAPIException) { } // if no specific error message specified, spitting out a generaic error message String errorMessage = (restAPIException.getMessage() != null)? - restAPIException.getMessage():"Error while fullfilling the request"; + restAPIException.getMessage():"Error while fulfilling the request"; // if no specific error specified we are throwing the bad request http status code by default Response.Status httpStatus= (restAPIException.getHTTPStatusCode() != null)? restAPIException.getHTTPStatusCode():Response.Status.BAD_REQUEST; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java index 0f08728e17..74323de899 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/handlers/CustomThrowableExceptionMapper.java @@ -29,8 +29,8 @@ public class CustomThrowableExceptionMapper implements ExceptionMapper Date: Sat, 1 Nov 2014 10:21:33 +0530 Subject: [PATCH 354/436] Removing subscribe command from the CLI --- .../main/java/org/apache/stratos/cli/StratosApplication.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java index a528e61e02..3b1c55a05b 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java @@ -96,9 +96,6 @@ private void createCommands() { command = new ExitCommand(); commands.put(command.getName(), command); - command = new SubscribeCartridgeCommand(); - commands.put(command.getName(), command); - command = new UnsubscribeCommand(); commands.put(command.getName(), command); From b110067c7f68e58b888df99fd6f9b31925b69ece Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Sat, 1 Nov 2014 12:02:39 +0530 Subject: [PATCH 355/436] Adding isKubernetesCluster property to ApplicationClusterContext to propagate it to clusters --- .../cluster/ClusterMonitorFactory.java | 4 +- .../parser/DefaultApplicationParser.java | 14 +++++-- .../pojo/ApplicationClusterContext.java | 39 +++++++------------ .../controller/topology/TopologyBuilder.java | 2 + 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index e2861871cc..d2f45f783f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -100,7 +100,7 @@ private static VMServiceClusterMonitor getVMServiceClusterMonitor(Cluster cluste .getDeploymentPolicy(deploymentPolicyName); if (deploymentPolicy == null) { - String msg = "Deployment Policy is null. Policy name: " + deploymentPolicyName; + String msg = "Deployment policy is null: [policy-name] " + deploymentPolicyName; log.error(msg); throw new PolicyValidationException(msg); } @@ -108,7 +108,7 @@ private static VMServiceClusterMonitor getVMServiceClusterMonitor(Cluster cluste Partition[] allPartitions = deploymentPolicy.getAllPartitions(); if (allPartitions == null) { String msg = - "Deployment Policy's Partitions are null. Policy name: " + + "Partitions are null in deployment policy: [policy-name]: " + deploymentPolicyName; log.error(msg); throw new PolicyValidationException(msg); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 9d909caabb..8f031a7a77 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -33,6 +33,7 @@ import org.apache.stratos.cloud.controller.pojo.application.*; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; +import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.*; import java.util.*; @@ -549,12 +550,14 @@ private Map parseLeafLevelSubscriptions (String appId String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); + boolean isKubernetesCluster = StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType()); // create and collect this cluster's information assert subscribableInfoCtxt != null; ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), - clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases()); + clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), + false, isKubernetesCluster, subscribableInfoCtxt.getDependencyAliases()); appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); @@ -579,7 +582,8 @@ private Map parseLeafLevelSubscriptions (String appId * @param clusterId Cluster id * @param hostname Hostname * @param deploymentPolicy Deployment policy used - * @param isLB if this cluster is an LB + * @param isLBCluster if this cluster is an LB + * @param isKubernetesCluster if this cluster is a Kubernetes cluster * @return ApplicationClusterContext object with relevant information * * @throws ApplicationDefinitionException If any error occurs @@ -587,14 +591,16 @@ private Map parseLeafLevelSubscriptions (String appId private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String repoUrl, String alias, String clusterId, String hostname, - String deploymentPolicy, boolean isLB, String[] dependencyAliases) + String deploymentPolicy, boolean isLBCluster, + boolean isKubernetesCluster, String[] dependencyAliases) throws ApplicationDefinitionException { // Create text payload String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId, hostname, repoUrl, alias, null, dependencyAliases).toString(); - return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); + return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, + isLBCluster, isKubernetesCluster); } private Cartridge getCartridge (String cartridgeType) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java index 030a38a4be..ffb0b768a4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -28,22 +28,25 @@ public class ApplicationClusterContext implements Serializable { // cluster id private String clusterId; // cartridge type - private String cartridgeType; + private final String cartridgeType; // payload as a String - private String textPayload; + private final String textPayload; // host name private String hostName; // flag to indicate LB cluster - private boolean isLbCluster; + private final boolean isLbCluster; + // flag to indicate Kubernetes cluster + private final boolean isKubernetesCluster; // autoscaling policy private String autoscalePolicyName; // deployment policy - private String deploymentPolicyName; + private final String deploymentPolicyName; // tenant rance - private String tenantRange; + private final String tenantRange; public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName, - String textPayload, String deploymentPolicyName, boolean isLbCluster) { + String textPayload, String deploymentPolicyName, boolean isLbCluster, + boolean isKubernetesCluster) { this.cartridgeType = cartridgeType; this.clusterId = clusterId; @@ -51,6 +54,7 @@ public ApplicationClusterContext (String cartridgeType, String clusterId, String this.textPayload = textPayload; this.deploymentPolicyName = deploymentPolicyName; this.isLbCluster = isLbCluster; + this.isKubernetesCluster = isKubernetesCluster; this.tenantRange = "*"; } @@ -66,18 +70,10 @@ public String getCartridgeType() { return cartridgeType; } - public void setCartridgeType(String cartridgeType) { - this.cartridgeType = cartridgeType; - } - public String getTextPayload() { return textPayload; } - public void setTextPayload(String textPayload) { - this.textPayload = textPayload; - } - public String getHostName() { return hostName; } @@ -90,10 +86,6 @@ public boolean isLbCluster() { return isLbCluster; } - public void setLbCluster(boolean lbCluster) { - isLbCluster = lbCluster; - } - public String getAutoscalePolicyName() { return autoscalePolicyName; } @@ -106,18 +98,10 @@ public String getDeploymentPolicyName() { return deploymentPolicyName; } - public void setDeploymentPolicyName(String deploymentPolicyName) { - this.deploymentPolicyName = deploymentPolicyName; - } - public String getTenantRange() { return tenantRange; } - public void setTenantRange(String tenantRange) { - this.tenantRange = tenantRange; - } - public boolean equals(Object other) { if(other == null || !(other instanceof ApplicationClusterContext)) { @@ -138,4 +122,7 @@ public int hashCode () { return this.cartridgeType.hashCode() + this.clusterId.hashCode(); } + public boolean isKubernetesCluster() { + return isKubernetesCluster; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 550926665e..fa1a3eed46 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -566,6 +566,8 @@ public static synchronized void handleApplicationDeployed(Application applicatio //cluster.setStatus(Status.Created); cluster.addHostName(applicationClusterContext.getHostName()); cluster.setTenantRange(applicationClusterContext.getTenantRange()); + cluster.setLbCluster(applicationClusterContext.isLbCluster()); + cluster.setKubernetesCluster(applicationClusterContext.isKubernetesCluster()); clusters.add(cluster); Service service = topology.getService(applicationClusterContext.getCartridgeType()); From 262b674dc19c0e7e7d22485ae93cea997550974c Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Sat, 1 Nov 2014 13:23:54 +0530 Subject: [PATCH 356/436] Adding properties to application definition and propagating them to clusters --- .../parser/DefaultApplicationParser.java | 25 +- .../impl/CloudControllerServiceImpl.java | 5 +- .../pojo/ApplicationClusterContext.java | 17 +- .../pojo/application/ApplicationContext.java | 15 + .../controller/topology/TopologyBuilder.java | 1 + .../beans/ApplicationDefinition.java | 11 + .../application/beans/PropertyBean.java | 46 +++ .../DefaultCompositeApplicationParser.java | 15 +- .../structure/CompositeAppContext.java | 11 + .../rest/endpoint/services/ServiceUtils.java | 14 +- .../resources/CloudControllerService.wsdl | 386 +++++++++--------- 11 files changed, 330 insertions(+), 216 deletions(-) create mode 100644 components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java index 8f031a7a77..b3692f049a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java @@ -30,6 +30,7 @@ import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.pojo.Cartridge; +import org.apache.stratos.cloud.controller.pojo.Properties; import org.apache.stratos.cloud.controller.pojo.application.*; import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -253,7 +254,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, if (appCtxt.getComponents().getSubscribableContexts() != null) { clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), - subscribableInfoCtxts); + subscribableInfoCtxts, appCtxt.getProperties()); application.setClusterData(clusterDataMap); //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); } @@ -262,7 +263,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, if (appCtxt.getComponents().getGroupContexts() != null) { application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()), - subscribableInfoCtxts, definedGroupCtxts)); + subscribableInfoCtxts, definedGroupCtxts, appCtxt.getProperties())); } // get top level Dependency definitions @@ -306,13 +307,13 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, */ private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, Map subscribableInformation, - Map definedGroupCtxts) + Map definedGroupCtxts, Properties properties) throws ApplicationDefinitionException { Map groupAliasToGroup = new HashMap(); for (GroupContext groupCtxt : groupCtxts) { - Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts); + Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts, properties); groupAliasToGroup.put(group.getAlias(), group); } @@ -383,7 +384,7 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr */ private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, Map subscribableInfoCtxts, - Map definedGroupCtxts) + Map definedGroupCtxts, Properties properties) throws ApplicationDefinitionException { // check if are in the defined Group set @@ -411,7 +412,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g // get group level Subscribables if (groupCtxt.getSubscribableContexts() != null) { clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), - Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); + Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts, properties); group.setClusterData(clusterDataMap); } @@ -424,7 +425,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, subscribableInfoCtxts, - definedGroupCtxts); + definedGroupCtxts, properties); nestedGroups.put(nestedGroup.getAlias(), nestedGroup); } @@ -512,7 +513,8 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi */ private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, List subscribableCtxts, - Map subscribableInfoCtxts) + Map subscribableInfoCtxts, + Properties properties) throws ApplicationDefinitionException { Map clusterDataMap = new HashMap(); @@ -557,7 +559,7 @@ private Map parseLeafLevelSubscriptions (String appId ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), - false, isKubernetesCluster, subscribableInfoCtxt.getDependencyAliases()); + false, isKubernetesCluster, subscribableInfoCtxt.getDependencyAliases(), properties); appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); @@ -592,7 +594,8 @@ private ApplicationClusterContext createApplicationClusterContext (String appId, String subscriptionKey, int tenantId, String repoUrl, String alias, String clusterId, String hostname, String deploymentPolicy, boolean isLBCluster, - boolean isKubernetesCluster, String[] dependencyAliases) + boolean isKubernetesCluster, String[] dependencyAliases, + Properties properties) throws ApplicationDefinitionException { // Create text payload @@ -600,7 +603,7 @@ private ApplicationClusterContext createApplicationClusterContext (String appId, hostname, repoUrl, alias, null, dependencyAliases).toString(); return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, - isLBCluster, isKubernetesCluster); + isLBCluster, isKubernetesCluster, properties); } private Cartridge getCartridge (String cartridgeType) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 901082c86d..10b07300b9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1439,7 +1439,8 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), - applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster(), null)); + applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster(), + CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties()))); } TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), @@ -1448,7 +1449,7 @@ public void deployApplicationDefinition (ApplicationContext applicationContext) persist(); } - @Override + @Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java index ffb0b768a4..fb52ece60e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -43,10 +43,12 @@ public class ApplicationClusterContext implements Serializable { private final String deploymentPolicyName; // tenant rance private final String tenantRange; + // properties + private Properties properties; - public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName, - String textPayload, String deploymentPolicyName, boolean isLbCluster, - boolean isKubernetesCluster) { + public ApplicationClusterContext(String cartridgeType, String clusterId, String hostName, + String textPayload, String deploymentPolicyName, boolean isLbCluster, + boolean isKubernetesCluster, Properties properties) { this.cartridgeType = cartridgeType; this.clusterId = clusterId; @@ -56,6 +58,7 @@ public ApplicationClusterContext (String cartridgeType, String clusterId, String this.isLbCluster = isLbCluster; this.isKubernetesCluster = isKubernetesCluster; this.tenantRange = "*"; + this.properties = properties; } public String getClusterId() { @@ -125,4 +128,12 @@ public int hashCode () { public boolean isKubernetesCluster() { return isKubernetesCluster; } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java index 804babf96a..19ef8b6ecb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.pojo.application; +import org.apache.stratos.cloud.controller.pojo.Properties; + import java.io.Serializable; public class ApplicationContext implements Serializable { @@ -39,6 +41,11 @@ public class ApplicationContext implements Serializable { private SubscribableInfoContext[] subscribableInfoContexts; + private Properties properties; + + public ApplicationContext() { + } + public String getApplicationId() { return applicationId; } @@ -94,4 +101,12 @@ public String getTeantAdminUsername() { public void setTeantAdminUsername(String teantAdminUsername) { this.teantAdminUsername = teantAdminUsername; } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index fa1a3eed46..2c01be7166 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -568,6 +568,7 @@ public static synchronized void handleApplicationDeployed(Application applicatio cluster.setTenantRange(applicationClusterContext.getTenantRange()); cluster.setLbCluster(applicationClusterContext.isLbCluster()); cluster.setKubernetesCluster(applicationClusterContext.isKubernetesCluster()); + cluster.setProperties(CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties())); clusters.add(cluster); Service service = topology.getService(applicationClusterContext.getCartridgeType()); 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 index fb201f88a8..1c316af5c5 100644 --- 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 @@ -33,6 +33,9 @@ public class ApplicationDefinition { private List subscribableInfo; + private List property; + + public String getApplicationId() { return applicationId; } @@ -64,4 +67,12 @@ public List getSubscribableInfo() { public void setSubscribableInfo(List subscribableInfo) { this.subscribableInfo = subscribableInfo; } + + public List getProperty() { + return property; + } + + public void setProperty(List property) { + this.property = property; + } } 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 new file mode 100644 index 0000000000..c5c4c561c4 --- /dev/null +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/beans/PropertyBean.java @@ -0,0 +1,46 @@ +/* + * 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; + +@XmlRootElement(name = "property") +public class PropertyBean { + + 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; + } +} diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java index 9a49e2c20e..c16c24859e 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/parser/DefaultCompositeApplicationParser.java @@ -24,10 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.manager.client.CloudControllerServiceClient; -import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; -import org.apache.stratos.manager.composite.application.beans.GroupDefinition; -import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; -import org.apache.stratos.manager.composite.application.beans.SubscribableInfo; +import org.apache.stratos.manager.composite.application.beans.*; import org.apache.stratos.manager.composite.application.structure.CompositeAppContext; import org.apache.stratos.manager.composite.application.structure.GroupContext; import org.apache.stratos.manager.composite.application.structure.StartupOrder; @@ -210,7 +207,6 @@ private CompositeAppContext buildCompositeAppStructure (ApplicationDefinition co } // get top level Dependency definitions - if (compositeAppDefinition.getComponents().getDependencies() != null) { List startupOrderList = compositeAppDefinition.getComponents().getDependencies().getStartupOrders(); String [] startupOrders = new String [startupOrderList.size()]; @@ -219,6 +215,15 @@ private CompositeAppContext buildCompositeAppStructure (ApplicationDefinition co compositeAppContext.setKillBehaviour(compositeAppDefinition.getComponents().getDependencies().getKillBehaviour()); } + + // Set application properties + if(compositeAppDefinition.getProperty() != null) { + Properties properties = new Properties(); + for(PropertyBean propertyBean : compositeAppDefinition.getProperty()) { + properties.put(propertyBean.getName(), propertyBean.getValue()); + } + compositeAppContext.setProperties(properties); + } } return compositeAppContext; diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java index 287d475cc3..c3ffdd68ae 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/composite/application/structure/CompositeAppContext.java @@ -19,6 +19,7 @@ package org.apache.stratos.manager.composite.application.structure; +import java.util.Properties; import java.util.Set; public class CompositeAppContext { @@ -35,6 +36,8 @@ public class CompositeAppContext { private String killBehaviour; + private Properties properties; + public CompositeAppContext (String appId) { this.appId = appId; } @@ -104,4 +107,12 @@ public int hashCode () { return appId.hashCode(); } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index dc164b8625..b3e874768f 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -30,9 +30,8 @@ import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.*; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager; @@ -136,6 +135,15 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); + Properties properties = new Properties(); + for(org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { + Property property = new Property(); + property.setName(propertyBean.getName()); + property.setValue(propertyBean.getValue()); + properties.addProperties(property); + } + applicationContext.setProperties(properties); + try { CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index c0d195510c..a1af8a4797 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,13 +6,15 @@ - + + - - + + + @@ -20,9 +22,9 @@ - - - + + + @@ -36,9 +38,9 @@ - + - + @@ -61,7 +63,7 @@ - + @@ -71,27 +73,27 @@ - + - + - + - + - + @@ -101,191 +103,194 @@ - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -303,186 +308,183 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - - + - + - + - + + - + - + - + - + - + - + - + @@ -496,38 +498,21 @@ - + - - - - - - - - - - - - - - + - - + + + + - + - - - - - - - - + + @@ -541,37 +526,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -637,6 +591,24 @@ + + + + + + + + + + + + + + + + + + @@ -672,17 +644,34 @@ - + + + - - - - - + + + + + + + + + + + + + + + + + + + + @@ -691,6 +680,19 @@ + + + + + + + + + + + + + @@ -1756,22 +1758,22 @@ - + - + - + - + - + - + \ No newline at end of file From 52481bbf4ca6ad883c85cc28183859609b4bfb7a Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Sat, 1 Nov 2014 13:34:41 +0530 Subject: [PATCH 357/436] Fixing stratos distribution to move drools files to repository/conf/drools folder --- .../stratos/modules/distribution/src/assembly/bin.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/products/stratos/modules/distribution/src/assembly/bin.xml b/products/stratos/modules/distribution/src/assembly/bin.xml index 82ae6fc218..7be25344ce 100755 --- a/products/stratos/modules/distribution/src/assembly/bin.xml +++ b/products/stratos/modules/distribution/src/assembly/bin.xml @@ -669,21 +669,21 @@ true 755
- + src/main/conf/drools/mincheck.drl - ${pom.artifactId}-${pom.version}/repository/conf + ${pom.artifactId}-${pom.version}/repository/conf/drools true 755 src/main/conf/drools/scaling.drl - ${pom.artifactId}-${pom.version}/repository/conf + ${pom.artifactId}-${pom.version}/repository/conf/drools true 755 src/main/conf/drools/terminateall.drl - ${pom.artifactId}-${pom.version}/repository/conf + ${pom.artifactId}-${pom.version}/repository/conf/drools true 755 From 44fd12546831fa5f16fbf0bfead35548f1511d71 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Sat, 1 Nov 2014 21:24:02 +0530 Subject: [PATCH 358/436] fixing autoscaler topology event receiver logic --- .../AutoscalerTopologyEventReceiver.java | 457 +++++++----------- .../monitor/cluster/VMClusterMonitor.java | 4 + 2 files changed, 179 insertions(+), 282 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index d6a140a8cb..fedeab9f73 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -19,37 +19,76 @@ package org.apache.stratos.autoscaler.message.receiver.topology; +import java.util.Set; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.*; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.*; +import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.NetworkPartitionContext; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.PartitionValidationException; +import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; -import org.apache.stratos.autoscaler.monitor.cluster.KubernetesClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.partition.PartitionManager; -import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Application; +import org.apache.stratos.messaging.domain.topology.ApplicationStatus; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.GroupStatus; 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.event.topology.ApplicationActivatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; +import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterInactivateEvent; +import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent; +import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; +import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; +import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; +import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; +import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; +import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.ApplicationActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.ApplicationCreatedEventListener; +import org.apache.stratos.messaging.listener.topology.ApplicationTerminatedEventListener; +import org.apache.stratos.messaging.listener.topology.ApplicationTerminatingEventListener; +import org.apache.stratos.messaging.listener.topology.ApplicationUndeployedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterTerminatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterTerminatingEventListener; +import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; +import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupInActivateEventListener; +import org.apache.stratos.messaging.listener.topology.GroupTerminatedEventListener; +import org.apache.stratos.messaging.listener.topology.GroupTerminatingEventListener; +import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener; +import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; -import java.util.List; -import java.util.Set; - /** * Autoscaler topology receiver. */ @@ -464,297 +503,151 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = - (MemberReadyToShutdownEvent) event; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - String memberId = memberReadyToShutdownEvent.getMemberId(); - - if (asCtx.clusterMonitorExist(clusterId)) { - monitor = asCtx.getClusterMonitor(clusterId); - } else { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found " + - "in autoscaler context [cluster] %s", clusterId)); - } - return; - } - - if(monitor instanceof VMClusterMonitor) { - VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; - NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = vmClusterMonitor.getNetworkPartitionCtxt( - memberReadyToShutdownEvent.getNetworkPartitionId()); - - String partitionId = vmClusterMonitor.getPartitionOfMember(memberId); - PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); - - // terminate the member - CloudControllerClient ccClient = CloudControllerClient.getInstance(); - ccClient.terminate(memberId); - // remove from active member list - partitionCtxt.removeActiveMemberById(memberId); - - - if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active " + - "members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); - } - } else if(monitor instanceof KubernetesClusterMonitor) { - KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; - kubernetesClusterMonitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); - } - } catch (TerminationException e) { - log.error(e); - } - } - - }); + topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { + @Override + protected void onEvent(Event event) { + try { + MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent) event; + String clusterId = memberReadyToShutdownEvent.getClusterId(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); + } catch (Exception e) { + String msg = "Error processing event " + + e.getLocalizedMessage(); + log.error(msg, e); + } + } + }); topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { - @Override - protected void onEvent(Event event) { - - ClusterRemovedEvent clusterRemovedEvent = null; - try { - clusterRemovedEvent = (ClusterRemovedEvent) event; - //TopologyManager.acquireReadLock(); + @Override + protected void onEvent(Event event) { + ClusterRemovedEvent clusterRemovedEvent = (ClusterRemovedEvent) event; + try { + //TopologyManager.acquireReadLock(); TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), clusterRemovedEvent.getClusterId()); - - String clusterId = clusterRemovedEvent.getClusterId(); - String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); - - AbstractClusterMonitor monitor; - - if (clusterRemovedEvent.isLbCluster()) { - DeploymentPolicy depPolicy = PolicyManager.getInstance(). - getDeploymentPolicy(deploymentPolicy); - if (depPolicy != null) { - List lbHolders = PartitionManager.getInstance() - .getNetworkPartitionLbHolders(depPolicy); - - for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) { - // removes lb cluster ids - boolean isRemoved = networkPartitionLbHolder.removeLbClusterId(clusterId); - if (isRemoved) { - log.info("Removed the lb cluster [id]:" - + clusterId - + " reference from Network Partition [id]: " - + networkPartitionLbHolder - .getNetworkPartitionId()); - - } - if (log.isDebugEnabled()) { - log.debug(networkPartitionLbHolder); - } - - } - } - monitor = AutoscalerContext.getInstance() - .removeClusterMonitor(clusterId); - - } else { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() - .removeClusterMonitor(clusterId); - } - - // runTerminateAllRule(monitor); - if (monitor != null) { - monitor.destroy(); - log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", - clusterId)); - } - } catch (Exception e) { - log.error("Error processing event", e); - } finally { + String clusterId = clusterRemovedEvent.getClusterId(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleClusterRemovedEvent(clusterRemovedEvent); + asCtx.removeClusterMonitor(clusterId); + monitor.destroy(); + log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", + clusterId)); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } finally { //TopologyManager.releaseReadLock(); TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), clusterRemovedEvent.getClusterId()); } - } + } + }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - - MemberTerminatedEvent memberTerminatedEvent = null; - try { - //TopologyManager.acquireReadLock(); - - memberTerminatedEvent = (MemberTerminatedEvent) event; - String networkPartitionId = memberTerminatedEvent.getNetworkPartitionId(); - String clusterId = memberTerminatedEvent.getClusterId(); - String partitionId = memberTerminatedEvent.getPartitionId(); - - TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), - memberTerminatedEvent.getClusterId()); - - AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); - if(monitor == null) { - log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); - return; - } - - if(monitor instanceof VMClusterMonitor) { - VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; - NetworkPartitionContext networkPartitionContext = vmClusterMonitor. - getNetworkPartitionCtxt(networkPartitionId); - - PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); - String memberId = memberTerminatedEvent.getMemberId(); - partitionContext.removeMemberStatsContext(memberId); - - - if (partitionContext.removeTerminationPendingMember(memberId)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from termination pending " + - "members list: [member] %s", memberId)); - } - } else if (partitionContext.removePendingMember(memberId)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from pending members list: " + - "[member] %s", memberId)); - } - } else if (partitionContext.removeActiveMemberById(memberId)) { - log.warn(String.format("Member is in the wrong list and it is removed " + - "from active members list", memberId)); - } else { - log.warn(String.format("Member is not available in any of the list " + - "active, pending and termination pending", memberId)); - } - - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been removed " + - " successfully: [member] %s", memberId)); - } - //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated - StatusChecker.getInstance().onMemberTermination(clusterId); - } else if(monitor instanceof KubernetesClusterMonitor) { - KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; - kubernetesClusterMonitor.handleMemberTerminatedEvent(memberTerminatedEvent); - } - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), - memberTerminatedEvent.getClusterId()); - } - } - }); + @Override + protected void onEvent(Event event) { + try { + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + String clusterId = memberTerminatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberTerminatedEvent(memberTerminatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } + }); topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { - @Override - protected void onEvent(Event event) { - - MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; - - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), - memberActivatedEvent.getClusterId()); - - try { - - String networkPartitionId = memberActivatedEvent.getNetworkPartitionId(); - String clusterId = memberActivatedEvent.getClusterId(); - String partitionId = memberActivatedEvent.getPartitionId(); - String memberId = memberActivatedEvent.getMemberId(); - - AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); - if(monitor == null) { - log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); - return; - } - - if(monitor instanceof VMClusterMonitor) { - VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; - NetworkPartitionContext networkPartitionContext = vmClusterMonitor. - getNetworkPartitionCtxt(networkPartitionId); - PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); - - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - // TODO starting the pending clusters which are waiting for this member activation in a cluster - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added " + - "successfully: [member] %s", memberId)); - } - partitionContext.movePendingMemberToActiveMembers(memberId); - //triggering the status checker - StatusChecker.getInstance().onMemberStatusChange(memberActivatedEvent.getClusterId()); - } else if(monitor instanceof KubernetesClusterMonitor) { - KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; - kubernetesClusterMonitor.handleMemberActivatedEvent(memberActivatedEvent); - } - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { + @Override + protected void onEvent(Event event) { + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + try { + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), + memberActivatedEvent.getClusterId()); + String clusterId = memberActivatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberActivatedEvent(memberActivatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } finally { //TopologyManager.releaseReadLock(); TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), memberActivatedEvent.getClusterId()); } - } + } }); - + topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { - @Override - protected void onEvent(Event event) { - - MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; - - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), - memberMaintenanceModeEvent.getClusterId()); - - try { - - String memberId = memberMaintenanceModeEvent.getMemberId(); - String partitionId = memberMaintenanceModeEvent.getPartitionId(); - String networkPartitionId = memberMaintenanceModeEvent.getNetworkPartitionId(); - - PartitionContext partitionContext; - String clusterId = memberMaintenanceModeEvent.getClusterId(); - - AbstractClusterMonitor monitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); - if(monitor == null) { - log.error(String.format("Cluster monitor not found in autoscaler context: [clusterId] %s ", clusterId)); - return; - } - - if(monitor instanceof VMClusterMonitor) { - VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; - partitionContext = vmClusterMonitor.getNetworkPartitionCtxt(networkPartitionId). - getPartitionCtxt(partitionId); - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - if (log.isDebugEnabled()) { - log.debug(String.format("Member has been moved as pending termination: " + - "[member] %s", memberId)); - } - partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); - } else if(monitor instanceof KubernetesClusterMonitor) { - KubernetesClusterMonitor kubernetesClusterMonitor = (KubernetesClusterMonitor) monitor; - kubernetesClusterMonitor.handleMemberMaintenanceModeEvent(memberMaintenanceModeEvent); - } - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { + @Override + protected void onEvent(Event event) { + MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; + //TopologyManager.acquireReadLock(); + TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), + memberMaintenanceModeEvent.getClusterId()); + try { + String clusterId = memberMaintenanceModeEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberMaintenanceModeEvent(memberMaintenanceModeEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } finally { TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), memberMaintenanceModeEvent.getClusterId()); } - } + } }); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index d4b6a25fb5..336550354b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -30,6 +30,7 @@ import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; +import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; @@ -511,6 +512,7 @@ public void handleMemberTerminatedEvent( String networkPartitionId = memberTerminatedEvent.getNetworkPartitionId(); String memberId = memberTerminatedEvent.getMemberId(); + String clusterId = memberTerminatedEvent.getClusterId(); String partitionId = memberTerminatedEvent.getPartitionId(); NetworkPartitionContext networkPartitionContext = getNetworkPartitionCtxt(networkPartitionId); PartitionContext partitionContext = networkPartitionContext.getPartitionCtxt(partitionId); @@ -541,6 +543,8 @@ public void handleMemberTerminatedEvent( log.info(String.format("Member stat context has been removed successfully: " + "[member] %s", memberId)); } + //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated + StatusChecker.getInstance().onMemberTermination(clusterId); } @Override From a61fc9d0b484826f87426132a1a2a5bc18ad60f3 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Sat, 1 Nov 2014 22:50:34 +0530 Subject: [PATCH 359/436] Fixing NPE while deploying applications without properties --- .../rest/endpoint/services/ServiceUtils.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index b3e874768f..97eda8984a 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -136,13 +136,15 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co applicationContext.setTeantAdminUsername(userName); Properties properties = new Properties(); - for(org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { - Property property = new Property(); - property.setName(propertyBean.getName()); - property.setValue(propertyBean.getValue()); - properties.addProperties(property); + if(appDefinition.getProperty() != null) { + for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { + Property property = new Property(); + property.setName(propertyBean.getName()); + property.setValue(propertyBean.getValue()); + properties.addProperties(property); + } + applicationContext.setProperties(properties); } - applicationContext.setProperties(properties); try { CloudControllerServiceClient.getServiceClient().deployApplicationDefinition(applicationContext); From 572cbe329bfd8008df899919787ec0732c387b85 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Sun, 2 Nov 2014 15:42:36 +0530 Subject: [PATCH 360/436] more refactoring --- .../parser/ApplicationParser.java | 4 +- .../parser/DefaultApplicationParser.java | 10 +- .../topic/ApplicationBuilder.java | 4 +- .../application/ApplicationUtils.java | 291 ----- .../application/ClusterInformation.java | 27 - .../application/MTClusterInformation.java | 45 - .../application/STClusterInformation.java | 55 - .../parser/DefaultApplicationParser.java | 634 ---------- .../application/parser/ParserUtils.java | 142 --- .../ApplicationCartridgePayloadData.java | 27 - .../application/payload/BasicPayloadData.java | 311 ----- .../payload/DataCartridgePayloadData.java | 27 - .../FrameworkCartridgePayloadData.java | 27 - .../LoadBalancerCartridgePayloadData.java | 27 - .../application/payload/PayloadData.java | 69 - .../application/payload/PayloadFactory.java | 59 - .../impl/CloudControllerServiceImpl.java | 50 +- .../interfaces/ApplicationParser.java | 53 - .../interfaces/CloudControllerService.java | 17 - .../pojo/application/ApplicationContext.java | 93 -- .../pojo/application/ComponentContext.java | 54 - .../pojo/application/DependencyContext.java | 44 - .../pojo/application/GroupContext.java | 84 -- .../pojo/application/SubscribableContext.java | 44 - .../application/SubscribableInfoContext.java | 103 -- .../pojo/payload/MetaDataHolder.java | 99 -- .../CompositeApplicationParseTest.java | 1108 ++++++++--------- .../client/CloudControllerServiceClient.java | 17 - .../applications/ClusterDataHolder.java | 1 - .../rest/endpoint/services/ServiceUtils.java | 1 - .../pom.xml | 3 +- .../resources/CloudControllerService.wsdl | 622 ++++----- 32 files changed, 826 insertions(+), 3326 deletions(-) delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java delete mode 100755 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java index 529c1f8eb6..f1f59e5682 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java @@ -26,7 +26,9 @@ import java.util.Set; - +/** + * Parses the Application Definition + */ public interface ApplicationParser { /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index a2c8ce53fa..fa31385e85 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -40,12 +40,14 @@ import java.util.*; +/** + * Default implementation of the Application Parser. One Application should be processed by one + * instance of the DefaultApplicationParser. + */ public class DefaultApplicationParser implements ApplicationParser { private static Log log = LogFactory.getLog(DefaultApplicationParser.class); -// private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); - private Set applicationClusterContexts; public DefaultApplicationParser () { @@ -466,7 +468,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g */ private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { - ServiceGroup serviceGroup = null; + ServiceGroup serviceGroup; try { serviceGroup = RegistryManager.getInstance().getServiceGroup(groupContext.getName()); } catch (Exception e) { @@ -512,7 +514,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g */ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException { - ServiceGroup serviceGroup = null; + ServiceGroup serviceGroup; try { serviceGroup = RegistryManager.getInstance().getServiceGroup(serviceGroupName); } catch (Exception e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 07ddfb6ed9..6adf3b138f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -143,8 +143,8 @@ public class ApplicationBuilder { ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); }*/ - public static void handleApplicationCreated (Application application, - Set appClusterCtxts) { + public static synchronized void handleApplicationCreated (Application application, + Set appClusterContexts) { Applications applications = ApplicationHolder.getApplications(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java deleted file mode 100644 index 35600c4e82..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ApplicationUtils.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.payload.BasicPayloadData; -import org.apache.stratos.cloud.controller.application.payload.PayloadData; -import org.apache.stratos.cloud.controller.application.payload.PayloadFactory; -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.PortMapping; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableInfoContext; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; - -import java.util.*; -import java.util.regex.Pattern; - -public class ApplicationUtils { - private static final Log log = LogFactory.getLog(ApplicationUtils.class); - - public static boolean isAliasValid (String alias) { - - String patternString = "([a-z0-9]+([-][a-z0-9])*)+"; - Pattern pattern = Pattern.compile(patternString); - - return pattern.matcher(alias).matches(); - } - - public static boolean isValid (String arg) { - - if (arg == null || arg.isEmpty()) { - return false; - } else { - return true; - } - } - - public static Properties getGlobalPayloadData () { - - Properties globalProperties = new Properties(); - - if (System.getProperty("puppet.ip") != null) { - globalProperties.setProperty("PUPPET_IP", System.getProperty("puppet.ip")); - } - if (System.getProperty("puppet.hostname") != null) { - globalProperties.setProperty("PUPPET_HOSTNAME", System.getProperty("puppet.hostname")); - } - if (System.getProperty("puppet.env") != null) { - globalProperties.setProperty("PUPPET_ENV", System.getProperty("puppet.env")); - } - if (System.getProperty("puppet.dns.available") != null) { - globalProperties.setProperty("PUPPET_DNS_AVAILABLE", System.getProperty("puppet.dns.available")); - } - - return globalProperties; - } - - public static MetaDataHolder getClusterLevelPayloadData (String appId, String groupName, int tenantId, String key, - String hostname, String tenantRange, String clusterId, - SubscribableContext subscribableCtxt, - SubscribableInfoContext subscribableInfoCtxt, - Cartridge cartridge) { - - MetaDataHolder metaDataHolder; - if (groupName != null) { - metaDataHolder = new MetaDataHolder(appId, groupName, clusterId); - } else { - metaDataHolder = new MetaDataHolder(appId, clusterId); - } - - Properties clusterLevelPayloadProperties = new Properties(); - // app id - clusterLevelPayloadProperties.setProperty("APP_ID", appId); - // group name - if (groupName != null) { - clusterLevelPayloadProperties.setProperty("GROUP_NAME", groupName); - } - // service name - if (subscribableCtxt.getType() != null) { - clusterLevelPayloadProperties.put("SERVICE_NAME", subscribableCtxt.getType()); - } - // host name - if (hostname != null) { - clusterLevelPayloadProperties.put("HOST_NAME", hostname); - } - // multi tenant - clusterLevelPayloadProperties.put("MULTITENANT", String.valueOf(cartridge.isMultiTenant())); - // tenant range - if (tenantRange != null) { - clusterLevelPayloadProperties.put("TENANT_RANGE", tenantRange); - } - // cartridge alias - if (subscribableCtxt.getAlias() != null) { - clusterLevelPayloadProperties.put("CARTRIDGE_ALIAS", subscribableCtxt.getAlias()); - } - // cluster id - if (clusterId != null) { - clusterLevelPayloadProperties.put("CLUSTER_ID", clusterId); - } - // repo url - if (subscribableInfoCtxt.getRepoUrl() != null) { - clusterLevelPayloadProperties.put("REPO_URL", subscribableInfoCtxt.getRepoUrl()); - } - // ports -// if (createPortMappingPayloadString(cartridge) != null) { -// clusterLevelPayloadProperties.put("PORTS", createPortMappingPayloadString(cartridge)); -// } - // provider - if (cartridge.getProvider() != null) { - clusterLevelPayloadProperties.put("PROVIDER", cartridge.getProvider()); - } - // tenant id - clusterLevelPayloadProperties.setProperty("TENANT_ID", String.valueOf(tenantId)); - // cartridge key - clusterLevelPayloadProperties.setProperty("CARTRIDGE_KEY", key); - // get global payload params - //clusterLevelPayloadProperties.putAll(ApplicationUtils.getGlobalPayloadData()); - - metaDataHolder.setProperties(clusterLevelPayloadProperties); - return metaDataHolder; - } - - private static String createPortMappingPayloadString (Cartridge cartridge) { - - // port mappings - StringBuilder portMapBuilder = new StringBuilder(); - List portMappings = cartridge.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 StringBuilder getTextPayload (String appId, String groupName, String clusterId) { - - StringBuilder payloadBuilder = new StringBuilder(); - payloadBuilder.append("APP_ID=" + appId); - if (groupName != null) { - payloadBuilder.append(","); - payloadBuilder.append("GROUP_NAME=" + groupName); - } - payloadBuilder.append(","); - payloadBuilder.append("CLUSTER_ID=" + clusterId); - // puppet related - if (System.getProperty("puppet.ip") != null) { - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_IP=" + System.getProperty("puppet.ip")); - } - if (System.getProperty("puppet.hostname") != null) { - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); - } - if (System.getProperty("puppet.env") != null) { - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.env")); - } - if (System.getProperty("puppet.dns.available") != null) { - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.dns.available")); - } - // meta data endpoint - // if (MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl() != null) { - // TODO - //payloadBuilder.append(","); - //payloadBuilder.append("METADATA_ENDPOINT=" + MetaDataClientConfig.getInstance().getMetaDataServiceBaseUrl()); - // } - payloadBuilder.append(","); - - return payloadBuilder; - } - - public static PayloadData createPayload(String appId, String groupName, Cartridge cartridge, String subscriptionKey, int tenantId, String clusterId, - String hostName, String repoUrl, String alias, Map customPayloadEntries, String[] dependencyAliases) - throws ApplicationDefinitionException { - - //Create the payload - BasicPayloadData basicPayloadData = createBasicPayload(appId, groupName, cartridge, subscriptionKey, - clusterId, hostName, repoUrl, alias, tenantId, dependencyAliases); - //Populate the basic payload details - basicPayloadData.populatePayload(); - - PayloadData payloadData = PayloadFactory.getPayloadDataInstance(cartridge.getProvider(), - cartridge.getType(), basicPayloadData); - - boolean isDeploymentParam = false; - // get the payload parameters defined in the cartridge definition file for this cartridge type - if (cartridge.getProperties() != null && !cartridge.getProperties().isEmpty()) { - - for (Map.Entry propertyEntry : cartridge.getProperties().entrySet()) { - // 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 (propertyEntry.getKey() - .startsWith("payload_parameter.")) { - String payloadParamName = propertyEntry.getKey(); - String payloadParamSubstring = payloadParamName.substring(payloadParamName.indexOf(".") + 1); - if("DEPLOYMENT".equals(payloadParamSubstring)) { - isDeploymentParam = true; - } - payloadData.add(payloadParamSubstring, propertyEntry.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> entrySet = customPayloadEntries.entrySet(); - for (Map.Entry entry : entrySet) { - payloadData.add(entry.getKey(), entry.getValue()); - } - } - - return payloadData; - } - - private static BasicPayloadData createBasicPayload(String appId, String groupName, Cartridge cartridge, - String subscriptionKey, String clusterId, - String hostName, String repoUrl, String alias, - int tenantId, String[] dependencyAliases) { - - BasicPayloadData basicPayloadData = new BasicPayloadData(); - basicPayloadData.setAppId(appId); - basicPayloadData.setGroupName(groupName); - basicPayloadData.setApplicationPath(cartridge.getBaseDir()); - basicPayloadData.setSubscriptionKey(subscriptionKey); - //basicPayloadData.setDeployment("default");//currently hard coded to default - basicPayloadData.setMultitenant(String.valueOf(cartridge.isMultiTenant())); - basicPayloadData.setPortMappings(createPortMappingPayloadString(cartridge)); - basicPayloadData.setServiceName(cartridge.getType()); - basicPayloadData.setProvider(cartridge.getProvider()); - - if(repoUrl != null) { - basicPayloadData.setGitRepositoryUrl(repoUrl); - } - - if (clusterId != null) { - basicPayloadData.setClusterId(clusterId); - } - - if (hostName != null) { - basicPayloadData.setHostName(hostName); - } - - if (alias != null) { - basicPayloadData.setSubscriptionAlias(alias); - } - - basicPayloadData.setTenantId(tenantId); - - basicPayloadData.setTenantRange("*"); - basicPayloadData.setDependencyAliases(dependencyAliases); - if(cartridge.getExportingProperties() != null){ - basicPayloadData.setExportingProperties(cartridge.getExportingProperties()); - log.info("testing1 getExportingProperties " + cartridge.getExportingProperties()); - - } - - return basicPayloadData; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.java deleted file mode 100644 index 5fd6d571bc..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/ClusterInformation.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.cloud.controller.application; - -public interface ClusterInformation { - - public String getClusterId (String alias, String cartridgeType); - - public String getHostName (String alias, String cartridgeDefinitionHostName); -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.java deleted file mode 100644 index ef3b255590..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/MTClusterInformation.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.cloud.controller.application; - -public class MTClusterInformation implements ClusterInformation { - - @Override - public String getClusterId(String alias, String cartridgeType) { - - if (!ApplicationUtils.isValid(cartridgeType)) { - // cannot happen - throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); - } - - return cartridgeType + ".domain"; - } - - @Override - public String getHostName(String alias, String cartridgeDefinitionHostName) { - - if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { - // cannot happen - throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); - } - - return cartridgeDefinitionHostName; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java deleted file mode 100644 index c8c3d9b0a5..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/STClusterInformation.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application; - -public class STClusterInformation implements ClusterInformation { - - @Override - public String getClusterId(String alias, String cartridgeType) { - - if (!ApplicationUtils.isValid(alias)) { - // cannot happen - throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); - } - - if (!ApplicationUtils.isValid(cartridgeType)) { - // cannot happen - throw new IllegalArgumentException("Invalid cartridge type value provided: [ " + cartridgeType + " ]"); - } - - return alias + "." + cartridgeType + ".domain"; - } - - @Override - public String getHostName(String alias, String cartridgeDefinitionHostName) { - - if (!ApplicationUtils.isValid(alias)) { - // cannot happen - throw new IllegalArgumentException("Invalid alias value provided: [ " + alias + " ]"); - } - - if (!ApplicationUtils.isValid(cartridgeDefinitionHostName)) { - // cannot happen - throw new IllegalArgumentException("Invalid host name value provided: [ " + cartridgeDefinitionHostName + " ]"); - } - - return alias + "." + cartridgeDefinitionHostName; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java deleted file mode 100644 index c75e883db4..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/DefaultApplicationParser.java +++ /dev/null @@ -1,634 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application.parser; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.ApplicationUtils; -import org.apache.stratos.cloud.controller.application.ClusterInformation; -import org.apache.stratos.cloud.controller.application.MTClusterInformation; -import org.apache.stratos.cloud.controller.application.STClusterInformation; -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; -import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.application.*; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; -import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.applications.DependencyOrder; -import org.apache.stratos.messaging.domain.applications.Group; - -import java.util.*; - -public class DefaultApplicationParser implements ApplicationParser { - - private static Log log = LogFactory.getLog(DefaultApplicationParser.class); - -// private static FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); - - private Set applicationClusterContexts; - - private Set metaDataHolders; - - public DefaultApplicationParser () { - - this.applicationClusterContexts = new HashSet(); - this.metaDataHolders = new HashSet(); - } - - @Override - public Application parse(Object obj) throws ApplicationDefinitionException { - - ApplicationContext applicationCtxt = (ApplicationContext) obj; - - if (applicationCtxt == null) { - handleError("Invalid Composite Application Definition"); - } - - assert applicationCtxt != null; - if (applicationCtxt.getAlias() == null || applicationCtxt.getAlias().isEmpty()) { - handleError("Invalid alias specified"); - } - - if (applicationCtxt.getApplicationId() == null || applicationCtxt.getApplicationId().isEmpty()) { - handleError("Invalid Composite App id specified"); - } - - // get the defined groups - Map definedGroups = getDefinedGroups(applicationCtxt); - if (log.isDebugEnabled()) { - if (definedGroups != null) { - Set> groupEntries = definedGroups.entrySet(); - log.debug("Defined Groups: [ "); - for (Map.Entry groupEntry : groupEntries) { - log.debug("Group alias: " + groupEntry.getKey()); - } - log.debug(" ]"); - } else { - log.debug("No Group definitions found in app id " + applicationCtxt.getApplicationId()); - } - } - - // get the Subscribables Information - Map subscribablesInfo = getSubscribableInformation(applicationCtxt); - if (log.isDebugEnabled()) { - Set> subscribableInfoCtxtEntries = subscribablesInfo.entrySet(); - log.debug("Defined Subscribable Information: [ "); - for (Map.Entry subscribableInfoCtxtEntry : subscribableInfoCtxtEntries) { - log.debug("Subscribable Information alias: " + subscribableInfoCtxtEntry.getKey()); - } - log.debug(" ]"); - } - - if (subscribablesInfo == null) { - handleError("Invalid Composite Application Definition, no Subscribable Information specified"); - } - - return buildCompositeAppStructure (applicationCtxt, definedGroups, subscribablesInfo); - } - - @Override - public Set getApplicationClusterContexts() throws ApplicationDefinitionException { - return applicationClusterContexts; - } - - @Override - public Set getPayloadData() throws ApplicationDefinitionException { - return metaDataHolders; - } - - /** - * Extract Group information from Application Definition - * - * @param appCtxt ApplicationContext object with Application information - * @return Map [group alias -> Group] - * - * @throws ApplicationDefinitionException if the Group information is invalid - */ - private Map getDefinedGroups (ApplicationContext appCtxt) throws - ApplicationDefinitionException { - - // map [group alias -> Group Definition] - Map definedGroups = null; - - if (appCtxt.getComponents() != null) { - if (appCtxt.getComponents().getGroupContexts() != null) { - definedGroups = new HashMap(); - - for (GroupContext groupContext : appCtxt.getComponents().getGroupContexts()) { - - // check validity of group name - if (StringUtils.isEmpty(groupContext.getName())) { - handleError("Invalid Group name specified"); - } - - // check if group is deployed - if(!isGroupDeployed(groupContext.getName())) { - handleError("Group with name " + groupContext.getName() + " not deployed"); - } - - // check validity of group alias - - if (StringUtils.isEmpty(groupContext.getAlias()) || !ApplicationUtils.isAliasValid(groupContext.getAlias())) { - handleError("Invalid Group alias specified: [ " + groupContext.getAlias() + " ]"); - } - - // check if a group is already defined under the same alias - if(definedGroups.get(groupContext.getAlias()) != null) { - // a group with same alias already exists, can't continue - handleError("A Group with alias " + groupContext.getAlias() + " already exists"); - } - - definedGroups.put(groupContext.getAlias(), groupContext); - if (log.isDebugEnabled()) { - log.debug("Added Group Definition [ " + groupContext.getName() +" , " + groupContext.getAlias() + " ] to map [group alias -> Group Definition]"); - } - } - } - } - - return definedGroups; - } - - /** - * Extract Subscription Information from the Application Definition - * - * @param appCtxt ApplicationContext object with Application information - * @return Map [cartridge alias -> Group] - * - * @throws ApplicationDefinitionException if the Subscription information is invalid - */ - private Map getSubscribableInformation (ApplicationContext appCtxt) throws - ApplicationDefinitionException { - - // map [cartridge alias -> Subscribable Information] - Map subscribableInformation = null; - - if (appCtxt.getSubscribableInfoContext() != null) { - subscribableInformation = new HashMap(); - - for (SubscribableInfoContext subscribableInfoCtxt : appCtxt.getSubscribableInfoContext()) { - - if (StringUtils.isEmpty(subscribableInfoCtxt.getAlias()) || - !ApplicationUtils.isAliasValid(subscribableInfoCtxt.getAlias())) { - handleError("Invalid alias specified for Subscribable Information Obj: [ " + subscribableInfoCtxt.getAlias() + " ]"); - } - - // check if a group is already defined under the same alias - if(subscribableInformation.get(subscribableInfoCtxt.getAlias()) != null) { - // a group with same alias already exists, can't continue - handleError("A Subscribable Info obj with alias " + subscribableInfoCtxt.getAlias() + " already exists"); - } - - subscribableInformation.put(subscribableInfoCtxt.getAlias(), subscribableInfoCtxt); - if (log.isDebugEnabled()) { - log.debug("Added Subcribables Info obj [ " + subscribableInfoCtxt.getAlias() + " ] to map [cartridge alias -> Subscribable Information]"); - } - } - } - - return subscribableInformation; - } - - /** - * Check if a Group Definition is deployed - * - * @param serviceGroupName Group name - * @return true if the Group is deployed, else false - * - * @throws ApplicationDefinitionException - */ - private boolean isGroupDeployed (String serviceGroupName) throws ApplicationDefinitionException { - - return FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName) != null; - } - - /** - * Builds the Application structure - * - * @param appCtxt ApplicationContext object with Application information - * @param definedGroupCtxts Map [cartridge alias -> Group] with extracted Group Information - * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information - * @return Application Application object denoting the Application structure - * - * @throws ApplicationDefinitionException If an error occurs in building the Application structure - */ - private Application buildCompositeAppStructure (ApplicationContext appCtxt, - Map definedGroupCtxts, - Map subscribableInfoCtxts) - throws ApplicationDefinitionException { - - Application application = new Application(appCtxt.getApplicationId()); - - // set tenant related information - application.setTenantId(appCtxt.getTenantId()); - application.setTenantDomain(appCtxt.getTenantDomain()); - application.setTenantAdminUserName(appCtxt.getTeantAdminUsername()); - - // following keeps track of all Clusters created for this application - //Set clusters = new HashSet(); - //ClusterDataHolder clusterDataHolder = null; - Map clusterDataMap; - - if (appCtxt.getComponents() != null) { - // get top level Subscribables - if (appCtxt.getComponents().getSubscribableContexts() != null) { - clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), - application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), - subscribableInfoCtxts); - application.setClusterData(clusterDataMap); - //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); - } - - // get Groups - if (appCtxt.getComponents().getGroupContexts() != null) { - application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(), - application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()), - subscribableInfoCtxts, definedGroupCtxts)); - } - - // get top level Dependency definitions - if (appCtxt.getComponents().getDependencyContext() != null) { - DependencyOrder appDependencyOrder = new DependencyOrder(); - String [] startupOrders = appCtxt.getComponents().getDependencyContext().getStartupOrdersContexts(); - if (startupOrders != null) { - if (log.isDebugEnabled()) { - log.debug("parsing application ... buildCompositeAppStructure: startupOrders != null for app alias: " + - appCtxt.getAlias() + " #: " + startupOrders.length); - } - appDependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders)); - } else { - if (log.isDebugEnabled()) { - log.debug("parsing application ... buildCompositeAppStructure: startupOrders == null for app alias: " + appCtxt.getAlias()); - } - } - String terminationBehavior = appCtxt.getComponents().getDependencyContext().getTerminationBehaviour(); - validateTerminationBehavior(terminationBehavior); - appDependencyOrder.setTerminationBehaviour(terminationBehavior); - - application.setDependencyOrder(appDependencyOrder); - } - } - - log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); - - return application; - } - - /** - * Validates terminationBehavior. The terminationBehavior should be one of the following: - * 1. terminate-none - * 2. terminate-dependents - * 3. terminate-all - * - * @throws ApplicationDefinitionException if terminationBehavior is different to what is - * listed above - */ - private static void validateTerminationBehavior (String terminationBehavior) throws ApplicationDefinitionException { - - if (!(terminationBehavior == null || "terminate-none".equals(terminationBehavior) || - "terminate-dependents".equals(terminationBehavior) || "terminate-all".equals(terminationBehavior))) { - throw new ApplicationDefinitionException("Invalid Termination Behaviour specified: [ " + - terminationBehavior + " ], should be one of 'terminate-none', 'terminate-dependents', " + - " 'terminate-all' "); - } - } - - /** - * Parse Group information - * - * @param appId Application id - * @param tenantId tenant id of tenant which deployed the Application - * @param key Generated key for the Application - * @param groupCtxts Group information - * @param subscribableInformation Subscribable Information - * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information - * @return Map [alias -> Group] - * - * @throws ApplicationDefinitionException if an error occurs in parsing Group Information - */ - private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, - Map subscribableInformation, - Map definedGroupCtxts) - throws ApplicationDefinitionException { - - Map groupAliasToGroup = new HashMap(); - - for (GroupContext groupCtxt : groupCtxts) { - Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts); - groupAliasToGroup.put(group.getAlias(), group); - } - - //Set topLevelGroupContexts = getTopLevelGroupContexts(groupAliasToGroup); - Set nestedGroups = new HashSet(); - getNestedGroupContexts(nestedGroups, groupAliasToGroup.values()); - filterDuplicatedGroupContexts(groupAliasToGroup.values(), nestedGroups); - - return groupAliasToGroup; - } - - /** - * Extracts nested Group information recursively - * - * @param nestedGroups Nested Groups set to be populated recursively - * @param groups Collection of Groups - */ - private void getNestedGroupContexts (Set nestedGroups, Collection groups) { - - if (groups != null) { - for (Group group : groups) { - if (group.getGroups() != null) { - nestedGroups.addAll(group.getGroups()); - getNestedGroupContexts(nestedGroups, group.getGroups()); - } - } - } - } - - /** - * Filters duplicated Groups from top level - * - * @param topLevelGroups Top level Groups - * @param nestedGroups nested Groups - */ - private void filterDuplicatedGroupContexts (Collection topLevelGroups, Set nestedGroups) { - - for (Group nestedGroup : nestedGroups) { - filterNestedGroupFromTopLevel(topLevelGroups, nestedGroup); - } - } - - private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Group nestedGroup) { - - Iterator parentIterator = topLevelGroups.iterator(); - while (parentIterator.hasNext()) { - Group parentGroup = parentIterator.next(); - // if there is an exactly similar nested Group Context and a top level Group Context - // it implies that they are duplicates. Should be removed from top level. - if (parentGroup.equals(nestedGroup)) { - parentIterator.remove(); - } - } - } - - /** - * Parses an individual Group - * - * @param appId Application id - * @param tenantId tenant id of tenant which deployed the Application - * @param key Generated key for the Application - * @param groupCtxt Group definition information - * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information - * @param definedGroupCtxts Map [group alias -> Group] with extracted Group Information - * @return Group object - * - * @throws ApplicationDefinitionException if unable to parse - */ - private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, - Map subscribableInfoCtxts, - Map definedGroupCtxts) - throws ApplicationDefinitionException { - - // check if are in the defined Group set - GroupContext definedGroupDef = definedGroupCtxts.get(groupCtxt.getAlias()); - if (definedGroupDef == null) { - handleError("Group Definition with name: " + groupCtxt.getName() + ", alias: " + - groupCtxt.getAlias() + " is not found in the all Group Definitions collection"); - } - - Group group = new Group(appId, groupCtxt.getName(), groupCtxt.getAlias()); - - group.setAutoscalingPolicy(groupCtxt.getAutoscalingPolicy()); - group.setDeploymentPolicy(groupCtxt.getDeploymentPolicy()); - DependencyOrder dependencyOrder = new DependencyOrder(); - // create the Dependency Ordering - String [] startupOrders = getStartupOrderForGroup(groupCtxt); - if (startupOrders != null) { - dependencyOrder.setStartupOrders(ParserUtils.convert(startupOrders, groupCtxt)); - } - dependencyOrder.setTerminationBehaviour(getKillbehaviour(groupCtxt.getName())); - group.setDependencyOrder(dependencyOrder); - - Map clusterDataMap; - - // get group level Subscribables - if (groupCtxt.getSubscribableContexts() != null) { - clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), - Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); - group.setClusterData(clusterDataMap); - } - - // get nested groups - if (groupCtxt.getGroupContexts() != null) { - Map nestedGroups = new HashMap(); - // check sub groups - for (GroupContext subGroupCtxt : groupCtxt.getGroupContexts()) { - // get the complete Group Definition - subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); - Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, - subscribableInfoCtxts, - definedGroupCtxts); - nestedGroups.put(nestedGroup.getAlias(), nestedGroup); - } - - group.setGroups(nestedGroups); - } - - return group; - } - - /** - * Find the startup order - * - * @param groupContext GroupContext with Group defintion information - * @return Set of Startup Orders which are defined in the Group - * - * @throws ApplicationDefinitionException - */ - private String [] getStartupOrderForGroup(GroupContext groupContext) throws ApplicationDefinitionException { - - ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(groupContext.getName()); - - if (serviceGroup == null) { - handleError("Service Group Definition not found for name " + groupContext.getName()); - } - - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForGroup: " + groupContext.getName()); - } - - assert serviceGroup != null; - if (serviceGroup.getDependencies() != null) { - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForGroup: dependencies != null " ); - } - if (serviceGroup.getDependencies().getStartupOrders() != null) { - - String [] startupOrders = serviceGroup.getDependencies().getStartupOrders(); - if (log.isDebugEnabled()) { - log.debug("parsing application ... getStartupOrderForGroup: startupOrders != null # of: " + startupOrders.length); - } - return startupOrders; - } - } - - return null; - } - - /** - * Get kill behaviour related to a Group - * - * @param serviceGroupName Group name - * @return String indicating the kill behavior - * - * @throws ApplicationDefinitionException if an error occurs - */ - private String getKillbehaviour (String serviceGroupName) throws ApplicationDefinitionException { - - ServiceGroup serviceGroup = FasterLookUpDataHolder.getInstance().getServiceGroup(serviceGroupName); - - if (serviceGroup == null) { - handleError("Service Group Definition not found for name " + serviceGroupName); - } - - assert serviceGroup != null; - if (serviceGroup.getDependencies() != null) { - return serviceGroup.getDependencies().getKillBehaviour(); - } - - return null; - - } - - /** - * Parse Subscription Information - * - * @param appId Application id - * @param tenantId Tenant id of tenant which deployed the Application - * @param key Generated key for the Application - * @param groupName Group name (if relevant) - * @param subscribableCtxts Subscribable Information - * @param subscribableInfoCtxts Map [cartridge alias -> Group] with extracted Subscription Information - * @return Map [subscription alias -> ClusterDataHolder] - * - * @throws ApplicationDefinitionException - */ - private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, - List subscribableCtxts, - Map subscribableInfoCtxts) - throws ApplicationDefinitionException { - - Map clusterDataMap = new HashMap(); - - for (SubscribableContext subscribableCtxt : subscribableCtxts) { - - // check is there is a related Subscribable Information - SubscribableInfoContext subscribableInfoCtxt = subscribableInfoCtxts.get(subscribableCtxt.getAlias()); - if (subscribableInfoCtxt == null) { - handleError("Related Subscribable Information Ctxt not found for Subscribable with alias: " - + subscribableCtxt.getAlias()); - } - - // check if Cartridge Type is valid - if (StringUtils.isEmpty(subscribableCtxt.getType())) { - handleError("Invalid Cartridge Type specified : [ " - + subscribableCtxt.getType() + " ]"); - } - - // check if a cartridge with relevant type is already deployed. else, can't continue - Cartridge cartridge = getCartridge(subscribableCtxt.getType()); - if (cartridge == null) { - handleError("No deployed Cartridge found with type [ " + subscribableCtxt.getType() + - " ] for Composite Application"); - } - - // get hostname and cluster id - ClusterInformation clusterInfo; - assert cartridge != null; - if (cartridge.isMultiTenant()) { - clusterInfo = new MTClusterInformation(); - } else { - clusterInfo = new STClusterInformation(); - } - - String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridge.getHostName()); - String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); - - // create and collect this cluster's information - assert subscribableInfoCtxt != null; - ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridge, - key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), - clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases()); - - appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); - this.applicationClusterContexts.add(appClusterCtxt); - - // add relevant information to the map - clusterDataMap.put(subscribableCtxt.getAlias(), new ClusterDataHolder(subscribableCtxt.getType(), clusterId)); - } - - return clusterDataMap; - } - - /** - * Creates a ApplicationClusterContext object to keep information related to a Cluster in this Application - * - * @param appId Application id - * @param groupName Group name - * @param cartridge Cartridge information - * @param subscriptionKey Generated key for the Application - * @param tenantId Tenant Id of the tenant which deployed the Application - * @param repoUrl Repository URL - * @param alias alias specified for this Subscribable in the Application Definition - * @param clusterId Cluster id - * @param hostname Hostname - * @param deploymentPolicy Deployment policy used - * @param isLB if this cluster is an LB - * @return ApplicationClusterContext object with relevant information - * - * @throws ApplicationDefinitionException If any error occurs - */ - private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, Cartridge cartridge, - String subscriptionKey, int tenantId, String repoUrl, - String alias, String clusterId, String hostname, - String deploymentPolicy, boolean isLB, String[] dependencyAliases) - throws ApplicationDefinitionException { - - // Create text payload - String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridge, subscriptionKey, tenantId, clusterId, - hostname, repoUrl, alias, null, dependencyAliases).toString(); - - return new ApplicationClusterContext(cartridge.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); - } - - private Cartridge getCartridge (String cartridgeType) { - - return FasterLookUpDataHolder.getInstance().getCartridge(cartridgeType); - } - - private void handleError (String errorMsg) throws ApplicationDefinitionException { - log.error(errorMsg); - throw new ApplicationDefinitionException(errorMsg); - } - -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java deleted file mode 100644 index e6cdda09cd..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/parser/ParserUtils.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application.parser; - -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.pojo.application.GroupContext; -import org.apache.stratos.cloud.controller.pojo.application.SubscribableContext; -import org.apache.stratos.messaging.domain.applications.StartupOrder; - -import java.util.*; - -public class ParserUtils { - - public static Set convert (String [] startupOrderArr) throws ApplicationDefinitionException { - - Set startupOrders = new HashSet(); - - if (startupOrderArr == null) { - return startupOrders; - } - - for (String commaSeparatedStartupOrder : startupOrderArr) { - startupOrders.add(getStartupOrder(commaSeparatedStartupOrder)); - } - - return startupOrders; - } - - private static StartupOrder getStartupOrder (String commaSeparatedStartupOrder) throws ApplicationDefinitionException{ - - List startupOrders = new ArrayList(); - - for (String startupOrder : Arrays.asList(commaSeparatedStartupOrder.split(","))) { - startupOrder = startupOrder.trim(); - if (!startupOrder.startsWith("cartridge.") && !startupOrder.startsWith("group.")) { - throw new ApplicationDefinitionException("Incorrect Startup Order specified, should start with 'cartridge.' or 'group.'"); - } - - startupOrders.add(startupOrder); - } - - return new StartupOrder(startupOrders); - } - - public static Set convert (String [] startupOrderArr, GroupContext groupContext) - throws ApplicationDefinitionException { - - Set startupOrders = new HashSet(); - - if (startupOrderArr == null) { - return startupOrders; - } - - - for (String commaSeparatedStartupOrder : startupOrderArr) { - // convert all Startup Orders to aliases-based - List components = Arrays.asList(commaSeparatedStartupOrder.split(",")); - startupOrders.add(getStartupOrder(components, groupContext)); - } - - return startupOrders; - } - - private static StartupOrder getStartupOrder (List components, GroupContext groupContext) - throws ApplicationDefinitionException { - - List aliasBasedComponents = new ArrayList(); - - for (String component : components) { - component = component.trim(); - - String aliasBasedComponent; - if (component.startsWith("cartridge.")) { - String cartridgeType = component.substring(10); - aliasBasedComponent = getAliasForServiceType(cartridgeType, groupContext); - if (aliasBasedComponent == null) { - throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + - "cannot find the matching alias for Service type " + cartridgeType); - } - - aliasBasedComponent = "cartridge.".concat(aliasBasedComponent); - - } else if (component.startsWith("group.")) { - String groupName = component.substring(6); - aliasBasedComponent = getAliasForGroupName(groupName, groupContext); - if (aliasBasedComponent == null) { - throw new ApplicationDefinitionException("Unable convert Startup Order to alias-based; " + - "cannot find the matching alias for Group name " + groupName); - } - - aliasBasedComponent = "group.".concat(aliasBasedComponent); - - } else { - throw new ApplicationDefinitionException("Incorrect Startup Order specified, " + - "should start with 'cartridge.' or 'group.'"); - } - aliasBasedComponents.add(aliasBasedComponent); - } - - return new StartupOrder(aliasBasedComponents); - } - - private static String getAliasForGroupName (String groupName, GroupContext groupContext) { - - for (GroupContext groupCtxt : groupContext.getGroupContexts()) { - if (groupName.equals(groupCtxt.getName())) { - return groupCtxt.getAlias(); - } - } - - return null; - } - - - private static String getAliasForServiceType (String serviceType, GroupContext groupContext) { - - for (SubscribableContext subCtxt : groupContext.getSubscribableContexts()) { - if (serviceType.equals(subCtxt.getType())) { - return subCtxt.getAlias(); - } - } - - return null; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/ApplicationCartridgePayloadData.java deleted file mode 100644 index 870c22c38a..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/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.cloud.controller.application.payload; - -public class ApplicationCartridgePayloadData extends PayloadData { - - public ApplicationCartridgePayloadData(BasicPayloadData basicPayloadData) { - super(basicPayloadData); - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java deleted file mode 100644 index c655b1b883..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/BasicPayloadData.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application.payload; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.Serializable; - -/** - * Contains basic payload data fields - */ -public class BasicPayloadData implements Serializable { - - private static Log log = LogFactory.getLog(BasicPayloadData.class); - - private String appId; - private String groupName; - 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; - private String[] dependencyAliases; - private String[] exportingProperties; - - protected StringBuilder payloadBuilder; - - public BasicPayloadData() { - - } - - public void populatePayload () { - - payloadBuilder = new StringBuilder(); - - payloadBuilder.append("APP_ID=" + getAppId()); - payloadBuilder.append(","); - payloadBuilder.append("GROUP_NAME=" + getGroupName()); - payloadBuilder.append(","); - 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("puppet.ip")); - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_HOSTNAME=" + System.getProperty("puppet.hostname")); - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_DNS_AVAILABLE=" + System.getProperty("puppet.env")); - payloadBuilder.append(","); - payloadBuilder.append("PUPPET_ENV=" + System.getProperty("puppet.dns.available")); - payloadBuilder.append(","); - if(getDependencyAliasesPayloadString() != null){ - payloadBuilder.append("DEPENDECNY_ALIASES=" + getDependencyAliasesPayloadString()); - } - payloadBuilder.append(","); - if(getExportingPropertiesPayloadString() != null){ - payloadBuilder.append("EXPORTING_PROPERTIES=" + getExportingPropertiesPayloadString()); - } - - } - - 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; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getGroupName() { - return groupName; - } - - public void setGroupName(String groupName) { - this.groupName = groupName; - } - - public String[] getDependencyAliases() { - return dependencyAliases; - } - - public void setDependencyAliases(String[] dependencyAliases) { - this.dependencyAliases = dependencyAliases; - } - - private String getDependencyAliasesPayloadString(){ - if(dependencyAliases == null){ - return null; - } - - StringBuilder dependencyAliasesPayload = new StringBuilder(); - for(int i=0; i< dependencyAliases.length; i++){ - dependencyAliasesPayload.append(dependencyAliases[i]); - if(i != dependencyAliases.length -1){ - dependencyAliasesPayload.append("|"); - } - } - log.info("testing1 getDependencyAliasesPayloadString " + dependencyAliasesPayload); - return dependencyAliasesPayload.toString(); - } - - private String getExportingPropertiesPayloadString(){ - if(exportingProperties == null){ - return null; - } - - StringBuilder exportingPropertiesPayload = new StringBuilder(); - for(int i=0; i< exportingProperties.length; i++){ - exportingPropertiesPayload.append(exportingProperties[i]); - if(i != exportingProperties.length -1){ - exportingPropertiesPayload.append("|"); - } - } - log.info("testing1 getExportingPropertiesPayloadString " + exportingPropertiesPayload); - return exportingPropertiesPayload.toString(); - } - - public String[] getExportingProperties() { - return exportingProperties; - } - - public void setExportingProperties(String[] exportingProperties) { - this.exportingProperties = exportingProperties; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/DataCartridgePayloadData.java deleted file mode 100644 index 1848b6d042..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/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.cloud.controller.application.payload; - -public class DataCartridgePayloadData extends PayloadData { - - public DataCartridgePayloadData(BasicPayloadData basicPayloadData) { - super(basicPayloadData); - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/FrameworkCartridgePayloadData.java deleted file mode 100644 index a22d40bfc8..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/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.cloud.controller.application.payload; - -public class FrameworkCartridgePayloadData extends PayloadData { - - public FrameworkCartridgePayloadData(BasicPayloadData basicPayloadData) { - super(basicPayloadData); - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/LoadBalancerCartridgePayloadData.java deleted file mode 100644 index 6ceeba91d2..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/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.cloud.controller.application.payload; - -public class LoadBalancerCartridgePayloadData extends PayloadData { - - public LoadBalancerCartridgePayloadData(BasicPayloadData basicPayloadData) { - super(basicPayloadData); - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadData.java deleted file mode 100644 index 35b1fe6030..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/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.cloud.controller.application.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 completePayloadMap; - public PayloadData(BasicPayloadData basicPayloadData) { - - this.setBasicPayloadData(basicPayloadData); - completePayloadMap = new HashMap(); - } - - 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(); - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.java deleted file mode 100755 index 2b3ea8be59..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/payload/PayloadFactory.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.cloud.controller.application.payload; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; - - -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 - */ - public static PayloadData getPayloadDataInstance(String cartridgeProvider, String cartridgeType, - BasicPayloadData basicPayloadData) - throws ApplicationDefinitionException { - - PayloadData payloadData = null; - - //TODO: fix after adding the property Category to Cartridge Definition - if (cartridgeProvider.equals("data")) { - payloadData = new DataCartridgePayloadData(basicPayloadData); - } else { - payloadData = new FrameworkCartridgePayloadData(basicPayloadData); - } - - if(payloadData == null) { - throw new ApplicationDefinitionException("Unable to find matching payload for cartridge type " + cartridgeType + - ", provider " + cartridgeProvider); - } - - return payloadData; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index ca2cc1e3b4..a914946ccb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -24,17 +24,14 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor; import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.interfaces.Iaas; import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -42,7 +39,6 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; -import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; import org.jclouds.compute.ComputeService; @@ -1391,29 +1387,29 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } - public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - Application application = applicationParser.parse(applicationContext); - - // Create a Cluster Context obj. for each of the Clusters in the Application - for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { - dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), - applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), - applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); - } - - /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), - applicationParser.getPayloadData()); -*/ - persist(); - } - - @Override - public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - - //TopologyBuilder.handleApplicationUndeployed(applicationId); - } +// public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// Application application = applicationParser.parse(applicationContext); +// +// // Create a Cluster Context obj. for each of the Clusters in the Application +// for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { +// dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), +// applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), +// applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); +// } +// +// /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), +// applicationParser.getPayloadData()); +//*/ +// persist(); +// } +// +// @Override +// public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { +// +// //TopologyBuilder.handleApplicationUndeployed(applicationId); +// } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java deleted file mode 100644 index 33e98f9cd1..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/ApplicationParser.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.interfaces; - -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.pojo.ApplicationClusterContext; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.messaging.domain.applications.Application; - -import java.util.Set; - -public interface ApplicationParser { - - /** - * Parses the Application Definition - * - * @param obj Object with the Application Definition. An Object is used here since there can be - * significant changes between the way composite Applications are defined in different - * conventions - * @return Application structure denoting the parsed Application - * @throws ApplicationDefinitionException If the Application Definition is invalid - */ - public Application parse (Object obj) throws ApplicationDefinitionException; - - /** - * Returns a set of ApplicationClusterContext which will comprise of cluster related information - * extracted from the Application definition - * - * @return Set of ApplicationClusterContext objects - * @throws ApplicationDefinitionException if any error occurs - */ - public Set getApplicationClusterContexts() throws ApplicationDefinitionException; - - // TODO: remove - public Set getPayloadData () throws ApplicationDefinitionException; -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 5301b14946..016e98ebf6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -21,7 +21,6 @@ import org.apache.stratos.cloud.controller.deployment.partition.Partition; import org.apache.stratos.cloud.controller.exception.*; import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; /** * This API provides a way to communicate with underline @@ -168,20 +167,4 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit */ public ClusterContext getClusterContext (String clusterId); - /** - * deploys an Application Definition - * - * @param applicationContext {@link org.apache.stratos.cloud.controller.pojo.application.ApplicationContext} object - * @throws ApplicationDefinitionException if an error is encountered - */ - public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException; - - /** - * undeploys an Application Definition - * - * @param applicationId Id of the Application to be undeployed - * @throws ApplicationDefinitionException if an error is encountered - */ - public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException; - } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java deleted file mode 100644 index 3a8af441d3..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ApplicationContext.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.application; - -public class ApplicationContext { - - private int tenantId; - - private String tenantDomain; - - private String teantAdminUsername; - - private String applicationId; - - private String alias; - - private ComponentContext componentContext; - - private SubscribableInfoContext[] subscribableInfoContexts; - - public String getApplicationId() { - return applicationId; - } - - public void setApplicationId(String applicationId) { - this.applicationId = applicationId; - } - - public String getAlias() { - return alias; - } - - public void setAlias(String alias) { - this.alias = alias; - } - - public ComponentContext getComponents() { - return componentContext; - } - - public void setComponents(ComponentContext componentContext) { - this.componentContext = componentContext; - } - - public SubscribableInfoContext[] getSubscribableInfoContext() { - return subscribableInfoContexts; - } - - public void setSubscribableInfoContext(SubscribableInfoContext[] subscribableInfoContexts) { - this.subscribableInfoContexts = subscribableInfoContexts; - } - - 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; - } - - public String getTeantAdminUsername() { - return teantAdminUsername; - } - - public void setTeantAdminUsername(String teantAdminUsername) { - this.teantAdminUsername = teantAdminUsername; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.java deleted file mode 100644 index d1a13a5d9d..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/ComponentContext.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.cloud.controller.pojo.application; - -public class ComponentContext { - - private GroupContext[] groupContexts; - - private SubscribableContext[] subscribableContexts; - - private DependencyContext dependencyContext; - - - public GroupContext[] getGroupContexts() { - return groupContexts; - } - - public void setGroupContexts(GroupContext[] groupContexts) { - this.groupContexts = groupContexts; - } - - public SubscribableContext[] getSubscribableContexts() { - return subscribableContexts; - } - - public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { - this.subscribableContexts = subscribableContexts; - } - - public DependencyContext getDependencyContext() { - return dependencyContext; - } - - public void setDependencyContext(DependencyContext dependencyContext) { - this.dependencyContext = dependencyContext; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java deleted file mode 100644 index a99dcb0d4e..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/DependencyContext.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.application; - - -public class DependencyContext { - - private String [] startupOrdersContexts; - - private String terminationBehaviour; - - public String getTerminationBehaviour() { - return terminationBehaviour; - } - - public void setTerminationBehaviour(String terminationBehaviour) { - this.terminationBehaviour = terminationBehaviour; - } - - public String [] getStartupOrdersContexts() { - return startupOrdersContexts; - } - - public void setStartupOrdersContexts(String [] startupOrdersContexts) { - this.startupOrdersContexts = startupOrdersContexts; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java deleted file mode 100644 index fda4becbec..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/GroupContext.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.application; - -public class GroupContext { - - private String name; - - private String alias; - - private String deploymentPolicy; - - private String autoscalingPolicy; - - private SubscribableContext[] subscribableContexts; - - private GroupContext[] groupContexts; - - - 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 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 SubscribableContext[] getSubscribableContexts() { - return subscribableContexts; - } - - public void setSubscribableContexts(SubscribableContext[] subscribableContexts) { - this.subscribableContexts = subscribableContexts; - } - - public GroupContext[] getGroupContexts() { - return groupContexts; - } - - public void setGroupContexts(GroupContext[] groupContexts) { - this.groupContexts = groupContexts; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java deleted file mode 100644 index 6f7f4bc8ed..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableContext.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.application; - -public class SubscribableContext { - - 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; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java deleted file mode 100644 index 5f75a7c155..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/application/SubscribableInfoContext.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.application; - -public class SubscribableInfoContext { - - private String alias; - - private String deploymentPolicy; - - private String autoscalingPolicy; - - private String repoUrl; - - private boolean privateRepo; - - private String repoUsername; - - private String repoPassword; - - private String[] dependencyAliases; - - 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; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java deleted file mode 100644 index 3db9f71b50..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/payload/MetaDataHolder.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.pojo.payload; - -import java.util.Properties; - -/** - * Holds payload/meta data related to a cluster - */ - -public class MetaDataHolder { - - private String appId; - - private String groupName; - - private String clusterId; - - private Properties properties; - - public MetaDataHolder (String appId, String clusterId) { - - this.appId = appId; - this.clusterId = clusterId; - } - - public MetaDataHolder(String appId, String groupName, String clusterId) { - - this.appId = appId; - this.groupName = groupName; - this.clusterId = clusterId; - } - - public String getAppId() { - return appId; - } - - public String getGroupName() { - return groupName; - } - - public String getClusterId() { - return clusterId; - } - - public boolean equals(Object other) { - - if(other == null || !(other instanceof MetaDataHolder)) { - return false; - } - - if(this == other) { - return true; - } - - MetaDataHolder that = (MetaDataHolder)other; - - if (this.groupName == null || that.groupName == null) { - return this.appId.equals(that.appId) && this.clusterId.equals(that.clusterId); - } else { - return this.appId.equals(that.appId) && this.groupName.equals(that.groupName) && - this.clusterId.equals(that.clusterId); - } - } - - public int hashCode () { - - if (this.getGroupName() == null) { - return this.appId.hashCode() + this.clusterId.hashCode(); - } else { - return this.appId.hashCode() + this.groupName.hashCode() + this.clusterId.hashCode(); - } - } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } -} diff --git a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java index 1fc808e2f9..72b1581853 100644 --- a/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java +++ b/components/org.apache.stratos.cloud.controller/src/test/java/org/apache/stratos/cloud/controller/application/CompositeApplicationParseTest.java @@ -1,554 +1,554 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.stratos.cloud.controller.application; - -import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; -import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.Dependencies; -import org.apache.stratos.cloud.controller.pojo.ServiceGroup; -import org.apache.stratos.cloud.controller.pojo.application.*; -import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; - -public class CompositeApplicationParseTest { - - private static FasterLookUpDataHolder dataHolder = null; - - @BeforeClass - public static void setUpBeforeClass() { - - dataHolder = FasterLookUpDataHolder.getInstance(); - // add cartridges - // add php cartridge - dataHolder.addCartridge(new Cartridge("php", "stratos.com", "php-provider" , "1.0.0", false)); - // add tomcat cartridge - dataHolder.addCartridge(new Cartridge("tomcat", "stratos.com", "apache" , "1.0.0", false)); - // add mysql cartridge - dataHolder.addCartridge(new Cartridge("mysql", "stratos.com", "apache" , "1.0.0", false)); - - // add groups - // add group1 - ServiceGroup group1 = new ServiceGroup(); - group1.setName("group1"); - group1.setCartridges(new String[]{"mysql"}); - Dependencies group1Dependencies = new Dependencies(); - group1Dependencies.setKillBehaviour("terminate-none"); - group1.setDependencies(group1Dependencies); - dataHolder.addServiceGroup(group1); - // add group2 - ServiceGroup group2 = new ServiceGroup(); - group2.setName("group2"); - group2.setCartridges(new String[]{"php"}); - group2.setSubGroups(new String[]{"group1"}); - Dependencies group2Dependencies = new Dependencies(); - group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"}); - group2Dependencies.setKillBehaviour("terminate-dependents"); - group2.setDependencies(group2Dependencies); - dataHolder.addServiceGroup(group2); - } - - @Test - public void testParseSimpleApplication () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleApplicationWithNullAppId () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // no app id - simpleAppCtxt.setAlias("simpleAppAlias"); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleApplicationWithEmptyAppId () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // empty app id - simpleAppCtxt.setApplicationId(""); - simpleAppCtxt.setAlias("simpleAppAlias"); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleInvalidApp"); - simpleAppCtxt.setAlias("simpleInvalidAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - // give invalid cartridge type - simpleAppSubscribableContext.setType("php1"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleApplicationWithoutSubcriptionInformation() throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleInvalidApp"); - simpleAppCtxt.setAlias("simpleInvalidAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - // give invalid cartridge type - simpleAppSubscribableContext.setType("php1"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // invalid Subscription information - SubscribableInfoContext simpleAppEmptySubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppEmptySubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test - public void testParseSimpleApplicationWithMultipleSubsriptions () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleInvalidApp"); - simpleAppCtxt.setAlias("simpleInvalidAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); - simpleAppPhpSubscribableContext.setType("php"); - simpleAppPhpSubscribableContext.setAlias("myphp"); - SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); - simpleAppMySqlSubscribableContext.setType("mysql"); - simpleAppMySqlSubscribableContext.setAlias("mysql1"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, - simpleAppMySqlSubscribableContext}); - - DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); - simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"}); - simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); - - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - - // subscribable information - SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); - simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); - simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); - simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, - simpleAppMySqlSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test(expected = ApplicationDefinitionException.class) - public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrder () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleInvalidApp"); - simpleAppCtxt.setAlias("simpleInvalidAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); - simpleAppPhpSubscribableContext.setType("php"); - simpleAppPhpSubscribableContext.setAlias("myphp"); - SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); - simpleAppMySqlSubscribableContext.setType("mysql"); - simpleAppMySqlSubscribableContext.setAlias("mysql1"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, - simpleAppMySqlSubscribableContext}); - - DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); - // startup order is invalid, without prefix 'cartridge.' for mysql1 - simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"}); - simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); - - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - - // subscribable information - SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); - simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); - simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); - simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, - simpleAppMySqlSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test - public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - // top level cartridges - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - // top level group - GroupContext simpleGroupContext = new GroupContext(); - simpleGroupContext.setName("group1"); - simpleGroupContext.setAlias("mygroup1"); - simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); - simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); - SubscribableContext groupSubscribableCtxt = new SubscribableContext(); - groupSubscribableCtxt.setType("mysql"); - groupSubscribableCtxt.setAlias("mygroup1mysql"); - simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); - simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); - simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); - simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, - simpleAppGroupSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test (expected = ApplicationDefinitionException.class) - public void testAppWithOneCartridgeAndInvalidGroup () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - // top level cartridges - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - // top level group - GroupContext simpleGroupContext = new GroupContext(); - // invalid Group 'group11' - simpleGroupContext.setName("group11"); - simpleGroupContext.setAlias("mygroup1"); - simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); - simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); - SubscribableContext groupSubscribableCtxt = new SubscribableContext(); - groupSubscribableCtxt.setType("mysql"); - groupSubscribableCtxt.setAlias("mygroup1mysql"); - simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); - simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); - simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); - simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, - simpleAppGroupSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test - public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - // top level cartridges - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - // top level group - GroupContext simpleGroupContext = new GroupContext(); - simpleGroupContext.setName("group1"); - simpleGroupContext.setAlias("mygroup1"); - simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); - simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); - SubscribableContext groupSubscribableCtxt = new SubscribableContext(); - groupSubscribableCtxt.setType("mysql"); - groupSubscribableCtxt.setAlias("mygroup1mysql"); - simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); - simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // dependencies - DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); - simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"}); - simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); - simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); - simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, - simpleAppGroupSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test (expected = ApplicationDefinitionException.class) - public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - // top level cartridges - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - // top level group - GroupContext simpleGroupContext = new GroupContext(); - simpleGroupContext.setName("group1"); - simpleGroupContext.setAlias("mygroup1"); - simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); - simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); - SubscribableContext groupSubscribableCtxt = new SubscribableContext(); - groupSubscribableCtxt.setType("mysql"); - groupSubscribableCtxt.setAlias("mygroup1mysql"); - simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); - simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // dependencies - DependencyContext simpleAppDependecyCtxt = new DependencyContext(); - simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); - // invalid startup order, starting with 'group1' - simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"}); - simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - - SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); - simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); - simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, - simpleAppGroupSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @Test (expected = ApplicationDefinitionException.class) - public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - ApplicationContext simpleAppCtxt = new ApplicationContext(); - // app id - simpleAppCtxt.setApplicationId("simpleApp"); - simpleAppCtxt.setAlias("simpleAppAlias"); - // tenant info - simpleAppCtxt.setTenantId(-1234); - // components - ComponentContext simpleAppComponentCtxt = new ComponentContext(); - // top level cartridges - SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); - simpleAppSubscribableContext.setType("php"); - simpleAppSubscribableContext.setAlias("myphp"); - simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); - // top level group - GroupContext simpleGroupContext = new GroupContext(); - simpleGroupContext.setName("group1"); - simpleGroupContext.setAlias("mygroup1"); - simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); - simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); - SubscribableContext groupSubscribableCtxt = new SubscribableContext(); - groupSubscribableCtxt.setType("mysql"); - groupSubscribableCtxt.setAlias("mygroup1mysql"); - simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); - simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); - simpleAppCtxt.setComponents(simpleAppComponentCtxt); - // subscribable information - SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); - simpleAppSubscribableInfoCtxt.setAlias("myphp"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); - simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); - simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); - simpleAppSubscribableInfoCtxt.setPrivateRepo(true); - simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); - simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); - - simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); - - // parse - applicationParser.parse(simpleAppCtxt); - } - - @AfterClass - public static void tearDownAfterClass() { - - dataHolder = null; - } -} +///* +// * Licensed to the Apache Software Foundation (ASF) under one +// * or more contributor license agreements. See the NOTICE file +// * distributed with this work for additional information +// * regarding copyright ownership. The ASF licenses this file +// * to you under the Apache License, Version 2.0 (the +// * "License"); you may not use this file except in compliance +// * with the License. You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, +// * software distributed under the License is distributed on an +// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// * KIND, either express or implied. See the License for the +// * specific language governing permissions and limitations +// * under the License. +// */ +// +//package org.apache.stratos.cloud.controller.application; +// +//import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; +//import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; +//import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; +//import org.apache.stratos.cloud.controller.pojo.Cartridge; +//import org.apache.stratos.cloud.controller.pojo.Dependencies; +//import org.apache.stratos.cloud.controller.pojo.ServiceGroup; +//import org.apache.stratos.cloud.controller.pojo.application.*; +//import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; +//import org.junit.AfterClass; +//import org.junit.BeforeClass; +//import org.junit.Test; +// +//public class CompositeApplicationParseTest { +// +// private static FasterLookUpDataHolder dataHolder = null; +// +// @BeforeClass +// public static void setUpBeforeClass() { +// +// dataHolder = FasterLookUpDataHolder.getInstance(); +// // add cartridges +// // add php cartridge +// dataHolder.addCartridge(new Cartridge("php", "stratos.com", "php-provider" , "1.0.0", false)); +// // add tomcat cartridge +// dataHolder.addCartridge(new Cartridge("tomcat", "stratos.com", "apache" , "1.0.0", false)); +// // add mysql cartridge +// dataHolder.addCartridge(new Cartridge("mysql", "stratos.com", "apache" , "1.0.0", false)); +// +// // add groups +// // add group1 +// ServiceGroup group1 = new ServiceGroup(); +// group1.setName("group1"); +// group1.setCartridges(new String[]{"mysql"}); +// Dependencies group1Dependencies = new Dependencies(); +// group1Dependencies.setKillBehaviour("terminate-none"); +// group1.setDependencies(group1Dependencies); +// dataHolder.addServiceGroup(group1); +// // add group2 +// ServiceGroup group2 = new ServiceGroup(); +// group2.setName("group2"); +// group2.setCartridges(new String[]{"php"}); +// group2.setSubGroups(new String[]{"group1"}); +// Dependencies group2Dependencies = new Dependencies(); +// group2Dependencies.setStartupOrders(new String[]{"group.group1,cartridge.php"}); +// group2Dependencies.setKillBehaviour("terminate-dependents"); +// group2.setDependencies(group2Dependencies); +// dataHolder.addServiceGroup(group2); +// } +// +// @Test +// public void testParseSimpleApplication () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test(expected = ApplicationDefinitionException.class) +// public void testParseSimpleApplicationWithNullAppId () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // no app id +// simpleAppCtxt.setAlias("simpleAppAlias"); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test(expected = ApplicationDefinitionException.class) +// public void testParseSimpleApplicationWithEmptyAppId () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // empty app id +// simpleAppCtxt.setApplicationId(""); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test(expected = ApplicationDefinitionException.class) +// public void testParseSimpleApplicationWithInvalidCartridge() throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleInvalidApp"); +// simpleAppCtxt.setAlias("simpleInvalidAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// // give invalid cartridge type +// simpleAppSubscribableContext.setType("php1"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test(expected = ApplicationDefinitionException.class) +// public void testParseSimpleApplicationWithoutSubcriptionInformation() throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleInvalidApp"); +// simpleAppCtxt.setAlias("simpleInvalidAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// // give invalid cartridge type +// simpleAppSubscribableContext.setType("php1"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // invalid Subscription information +// SubscribableInfoContext simpleAppEmptySubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppEmptySubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test +// public void testParseSimpleApplicationWithMultipleSubsriptions () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleInvalidApp"); +// simpleAppCtxt.setAlias("simpleInvalidAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); +// simpleAppPhpSubscribableContext.setType("php"); +// simpleAppPhpSubscribableContext.setAlias("myphp"); +// SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); +// simpleAppMySqlSubscribableContext.setType("mysql"); +// simpleAppMySqlSubscribableContext.setAlias("mysql1"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, +// simpleAppMySqlSubscribableContext}); +// +// DependencyContext simpleAppDependecyCtxt = new DependencyContext(); +// simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); +// simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"cartridge.mysql1,cartridge.myphp"}); +// simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); +// +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// +// // subscribable information +// SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); +// simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); +// simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, +// simpleAppMySqlSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test(expected = ApplicationDefinitionException.class) +// public void testParseSimpleApplicationWithMultipleSubsriptionsInvalidStartupOrder () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleInvalidApp"); +// simpleAppCtxt.setAlias("simpleInvalidAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// SubscribableContext simpleAppPhpSubscribableContext = new SubscribableContext(); +// simpleAppPhpSubscribableContext.setType("php"); +// simpleAppPhpSubscribableContext.setAlias("myphp"); +// SubscribableContext simpleAppMySqlSubscribableContext = new SubscribableContext(); +// simpleAppMySqlSubscribableContext.setType("mysql"); +// simpleAppMySqlSubscribableContext.setAlias("mysql1"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppPhpSubscribableContext, +// simpleAppMySqlSubscribableContext}); +// +// DependencyContext simpleAppDependecyCtxt = new DependencyContext(); +// simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); +// // startup order is invalid, without prefix 'cartridge.' for mysql1 +// simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"mysql1,cartridge.myphp"}); +// simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); +// +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// +// // subscribable information +// SubscribableInfoContext simpleAppPhpSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppPhpSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppPhpSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppPhpSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppPhpSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppPhpSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppPhpSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppMySqlSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppMySqlSubscribableInfoCtxt.setAlias("mysql1"); +// simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_2"); +// simpleAppMySqlSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_2"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppPhpSubscribableInfoCtxt, +// simpleAppMySqlSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test +// public void testAppWithOneCartridgeAndOneGroup () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// // top level cartridges +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// // top level group +// GroupContext simpleGroupContext = new GroupContext(); +// simpleGroupContext.setName("group1"); +// simpleGroupContext.setAlias("mygroup1"); +// simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); +// simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); +// SubscribableContext groupSubscribableCtxt = new SubscribableContext(); +// groupSubscribableCtxt.setType("mysql"); +// groupSubscribableCtxt.setAlias("mygroup1mysql"); +// simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); +// simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); +// simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); +// simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, +// simpleAppGroupSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test (expected = ApplicationDefinitionException.class) +// public void testAppWithOneCartridgeAndInvalidGroup () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// // top level cartridges +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// // top level group +// GroupContext simpleGroupContext = new GroupContext(); +// // invalid Group 'group11' +// simpleGroupContext.setName("group11"); +// simpleGroupContext.setAlias("mygroup1"); +// simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); +// simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); +// SubscribableContext groupSubscribableCtxt = new SubscribableContext(); +// groupSubscribableCtxt.setType("mysql"); +// groupSubscribableCtxt.setAlias("mygroup1mysql"); +// simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); +// simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); +// simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); +// simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, +// simpleAppGroupSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test +// public void testAppWithOneCartridgeAndOneGroupWithDependencies () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// // top level cartridges +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// // top level group +// GroupContext simpleGroupContext = new GroupContext(); +// simpleGroupContext.setName("group1"); +// simpleGroupContext.setAlias("mygroup1"); +// simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); +// simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); +// SubscribableContext groupSubscribableCtxt = new SubscribableContext(); +// groupSubscribableCtxt.setType("mysql"); +// groupSubscribableCtxt.setAlias("mygroup1mysql"); +// simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); +// simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // dependencies +// DependencyContext simpleAppDependecyCtxt = new DependencyContext(); +// simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); +// simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group.group1,cartridge.myphp"}); +// simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); +// simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); +// simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, +// simpleAppGroupSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test (expected = ApplicationDefinitionException.class) +// public void testAppWithOneCartridgeAndOneGroupWithInvalidDependencies () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// // top level cartridges +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// // top level group +// GroupContext simpleGroupContext = new GroupContext(); +// simpleGroupContext.setName("group1"); +// simpleGroupContext.setAlias("mygroup1"); +// simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); +// simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); +// SubscribableContext groupSubscribableCtxt = new SubscribableContext(); +// groupSubscribableCtxt.setType("mysql"); +// groupSubscribableCtxt.setAlias("mygroup1mysql"); +// simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); +// simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // dependencies +// DependencyContext simpleAppDependecyCtxt = new DependencyContext(); +// simpleAppDependecyCtxt.setTerminationBehaviour("terminate-dependents"); +// // invalid startup order, starting with 'group1' +// simpleAppDependecyCtxt.setStartupOrdersContexts(new String[]{"group1.group1,cartridge.myphp"}); +// simpleAppComponentCtxt.setDependencyContext(simpleAppDependecyCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// SubscribableInfoContext simpleAppGroupSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppGroupSubscribableInfoCtxt.setAlias("mygroup1mysql"); +// simpleAppGroupSubscribableInfoCtxt.setAutoscalingPolicy("mysql_autoscaling_policy"); +// simpleAppGroupSubscribableInfoCtxt.setDeploymentPolicy("mysql_deployment_policy"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt, +// simpleAppGroupSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @Test (expected = ApplicationDefinitionException.class) +// public void testAppWithOneCartridgeAndOneGroupWithNoSubcribableInfoForGroup () throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// ApplicationContext simpleAppCtxt = new ApplicationContext(); +// // app id +// simpleAppCtxt.setApplicationId("simpleApp"); +// simpleAppCtxt.setAlias("simpleAppAlias"); +// // tenant info +// simpleAppCtxt.setTenantId(-1234); +// // components +// ComponentContext simpleAppComponentCtxt = new ComponentContext(); +// // top level cartridges +// SubscribableContext simpleAppSubscribableContext = new SubscribableContext(); +// simpleAppSubscribableContext.setType("php"); +// simpleAppSubscribableContext.setAlias("myphp"); +// simpleAppComponentCtxt.setSubscribableContexts(new SubscribableContext[]{simpleAppSubscribableContext}); +// // top level group +// GroupContext simpleGroupContext = new GroupContext(); +// simpleGroupContext.setName("group1"); +// simpleGroupContext.setAlias("mygroup1"); +// simpleGroupContext.setAutoscalingPolicy("group_autoscaling_policy_1"); +// simpleGroupContext.setDeploymentPolicy("group_deployment_policy_1"); +// SubscribableContext groupSubscribableCtxt = new SubscribableContext(); +// groupSubscribableCtxt.setType("mysql"); +// groupSubscribableCtxt.setAlias("mygroup1mysql"); +// simpleGroupContext.setSubscribableContexts(new SubscribableContext[]{groupSubscribableCtxt}); +// simpleAppComponentCtxt.setGroupContexts(new GroupContext[]{simpleGroupContext}); +// simpleAppCtxt.setComponents(simpleAppComponentCtxt); +// // subscribable information +// SubscribableInfoContext simpleAppSubscribableInfoCtxt = new SubscribableInfoContext(); +// simpleAppSubscribableInfoCtxt.setAlias("myphp"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("deployment_policy_1"); +// simpleAppSubscribableInfoCtxt.setAutoscalingPolicy("autoscale_policy_1"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("www.mygit.com/myphp.git"); +// simpleAppSubscribableInfoCtxt.setPrivateRepo(true); +// simpleAppSubscribableInfoCtxt.setRepoUsername("admin"); +// simpleAppSubscribableInfoCtxt.setRepoUrl("admin123"); +// +// simpleAppCtxt.setSubscribableInfoContext(new SubscribableInfoContext[]{simpleAppSubscribableInfoCtxt}); +// +// // parse +// applicationParser.parse(simpleAppCtxt); +// } +// +// @AfterClass +// public static void tearDownAfterClass() { +// +// dataHolder = null; +// } +//} 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 75f48d876a..a848c11be0 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 @@ -24,7 +24,6 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.manager.internal.DataHolder; @@ -130,22 +129,6 @@ public boolean register(String clusterId, String cartridgeType, } - - public void deployApplicationDefinition(ApplicationContext applicationContext) - throws RemoteException, - CloudControllerServiceInvalidIaasProviderExceptionException, CloudControllerServiceApplicationDefinitionExceptionException { - - stub.deployApplicationDefinition(applicationContext); - - } - - public void undeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws CloudControllerServiceApplicationDefinitionExceptionException, - RemoteException { - - stub.unDeployApplicationDefinition(applicationId, tenantId, tenantDomain); - } - - @SuppressWarnings("unused") private Properties extractProperties(java.util.Properties properties) { diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java index 6a7e421dad..9f41b0eb31 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/domain/applications/ClusterDataHolder.java @@ -30,7 +30,6 @@ public class ClusterDataHolder implements Serializable { // Service/Cartridge type private String serviceType; - // Cluster id private String clusterId; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 012611fa93..a7ab51b9bd 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -31,7 +31,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml index 7aff96698f..e527dd43bd 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml @@ -46,7 +46,7 @@ - + @@ -89,7 +89,6 @@ org.apache.stratos.cloud.controller.stub.exception.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.deployment.partition.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.pojo.*; version=${project.version}, - org.apache.stratos.cloud.controller.stub.pojo.application.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.impl.*; version=${project.version}, org.apache.stratos.cloud.controller.stub.*; version=${project.version} diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 602de3f606..696060a700 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,275 +1,213 @@ - + CloudControllerService - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - - + - - + + - + - + - + - + - + - + - + - + - - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -286,49 +224,35 @@ - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + @@ -344,87 +268,103 @@ - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + - + - - - - + + + - - - - + + + + + + + + + @@ -439,78 +379,65 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + - - - - - - @@ -518,75 +445,65 @@ - + - + - + + - - - + + + - - - - - - - + - - + + + + + - + + + + + - + - - + - + - - - - - - - - - - - - - + + + - + + + + - - - - - - - - - + + + + + @@ -633,12 +550,6 @@ - - - - - - @@ -666,17 +577,14 @@ - - - - - + + @@ -741,10 +649,6 @@ - - - - @@ -765,18 +669,14 @@ - - - - - - - + + + @@ -874,29 +774,8 @@ - - - - - - - - - - - - - - - - - - - - - - - + + @@ -907,8 +786,8 @@ - - + + @@ -931,16 +810,16 @@ - - + + - - + + @@ -952,13 +831,16 @@ - - + + - - + + + + + @@ -1096,29 +978,8 @@ - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1129,8 +990,8 @@ - - + + @@ -1153,16 +1014,16 @@ - - + + - - + + @@ -1174,13 +1035,16 @@ - - + + - - + + + + + @@ -1297,23 +1161,8 @@ - - - - - - - - - - - - - - - - - + + @@ -1321,8 +1170,8 @@ - - + + @@ -1336,8 +1185,8 @@ - - + + @@ -1351,11 +1200,14 @@ - - + + + + + @@ -1411,22 +1263,22 @@ - + - + - + - + - + - + \ No newline at end of file From 14f5fe030ae1b5423af5e178d66be4b27ca01ac4 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 11:26:21 +0530 Subject: [PATCH 361/436] support application monitor creation based on complete topology event --- .../ApplicationSynchronizeTask.java | 4 +- .../topic/ApplicationBuilder.java | 149 ++++++++++++++++++ .../internal/AutoscalerServerComponent.java | 6 +- .../AutoscalerTopologyEventReceiver.java | 62 +++++++- 4 files changed, 210 insertions(+), 11 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java index 9f0ca8c73f..22a2805969 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.wso2.carbon.ntask.core.Task; @@ -36,7 +37,8 @@ public void execute() { } // publish to the topic if (ApplicationHolder.getApplications() != null) { - ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications()); + //ApplicationsEventPublisher.sendCompleteApplicationsEvent(ApplicationHolder.getApplications()); + ApplicationBuilder.handleCompleteApplication(ApplicationHolder.getApplications()); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 6adf3b138f..bf0ad01d9a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -20,9 +20,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; +import org.apache.stratos.autoscaler.exception.DependencyBuilderException; +import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.messaging.domain.applications.*; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.Collection; import java.util.Set; @@ -143,6 +150,17 @@ public class ApplicationBuilder { ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); }*/ + + public static synchronized void handleCompleteApplication (Applications applications) { + log.info("Handling complete application"); + ApplicationHolder.acquireReadLock(); + try { + ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications); + } finally { + ApplicationHolder.releaseReadLock(); + } + } + public static synchronized void handleApplicationCreated (Application application, Set appClusterContexts) { @@ -153,6 +171,7 @@ public static synchronized void handleApplicationCreated (Application applicatio try { if (applications.getApplication(application.getUniqueIdentifier()) != null) { ApplicationHolder.persistApplication(application); + // startApplicationMonitor(application.getUniqueIdentifier()); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); } @@ -512,4 +531,134 @@ public static void handleApplicationTerminatedEvent(String appId) { ApplicationHolder.releaseWriteLock(); } } + + + protected static synchronized void startApplicationMonitor(String appId) { + + ApplicationMonitor applicationMonitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + long start = System.currentTimeMillis(); + if (log.isDebugEnabled()) { + log.debug("application monitor is going to be started for [application] " + + appId); + } + applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); + + long end = System.currentTimeMillis(); + log.info("Time taken to start app monitor: " + (end - start) / 1000); + success = true; + } catch (DependencyBuilderException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } + } while (!success && retries != 0); + + if (applicationMonitor == null) { + String msg = "Application monitor creation failed, even after retrying for 5 times, " + + "for Application: " + appId; + log.error(msg); + throw new RuntimeException(msg); + } + + AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); + + if (log.isInfoEnabled()) { + log.info(String.format("Application monitor has been added successfully: " + + "[application] %s", applicationMonitor.getId())); + } + } + + + /*Thread th = null; + if (!AutoscalerContext.getInstance() + .appMonitorExist(applicationId)) { + th = new Thread( + new ApplicationMonitorAdder(applicationId)); + } + + if (th != null) { + th.start(); + // try { + // th.join(); + // } catch (InterruptedException ignore) { + + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread has been started successfully: " + + "[application] %s ", applicationId)); + } + } else { + if (log.isDebugEnabled()) { + log.debug(String + .format("Application monitor thread already exists: " + + "[application] %s ", applicationId)); + } + }*/ + + + private class ApplicationMonitorAdder implements Runnable { + private String appId; + + public ApplicationMonitorAdder(String appId) { + this.appId = appId; + } + + public void run() { + ApplicationMonitor applicationMonitor = null; + int retries = 5; + boolean success = false; + do { + try { + Thread.sleep(5000); + } catch (InterruptedException e1) { + } + try { + long start = System.currentTimeMillis(); + if (log.isDebugEnabled()) { + log.debug("application monitor is going to be started for [application] " + + appId); + } + applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); + + long end = System.currentTimeMillis(); + log.info("Time taken to start app monitor: " + (end - start) / 1000); + success = true; + } catch (DependencyBuilderException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } catch (TopologyInConsistentException e) { + String msg = "Application monitor creation failed for Application: "; + log.warn(msg, e); + retries--; + } + } while (!success && retries != 0); + + if (applicationMonitor == null) { + String msg = "Application monitor creation failed, even after retrying for 5 times, " + + "for Application: " + appId; + log.error(msg); + throw new RuntimeException(msg); + } + + AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); + + if (log.isInfoEnabled()) { + log.info(String.format("Application monitor has been added successfully: " + + "[application] %s", applicationMonitor.getId())); + } + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java index 5ada0b7d4e..a946977d14 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java @@ -43,14 +43,14 @@ /** * @scr.component name=org.apache.stratos.autoscaler.internal.AutoscalerServerComponent" * immediate="true" - * @scr.reference name="ntask.component" interface="org.wso2.carbon.ntask.core.service.TaskService" - * cardinality="1..1" policy="dynamic" bind="setTaskService" - * unbind="unsetTaskService" * @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 AutoscalerServerComponent { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index dcf3a82de4..72dc6e5c13 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.*; +import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; @@ -39,6 +40,7 @@ import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.messaging.event.Event; @@ -93,6 +95,46 @@ public void run() { } } + private boolean allClustersInitialized(Application application) { + boolean allClustersInitialized = false; + for(ClusterDataHolder holder : application.getClusterDataMap().values()) { + TopologyManager.acquireReadLockForCluster(holder.getServiceType(), + holder.getClusterId()); + + try { + Topology topology = TopologyManager.getTopology(); + if(topology != null) { + Service service = topology.getService(holder.getServiceType()); + if(service != null) { + if(service.clusterExists(holder.getClusterId())) { + allClustersInitialized = true; + } else { + if(log.isDebugEnabled()) { + log.debug("[Cluster] " + holder.getClusterId() + " is not found in " + + "the Topology"); + } + allClustersInitialized = false; + return allClustersInitialized; + } + } else { + if(log.isDebugEnabled()) { + log.debug("Service is null in the CompleteTopologyEvent"); + } + } + } else { + if(log.isDebugEnabled()) { + log.debug("Topology is null in the CompleteTopologyEvent"); + } + } + } finally { + TopologyManager.releaseReadLockForCluster(holder.getServiceType(), + holder.getClusterId()); + } + } + return allClustersInitialized; + } + + private void addEventListeners() { // Listen to topology events that affect clusters topologyEventReceiver.addEventListener(new CompleteTopologyEventListener() { @@ -101,18 +143,24 @@ protected void onEvent(Event event) { if (!topologyInitialized) { log.info("[CompleteTopologyEvent] Received: " + event.getClass()); - - TopologyManager.acquireReadLock(); + ApplicationHolder.acquireReadLock(); try { - for (Application application : ApplicationManager.getApplications().getApplications().values()) { - startApplicationMonitor(application.getUniqueIdentifier()); + Applications applications = ApplicationHolder.getApplications(); + if(applications != null) { + for (Application application : applications.getApplications().values()) { + if(allClustersInitialized(application)) { + startApplicationMonitor(application.getUniqueIdentifier()); + } else { + log.error("Complete Topology is not consistent with the applications " + + "which got persisted"); + } + } + topologyInitialized = true; } - - topologyInitialized = true; } catch (Exception e) { log.error("Error processing event", e); } finally { - TopologyManager.releaseReadLock(); + ApplicationHolder.releaseReadLock(); } } } From c98411b6178670e89bc74971f71e8db4fd85445e Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 12:19:10 +0530 Subject: [PATCH 362/436] adding clusters created event and handling it in autoscaler --- .../topic/ApplicationBuilder.java | 2 + .../AutoscalerTopologyEventReceiver.java | 20 +-- .../ApplicationClustersCreatedEvent.java | 45 ++++++ ...plicationClustersCreatedEventListener.java | 27 ++++ ...cationClustersCreatedMessageProcessor.java | 139 ++++++++++++++++++ .../TopologyMessageProcessorChain.java | 6 + 6 files changed, 229 insertions(+), 10 deletions(-) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationClustersCreatedEvent.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationClustersCreatedEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index bf0ad01d9a..7e826f0020 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -25,6 +25,7 @@ import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; +import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.messaging.domain.applications.*; @@ -171,6 +172,7 @@ public static synchronized void handleApplicationCreated (Application applicatio try { if (applications.getApplication(application.getUniqueIdentifier()) != null) { ApplicationHolder.persistApplication(application); + //TODO cloud controller client and register clusters // startApplicationMonitor(application.getUniqueIdentifier()); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 72dc6e5c13..d79d7f0219 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -167,26 +167,26 @@ protected void onEvent(Event event) { }); - /*topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() { + topologyEventReceiver.addEventListener(new ApplicationClustersCreatedEventListener() { @Override protected void onEvent(Event event) { try { - log.info("[ApplicationCreatedEvent] Received: " + event.getClass()); - ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; + log.info("[ApplicationClustersCreatedEvent] Received: " + event.getClass()); + ApplicationClustersCreatedEvent applicationClustersCreatedEvent = + (ApplicationClustersCreatedEvent) event; + String appId = applicationClustersCreatedEvent.getAppId(); try { - //acquire read lock - TopologyManager.acquireReadLockForApplication( - applicationCreatedEvent.getApplication().getUniqueIdentifier()); + ApplicationHolder.acquireReadLock(); //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication().getUniqueIdentifier()); + startApplicationMonitor(appId); } catch (Exception e) { String msg = "Error processing event " + e.getLocalizedMessage(); log.error(msg, e); } finally { //release read lock - TopologyManager.releaseReadLockForApplication( - applicationCreatedEvent.getApplication().getUniqueIdentifier()); + ApplicationHolder.releaseReadLock(); + } } catch (ClassCastException e) { String msg = "Error while casting the event " + e.getLocalizedMessage(); @@ -194,7 +194,7 @@ protected void onEvent(Event event) { } } - });*/ + }); topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { @Override diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationClustersCreatedEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationClustersCreatedEvent.java new file mode 100644 index 0000000000..368dabfeb9 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/topology/ApplicationClustersCreatedEvent.java @@ -0,0 +1,45 @@ +/* + * 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.messaging.event.topology; + +import org.apache.stratos.messaging.domain.topology.Cluster; + +import java.io.Serializable; +import java.util.List; + +/** + * This will have the list of clusters which associated with an application + */ +public class ApplicationClustersCreatedEvent extends TopologyEvent implements Serializable { + private List clusterList; + private String appId; + + public ApplicationClustersCreatedEvent(List clusters, String appId) { + this.clusterList = clusters; + this.appId = appId; + } + + public List getClusterList() { + return clusterList; + } + + public String getAppId() { + return appId; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationClustersCreatedEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationClustersCreatedEventListener.java new file mode 100644 index 0000000000..4dda06d76a --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/topology/ApplicationClustersCreatedEventListener.java @@ -0,0 +1,27 @@ +/* + * 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.messaging.listener.topology; + +import org.apache.stratos.messaging.listener.EventListener; + +/** + * This will get triggered when clusters created for an application. + */ +abstract public class ApplicationClustersCreatedEventListener extends EventListener{ +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java new file mode 100644 index 0000000000..3780db51c8 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java @@ -0,0 +1,139 @@ +/* + * 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.messaging.message.processor.topology; + +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.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; +import org.apache.stratos.messaging.event.topology.ApplicationClustersCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.message.filter.topology.TopologyClusterFilter; +import org.apache.stratos.messaging.message.filter.topology.TopologyServiceFilter; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.message.processor.topology.updater.TopologyUpdater; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; +import org.apache.stratos.messaging.util.Util; + +import java.util.List; + +/** + * This will process the clusters and add them to relevant service. + */ +public class ApplicationClustersCreatedMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(ApplicationClustersCreatedMessageProcessor.class); + private MessageProcessor nextProcessor; + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + Topology topology = (Topology) object; + if (ApplicationClustersCreatedEvent.class.getName().equals(type)) { + // Return if topology has not been initialized + if (!topology.isInitialized()) { + return false; + } + + // Parse complete message and build event + ApplicationClustersCreatedEvent event = (ApplicationClustersCreatedEvent) Util. + jsonToObject(message, ApplicationClustersCreatedEvent.class); + return doProcess(event, topology); + + + } else { + if (nextProcessor != null) { + // ask the next processor to take care of the message. + return nextProcessor.process(type, message, topology); + } else { + throw new RuntimeException(String.format("Failed to process message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + private boolean doProcess (ApplicationClustersCreatedEvent event,Topology topology) { + List clusters = event.getClusterList(); + + for(Cluster cluster : clusters) { + String serviceName = cluster.getServiceName(); + String clusterId = cluster.getClusterId(); + TopologyUpdater.acquireWriteLockForCluster(clusterId, serviceName); + try { + + // Apply service filter + if (TopologyServiceFilter.getInstance().isActive()) { + if (TopologyServiceFilter.getInstance().serviceNameExcluded(serviceName)) { + // Service is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Service is excluded: [service] %s", serviceName)); + } + return false; + } + } + + // Apply cluster filter + if (TopologyClusterFilter.getInstance().isActive()) { + if (TopologyClusterFilter.getInstance().clusterIdExcluded(clusterId)) { + // Cluster is excluded, do not update topology or fire event + if (log.isDebugEnabled()) { + log.debug(String.format("Cluster is excluded: [cluster] %s", clusterId)); + } + return false; + } + } + + // Validate event against the existing topology + Service service = topology.getService(serviceName); + if (service == null) { + if (log.isWarnEnabled()) { + log.warn(String.format("Service does not exist: [service] %s", + serviceName)); + } + return false; + } + if (service.clusterExists(clusterId)) { + if (log.isWarnEnabled()) { + log.warn(String.format("Cluster already exists in service: [service] %s " + + "[cluster] %s",serviceName , + clusterId)); + } + } else { + + // Apply changes to the topology + service.addCluster(cluster); + cluster.setStatus(ClusterStatus.Created); + if (log.isInfoEnabled()) { + log.info(String.format("Cluster created: %s", + cluster.toString())); + } + } + } finally { + TopologyUpdater.releaseWriteLockForCluster(clusterId, serviceName); + } + } + + // Notify event listeners + notifyEventListeners(event); + return true; + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java index f5ada8959b..1a84c8ca67 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/TopologyMessageProcessorChain.java @@ -35,6 +35,7 @@ public class TopologyMessageProcessorChain extends MessageProcessorChain { private CompleteTopologyMessageProcessor completeTopologyMessageProcessor; private ServiceCreatedMessageProcessor serviceCreatedMessageProcessor; private ServiceRemovedMessageProcessor serviceRemovedMessageProcessor; + private ApplicationClustersCreatedMessageProcessor clustersCreatedMessageProcessor; private ClusterCreatedMessageProcessor clusterCreatedMessageProcessor; private ClusterResetMessageProcessor clusterResetMessageProcessor; private ClusterActivatedProcessor clusterActivatedProcessor; @@ -61,6 +62,9 @@ public void initialize() { serviceRemovedMessageProcessor = new ServiceRemovedMessageProcessor(); add(serviceRemovedMessageProcessor); + clustersCreatedMessageProcessor = new ApplicationClustersCreatedMessageProcessor(); + add(clustersCreatedMessageProcessor); + clusterCreatedMessageProcessor = new ClusterCreatedMessageProcessor(); add(clusterCreatedMessageProcessor); @@ -113,6 +117,8 @@ public void addEventListener(EventListener eventListener) { completeTopologyMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterCreatedEventListener) { clusterCreatedMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof ApplicationClustersCreatedEventListener) { + clustersCreatedMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterActivatedEventListener) { clusterActivatedProcessor.addEventListener(eventListener); } else if (eventListener instanceof ClusterInActivateEventListener) { From eac9d65f340096d5885b22691cff22a62a63d360 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 12:55:48 +0530 Subject: [PATCH 363/436] updating the monitors with the status changes --- .../topic/ApplicationBuilder.java | 135 +++++++++++++----- .../AutoscalerTopologyEventReceiver.java | 35 ++--- 2 files changed, 118 insertions(+), 52 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 7e826f0020..0426382b5c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -28,6 +28,7 @@ import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -227,15 +228,21 @@ public static void handleGroupTerminatedEvent(String appId, String groupId) { try { ApplicationHolder.acquireWriteLock(); - group.setStatus(GroupStatus.Terminated); - log.info("Group terminated adding status started for " + group.getUniqueIdentifier()); - + GroupStatus status = GroupStatus.Terminated; + if (group.isStateTransitionValid(status)) { + log.info("Group Terminated adding status started for " + group.getUniqueIdentifier()); + group.setStatus(status); + //updating the groupMonitor + updateGroupMonitor(appId, groupId, status); + //publishing data + ApplicationsEventPublisher.sendGroupTerminatedEvent(appId, groupId); + } else { + log.warn("Terminated is not in the possible state list of [group] " + groupId); + } ApplicationHolder.persistApplication(application); } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendGroupTerminatedEvent(appId, groupId); } public static void handleGroupActivatedEvent(String appId, String groupId) { @@ -257,16 +264,21 @@ public static void handleGroupActivatedEvent(String appId, String groupId) { try { ApplicationHolder.acquireWriteLock(); - group.setStatus(GroupStatus.Active); - log.info("Group activated adding status started for " + group.getUniqueIdentifier()); - + GroupStatus status = GroupStatus.Active; + if (group.isStateTransitionValid(status)) { + log.info("Group Active adding status started for " + group.getUniqueIdentifier()); + group.setStatus(status); + //updating the groupMonitor + updateGroupMonitor(appId, groupId, status); + //publishing data + ApplicationsEventPublisher.sendGroupActivatedEvent(appId, groupId); + } else { + log.warn("Active is not in the possible state list of [group] " + groupId); + } ApplicationHolder.persistApplication(application); } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendGroupActivatedEvent(application.getUniqueIdentifier(), - group.getUniqueIdentifier()); } public static void handleGroupCreatedEvent(String appId, String groupId) { @@ -288,15 +300,22 @@ public static void handleGroupCreatedEvent(String appId, String groupId) { try { ApplicationHolder.acquireWriteLock(); - group.setStatus(GroupStatus.Created); - log.info("Group created adding status started for " + group.getUniqueIdentifier()); - + GroupStatus status = GroupStatus.Created; + if (group.isStateTransitionValid(status)) { + log.info("Group created adding status started for " + group.getUniqueIdentifier()); + group.setStatus(status); + //updating the groupMonitor + updateGroupMonitor(appId, groupId, status); + //publishing data + ApplicationsEventPublisher.sendGroupCreatedEvent(appId, groupId); + } else { + log.warn("Created is not in the possible state list of [group] " + groupId); + } ApplicationHolder.persistApplication(application); } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendGroupCreatedEvent(appId, groupId); + } public static void handleGroupInActivateEvent(String appId, String groupId) { @@ -318,15 +337,21 @@ public static void handleGroupInActivateEvent(String appId, String groupId) { try { ApplicationHolder.acquireWriteLock(); - group.setStatus(GroupStatus.Inactive); - log.info("Group in-active adding status started for " + group.getUniqueIdentifier()); - + GroupStatus status = GroupStatus.Inactive; + if (group.isStateTransitionValid(status)) { + log.info("Group Inactive adding status started for " + group.getUniqueIdentifier()); + group.setStatus(status); + //updating the groupMonitor + updateGroupMonitor(appId, groupId, status); + //publishing data + ApplicationsEventPublisher.sendGroupInActivateEvent(appId, groupId); + } else { + log.warn("Inactive is not in the possible state list of [group] " + groupId); + } ApplicationHolder.persistApplication(application); } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendGroupInActivateEvent(appId, groupId); } public static void handleGroupTerminatingEvent(String appId, String groupId) { @@ -348,15 +373,21 @@ public static void handleGroupTerminatingEvent(String appId, String groupId) { try { ApplicationHolder.acquireWriteLock(); - group.setStatus(GroupStatus.Terminating); - log.info("Group terminating adding status started for " + group.getUniqueIdentifier()); - + GroupStatus status = GroupStatus.Terminating; + if (group.isStateTransitionValid(status)) { + log.info("Group Terminating adding status started for " + group.getUniqueIdentifier()); + group.setStatus(status); + //updating the groupMonitor + updateGroupMonitor(appId, groupId, status); + //publishing data + ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, groupId); + } else { + log.warn("Terminating is not in the possible state list of [group] " + groupId); + } ApplicationHolder.persistApplication(application); } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendGroupTerminatingEvent(appId, groupId); } public static void handleApplicationActivatedEvent(String appId) { @@ -371,15 +402,19 @@ public static void handleApplicationActivatedEvent(String appId) { try { ApplicationHolder.acquireWriteLock(); - application.setStatus(ApplicationStatus.Active); - log.info("Application activated adding status started for Applications"); - - ApplicationHolder.persistApplication(application); + ApplicationStatus status = ApplicationStatus.Active; + if(application.isStateTransitionValid(status)) { + application.setStatus(status); + updateApplicationMonitor(appId, status); + log.info("Application activated adding status started for Applications"); + ApplicationHolder.persistApplication(application); + //publishing data + ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); + } } finally { ApplicationHolder.releaseWriteLock(); } - //publishing data - ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); + } /*public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { @@ -433,18 +468,19 @@ public static void handleApplicationTerminatingEvent(String appId) { Application application = applications.getApplication(applicationId); // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { + ApplicationStatus status = ApplicationStatus.Terminating; + if (!application.isStateTransitionValid(status)) { log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); } // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); + application.setStatus(status); log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); - + updateApplicationMonitor(appId, status); + ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); } finally { ApplicationHolder.releaseWriteLock(); } - ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); } private static void updateGroupStatusesRecursively(GroupStatus groupStatus, Collection groups) { @@ -482,6 +518,7 @@ public static void handleApplicationTerminatedEvent(String appId) { } // forcefully set status for now application.setStatus(ApplicationStatus.Terminated); + updateApplicationMonitor(appId, ApplicationStatus.Terminated); int tenantId = application.getTenantId(); String tenantDomain = application.getTenantDomain(); @@ -663,4 +700,30 @@ public void run() { } } } + + + private static void updateApplicationMonitor(String appId, ApplicationStatus status) { + //Updating the Application Monitor + ApplicationMonitor applicationMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + if(applicationMonitor != null) { + applicationMonitor.setStatus(status); + } else { + //TODO + } + + } + + private static void updateGroupMonitor(String appId, String groupId, GroupStatus status) { + //Updating the Application Monitor + ApplicationMonitor applicationMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); + if(applicationMonitor != null) { + GroupMonitor monitor = (GroupMonitor) applicationMonitor.findGroupMonitorWithId(groupId); + if(monitor != null) { + monitor.setStatus(status); + } else { + //TODO + } + } + + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index d79d7f0219..dee3e97af6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -23,12 +23,12 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.*; import org.apache.stratos.autoscaler.applications.ApplicationHolder; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; @@ -42,12 +42,13 @@ import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; import org.apache.stratos.messaging.listener.topology.*; -import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -97,19 +98,19 @@ public void run() { private boolean allClustersInitialized(Application application) { boolean allClustersInitialized = false; - for(ClusterDataHolder holder : application.getClusterDataMap().values()) { + for (ClusterDataHolder holder : application.getClusterDataMap().values()) { TopologyManager.acquireReadLockForCluster(holder.getServiceType(), holder.getClusterId()); try { Topology topology = TopologyManager.getTopology(); - if(topology != null) { + if (topology != null) { Service service = topology.getService(holder.getServiceType()); - if(service != null) { - if(service.clusterExists(holder.getClusterId())) { + if (service != null) { + if (service.clusterExists(holder.getClusterId())) { allClustersInitialized = true; } else { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("[Cluster] " + holder.getClusterId() + " is not found in " + "the Topology"); } @@ -117,12 +118,12 @@ private boolean allClustersInitialized(Application application) { return allClustersInitialized; } } else { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Service is null in the CompleteTopologyEvent"); } } } else { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Topology is null in the CompleteTopologyEvent"); } } @@ -146,9 +147,9 @@ protected void onEvent(Event event) { ApplicationHolder.acquireReadLock(); try { Applications applications = ApplicationHolder.getApplications(); - if(applications != null) { + if (applications != null) { for (Application application : applications.getApplications().values()) { - if(allClustersInitialized(application)) { + if (allClustersInitialized(application)) { startApplicationMonitor(application.getUniqueIdentifier()); } else { log.error("Complete Topology is not consistent with the applications " + @@ -156,6 +157,8 @@ protected void onEvent(Event event) { } } topologyInitialized = true; + } else { + log.info("No applications found in the complete topology"); } } catch (Exception e) { log.error("Error processing event", e); @@ -173,7 +176,7 @@ protected void onEvent(Event event) { try { log.info("[ApplicationClustersCreatedEvent] Received: " + event.getClass()); ApplicationClustersCreatedEvent applicationClustersCreatedEvent = - (ApplicationClustersCreatedEvent) event; + (ApplicationClustersCreatedEvent) event; String appId = applicationClustersCreatedEvent.getAppId(); try { //acquire read lock @@ -208,7 +211,7 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - if(clusterMonitor!= null) { + if (clusterMonitor != null) { clusterMonitor.setStatus(ClusterStatus.Active); } @@ -258,7 +261,7 @@ protected void onEvent(Event event) { (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); //changing the status in the monitor, will notify its parent monitor - if(clusterMonitor!= null) { + if (clusterMonitor != null) { clusterMonitor.setStatus(ClusterStatus.Inactive); } @@ -429,7 +432,7 @@ protected void onEvent(Event event) { if (clusterDataHolders != null) { for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { ClusterMonitor clusterMonitor = - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId())); + ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId())); if (clusterMonitor == null) { // Cluster Monitor not found; send Cluster Terminated event to cleanup ClusterStatusEventPublisher.sendClusterTerminatedEvent( From 3841007cf0949953aab920385c29303c0363dcac Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 12:18:03 +0530 Subject: [PATCH 364/436] sending app cluster information to CC via a service call - initial stuff --- ...plicationClusterRegistrationException.java | 47 +++++++++++++++++++ .../impl/CloudControllerServiceImpl.java | 20 ++++++++ .../interfaces/CloudControllerService.java | 2 + ...java => ApplicationClusterContextDTO.java} | 10 ++-- .../controller/topology/TopologyBuilder.java | 5 ++ 5 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/{ApplicationClusterContext.java => ApplicationClusterContextDTO.java} (90%) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java new file mode 100644 index 0000000000..af2a383ea0 --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/ApplicationClusterRegistrationException.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.stratos.cloud.controller.exception; + +public class ApplicationClusterRegistrationException extends Exception { + + private String message; + + public ApplicationClusterRegistrationException () { + super(); + } + + public ApplicationClusterRegistrationException (String message, Throwable cause) { + super(message, cause); + this.message = message; + } + + public ApplicationClusterRegistrationException (String message) { + super(message); + this.message = message; + } + + public ApplicationClusterRegistrationException (Throwable cause) { + super(cause); + } + + public String getMessage() { + return message; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index a914946ccb..19c87f82d1 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1387,6 +1387,26 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } + @Override + public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + ApplicationClusterRegistrationException { + + // Create a Cluster Context obj. for each of the Clusters in the Application + if (appClustersContexts == null || appClustersContexts.length == 0) { + String errorMsg = "No application cluster information found, unable to create clusters" ; + log.error(errorMsg); + throw new ApplicationClusterRegistrationException(errorMsg); + } + + for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { + dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster())); + } + + persist(); + } + // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // // ApplicationParser applicationParser = new DefaultApplicationParser(); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index 016e98ebf6..e9f526a1e9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -167,4 +167,6 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit */ public ClusterContext getClusterContext (String clusterId); + public void registerApplicationClusters (ApplicationClusterContextDTO [] appClustersContexts) throws + ApplicationClusterRegistrationException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java similarity index 90% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index 8fa9feef95..2b601e0d6a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -19,7 +19,7 @@ package org.apache.stratos.cloud.controller.pojo; -public class ApplicationClusterContext { +public class ApplicationClusterContextDTO { // cluster id private String clusterId; @@ -38,8 +38,8 @@ public class ApplicationClusterContext { // tenant rance private String tenantRange; - public ApplicationClusterContext (String cartridgeType, String clusterId, String hostName, - String textPayload, String deploymentPolicyName, boolean isLbCluster) { + public ApplicationClusterContextDTO (String cartridgeType, String clusterId, String hostName, + String textPayload, String deploymentPolicyName, boolean isLbCluster) { this.cartridgeType = cartridgeType; this.clusterId = clusterId; @@ -116,7 +116,7 @@ public void setTenantRange(String tenantRange) { public boolean equals(Object other) { - if(other == null || !(other instanceof ApplicationClusterContext)) { + if(other == null || !(other instanceof ApplicationClusterContextDTO)) { return false; } @@ -124,7 +124,7 @@ public boolean equals(Object other) { return true; } - ApplicationClusterContext that = (ApplicationClusterContext)other; + ApplicationClusterContextDTO that = (ApplicationClusterContextDTO)other; return this.cartridgeType.equals(that.cartridgeType) && this.clusterId.equals(that.clusterId); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 0ec8f01d2e..2d5d181b5e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -147,6 +147,11 @@ public static void handleClusterCreated(ClusterStatusClusterCreatedEvent event) TopologyEventPublisher.sendClusterCreatedEvent(cluster); } + public static void handleApplicationClustersRegisterd () { + + + } + public static void handleClusterReset(ClusterStatusClusterResetEvent event) { From b141bc3cc97ea9d2ab015c69782b048e0df9b158 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 12:56:16 +0530 Subject: [PATCH 365/436] CC api changes to create app cluster objects --- .../impl/CloudControllerServiceImpl.java | 15 ++++- .../interfaces/CloudControllerService.java | 9 ++- .../controller/topology/TopologyBuilder.java | 24 ++++++- .../topology/TopologyEventPublisher.java | 9 +++ ...cationClustersCreatedMessageProcessor.java | 4 +- .../resources/CloudControllerService.wsdl | 66 +++++++++++++++++++ 6 files changed, 122 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 19c87f82d1..e9a48527da 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -39,6 +39,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; +import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; import org.jclouds.compute.ComputeService; @@ -1388,7 +1389,7 @@ public ClusterContext getClusterContext (String clusterId) { } @Override - public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException { // Create a Cluster Context obj. for each of the Clusters in the Application @@ -1398,12 +1399,24 @@ public void registerApplicationClusters(ApplicationClusterContextDTO[] appCluste throw new ApplicationClusterRegistrationException(errorMsg); } + List clusters = new ArrayList(); + for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { + // add the context data dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster())); + // create Cluster objects + Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), + appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); + newCluster.setLbCluster(false); + newCluster.setTenantRange("*"); + newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); + clusters.add(newCluster); } + TopologyBuilder.handleApplicationClustersCreated(appId, clusters); + persist(); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java index e9f526a1e9..86899b3b35 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/interfaces/CloudControllerService.java @@ -167,6 +167,13 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit */ public ClusterContext getClusterContext (String clusterId); - public void registerApplicationClusters (ApplicationClusterContextDTO [] appClustersContexts) throws + /** + * Creates the clusters relevant to an application in the topology model + * + * @param appId application id + * @param appClustersContexts cluster information holder object + * @throws ApplicationClusterRegistrationException if the cluster information are null/empty + */ + public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException; } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 2d5d181b5e..6360d617f8 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -147,9 +147,31 @@ public static void handleClusterCreated(ClusterStatusClusterCreatedEvent event) TopologyEventPublisher.sendClusterCreatedEvent(cluster); } - public static void handleApplicationClustersRegisterd () { + public static void handleApplicationClustersCreated(String appId, List appClusters) { + TopologyManager.acquireWriteLock(); + + try { + Topology topology = TopologyManager.getTopology(); + + for (Cluster cluster : appClusters) { + Service service = topology.getService(cluster.getServiceName()); + if (service == null) { + log.error("Service " + cluster.getServiceName() + + " not found in Topology, unable to create Application cluster"); + } else { + service.addCluster(cluster); + log.info("Application Cluster " + cluster.getClusterId() + " created in CC topology"); + } + } + + TopologyManager.updateTopology(topology); + + } finally { + TopologyManager.releaseWriteLock(); + } + TopologyEventPublisher.sendApplicationClustersCreated(appId, appClusters); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index 3f580804fb..b855b7f6b2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -113,6 +113,15 @@ public static void sendApplicationUndeployedEvent (String applicationId, Set clusters) { + + if (log.isInfoEnabled()) { + log.info("Publishing Application Clusters registered event for Application: " + appId); + } + + publishEvent(new ApplicationClustersCreatedEvent(clusters, appId)); + } + // public static void sendApplicationRemovedEvent(String applicationId, Set clusterData, // int tenantId, String tenantDomain) { // diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java index 3780db51c8..58d54d877e 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/topology/ApplicationClustersCreatedMessageProcessor.java @@ -77,7 +77,7 @@ private boolean doProcess (ApplicationClustersCreatedEvent event,Topology topolo for(Cluster cluster : clusters) { String serviceName = cluster.getServiceName(); String clusterId = cluster.getClusterId(); - TopologyUpdater.acquireWriteLockForCluster(clusterId, serviceName); + TopologyUpdater.acquireWriteLockForService(serviceName); try { // Apply service filter @@ -128,7 +128,7 @@ private boolean doProcess (ApplicationClustersCreatedEvent event,Topology topolo } } } finally { - TopologyUpdater.releaseWriteLockForCluster(clusterId, serviceName); + TopologyUpdater.releaseWriteLockForService(serviceName); } } diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 696060a700..316ad85b97 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -47,6 +47,11 @@ + + + + + @@ -317,6 +322,21 @@ + + + + + + + + + + + + + + + @@ -494,6 +514,18 @@ + + + + + + + + + + + + @@ -517,6 +549,12 @@ + + + + + + @@ -628,6 +666,10 @@ + + + + @@ -711,6 +753,15 @@ + + + + + + + + + @@ -915,6 +966,15 @@ + + + + + + + + + @@ -1119,6 +1179,12 @@ + + + + + + From c6febda9a835d3dccc86394ab62906946783abfc Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 13:10:33 +0530 Subject: [PATCH 366/436] calling createClusters in CC from AS --- .../topic/ApplicationBuilder.java | 2 + .../controller/CloudControllerClient.java | 45 +++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 0426382b5c..f9a38a14cd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -23,6 +23,7 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; +import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; @@ -174,6 +175,7 @@ public static synchronized void handleApplicationCreated (Application applicatio if (applications.getApplication(application.getUniqueIdentifier()) != null) { ApplicationHolder.persistApplication(application); //TODO cloud controller client and register clusters + CloudControllerClient.getInstance().createApplicationClusters(); // startApplicationMonitor(application.getUniqueIdentifier()); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index b13465f8f6..4ca2b9a08a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -24,6 +24,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.CartridgeInformationException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; @@ -32,12 +33,13 @@ import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.messaging.event.topology.ApplicationClustersCreatedEvent; import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; /** @@ -202,6 +204,41 @@ public synchronized void terminateAllInstances(String clusterId) throws Terminat } } + public synchronized void createApplicationClusters( String appId, + Set appClusterContexts) { + List contextDTOs = + new ArrayList(); + for(ApplicationClusterContext context : appClusterContexts) { + ApplicationClusterContextDTO dto = new ApplicationClusterContextDTO(); + dto.setClusterId(context.getClusterId()); + dto.setAutoscalePolicyName(context.getAutoscalePolicyName()); + dto.setDeploymentPolicyName(context.getDeploymentPolicyName()); + dto.setCartridgeType(context.getCartridgeType()); + dto.setHostName(context.getHostName()); + dto.setTenantRange(context.getTenantRange()); + dto.setTextPayload(context.getTextPayload()); + dto.setLbCluster(context.isLbCluster()); + contextDTOs.add(dto); + } + + ApplicationClusterContextDTO[] applicationClusterContextDTOs = + new ApplicationClusterContextDTO[contextDTOs.size()]; + contextDTOs.toArray(applicationClusterContextDTOs); + try { + stub.createApplicationClusters(appId, applicationClusterContextDTOs); + } catch (RemoteException e) { + String msg = e.getMessage(); + log.error(msg, e); + //throw new TerminationException(msg, e); + } catch (CloudControllerServiceApplicationClusterRegistrationExceptionException e) { + //e.printStackTrace(); + String msg = e.getMessage(); + log.error(msg, e); + } + + + } + public synchronized void terminate(String memberId) throws TerminationException { try { if(log.isInfoEnabled()) { From 5b594889878f139dceb2df7755cc9614599e62db Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 13:19:46 +0530 Subject: [PATCH 367/436] fixing a compilation failure --- .../autoscaler/applications/topic/ApplicationBuilder.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index f9a38a14cd..b14e13caa4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -167,15 +167,15 @@ public static synchronized void handleCompleteApplication (Applications applicat public static synchronized void handleApplicationCreated (Application application, Set appClusterContexts) { - Applications applications = ApplicationHolder.getApplications(); - ApplicationHolder.acquireWriteLock(); + Applications applications = ApplicationHolder.getApplications(); + try { if (applications.getApplication(application.getUniqueIdentifier()) != null) { + CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), + appClusterContexts); ApplicationHolder.persistApplication(application); - //TODO cloud controller client and register clusters - CloudControllerClient.getInstance().createApplicationClusters(); // startApplicationMonitor(application.getUniqueIdentifier()); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); From fb80e2ca8afc1514842b91eef229ff5724facd6c Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Mon, 3 Nov 2014 13:40:00 +0530 Subject: [PATCH 368/436] fixes conflicts in messaging component --- .../ApplicationsEventMessageListener.java | 18 +++---- .../ClusterStatusEventMessageListener.java | 54 ++++++++++++------- .../stratos/messaging/util/Constants.java | 2 + 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java index e53e0832f5..08fce23ba9 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/applications/ApplicationsEventMessageListener.java @@ -16,7 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.messaging.message.receiver.application.status; +package org.apache.stratos.messaging.message.receiver.applications; + +import javax.jms.JMSException; +import javax.jms.TextMessage; import org.apache.activemq.command.ActiveMQTextMessage; import org.apache.commons.logging.Log; @@ -27,17 +30,12 @@ import org.eclipse.paho.client.mqttv3.MqttCallback; import org.eclipse.paho.client.mqttv3.MqttMessage; -import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; -import javax.jms.TextMessage; - -public class ApplicationStatusEventMessageListener implements MqttCallback { - private static final Log log = LogFactory.getLog(ApplicationStatusEventMessageListener.class); +public class ApplicationsEventMessageListener implements MqttCallback { + private static final Log log = LogFactory.getLog(ApplicationsEventMessageListener.class); - private ApplicationStatusEventMessageQueue messageQueue; + private ApplicationsEventMessageQueue messageQueue; - public ApplicationStatusEventMessageListener(ApplicationStatusEventMessageQueue messageQueue) { + public ApplicationsEventMessageListener(ApplicationsEventMessageQueue messageQueue) { this.messageQueue = messageQueue; } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java index 12c7800208..6c973f411c 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/receiver/cluster/status/ClusterStatusEventMessageListener.java @@ -18,15 +18,19 @@ */ package org.apache.stratos.messaging.message.receiver.cluster.status; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import javax.jms.JMSException; -import javax.jms.Message; -import javax.jms.MessageListener; import javax.jms.TextMessage; -public class ClusterStatusEventMessageListener implements MessageListener { +import org.apache.activemq.command.ActiveMQTextMessage; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.messaging.util.Util; +import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken; +import org.eclipse.paho.client.mqttv3.MqttCallback; +import org.eclipse.paho.client.mqttv3.MqttMessage; + +public class ClusterStatusEventMessageListener implements MqttCallback { private static final Log log = LogFactory.getLog(ClusterStatusEventMessageListener.class); private ClusterStatusEventMessageQueue messageQueue; @@ -34,21 +38,35 @@ public class ClusterStatusEventMessageListener implements MessageListener { public ClusterStatusEventMessageListener(ClusterStatusEventMessageQueue messageQueue) { this.messageQueue = messageQueue; } + + @Override + public void connectionLost(Throwable throwable) { + log.warn("Connection is lost", throwable); + } @Override - public void onMessage(Message message) { - if (message instanceof TextMessage) { - TextMessage receivedMessage = (TextMessage) message; - try { - if (log.isDebugEnabled()) { - log.debug(String.format("Tenant message received: %s", ((TextMessage) message).getText())); - } - // Add received message to the queue - messageQueue.add(receivedMessage); - - } catch (JMSException e) { - log.error(e.getMessage(), e); + public void deliveryComplete(IMqttDeliveryToken deliveryToken) { + if (log.isDebugEnabled()) { + log.debug(String.format("Message delivery is complete: %s", + ((deliveryToken != null) ? deliveryToken.toString() : ""))); + } + } + + @Override + public void messageArrived(String topicName, MqttMessage message) throws Exception { + TextMessage textMessage = new ActiveMQTextMessage(); + textMessage.setText(new String(message.getPayload())); + textMessage.setStringProperty(Constants.EVENT_CLASS_NAME, Util.getEventNameForTopic(topicName)); + + try { + if (log.isDebugEnabled()) { + log.debug(String.format("Tenant message received: %s", textMessage.getText())); } + // Add received message to the queue + messageQueue.add(textMessage); + + } catch (JMSException e) { + log.error(e.getMessage(), e); } } } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index f677d113f3..7fdd6a49ab 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -25,6 +25,8 @@ public class Constants { public static final String INSTANCE_STATUS_TOPIC = "instance/status/#"; public static final String INSTANCE_NOTIFIER_TOPIC = "instance/notifier/#"; public static final String APPLICATION_STATUS_TOPIC = "application-status"; + public static final String APPLICATIONS_TOPIC = "applications"; + public static final String CLUSTER_STATUS_TOPIC = "applications"; public static final String PING_TOPIC = "ping"; public static final String TENANT_TOPIC = "tenant/#"; public static final String TENANT_RANGE_ALL = "*"; From 63f29405a163e3c7ed9096410232c6694bad3f6d Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 14:34:28 +0530 Subject: [PATCH 369/436] updating the in-correct topic name --- .../main/java/org/apache/stratos/messaging/util/Constants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java index 2d2d532858..ea1658f027 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/util/Constants.java @@ -25,7 +25,7 @@ public class Constants { public static final String INSTANCE_STATUS_TOPIC = "instance-status"; public static final String INSTANCE_NOTIFIER_TOPIC = "instance-notifier"; public static final String APPLICATIONS_TOPIC = "applications"; - public static final String CLUSTER_STATUS_TOPIC = "applications"; + public static final String CLUSTER_STATUS_TOPIC = "cluster-status"; public static final String PING_TOPIC = "ping"; public static final String TENANT_TOPIC = "tenant"; From a1f34c8ea8549e88c2ff62335d7bd3fadcb14d21 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 14:35:34 +0530 Subject: [PATCH 370/436] udpating the cluster status --- .../cloud/controller/impl/CloudControllerServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index e9a48527da..e212873a30 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -40,6 +40,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.MemberStatus; import org.apache.stratos.messaging.util.Constants; import org.jclouds.compute.ComputeService; @@ -1411,6 +1412,7 @@ public void createApplicationClusters(String appId, ApplicationClusterContextDTO appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); newCluster.setLbCluster(false); newCluster.setTenantRange("*"); + newCluster.setStatus(ClusterStatus.Created); newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); clusters.add(newCluster); } From d3aeca785c4ca07a43587e0078d8ce39224f4158 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 14:36:26 +0530 Subject: [PATCH 371/436] correcting an incorrect package name --- .../stratos/autoscaler/applications/ClusterInformation.java | 2 +- .../stratos/autoscaler/applications/MTClusterInformation.java | 2 -- .../stratos/autoscaler/applications/STClusterInformation.java | 2 -- .../applications/parser/DefaultApplicationParser.java | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java index 5fd6d571bc..e87b13ba53 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.cloud.controller.application; +package org.apache.stratos.autoscaler.applications; public interface ClusterInformation { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java index a0a59d420b..ece8992b72 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java @@ -19,8 +19,6 @@ package org.apache.stratos.autoscaler.applications; -import org.apache.stratos.cloud.controller.application.ClusterInformation; - public class MTClusterInformation implements ClusterInformation { @Override diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java index 9a5bea88ef..a8ea21e3f3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java @@ -19,8 +19,6 @@ package org.apache.stratos.autoscaler.applications; -import org.apache.stratos.cloud.controller.application.ClusterInformation; - public class STClusterInformation implements ClusterInformation { @Override diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index fa31385e85..0d3d6d9159 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.applications.ApplicationUtils; +import org.apache.stratos.autoscaler.applications.ClusterInformation; import org.apache.stratos.autoscaler.applications.MTClusterInformation; import org.apache.stratos.autoscaler.applications.STClusterInformation; import org.apache.stratos.autoscaler.applications.pojo.*; @@ -31,7 +32,6 @@ import org.apache.stratos.autoscaler.exception.CartridgeInformationException; import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.registry.RegistryManager; -import org.apache.stratos.cloud.controller.application.ClusterInformation; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; From e819fad7b6b28ad23c2c51ba3b2824045825a8ac Mon Sep 17 00:00:00 2001 From: lasinducharith Date: Mon, 3 Nov 2014 14:42:18 +0530 Subject: [PATCH 372/436] Fixing compilation errors in CC --- .../impl/CloudControllerServiceImpl.java | 29 ----- .../internal/CloudControllerDSComponent.java | 8 +- .../controller/topology/TopologyBuilder.java | 109 ------------------ .../topology/TopologyEventPublisher.java | 9 -- 4 files changed, 4 insertions(+), 151 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 10b07300b9..04e365aa4c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -25,7 +25,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor; import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor; @@ -34,12 +33,10 @@ import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToKubernetesService; import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToReplicationController; import org.apache.stratos.cloud.controller.functions.PodToMemberContext; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.interfaces.Iaas; import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -65,7 +62,6 @@ import org.jclouds.compute.domain.Template; import org.jclouds.rest.ResourceNotFoundException; import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.apache.stratos.messaging.domain.topology.Application; import java.util.*; import java.util.Map.Entry; @@ -1430,25 +1426,6 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } - public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - Application application = applicationParser.parse(applicationContext); - - // Create a Cluster Context obj. for each of the Clusters in the Application - for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { - dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), - applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), - applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster(), - CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties()))); - } - - TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), - applicationParser.getPayloadData()); - - persist(); - } - @Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException { @@ -1864,12 +1841,6 @@ public MemberContext[] updateContainers(String clusterId, int replicas) } } - @Override - public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - - TopologyBuilder.handleApplicationUndeployed(applicationId); - } - @Override public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 19efc446ae..a70a6509b2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -82,13 +82,13 @@ protected void activate(ComponentContext context) { log.info("Instance status message receiver thread started"); } - ApplicationStatusTopicReceiver applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver(); - Thread appThread = new Thread(applicationStatusTopicReceiver); clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); - Thread appThread = new Thread(clusterStatusTopicReceiver); - appThread.start(); + Thread tClusterStatusTopicReceiver = new Thread(clusterStatusTopicReceiver); + tClusterStatusTopicReceiver.start(); + if(log.isInfoEnabled()) { log.info("Application status message receiver thread started"); + } if (log.isDebugEnabled()) { log.debug("Cluster status Receiver thread started"); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index eebc0771ee..08d3d2874e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -608,116 +608,7 @@ public static void handleMemberSuspended() { } public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) { - Topology topology = TopologyManager.getTopology(); - try { - TopologyManager.acquireWriteLock(); - - if (topology.applicationExists(application.getUniqueIdentifier())) { - log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology"); - return; - } - List clusters = new ArrayList(); - for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { - Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), - applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); - //cluster.setStatus(Status.Created); - cluster.addHostName(applicationClusterContext.getHostName()); - cluster.setTenantRange(applicationClusterContext.getTenantRange()); - cluster.setLbCluster(applicationClusterContext.isLbCluster()); - cluster.setKubernetesCluster(applicationClusterContext.isKubernetesCluster()); - cluster.setProperties(CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties())); - clusters.add(cluster); - - Service service = topology.getService(applicationClusterContext.getCartridgeType()); - if (service != null) { - service.addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier()); - } else { - log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); - return; - } - } - - // add to Topology and update - topology.addApplication(application); - TopologyManager.updateTopology(topology); - - log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully"); - org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters); - TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); - - } finally { - TopologyManager.releaseWriteLock(); - } - } - - public static synchronized void handleApplicationUndeployed(String applicationId) { - - Set clusterData; - - // update the Application and Cluster Statuses as 'Terminating' - TopologyManager.acquireWriteLock(); - - try { - - Topology topology = TopologyManager.getTopology(); - - if (!topology.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - return; - } - - Application application = topology.getApplication(applicationId); - // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); - - // update all the Clusters' statuses to 'Terminating' - clusterData = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Topology"); - } - - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); - } - } - - // update all Group's statuses to 'Terminating' - if (application.getGroups() != null) { - updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); - } - - TopologyManager.updateTopology(topology); - - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); - } - - public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterActivatedEvent.getServiceName()); //update the status of the cluster diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index aff2b6d690..c813eefcac 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -1,4 +1,3 @@ -package org.apache.stratos.cloud.controller.topology; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -85,14 +84,6 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } } - public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId); - - if (log.isInfoEnabled()) { - log.info("Publishing cluster created event: " + clusterId); - } - publishEvent(clusterCreatedEvent); - } public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) { ClusterResetEvent clusterResetEvent = new ClusterResetEvent(appId,serviceName, clusterId); From fad19f3d57dd5ab177090436e77c42118fc9fb09 Mon Sep 17 00:00:00 2001 From: lasinducharith Date: Mon, 3 Nov 2014 14:42:18 +0530 Subject: [PATCH 373/436] Fixing compilation errors in CC --- .../impl/CloudControllerServiceImpl.java | 29 ----- .../internal/CloudControllerDSComponent.java | 9 +- .../controller/topology/TopologyBuilder.java | 109 ------------------ .../topology/TopologyEventPublisher.java | 9 -- 4 files changed, 3 insertions(+), 153 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 10b07300b9..04e365aa4c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -25,7 +25,6 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.parser.DefaultApplicationParser; import org.apache.stratos.cloud.controller.concurrent.PartitionValidatorCallable; import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor; import org.apache.stratos.cloud.controller.concurrent.ThreadExecutor; @@ -34,12 +33,10 @@ import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToKubernetesService; import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToReplicationController; import org.apache.stratos.cloud.controller.functions.PodToMemberContext; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.interfaces.Iaas; import org.apache.stratos.cloud.controller.persist.Deserializer; import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.application.ApplicationContext; import org.apache.stratos.cloud.controller.publisher.CartridgeInstanceDataPublisher; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; @@ -65,7 +62,6 @@ import org.jclouds.compute.domain.Template; import org.jclouds.rest.ResourceNotFoundException; import org.wso2.carbon.registry.core.exceptions.RegistryException; -import org.apache.stratos.messaging.domain.topology.Application; import java.util.*; import java.util.Map.Entry; @@ -1430,25 +1426,6 @@ public ClusterContext getClusterContext (String clusterId) { return dataHolder.getClusterContext(clusterId); } - public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { - - ApplicationParser applicationParser = new DefaultApplicationParser(); - Application application = applicationParser.parse(applicationContext); - - // Create a Cluster Context obj. for each of the Clusters in the Application - for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { - dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), - applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), - applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster(), - CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties()))); - } - - TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), - applicationParser.getPayloadData()); - - persist(); - } - @Override public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) throws UnregisteredCartridgeException { @@ -1864,12 +1841,6 @@ public MemberContext[] updateContainers(String clusterId, int replicas) } } - @Override - public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { - - TopologyBuilder.handleApplicationUndeployed(applicationId); - } - @Override public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index 19efc446ae..b286390c1b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -82,13 +82,10 @@ protected void activate(ComponentContext context) { log.info("Instance status message receiver thread started"); } - ApplicationStatusTopicReceiver applicationStatusTopicReceiver = new ApplicationStatusTopicReceiver(); - Thread appThread = new Thread(applicationStatusTopicReceiver); clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); - Thread appThread = new Thread(clusterStatusTopicReceiver); - appThread.start(); - if(log.isInfoEnabled()) { - log.info("Application status message receiver thread started"); + Thread tClusterStatusTopicReceiver = new Thread(clusterStatusTopicReceiver); + tClusterStatusTopicReceiver.start(); + if (log.isDebugEnabled()) { log.debug("Cluster status Receiver thread started"); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index eebc0771ee..08d3d2874e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -608,116 +608,7 @@ public static void handleMemberSuspended() { } public static void handleClusterActivatedEvent(ClusterStatusClusterActivatedEvent clusterActivatedEvent) { - Topology topology = TopologyManager.getTopology(); - try { - TopologyManager.acquireWriteLock(); - - if (topology.applicationExists(application.getUniqueIdentifier())) { - log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Topology"); - return; - } - List clusters = new ArrayList(); - for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { - Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), - applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); - //cluster.setStatus(Status.Created); - cluster.addHostName(applicationClusterContext.getHostName()); - cluster.setTenantRange(applicationClusterContext.getTenantRange()); - cluster.setLbCluster(applicationClusterContext.isLbCluster()); - cluster.setKubernetesCluster(applicationClusterContext.isKubernetesCluster()); - cluster.setProperties(CloudControllerUtil.toJavaUtilProperties(applicationClusterContext.getProperties())); - clusters.add(cluster); - - Service service = topology.getService(applicationClusterContext.getCartridgeType()); - if (service != null) { - service.addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Topology for Application with id: " + application.getUniqueIdentifier()); - } else { - log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); - return; - } - } - - // add to Topology and update - topology.addApplication(application); - TopologyManager.updateTopology(topology); - - log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Topology successfully"); - org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent(application, clusters); - TopologyEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); - - } finally { - TopologyManager.releaseWriteLock(); - } - } - - public static synchronized void handleApplicationUndeployed(String applicationId) { - - Set clusterData; - - // update the Application and Cluster Statuses as 'Terminating' - TopologyManager.acquireWriteLock(); - - try { - - Topology topology = TopologyManager.getTopology(); - - if (!topology.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Topology"); - return; - } - - Application application = topology.getApplication(applicationId); - // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); - - // update all the Clusters' statuses to 'Terminating' - clusterData = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = topology.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Topology"); - } - - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Topology, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); - } - } - - // update all Group's statuses to 'Terminating' - if (application.getGroups() != null) { - updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); - } - - TopologyManager.updateTopology(topology); - - } finally { - TopologyManager.releaseWriteLock(); - } - - TopologyEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); - } - - public static void handleClusterActivatedEvent(AppStatusClusterActivatedEvent clusterActivatedEvent) { Topology topology = TopologyManager.getTopology(); Service service = topology.getService(clusterActivatedEvent.getServiceName()); //update the status of the cluster diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index aff2b6d690..c813eefcac 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -1,4 +1,3 @@ -package org.apache.stratos.cloud.controller.topology; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -85,14 +84,6 @@ public static void sendServiceRemovedEvent(List cartridgeList) { } } - public static void sendClusterCreatedEvent(String appId, String serviceName, String clusterId) { - ClusterCreatedEvent clusterCreatedEvent = new ClusterCreatedEvent(appId, serviceName, clusterId); - - if (log.isInfoEnabled()) { - log.info("Publishing cluster created event: " + clusterId); - } - publishEvent(clusterCreatedEvent); - } public static void sendClusterResetEvent(String appId, String serviceName, String clusterId) { ClusterResetEvent clusterResetEvent = new ClusterResetEvent(appId,serviceName, clusterId); From 5a6043553cb4c276d618b3983e93a78a3712fc49 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 15:09:40 +0530 Subject: [PATCH 374/436] correcting a logic issue --- .../autoscaler/applications/topic/ApplicationBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index b14e13caa4..53a8ca463d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -172,7 +172,7 @@ public static synchronized void handleApplicationCreated (Application applicatio Applications applications = ApplicationHolder.getApplications(); try { - if (applications.getApplication(application.getUniqueIdentifier()) != null) { + if (applications.getApplication(application.getUniqueIdentifier()) == null) { CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); From 8b66cbaca6ad51b6ac8f669d82ac188062c7c723 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Mon, 3 Nov 2014 15:21:21 +0530 Subject: [PATCH 375/436] fixing AS issues due to merging --- .../stratos/autoscaler/AutoscalerContext.java | 5 +- .../applications/ClusterInformation.java | 2 +- .../applications/MTClusterInformation.java | 2 +- .../applications/STClusterInformation.java | 2 +- .../parser/DefaultApplicationParser.java | 69 +- .../applications/pojo/ApplicationContext.java | 12 - .../topic/ApplicationBuilder.java | 2 +- .../AutoScalerServiceInterface.java | 1 - .../AutoscalerTopologyEventReceiver.java | 770 ++++-------------- .../monitor/AbstractClusterMonitor.java | 277 ------- .../monitor/ParentComponentMonitor.java | 2 + .../ApplicationMonitorFactory.java | 32 +- .../cluster/AbstractClusterMonitor.java | 62 +- .../KubernetesServiceClusterMonitor.java | 3 +- .../monitor/cluster/VMClusterMonitor.java | 7 + .../monitor/cluster/VMLbClusterMonitor.java | 9 +- .../cluster/VMServiceClusterMonitor.java | 148 ++-- .../status/checker/StatusChecker.java | 18 +- 18 files changed, 331 insertions(+), 1092 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index e8553bc4ea..88ff3cf0fc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -23,17 +23,14 @@ import java.util.HashMap; import java.util.Map; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; /** * It holds all cluster monitors which are active in stratos. */ public class AutoscalerContext { - private static final Log log = LogFactory.getLog(AutoscalerContext.class); private static final AutoscalerContext INSTANCE = new AutoscalerContext(); // Map diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java index 5fd6d571bc..e87b13ba53 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ClusterInformation.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.cloud.controller.application; +package org.apache.stratos.autoscaler.applications; public interface ClusterInformation { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java index a0a59d420b..36185f9ecc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/MTClusterInformation.java @@ -19,7 +19,7 @@ package org.apache.stratos.autoscaler.applications; -import org.apache.stratos.cloud.controller.application.ClusterInformation; +import org.apache.stratos.autoscaler.applications.ClusterInformation; public class MTClusterInformation implements ClusterInformation { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java index 9a5bea88ef..f2882338c0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/STClusterInformation.java @@ -19,7 +19,7 @@ package org.apache.stratos.autoscaler.applications; -import org.apache.stratos.cloud.controller.application.ClusterInformation; +import org.apache.stratos.autoscaler.applications.ClusterInformation; public class STClusterInformation implements ClusterInformation { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index 16a14de08f..ce68f8abc9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -17,41 +17,40 @@ * under the License. */ -package org.apache.stratos.cloud.controller.application.parser; +package org.apache.stratos.autoscaler.applications.parser; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.applications.ApplicationUtils; +import org.apache.stratos.autoscaler.applications.ClusterInformation; import org.apache.stratos.autoscaler.applications.MTClusterInformation; import org.apache.stratos.autoscaler.applications.STClusterInformation; -import org.apache.stratos.autoscaler.applications.pojo.*; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; +import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; +import org.apache.stratos.autoscaler.applications.pojo.GroupContext; +import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext; +import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.autoscaler.exception.CartridgeInformationException; import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.registry.RegistryManager; -import org.apache.stratos.cloud.controller.application.ClusterInformation; -import org.apache.stratos.cloud.controller.application.MTClusterInformation; -import org.apache.stratos.cloud.controller.application.STClusterInformation; -import org.apache.stratos.cloud.controller.exception.ApplicationDefinitionException; -import org.apache.stratos.cloud.controller.interfaces.ApplicationParser; -import org.apache.stratos.cloud.controller.pojo.*; -import org.apache.stratos.cloud.controller.pojo.Cartridge; -import org.apache.stratos.cloud.controller.pojo.Properties; -import org.apache.stratos.cloud.controller.pojo.application.*; -import org.apache.stratos.cloud.controller.pojo.payload.MetaDataHolder; -import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; -import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.messaging.domain.topology.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.applications.DependencyOrder; import org.apache.stratos.messaging.domain.applications.Group; -import java.util.*; - /** * Default implementation of the Application Parser. One Application should be processed by one * instance of the DefaultApplicationParser. @@ -123,11 +122,6 @@ public Set getApplicationClusterContexts() throws App return applicationClusterContexts; } - @Override - public Set getPayloadData() throws ApplicationDefinitionException { - return metaDataHolders; - } - /** * Extract Group information from Application Definition * @@ -273,7 +267,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, if (appCtxt.getComponents().getSubscribableContexts() != null) { clusterDataMap = parseLeafLevelSubscriptions(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), null, Arrays.asList(appCtxt.getComponents().getSubscribableContexts()), - subscribableInfoCtxts, appCtxt.getProperties()); + subscribableInfoCtxts); application.setClusterData(clusterDataMap); //clusters.addAll(clusterDataHolder.getApplicationClusterContexts()); } @@ -282,7 +276,7 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, if (appCtxt.getComponents().getGroupContexts() != null) { application.setGroups(parseGroups(appCtxt.getApplicationId(), appCtxt.getTenantId(), application.getKey(), Arrays.asList(appCtxt.getComponents().getGroupContexts()), - subscribableInfoCtxts, definedGroupCtxts, appCtxt.getProperties())); + subscribableInfoCtxts, definedGroupCtxts)); } // get top level Dependency definitions @@ -347,13 +341,13 @@ private static void validateTerminationBehavior (String terminationBehavior) thr */ private Map parseGroups (String appId, int tenantId, String key, List groupCtxts, Map subscribableInformation, - Map definedGroupCtxts, Properties properties) + Map definedGroupCtxts) throws ApplicationDefinitionException { Map groupAliasToGroup = new HashMap(); for (GroupContext groupCtxt : groupCtxts) { - Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts, properties); + Group group = parseGroup(appId, tenantId, key, groupCtxt, subscribableInformation, definedGroupCtxts); groupAliasToGroup.put(group.getAlias(), group); } @@ -424,7 +418,7 @@ private void filterNestedGroupFromTopLevel (Collection topLevelGroups, Gr */ private Group parseGroup (String appId, int tenantId, String key, GroupContext groupCtxt, Map subscribableInfoCtxts, - Map definedGroupCtxts, Properties properties) + Map definedGroupCtxts) throws ApplicationDefinitionException { // check if are in the defined Group set @@ -452,7 +446,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g // get group level Subscribables if (groupCtxt.getSubscribableContexts() != null) { clusterDataMap = parseLeafLevelSubscriptions(appId, tenantId, key, groupCtxt.getName(), - Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts, properties); + Arrays.asList(groupCtxt.getSubscribableContexts()), subscribableInfoCtxts); group.setClusterData(clusterDataMap); } @@ -465,7 +459,7 @@ private Group parseGroup (String appId, int tenantId, String key, GroupContext g subGroupCtxt = definedGroupCtxts.get(subGroupCtxt.getAlias()); Group nestedGroup = parseGroup(appId, tenantId, key, subGroupCtxt, subscribableInfoCtxts, - definedGroupCtxts, properties); + definedGroupCtxts); nestedGroups.put(nestedGroup.getAlias(), nestedGroup); } @@ -569,8 +563,7 @@ private String getKillbehaviour (String serviceGroupName) throws ApplicationDefi */ private Map parseLeafLevelSubscriptions (String appId, int tenantId, String key, String groupName, List subscribableCtxts, - Map subscribableInfoCtxts, - Properties properties) + Map subscribableInfoCtxts) throws ApplicationDefinitionException { Map clusterDataMap = new HashMap(); @@ -608,14 +601,12 @@ private Map parseLeafLevelSubscriptions (String appId String hostname = clusterInfo.getHostName(subscribableCtxt.getAlias(), cartridgeInfo.getHostName()); String clusterId = clusterInfo.getClusterId(subscribableCtxt.getAlias(), subscribableCtxt.getType()); - boolean isKubernetesCluster = StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType()); // create and collect this cluster's information assert subscribableInfoCtxt != null; ApplicationClusterContext appClusterCtxt = createApplicationClusterContext(appId, groupName, cartridgeInfo, key, tenantId, subscribableInfoCtxt.getRepoUrl(), subscribableCtxt.getAlias(), - clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), - false, isKubernetesCluster, subscribableInfoCtxt.getDependencyAliases(), properties); + clusterId, hostname, subscribableInfoCtxt.getDeploymentPolicy(), false, subscribableInfoCtxt.getDependencyAliases()); appClusterCtxt.setAutoscalePolicyName(subscribableInfoCtxt.getAutoscalingPolicy()); this.applicationClusterContexts.add(appClusterCtxt); @@ -640,8 +631,7 @@ private Map parseLeafLevelSubscriptions (String appId * @param clusterId Cluster id * @param hostname Hostname * @param deploymentPolicy Deployment policy used - * @param isLBCluster if this cluster is an LB - * @param isKubernetesCluster if this cluster is a Kubernetes cluster + * @param isLB if this cluster is an LB * @return ApplicationClusterContext object with relevant information * * @throws ApplicationDefinitionException If any error occurs @@ -649,17 +639,14 @@ private Map parseLeafLevelSubscriptions (String appId private ApplicationClusterContext createApplicationClusterContext (String appId, String groupName, CartridgeInfo cartridgeInfo, String subscriptionKey, int tenantId, String repoUrl, String alias, String clusterId, String hostname, - String deploymentPolicy, boolean isLBCluster, - boolean isKubernetesCluster, String[] dependencyAliases, - Properties properties) + String deploymentPolicy, boolean isLB, String[] dependencyAliases) throws ApplicationDefinitionException { // Create text payload String textPayload = ApplicationUtils.createPayload(appId, groupName, cartridgeInfo, subscriptionKey, tenantId, clusterId, hostname, repoUrl, alias, null, dependencyAliases).toString(); - return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, - isLB, isKubernetesCluster, properties); + return new ApplicationClusterContext(cartridgeInfo.getType(), clusterId, hostname, textPayload, deploymentPolicy, isLB); } private CartridgeInfo getCartridge (String cartridgeType) throws ApplicationDefinitionException { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java index b3560c3ad0..5d97ad5e62 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java @@ -19,8 +19,6 @@ package org.apache.stratos.autoscaler.applications.pojo; -import org.apache.stratos.cloud.controller.pojo.Properties; - import java.io.Serializable; public class ApplicationContext implements Serializable { @@ -41,8 +39,6 @@ public class ApplicationContext implements Serializable { private SubscribableInfoContext[] subscribableInfoContexts; - private Properties properties; - public ApplicationContext() { } @@ -101,12 +97,4 @@ public String getTeantAdminUsername() { public void setTeantAdminUsername(String teantAdminUsername) { this.teantAdminUsername = teantAdminUsername; } - - public Properties getProperties() { - return properties; - } - - public void setProperties(Properties properties) { - this.properties = properties; - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index bf0ad01d9a..a92ce09de2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -25,8 +25,8 @@ import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 16e809dd0e..74c9c8c2db 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -1,4 +1,3 @@ -package org.apache.stratos.autoscaler.interfaces; /* * * Licensed to the Apache Software Foundation (ASF) under one diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index f449560505..0f5276533a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -19,57 +19,42 @@ package org.apache.stratos.autoscaler.message.receiver.topology; +import java.util.List; import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; +import org.apache.stratos.autoscaler.MemberStatsContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.*; +import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; +import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; +import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; -import org.apache.stratos.autoscaler.exception.PartitionValidationException; -import org.apache.stratos.autoscaler.exception.PolicyValidationException; +import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; -import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; -import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.messaging.domain.topology.Application; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.messaging.domain.topology.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; +import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; -import org.apache.stratos.messaging.listener.topology.*; -import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; -import org.apache.stratos.messaging.event.topology.ApplicationActivatedEvent; -import org.apache.stratos.messaging.event.topology.ApplicationCreatedEvent; -import org.apache.stratos.messaging.event.topology.ApplicationTerminatedEvent; -import org.apache.stratos.messaging.event.topology.ApplicationTerminatingEvent; import org.apache.stratos.messaging.event.topology.ApplicationUndeployedEvent; import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; @@ -77,33 +62,23 @@ import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent; -import org.apache.stratos.messaging.event.topology.GroupActivatedEvent; -import org.apache.stratos.messaging.event.topology.GroupInactivateEvent; -import org.apache.stratos.messaging.event.topology.GroupTerminatedEvent; -import org.apache.stratos.messaging.event.topology.GroupTerminatingEvent; import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; -import org.apache.stratos.messaging.listener.topology.ApplicationActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.ApplicationCreatedEventListener; -import org.apache.stratos.messaging.listener.topology.ApplicationTerminatedEventListener; -import org.apache.stratos.messaging.listener.topology.ApplicationTerminatingEventListener; -import org.apache.stratos.messaging.listener.topology.ApplicationUndeployedEventListener; +import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterResetEventListener; import org.apache.stratos.messaging.listener.topology.ClusterTerminatedEventListener; import org.apache.stratos.messaging.listener.topology.ClusterTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; -import org.apache.stratos.messaging.listener.topology.GroupActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupInActivateEventListener; -import org.apache.stratos.messaging.listener.topology.GroupTerminatedEventListener; -import org.apache.stratos.messaging.listener.topology.GroupTerminatingEventListener; import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener; import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener; +import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; @@ -221,43 +196,12 @@ protected void onEvent(Event event) { } }); - - /*topologyEventReceiver.addEventListener(new ApplicationCreatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - log.info("[ApplicationCreatedEvent] Received: " + event.getClass()); - ApplicationCreatedEvent applicationCreatedEvent = (ApplicationCreatedEvent) event; - try { - - //acquire read lock - TopologyManager.acquireReadLockForApplication( - applicationCreatedEvent.getApplication().getUniqueIdentifier()); - //start the application monitor - startApplicationMonitor(applicationCreatedEvent.getApplication().getUniqueIdentifier()); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } finally { - //release read lock - TopologyManager.releaseReadLockForApplication( - applicationCreatedEvent.getApplication().getUniqueIdentifier()); - } - } catch (ClassCastException e) { - String msg = "Error while casting the event " + e.getLocalizedMessage(); - log.error(msg, e); - } - - } - });*/ - topologyEventReceiver.addEventListener(new ClusterActivatedEventListener() { @Override protected void onEvent(Event event) { log.info("[ClusterActivatedEvent] Received: " + event.getClass()); ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; - String appId = clusterActivatedEvent.getAppId(); String clusterId = clusterActivatedEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); @@ -291,23 +235,16 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterCreatedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterCreatedEvent] Received: " + event.getClass()); - - ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; - //TODO notify the monitor about cluster creation - } }); topologyEventReceiver.addEventListener(new ClusterInActivateEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterInActivateEvent] Received: " + event.getClass()); ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; - String appId = clusterInactivateEvent.getAppId(); String clusterId = clusterInactivateEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); @@ -351,11 +288,9 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterTerminatedEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterTerminatedEvent] Received: " + event.getClass()); ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; - String appId = clusterTerminatedEvent.getAppId(); String clusterId = clusterTerminatedEvent.getClusterId(); AbstractClusterMonitor clusterMonitor = AutoscalerContext.getInstance().getClusterMonitor(clusterId); @@ -367,105 +302,6 @@ protected void onEvent(Event event) { } }); - /*topologyEventReceiver.addEventListener(new GroupActivatedEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[GroupActivatedEvent] Received: " + event.getClass()); - - GroupActivatedEvent groupActivatedEvent = (GroupActivatedEvent) event; - String appId = groupActivatedEvent.getAppId(); - String groupId = groupActivatedEvent.getGroupId(); - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); - - //changing the status in the monitor, will notify its parent monitor - if (monitor != null) { - monitor.setStatus(GroupStatus.Active); - } - } - }); - - topologyEventReceiver.addEventListener(new GroupInActivateEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[GroupInActivateEvent] Received: " + event.getClass()); - - GroupInactivateEvent groupInactivateEvent = (GroupInactivateEvent) event; - String appId = groupInactivateEvent.getAppId(); - String groupId = groupInactivateEvent.getGroupId(); - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); - - //changing the status in the monitor, will notify its parent monitor - if (monitor != null) { - monitor.setStatus(GroupStatus.Inactive); - } - - } - }); - - topologyEventReceiver.addEventListener(new GroupTerminatingEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[GroupTerminatingEvent] Received: " + event.getClass()); - - GroupTerminatingEvent groupTerminatingEvent = (GroupTerminatingEvent) event; - String appId = groupTerminatingEvent.getAppId(); - String groupId = groupTerminatingEvent.getGroupId(); - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); - - //changing the status in the monitor, will notify its parent monitor - if (monitor != null) { - monitor.setStatus(GroupStatus.Terminating); - } - - } - }); - - topologyEventReceiver.addEventListener(new GroupTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[GroupTerminatedEvent] Received: " + event.getClass()); - - GroupTerminatedEvent groupTerminatedEvent = (GroupTerminatedEvent) event; - String appId = groupTerminatedEvent.getAppId(); - String groupId = groupTerminatedEvent.getGroupId(); - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - GroupMonitor monitor = (GroupMonitor) appMonitor.findGroupMonitorWithId(groupId); - - //changing the status in the monitor, will notify its parent monitor - if (monitor != null) { - monitor.setStatus(GroupStatus.Terminated); - } - - } - }); - - topologyEventReceiver.addEventListener(new ApplicationActivatedEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[ApplicationActivatedEvent] Received: " + event.getClass()); - - ApplicationActivatedEvent applicationActivatedEvent = (ApplicationActivatedEvent) event; - String appId = applicationActivatedEvent.getAppId(); - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); - if(appMonitor != null) { - appMonitor.setStatus(ApplicationStatus.Active); - } - } - });*/ - topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { @Override protected void onEvent(Event event) { @@ -482,8 +318,8 @@ protected void onEvent(Event event) { Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); if (clusterDataHolders != null) { for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { - ClusterMonitor clusterMonitor = - ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterDataHolder.getClusterId())); + VMClusterMonitor clusterMonitor = + ((VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterDataHolder.getClusterId())); if (clusterMonitor == null) { // Cluster Monitor not found; send Cluster Terminated event to cleanup ClusterStatusEventPublisher.sendClusterTerminatedEvent( @@ -594,269 +430,95 @@ protected void onEvent(Event event) { } }); - - /*topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[ApplicationTerminatingEvent] Received: " + event.getClass()); - - ApplicationTerminatingEvent appTerminatingEvent = (ApplicationTerminatingEvent) event; - - // acquire reead locks for application and relevant clusters - TopologyManager.acquireReadLockForApplication(appTerminatingEvent.getAppId()); - - try { - ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). - getAppMonitor(appTerminatingEvent.getAppId()); - - if (appMonitor != null) { - // update the status as Terminating - appMonitor.setStatus(ApplicationStatus.Terminating); - - } else { - log.warn("Application Monitor cannot be found for the undeployed [application] " - + appTerminatingEvent.getAppId()); - } - - } finally { - TopologyManager. - releaseReadLockForApplication(appTerminatingEvent.getAppId()); - } - } - });*/ - -// topologyEventReceiver.addEventListener(new ApplicationRemovedEventListener() { + topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { + @Override + protected void onEvent(Event event) { + try { + MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent) event; + String clusterId = memberReadyToShutdownEvent.getClusterId(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } + }); +//TODO delete this if we don't want this +// topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { // @Override -// protected void onChildEvent(Event event) { +// protected void onEvent(Event event) { +// +// ClusterRemovedEvent clusterRemovedEvent = null; +// try { +// clusterRemovedEvent = (ClusterRemovedEvent) event; +// //TopologyManager.acquireReadLock(); +// TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), +// clusterRemovedEvent.getClusterId()); // -// log.info("[ApplicationRemovedEvent] Received: " + event.getClass()); +// String clusterId = clusterRemovedEvent.getClusterId(); +// String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); // -// ApplicationRemovedEvent applicationRemovedEvent = (ApplicationRemovedEvent) event; +// AbstractClusterMonitor monitor; // -// //acquire read lock -// TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getApplicationId()); -// Set clusterDataHolders = applicationRemovedEvent.getClusterData(); -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } +// if (clusterRemovedEvent.isLbCluster()) { +// DeploymentPolicy depPolicy = PolicyManager.getInstance(). +// getDeploymentPolicy(deploymentPolicy); +// if (depPolicy != null) { +// List lbHolders = PartitionManager.getInstance() +// .getNetworkPartitionLbHolders(depPolicy); // -// try { -// //TODO remove monitors as well as any starting or pending threads -// ApplicationMonitor monitor = AutoscalerContext.getInstance(). -// getAppMonitor(applicationRemovedEvent.getApplicationId()); -// if (monitor != null) { -// //List clusters = monitor. -// // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// //stopping the cluster monitor and remove it from the AS -// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())). -// setDestroyed(true); -// AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); +// for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) { +// // removes lb cluster ids +// boolean isRemoved = networkPartitionLbHolder.removeLbClusterId(clusterId); +// if (isRemoved) { +// log.info("Removed the lb cluster [id]:" +// + clusterId +// + " reference from Network Partition [id]: " +// + networkPartitionLbHolder +// .getNetworkPartitionId()); +// +// } +// if (log.isDebugEnabled()) { +// log.debug(networkPartitionLbHolder); +// } +// +// } // } -// //removing the application monitor -// AutoscalerContext.getInstance(). -// removeAppMonitor(applicationRemovedEvent.getApplicationId()); +// monitor = AutoscalerContext.getInstance() +// .removeLbMonitor(clusterId); +// // } else { -// log.warn("Application Monitor cannot be found for the removed [application] " -// + applicationRemovedEvent.getApplicationId()); +// monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() +// .removeMonitor(clusterId); // } // -// -// } finally { -// //release read lock -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } +// // runTerminateAllRule(monitor); +// if (monitor != null) { +// monitor.destroy(); +// log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", +// clusterId)); // } -// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getApplicationId()); +// } catch (Exception e) { +// log.error("Error processing event", e); +// } finally { +// //TopologyManager.releaseReadLock(); +// TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), +// clusterRemovedEvent.getClusterId()); // } -// // } +// // }); - /*topologyEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[ApplicationTerminatedEvent] Received: " + event.getClass()); - - ApplicationTerminatedEvent applicationRemovedEvent = (ApplicationTerminatedEvent) event; - - // no need to access the locks since the Topology is not accessed - //acquire read lock - //TopologyManager.acquireReadLockForApplication(applicationRemovedEvent.getAppId()); - Set clusterDataHolders = applicationRemovedEvent.getClusterData(); -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } - - try { - //TODO remove monitors as well as any starting or pending threads - ApplicationMonitor monitor = AutoscalerContext.getInstance(). - getAppMonitor(applicationRemovedEvent.getAppId()); - if (monitor != null) { - //List clusters = monitor. - // findClustersOfApplication(applicationRemovedEvent.getApplicationId()); - for (ClusterDataHolder clusterData : clusterDataHolders) { - //stopping the cluster monitor and remove it from the AS - ClusterMonitor clusterMonitor = ((ClusterMonitor) - AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); - if (clusterMonitor != null) { - clusterMonitor.setDestroyed(true); - AutoscalerContext.getInstance().removeMonitor(clusterData.getClusterId()); - } else { - log.warn("Cluster Monitor not found for [ cluster id ] " + - clusterData.getClusterId() + ", unable to remove"); - } - } - //removing the application monitor - AutoscalerContext.getInstance(). - removeAppMonitor(applicationRemovedEvent.getAppId()); - } else { - log.warn("Application Monitor cannot be found for the terminated [application] " - + applicationRemovedEvent.getAppId() + ", unable to remove"); - } - - - } finally { - //release read lock -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } -// TopologyManager.releaseReadLockForApplication(applicationRemovedEvent.getAppId()); - } - - } - }); -*/ - topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = - (MemberReadyToShutdownEvent) event; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - String memberId = memberReadyToShutdownEvent.getMemberId(); - - if (asCtx.monitorExist(clusterId)) { - monitor = (AbstractClusterMonitor) asCtx.getMonitor(clusterId); - } else if (asCtx.lbMonitorExist(clusterId)) { - monitor = asCtx.getLBMonitor(clusterId); - } else { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found " + - "in autoscaler context [cluster] %s", clusterId)); - } - return; - } - - NetworkPartitionContext nwPartitionCtxt; - nwPartitionCtxt = monitor.getNetworkPartitionCtxt( - memberReadyToShutdownEvent.getNetworkPartitionId()); - - // start a new member in the same Partition - String partitionId = monitor.getPartitionOfMember(memberId); - PartitionContext partitionCtxt = nwPartitionCtxt.getPartitionCtxt(partitionId); - - - // terminate the shutdown ready member - CloudControllerClient ccClient = CloudControllerClient.getInstance(); - ccClient.terminate(memberId); - - // remove from active member list - partitionCtxt.removeActiveMemberById(memberId); - - if (log.isInfoEnabled()) { - log.info(String.format("Member is terminated and removed from the active " + - "members list: [member] %s [partition] %s [cluster] %s ", - memberId, partitionId, clusterId)); - } - } catch (TerminationException e) { - log.error(e); - } - } - - }); - - topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { - @Override - protected void onEvent(Event event) { - - ClusterRemovedEvent clusterRemovedEvent = null; - try { - clusterRemovedEvent = (ClusterRemovedEvent) event; - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), - clusterRemovedEvent.getClusterId()); - - String clusterId = clusterRemovedEvent.getClusterId(); - String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); - - AbstractClusterMonitor monitor; - - if (clusterRemovedEvent.isLbCluster()) { - DeploymentPolicy depPolicy = PolicyManager.getInstance(). - getDeploymentPolicy(deploymentPolicy); - if (depPolicy != null) { - List lbHolders = PartitionManager.getInstance() - .getNetworkPartitionLbHolders(depPolicy); - - for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) { - // removes lb cluster ids - boolean isRemoved = networkPartitionLbHolder.removeLbClusterId(clusterId); - if (isRemoved) { - log.info("Removed the lb cluster [id]:" - + clusterId - + " reference from Network Partition [id]: " - + networkPartitionLbHolder - .getNetworkPartitionId()); - - } - if (log.isDebugEnabled()) { - log.debug(networkPartitionLbHolder); - } - - } - } - monitor = AutoscalerContext.getInstance() - .removeLbMonitor(clusterId); - - } else { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() - .removeMonitor(clusterId); - } - - // runTerminateAllRule(monitor); - if (monitor != null) { - monitor.destroy(); - log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", - clusterId)); - } - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), - clusterRemovedEvent.getClusterId()); - } - } - - }); - topologyEventReceiver.addEventListener(new MemberStartedEventListener() { @Override protected void onEvent(Event event) { @@ -866,176 +528,75 @@ protected void onEvent(Event event) { }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - - MemberTerminatedEvent memberTerminatedEvent = null; - try { - //TopologyManager.acquireReadLock(); - - memberTerminatedEvent = (MemberTerminatedEvent) event; - String networkPartitionId = memberTerminatedEvent.getNetworkPartitionId(); - String clusterId = memberTerminatedEvent.getClusterId(); - String partitionId = memberTerminatedEvent.getPartitionId(); - AbstractClusterMonitor monitor; - - TopologyManager.acquireReadLockForCluster(memberTerminatedEvent.getServiceName(), - memberTerminatedEvent.getClusterId()); - - if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - } else { - //This is LB member - monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); - } - - NetworkPartitionContext networkPartitionContext = monitor. - getNetworkPartitionCtxt(networkPartitionId); - - PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); - String memberId = memberTerminatedEvent.getMemberId(); - partitionContext.removeMemberStatsContext(memberId); - - - if (partitionContext.removeTerminationPendingMember(memberId)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from termination pending " + - "members list: [member] %s", memberId)); - } - } else if (partitionContext.removePendingMember(memberId)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Member is removed from pending members list: " + - "[member] %s", memberId)); - } - } else if (partitionContext.removeActiveMemberById(memberId)) { - log.warn(String.format("Member is in the wrong list and it is removed " + - "from active members list", memberId)); - } else { - log.warn(String.format("Member is not available in any of the list " + - "active, pending and termination pending", memberId)); - } - - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been removed " + - " successfully: [member] %s", memberId)); - } - //Checking whether the cluster state can be changed either from in_active to created/terminating to terminated - StatusChecker.getInstance().onMemberTermination(clusterId); - -// partitionContext.decrementCurrentActiveMemberCount(1); - - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(memberTerminatedEvent.getServiceName(), - memberTerminatedEvent.getClusterId()); - } - } - + @Override + protected void onEvent(Event event) { + try { + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + String clusterId = memberTerminatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberTerminatedEvent(memberTerminatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { - @Override - protected void onEvent(Event event) { - - MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; - - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(memberActivatedEvent.getServiceName(), - memberActivatedEvent.getClusterId()); - - try { - - String networkPartitionId = memberActivatedEvent.getNetworkPartitionId(); - String clusterId = memberActivatedEvent.getClusterId(); - String partitionId = memberActivatedEvent.getPartitionId(); - String memberId = memberActivatedEvent.getMemberId(); - - AbstractClusterMonitor monitor; - - if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - } else { - //This is LB member - monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); - } - - NetworkPartitionContext networkPartitionContext = monitor. - getNetworkPartitionCtxt(networkPartitionId); - - PartitionContext partitionContext = networkPartitionContext. - getPartitionCtxt(partitionId); - - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - // TODO starting the pending clusters which are waiting for this member activation in a cluster - - - if (log.isInfoEnabled()) { - log.info(String.format("Member stat context has been added " + - "successfully: [member] %s", memberId)); - } -// partitionContext.incrementCurrentActiveMemberCount(1); - partitionContext.movePendingMemberToActiveMembers(memberId); - //triggering the status checker - StatusChecker.getInstance().onMemberStatusChange(memberActivatedEvent.getClusterId()); - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(memberActivatedEvent.getServiceName(), - memberActivatedEvent.getClusterId()); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + String clusterId = memberActivatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberActivatedEvent(memberActivatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { - @Override - protected void onEvent(Event event) { - - MemberMaintenanceModeEvent memberMaintenanceModeEvent = (MemberMaintenanceModeEvent) event; - - //TopologyManager.acquireReadLock(); - TopologyManager.acquireReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), - memberMaintenanceModeEvent.getClusterId()); - - try { - - String memberId = memberMaintenanceModeEvent.getMemberId(); - String partitionId = memberMaintenanceModeEvent.getPartitionId(); - String networkPartitionId = memberMaintenanceModeEvent.getNetworkPartitionId(); - - PartitionContext partitionContext; - String clusterId = memberMaintenanceModeEvent.getClusterId(); - AbstractClusterMonitor monitor; - - if (AutoscalerContext.getInstance().monitorExist(clusterId)) { - monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). - getPartitionCtxt(partitionId); - } else { - monitor = AutoscalerContext.getInstance().getLBMonitor(clusterId); - partitionContext = monitor.getNetworkPartitionCtxt(networkPartitionId). - getPartitionCtxt(partitionId); - } - partitionContext.addMemberStatsContext(new MemberStatsContext(memberId)); - if (log.isDebugEnabled()) { - log.debug(String.format("Member has been moved as pending termination: " + - "[member] %s", memberId)); - } - partitionContext.moveActiveMemberToTerminationPendingMembers(memberId); - - } catch (Exception e) { - log.error("Error processing event", e); - } finally { - //TopologyManager.releaseReadLock(); - TopologyManager.releaseReadLockForCluster(memberMaintenanceModeEvent.getServiceName(), - memberMaintenanceModeEvent.getClusterId()); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberMaintenanceModeEvent maintenanceModeEvent = (MemberMaintenanceModeEvent) event; + String clusterId = maintenanceModeEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberMaintenanceModeEvent(maintenanceModeEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); } @@ -1061,29 +622,6 @@ public void terminate() { terminated = true; } - protected synchronized void startClusterMonitor(Cluster cluster) { - Thread th = null; - - AbstractClusterMonitor monitor; - monitor = AutoscalerContext.getInstance().getClusterMonitor(cluster.getClusterId()); - - if (null == monitor) { - th = new Thread(new ClusterMonitorAdder(cluster)); - } - if (th != null) { - th.start(); - try { - th.join(); - } catch (InterruptedException ignore) { - } - - if (log.isDebugEnabled()) { - log.debug(String.format("Cluster monitor thread has been started successfully: " - + "[cluster] %s ", cluster.getClusterId())); - } - } - } - protected synchronized void startApplicationMonitor(String applicationId) { Thread th = null; if (!AutoscalerContext.getInstance().appMonitorExist(applicationId)) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java deleted file mode 100644 index fb23985930..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/AbstractClusterMonitor.java +++ /dev/null @@ -1,277 +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.autoscaler.monitor; - -import org.apache.commons.configuration.XMLConfiguration; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; -import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; -import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.autoscaler.util.AutoScalerConstants; -import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.drools.runtime.StatefulKnowledgeSession; -import org.drools.runtime.rule.FactHandle; - -import java.util.Map; - -/** - * Is responsible for monitoring a service cluster. This runs periodically - * and perform minimum instance check and scaling check using the underlying - * rules engine. - */ -abstract public class AbstractClusterMonitor extends Monitor implements Runnable { - - private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); - // Map - protected Map networkPartitionCtxts; - protected DeploymentPolicy deploymentPolicy; - protected AutoscalePolicy autoscalePolicy; - - - protected FactHandle minCheckFactHandle; - protected FactHandle scaleCheckFactHandle; - protected FactHandle terminateDependencyFactHandle; - protected FactHandle terminateAllFactHandle; - - protected StatefulKnowledgeSession minCheckKnowledgeSession; - protected StatefulKnowledgeSession scaleCheckKnowledgeSession; - protected StatefulKnowledgeSession terminateAllKnowledgeSession; - protected boolean isDestroyed; - - protected String clusterId; - protected String serviceId; - protected String appId; - - protected boolean hasFaultyMember = false; - - protected ClusterStatus status; - - //protected ParentComponentMonitor parent; - - protected AutoscalerRuleEvaluator autoscalerRuleEvaluator; - - // time intereval between two runs of the Monitor. Default is 90000ms. - protected int monitorInterval; - - public AbstractClusterMonitor() { - readConfigurations(); - status = ClusterStatus.Created; - } - - private void readConfigurations() { - - XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); - monitorInterval = conf.getInt(AutoScalerConstants.AUTOSCALER_MONITOR_INTERVAL, 90000); - if (log.isDebugEnabled()) { - log.debug("Cluster Monitor task interval: " + getMonitorInterval()); - } - } - - @Override - public void run() { - // TODO Auto-generated method stub - } - - - public NetworkPartitionContext getNetworkPartitionCtxt(Member member) { - log.info("***** getNetworkPartitionCtxt " + member.getNetworkPartitionId()); - String networkPartitionId = member.getNetworkPartitionId(); - if (networkPartitionCtxts.containsKey(networkPartitionId)) { - log.info("returnnig network partition context " + networkPartitionCtxts.get(networkPartitionId)); - return networkPartitionCtxts.get(networkPartitionId); - } - log.info("returning null getNetworkPartitionCtxt"); - return null; - } - - public String getPartitionOfMember(String memberId) { - for (Service service : TopologyManager.getTopology().getServices()) { - for (Cluster cluster : service.getClusters()) { - if (cluster.memberExists(memberId)) { - return cluster.getMember(memberId).getPartitionId(); - } - } - } - return null; - } - - public void destroy() { - minCheckKnowledgeSession.dispose(); - scaleCheckKnowledgeSession.dispose(); - terminateAllKnowledgeSession.dispose(); - setDestroyed(true); - if (log.isDebugEnabled()) { - log.debug("Cluster Monitor Drools session has been disposed. " + this.toString()); - } - } - - public abstract void terminateAllMembers (); - - public boolean isDestroyed() { - return isDestroyed; - } - - public void setDestroyed(boolean isDestroyed) { - this.isDestroyed = isDestroyed; - } - - public String getServiceId() { - return serviceId; - } - - public void setServiceId(String serviceId) { - this.serviceId = serviceId; - } - - public DeploymentPolicy getDeploymentPolicy() { - return deploymentPolicy; - } - - public void setDeploymentPolicy(DeploymentPolicy deploymentPolicy) { - this.deploymentPolicy = deploymentPolicy; - } - - public AutoscalePolicy getAutoscalePolicy() { - return autoscalePolicy; - } - - public void setAutoscalePolicy(AutoscalePolicy autoscalePolicy) { - this.autoscalePolicy = autoscalePolicy; - } - - public String getClusterId() { - return clusterId; - } - - public void setClusterId(String clusterId) { - this.clusterId = clusterId; - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public Map getNetworkPartitionCtxts() { - return networkPartitionCtxts; - } - - public NetworkPartitionContext getNetworkPartitionCtxt(String networkPartitionId) { - return networkPartitionCtxts.get(networkPartitionId); - } - - public void setPartitionCtxt(Map partitionCtxt) { - this.networkPartitionCtxts = partitionCtxt; - } - - public boolean partitionCtxtAvailable(String partitionId) { - return networkPartitionCtxts.containsKey(partitionId); - } - - public void addNetworkPartitionCtxt(NetworkPartitionContext ctxt) { - this.networkPartitionCtxts.put(ctxt.getId(), ctxt); - } - - public NetworkPartitionContext getPartitionCtxt(String id) { - return this.networkPartitionCtxts.get(id); - } - - public StatefulKnowledgeSession getMinCheckKnowledgeSession() { - return minCheckKnowledgeSession; - } - - public void setMinCheckKnowledgeSession(StatefulKnowledgeSession minCheckKnowledgeSession) { - this.minCheckKnowledgeSession = minCheckKnowledgeSession; - } - - public FactHandle getMinCheckFactHandle() { - return minCheckFactHandle; - } - - public void setMinCheckFactHandle(FactHandle minCheckFactHandle) { - this.minCheckFactHandle = minCheckFactHandle; - } - - - public int getMonitorInterval() { - return monitorInterval; - } - - public ClusterStatus getStatus() { - return status; - } - - public void setStatus(ClusterStatus status) { - - //if(this.status != status) { - this.status = status; - /** - * notifying the parent monitor about the state change - * If the cluster in_active and if it is a in_dependent cluster, - * then won't send the notification to parent. - */ - if (status == ClusterStatus.Inactive && !this.hasDependent) { - log.info("[Cluster] " + clusterId + "is not notifying the parent, " + - "since it is identified as the independent unit"); - - } else if (status == ClusterStatus.Terminating) { - // notify parent - log.info("[Cluster] " + clusterId + " is not notifying the parent, " + - "since it is in Terminating State"); - - } else { - MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); - } - //} - - } - - @Override - public void onChildEvent(MonitorStatusEvent statusEvent) { - - } - - @Override - public void onEvent(MonitorTerminateAllEvent terminateAllEvent) { - - } - - @Override - public void onEvent(MonitorScalingEvent scalingEvent) { - - } - - public boolean isHasFaultyMember() { - return hasFaultyMember; - } - - public void setHasFaultyMember(boolean hasFaultyMember) { - this.hasFaultyMember = hasFaultyMember; - } -} \ No newline at end of file diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index 593807789f..bd36091af0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -31,6 +31,8 @@ import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.ParentComponent; +import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; +import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import java.util.HashMap; import java.util.List; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java index 7f3de58abe..66891d03d1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java @@ -18,48 +18,32 @@ */ package org.apache.stratos.autoscaler.monitor.application; +import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.MemberStatsContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; +import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext; +import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.applications.dependency.context.GroupContext; -import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; -import org.apache.stratos.autoscaler.grouping.dependency.context.ApplicationContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.ClusterContext; -import org.apache.stratos.autoscaler.grouping.dependency.context.GroupContext; import org.apache.stratos.autoscaler.monitor.Monitor; import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.autoscaler.partition.PartitionGroup; -import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Group; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Service; +import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.apache.stratos.messaging.util.Constants; - -import java.util.Map; /** * Factory class to get the Monitors. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index f043f513ae..fa9736e372 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -22,17 +22,17 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.exception.InvalidArgumentException; -import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.Monitor; +import org.apache.stratos.autoscaler.monitor.MonitorStatusEventBuilder; import org.apache.stratos.autoscaler.monitor.events.MonitorScalingEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.messaging.domain.topology.ApplicationStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import org.apache.stratos.messaging.domain.topology.GroupStatus; import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; import org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent; @@ -62,10 +62,13 @@ * Every cluster monitor, which are monitoring a cluster, should extend this class. */ public abstract class AbstractClusterMonitor extends Monitor implements Runnable { + + private static final Log log = LogFactory.getLog(AbstractClusterMonitor.class); private String clusterId; private String serviceId; - protected ClusterStatus status; + private String appId; + private ClusterStatus status; private int monitoringIntervalMilliseconds; protected FactHandle minCheckFactHandle; @@ -76,6 +79,7 @@ public abstract class AbstractClusterMonitor extends Monitor implements Runnable private AutoscalerRuleEvaluator autoscalerRuleEvaluator; protected boolean hasFaultyMember = false; + protected boolean stop = false; private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); @@ -88,6 +92,7 @@ protected AbstractClusterMonitor(String clusterId, String serviceId, this.autoscalerRuleEvaluator = autoscalerRuleEvaluator; this.scaleCheckKnowledgeSession = autoscalerRuleEvaluator.getScaleCheckStatefulSession(); this.minCheckKnowledgeSession = autoscalerRuleEvaluator.getMinCheckStatefulSession(); + this.status = ClusterStatus.Created; } protected abstract void readConfigurations(); @@ -178,14 +183,35 @@ public void setClusterId(String clusterId) { this.clusterId = clusterId; } - public void setStatus(ClusterStatus status) { - this.status = status; - } - public ClusterStatus getStatus() { return status; } + public void setStatus(ClusterStatus status) { + + //if(this.status != status) { + this.status = status; + /** + * notifying the parent monitor about the state change + * If the cluster in_active and if it is a in_dependent cluster, + * then won't send the notification to parent. + */ + if (status == ClusterStatus.Inactive && !this.hasDependent) { + log.info("[Cluster] " + clusterId + "is not notifying the parent, " + + "since it is identified as the independent unit"); + + } else if (status == ClusterStatus.Terminating) { + // notify parent + log.info("[Cluster] " + clusterId + " is not notifying the parent, " + + "since it is in Terminating State"); + + } else { + MonitorStatusEventBuilder.handleClusterStatusEvent(this.parent, this.status, this.clusterId); + } + //} + + } + public String getServiceId() { return serviceId; } @@ -252,15 +278,19 @@ public void setAutoscalerRuleEvaluator( AutoscalerRuleEvaluator autoscalerRuleEvaluator) { this.autoscalerRuleEvaluator = autoscalerRuleEvaluator; } + + public String getAppId() { + return this.appId; + } @Override public void onParentEvent(MonitorStatusEvent statusEvent) { // send the ClusterTerminating event - if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == - ApplicationStatus.Terminating) { - StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); - } +// if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == +// ApplicationStatus.Terminating) { +// StatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); +// } } @Override @@ -287,4 +317,12 @@ public boolean isHasFaultyMember() { } public abstract void terminateAllMembers(); + + public boolean isStop() { + return stop; + } + + public void setStop(boolean stop) { + this.stop = stop; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java index 26156516f6..1f17daab90 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java @@ -18,6 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.cluster; +import java.util.Arrays; import java.util.List; import org.apache.commons.configuration.XMLConfiguration; @@ -33,8 +34,6 @@ import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; -import edu.emory.mathcs.backport.java.util.Arrays; - /* * It is monitoring a kubernetes service cluster periodically. */ diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 336550354b..19d3704c30 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -27,11 +27,13 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.exception.InvalidArgumentException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; @@ -552,6 +554,11 @@ public void handleClusterRemovedEvent( ClusterRemovedEvent clusterRemovedEvent) { } + + @Override + public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException { + + } private String getNetworkPartitionIdByMemberId(String memberId) { for (Service service : TopologyManager.getTopology().getServices()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java index 8a0959ce61..3c82bdd4b3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java @@ -28,14 +28,12 @@ import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.InvalidArgumentException; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; @@ -68,7 +66,7 @@ public void run() { log.debug("Cluster monitor is running.. " + this.toString()); } try { - if (!ClusterStatus.Inactive.equals(status)) { + if (!ClusterStatus.Inactive.equals(getStatus())) { monitor(); } else { if (log.isDebugEnabled()) { @@ -173,9 +171,4 @@ public String toString() { return "VMLbClusterMonitor [clusterId=" + getClusterId() + ", serviceId=" + getServiceId() + "]"; } - @Override - public void handleDynamicUpdates(Properties properties) throws InvalidArgumentException { - // TODO - - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index dc97dc7a12..cc351de2f6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -28,10 +28,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.InvalidArgumentException; -import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; @@ -40,10 +37,10 @@ import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.GroupStatus; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; /** * Is responsible for monitoring a service cluster. This runs periodically @@ -66,22 +63,23 @@ public VMServiceClusterMonitor(String clusterId, String serviceId, new ConcurrentHashMap()); readConfigurations(); } - - private static void terminateMember(String memberId) { - try { - CloudControllerClient.getInstance().terminate(memberId); - - } catch (TerminationException e) { - log.error("Unable to terminate member [member id ] " + memberId, e); - } - } + +//TODO why this method? +// private static void terminateMember(String memberId) { +// try { +// CloudControllerClient.getInstance().terminate(memberId); +// +// } catch (TerminationException e) { +// log.error("Unable to terminate member [member id ] " + memberId, e); +// } +// } @Override public void run() { while (!isDestroyed()) { try { - if ((this.status.getCode() <= ClusterStatus.Active.getCode()) || - (this.status == ClusterStatus.Inactive && !hasDependent) || + if ((getStatus().getCode() <= ClusterStatus.Active.getCode()) || + (getStatus() == ClusterStatus.Inactive && !hasDependent) || !this.hasFaultyMember) { if (log.isDebugEnabled()) { log.debug("Cluster monitor is running.. " + this.toString()); @@ -97,56 +95,57 @@ public void run() { log.error("Cluster monitor: Monitor failed." + this.toString(), e); } try { - Thread.sleep(monitorInterval); + Thread.sleep(getMonitorIntervalMilliseconds()); } catch (InterruptedException ignore) { } } } - - @Override - public void terminateAllMembers() { - - Thread memberTerminator = new Thread(new Runnable() { - public void run() { - - for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { - for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { - //if (log.isDebugEnabled()) { - log.info("Starting to terminate all members in Network Partition [ " + - networkPartitionContext.getId() + " ], Partition [ " + - partitionContext.getPartitionId() + " ]"); - // } - // need to terminate active, pending and obsolete members - - // active members - for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) { - log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId()); - terminateMember(activeMemberCtxt.getMemberId()); - } - - // pending members - for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { - log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); - terminateMember(pendingMemberCtxt.getMemberId()); - } - - // obsolete members - for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) { - log.info("Terminating obsolete member [member id] " + obsoleteMemberId); - terminateMember(obsoleteMemberId); - } - -// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll -// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); - } - } - } - }, "Member Terminator - [cluster id] " + this.clusterId); - - memberTerminator.start(); - } + +//TODO why this method? +// @Override +// public void terminateAllMembers() { +// +// Thread memberTerminator = new Thread(new Runnable() { +// public void run() { +// +// for (NetworkPartitionContext networkPartitionContext : networkPartitionCtxts.values()) { +// for (PartitionContext partitionContext : networkPartitionContext.getPartitionCtxts().values()) { +// //if (log.isDebugEnabled()) { +// log.info("Starting to terminate all members in Network Partition [ " + +// networkPartitionContext.getId() + " ], Partition [ " + +// partitionContext.getPartitionId() + " ]"); +// // } +// // need to terminate active, pending and obsolete members +// +// // active members +// for (MemberContext activeMemberCtxt : partitionContext.getActiveMembers()) { +// log.info("Terminating active member [member id] " + activeMemberCtxt.getMemberId()); +// terminateMember(activeMemberCtxt.getMemberId()); +// } +// +// // pending members +// for (MemberContext pendingMemberCtxt : partitionContext.getPendingMembers()) { +// log.info("Terminating pending member [member id] " + pendingMemberCtxt.getMemberId()); +// terminateMember(pendingMemberCtxt.getMemberId()); +// } +// +// // obsolete members +// for (String obsoleteMemberId : partitionContext.getObsoletedMembers()) { +// log.info("Terminating obsolete member [member id] " + obsoleteMemberId); +// terminateMember(obsoleteMemberId); +// } +// +//// terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll +//// (terminateAllKnowledgeSession, terminateAllFactHandle, partitionContext); +// } +// } +// } +// }, "Member Terminator - [cluster id] " + this.clusterId); +// +// memberTerminator.start(); +// } private boolean isPrimaryMember(MemberContext memberContext) { Properties props = memberContext.getProperties(); @@ -191,16 +190,16 @@ public void monitor() { } } primaryMemberListInNetworkPartition.addAll(primaryMemberListInPartition); - minCheckKnowledgeSession.setGlobal("clusterId", clusterId); - minCheckKnowledgeSession.setGlobal("lbRef", lbReferenceType); - minCheckKnowledgeSession.setGlobal("isPrimary", hasPrimary); + getMinCheckKnowledgeSession().setGlobal("clusterId", getClusterId()); + getMinCheckKnowledgeSession().setGlobal("lbRef", lbReferenceType); + getMinCheckKnowledgeSession().setGlobal("isPrimary", hasPrimary); if (log.isDebugEnabled()) { log.debug(String.format("Running minimum check for partition %s ", partitionContext.getPartitionId())); } - minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(minCheckKnowledgeSession + minCheckFactHandle = AutoscalerRuleEvaluator.evaluateMinCheck(getMinCheckKnowledgeSession() , minCheckFactHandle, partitionContext); //checking the status of the cluster @@ -246,25 +245,6 @@ public void monitor() { } } - private boolean isPrimaryMember(MemberContext memberContext) { - Properties props = memberContext.getProperties(); - if (log.isDebugEnabled()) { - log.debug(" Properties [" + props + "] "); - } - if (props != null && props.getProperties() != null) { - for (Property prop : props.getProperties()) { - if (prop.getName().equals("PRIMARY")) { - if (Boolean.parseBoolean(prop.getValue())) { - log.debug("Adding member id [" + memberContext.getMemberId() + "] " + - "member instance id [" + memberContext.getInstanceId() + "] as a primary member"); - return true; - } - } - } - } - return false; - } - @Override protected void readConfigurations() { XMLConfiguration conf = ConfUtil.getInstance(null).getConfiguration(); @@ -320,7 +300,7 @@ public void onParentEvent(MonitorStatusEvent statusEvent) { // send the ClusterTerminating event if (statusEvent.getStatus() == GroupStatus.Terminating || statusEvent.getStatus() == ApplicationStatus.Terminating) { - ClusterStatusEventPublisher.sendClusterTerminatingEvent(appId, serviceId, clusterId); + ClusterStatusEventPublisher.sendClusterTerminatingEvent(getAppId(), getServiceId(), getClusterId()); } } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index d828309d88..1b9d44d546 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -18,24 +18,28 @@ */ package org.apache.stratos.autoscaler.status.checker; +import java.util.Map; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; -import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; -import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; -import org.apache.stratos.messaging.domain.applications.*; -import org.apache.stratos.autoscaler.grouping.topic.StatusEventPublisher; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; -import org.apache.stratos.messaging.domain.topology.*; +import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.messaging.domain.applications.ApplicationStatus; +import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; +import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.applications.GroupStatus; +import org.apache.stratos.messaging.domain.applications.ParentComponent; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.Map; - /** * This will be used to evaluate the status of a group * and notify the interested parties about the status changes. From a3c18428e20a5af68f1ac317456bb311dbd69ae3 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Mon, 3 Nov 2014 15:40:23 +0530 Subject: [PATCH 376/436] adding AS wsdl --- .../src/main/resources/AutoScalerService.wsdl | 1001 +++++++++++------ 1 file changed, 688 insertions(+), 313 deletions(-) diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index 7d56741488..647c56048b 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,295 +1,335 @@ - + AutoScalerService - - - - - - - + + + + - + + + + + + - + + + - + + + + + + + - + - + + + - + - + + - + - + + + + + + - + - + + - + - + + + + + + + + - + + + - + + + + - + - + + - - + + - - + + + + + + - + - - - - + + + - - - + - - - - + + - + - + + - + - - + + - - - - - - - - - - + + + + - - - - - - + + + - + + + + - - + + + + + + + + + + + + + + - + + + + - - - - + + + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + @@ -322,101 +362,95 @@ - + - - - + - + - + - + - - - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -430,7 +464,7 @@ - + @@ -442,55 +476,96 @@ - + - + - + + + - + - + - + - + + + - + - + - + - + + + - + - + - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -526,6 +601,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -541,173 +660,222 @@ - + - + - + - + + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + - - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + - - - + + - + + + - - + + - + - - + + + + - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - - - - + - - - - + - - - - - - - - - - - - - - + + + + + + + + @@ -761,6 +929,12 @@ + + + + + + @@ -779,6 +953,18 @@ + + + + + + + + + + + + @@ -797,6 +983,12 @@ + + + + + + @@ -812,6 +1004,9 @@ + + + @@ -902,6 +1097,12 @@ + + + + + + @@ -958,6 +1159,10 @@ + + + + @@ -968,6 +1173,14 @@ + + + + + + + + @@ -981,6 +1194,10 @@ + + + + @@ -991,6 +1208,10 @@ + + + + @@ -1053,6 +1274,10 @@ + + + + @@ -1147,6 +1372,15 @@ + + + + + + + + + @@ -1171,6 +1405,24 @@ + + + + + + + + + + + + + + + + + + @@ -1201,6 +1453,15 @@ + + + + + + + + + @@ -1225,6 +1486,15 @@ + + + + + + + + + @@ -1264,37 +1534,37 @@ - - + + + + + - - + + - - - - - + + - - + + @@ -1369,14 +1639,14 @@ - - + + - - - + + + @@ -1393,17 +1663,14 @@ - - + + - - - @@ -1414,6 +1681,18 @@ + + + + + + + + + + + + @@ -1489,6 +1768,15 @@ + + + + + + + + + @@ -1513,6 +1801,24 @@ + + + + + + + + + + + + + + + + + + @@ -1543,6 +1849,15 @@ + + + + + + + + + @@ -1567,6 +1882,15 @@ + + + + + + + + + @@ -1606,37 +1930,37 @@ - - + + + + + - - + + - - - - - + + - - + + @@ -1711,14 +2035,14 @@ - - + + - - - + + + @@ -1735,17 +2059,14 @@ - - + + - - - @@ -1756,6 +2077,18 @@ + + + + + + + + + + + + @@ -1822,6 +2155,15 @@ + + + + + + + + + @@ -1840,6 +2182,21 @@ + + + + + + + + + + + + + + + @@ -1867,6 +2224,12 @@ + + + + + + @@ -1885,6 +2248,12 @@ + + + + + + @@ -1921,8 +2290,8 @@ - - + + @@ -1930,8 +2299,8 @@ - - + + @@ -1939,8 +2308,8 @@ - - + + @@ -2008,14 +2377,11 @@ - - + + - - - @@ -2026,8 +2392,8 @@ - - + + @@ -2041,25 +2407,34 @@ + + + + + + + + + - + - + - + - + - + - + \ No newline at end of file From 8d1b5ff214005a1e3727b48317fdd2320faba430 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Mon, 3 Nov 2014 16:24:03 +0530 Subject: [PATCH 377/436] adding CC wsdl --- .../resources/CloudControllerService.wsdl | 402 +++++++++--------- 1 file changed, 201 insertions(+), 201 deletions(-) diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index a1af8a4797..487b4ab2c3 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,15 +6,15 @@ - + - - - + + + @@ -22,9 +22,9 @@ - - - + + + @@ -38,9 +38,9 @@ - + - + @@ -63,32 +63,32 @@ - + - + - + - + - + - + @@ -108,7 +108,7 @@ - + @@ -119,150 +119,158 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + + + + + + + + - + - + + - + - + - + - + @@ -304,28 +312,14 @@ - - - - - - - - - - - - - - - + - + @@ -339,7 +333,7 @@ - + @@ -362,24 +356,24 @@ - + - + - + - + - + @@ -393,14 +387,14 @@ - + - + @@ -414,7 +408,7 @@ - + @@ -429,14 +423,14 @@ - + - + @@ -450,41 +444,47 @@ - + - + - - + - + - + - + - + - + + + + + + + + - + - + @@ -493,120 +493,88 @@ - + - - + - - - - - - - - - - - - - - - + + - + + + + + + + + + - + - - + + + + + + + + - + + - - - - - + - - - + + + - - - - - - - - + - - - - - + - - - - - - + - + + - + - - - + - + - - + + - - - - - - - - - - - - - + @@ -616,45 +584,63 @@ - + - + + + + - + - - - + + + - + - + + + + + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + @@ -668,29 +654,43 @@ - + - + + + + + + + + + + + + + + + - + - + + + - - - - - + + + @@ -1758,22 +1758,22 @@ - + - + - + - + - + - + \ No newline at end of file From 8159b5cc38bcf7779aa3881ed7c92833dade8c21 Mon Sep 17 00:00:00 2001 From: Manula Thantriwatte Date: Mon, 3 Nov 2014 11:21:12 +0000 Subject: [PATCH 378/436] Add deploy-application, undeploy-application, deploy-service-group and undeploy-service-group commands to CLI --- .../org/apache/stratos/cli/RestClient.java | 1 + .../stratos/cli/RestCommandLineService.java | 24 ++++ .../stratos/cli/StratosApplication.java | 12 ++ .../commands/DeployApplicationCommand.java | 111 ++++++++++++++++++ .../DeployKubernetesGroupCommand.java | 1 + .../commands/DeployKubernetesHostCommand.java | 1 + .../commands/DeployServiceGroupCommand.java | 111 ++++++++++++++++++ .../commands/UndeployApplicationCommand.java | 76 ++++++++++++ .../commands/UndeployServiceGroupCommand.java | 76 ++++++++++++ 9 files changed, 413 insertions(+) create mode 100644 components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java create mode 100644 components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java create mode 100644 components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java create mode 100644 components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceGroupCommand.java diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java index a2560eba87..0c549eb411 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/RestClient.java @@ -290,6 +290,7 @@ private int executePut(String serviceEndpoint, String postBody) throws IOExcepti private int executeDelete(String serviceEndpoint, String identifier) throws IOException { DefaultHttpClient httpClient = new DefaultHttpClient(); try { + System.out.println(getBaseURL() + serviceEndpoint.replace("{id}", identifier)); HttpResponse response = doDelete(httpClient, getBaseURL() + serviceEndpoint.replace("{id}", identifier)); int responseCode = response.getStatusLine().getStatusCode(); 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 64df59ebf8..e52e659c6a 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 @@ -86,9 +86,13 @@ public class RestCommandLineService { private static final String ENDPOINT_DEPLOY_SERVICE = "/stratos/admin/service/definition"; private static final String ENDPOINT_DEPLOY_KUBERNETES_GROUP = "/stratos/admin/kubernetes/deploy/group"; private static final String ENDPOINT_DEPLOY_KUBERNETES_HOST = "/stratos/admin/kubernetes/deploy/host"; + private static final String ENDPOINT_DEPLOY_SERVICE_GROUP = "/stratos/admin/group/definition"; + private static final String ENDPOINT_DEPLOY_APPLICATION = "/stratos/admin/application/definition"; private static final String ENDPOINT_UNDEPLOY_KUBERNETES_GROUP = "/stratos/admin/kubernetes/group/{id}"; private static final String ENDPOINT_UNDEPLOY_KUBERNETES_HOST = "/stratos/admin/kubernetes/host/{id}"; + private static final String ENDPOINT_UNDEPLOY_SERVICE_GROUP = "/stratos/admin/group/definition/{id}"; + private static final String ENDPOINT_UNDEPLOY_APPLICATION = "/stratos/admin/application/definition/{id}"; private static final String ENDPOINT_LIST_PARTITIONS = "/stratos/admin/partition"; private static final String ENDPOINT_LIST_AUTOSCALING_POLICIES = "/stratos/admin/policy/autoscale"; @@ -1807,4 +1811,24 @@ public void updateSubscritptionProperties(String alias, String subscriptionJson) String url = ENDPOINT_UPDATE_SUBSCRIPTION_PROPERTIES.replace("{alias}", alias); restClient.updateEntity(url, subscriptionJson, "subscription alias: "+alias); } + + // This method helps to deploy service groups + public void deployServiceGroup (String entityBody) { + restClient.deployEntity(ENDPOINT_DEPLOY_SERVICE_GROUP, entityBody, "service group"); + } + + // This method helps to undeploy service groups + public void undeployServiceGroup (String groupDefinitionName) throws CommandException { + restClient.undeployEntity(ENDPOINT_UNDEPLOY_SERVICE_GROUP, "service group", groupDefinitionName); + } + + // This method helps to deploy applications + public void deployApplication (String entityBody) { + restClient.deployEntity(ENDPOINT_DEPLOY_APPLICATION, entityBody, "application"); + } + + // This method helps to undeploy applications + public void undeployApplication(String id) throws CommandException { + restClient.undeployEntity(ENDPOINT_UNDEPLOY_APPLICATION, "application", id); + } } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java index 3b1c55a05b..9fc783ba39 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/StratosApplication.java @@ -213,6 +213,18 @@ private void createCommands() { command = new UpdateDeploymentPolicyCommand(); commands.put(command.getName(), command); + command = new DeployServiceGroupCommand(); + commands.put(command.getName(), command); + + command = new UndeployServiceGroupCommand(); + commands.put(command.getName(), command); + + command = new DeployApplicationCommand(); + commands.put(command.getName(), command); + + command = new UndeployApplicationCommand(); + commands.put(command.getName(), command); + if (logger.isDebugEnabled()) { logger.debug("Created {} commands for the application. {}", commands.size(), commands.keySet()); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java new file mode 100644 index 0000000000..25e95672bb --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployApplicationCommand.java @@ -0,0 +1,111 @@ +/** + * 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.cli.commands; + +import org.apache.commons.cli.*; +import org.apache.stratos.cli.Command; +import org.apache.stratos.cli.RestCommandLineService; +import org.apache.stratos.cli.StratosCommandContext; +import org.apache.stratos.cli.exception.CommandException; +import org.apache.stratos.cli.utils.CliConstants; +import org.apache.stratos.cli.utils.CliUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.IOException; + +/** + * Deploy application command. + */ +public class DeployApplicationCommand implements Command { + + private static final Logger logger = LoggerFactory.getLogger(DeployApplicationCommand.class); + + private Options options; + + public DeployApplicationCommand() { + options = new Options(); + Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true, + "Application resource path"); + option.setArgName("resource path"); + options.addOption(option); + } + + @Override + public String getName() { + return "deploy-application"; + } + + @Override + public String getDescription() { + return "Deploy application"; + } + + @Override + public String getArgumentSyntax() { + return null; + } + + @Override + public Options getOptions() { + return options; + } + + @Override + public int execute(StratosCommandContext context, String[] args) throws CommandException { + if (logger.isDebugEnabled()) { + logger.debug("Executing command: ", getName()); + } + + if ((args == null) || (args.length <= 0)) { + context.getStratosApplication().printUsage(getName()); + return CliConstants.COMMAND_FAILED; + } + + try { + CommandLineParser parser = new GnuParser(); + CommandLine commandLine = parser.parse(options, args); + if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + if (resourcePath == null) { + System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]"); + return CliConstants.COMMAND_FAILED; + } + String resourceFileContent = CliUtils.readResource(resourcePath); + RestCommandLineService.getInstance().deployApplication(resourceFileContent); + return CliConstants.COMMAND_SUCCESSFULL; + } else { + System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]"); + return CliConstants.COMMAND_FAILED; + } + } catch (ParseException e) { + logger.error("Error parsing arguments", e); + System.out.println(e.getMessage()); + return CliConstants.COMMAND_FAILED; + } catch (IOException e) { + System.out.println("Invalid resource path"); + return CliConstants.COMMAND_FAILED; + } catch (Exception e) { + String message = "Unknown error occurred: " + e.getMessage(); + System.out.println(message); + logger.error(message, e); + return CliConstants.COMMAND_FAILED; + } + } +} diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java index 1f73bd313c..d7f7912aaa 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesGroupCommand.java @@ -44,6 +44,7 @@ public DeployKubernetesGroupCommand() { options = new Options(); Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true, "Kubernetes group resource path"); + option.setArgName("resource path"); options.addOption(option); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java index a107a94baf..a9c9f749ec 100644 --- a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployKubernetesHostCommand.java @@ -44,6 +44,7 @@ public DeployKubernetesHostCommand() { options = new Options(); Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true, "Kubernetes host resource path"); + option.setArgName("resource path"); options.addOption(option); } diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java new file mode 100644 index 0000000000..c59da2e082 --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/DeployServiceGroupCommand.java @@ -0,0 +1,111 @@ +/** + * 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.cli.commands; + +import org.apache.commons.cli.*; +import org.apache.stratos.cli.Command; +import org.apache.stratos.cli.RestCommandLineService; +import org.apache.stratos.cli.StratosCommandContext; +import org.apache.stratos.cli.exception.CommandException; +import org.apache.stratos.cli.utils.CliConstants; +import org.apache.stratos.cli.utils.CliUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import java.io.IOException; + +/** + * Deploy service group command. + */ +public class DeployServiceGroupCommand implements Command { + + private static final Logger logger = LoggerFactory.getLogger(DeployServiceGroupCommand.class); + + private Options options; + + public DeployServiceGroupCommand() { + options = new Options(); + Option option = new Option(CliConstants.RESOURCE_PATH, CliConstants.RESOURCE_PATH_LONG_OPTION, true, + "Service group resource path"); + option.setArgName("resource path"); + options.addOption(option); + } + + @Override + public String getName() { + return "deploy-service-group"; + } + + @Override + public String getDescription() { + return "Deploy service group"; + } + + @Override + public String getArgumentSyntax() { + return null; + } + + @Override + public Options getOptions() { + return options; + } + + @Override + public int execute(StratosCommandContext context, String[] args) throws CommandException { + if (logger.isDebugEnabled()) { + logger.debug("Executing command: ", getName()); + } + + if ((args == null) || (args.length <= 0)) { + context.getStratosApplication().printUsage(getName()); + return CliConstants.COMMAND_FAILED; + } + + try { + CommandLineParser parser = new GnuParser(); + CommandLine commandLine = parser.parse(options, args); + if (commandLine.hasOption(CliConstants.RESOURCE_PATH)) { + String resourcePath = commandLine.getOptionValue(CliConstants.RESOURCE_PATH); + if (resourcePath == null) { + System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]"); + return CliConstants.COMMAND_FAILED; + } + String resourceFileContent = CliUtils.readResource(resourcePath); + RestCommandLineService.getInstance().deployServiceGroup(resourceFileContent); + return CliConstants.COMMAND_SUCCESSFULL; + } else { + System.out.println("usage: " + getName() + " [-" + CliConstants.RESOURCE_PATH + " " + CliConstants.RESOURCE_PATH_LONG_OPTION + "]"); + return CliConstants.COMMAND_FAILED; + } + } catch (ParseException e) { + logger.error("Error parsing arguments", e); + System.out.println(e.getMessage()); + return CliConstants.COMMAND_FAILED; + } catch (IOException e) { + System.out.println("Invalid resource path"); + return CliConstants.COMMAND_FAILED; + } catch (Exception e) { + String message = "Unknown error occurred: " + e.getMessage(); + System.out.println(message); + logger.error(message, e); + return CliConstants.COMMAND_FAILED; + } + } +} diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.java new file mode 100644 index 0000000000..0fba797b0f --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployApplicationCommand.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.cli.commands; + +import org.apache.commons.cli.Options; +import org.apache.stratos.cli.Command; +import org.apache.stratos.cli.RestCommandLineService; +import org.apache.stratos.cli.StratosCommandContext; +import org.apache.stratos.cli.exception.CommandException; +import org.apache.stratos.cli.utils.CliConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Un-deploy application command. + */ +public class UndeployApplicationCommand implements Command { + + private static final Logger logger = LoggerFactory.getLogger(UndeployApplicationCommand.class); + + public UndeployApplicationCommand() { + } + + @Override + public String getName() { + return "undeploy-application"; + } + + @Override + public String getDescription() { + return "Undeploy application"; + } + + @Override + public String getArgumentSyntax() { + return "[application-id]"; + } + + @Override + public Options getOptions() { + return null; + } + + @Override + public int execute(StratosCommandContext context, String[] args) throws CommandException { + if (logger.isDebugEnabled()) { + logger.debug("Executing command: ", getName()); + } + + if ((args == null) || (args.length <= 0)) { + context.getStratosApplication().printUsage(getName()); + return CliConstants.COMMAND_FAILED; + } + + String applicationId = args[0]; + RestCommandLineService.getInstance().undeployApplication(applicationId); + return CliConstants.COMMAND_SUCCESSFULL; + } +} diff --git a/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceGroupCommand.java b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceGroupCommand.java new file mode 100644 index 0000000000..5b3912495d --- /dev/null +++ b/components/org.apache.stratos.cli/src/main/java/org/apache/stratos/cli/commands/UndeployServiceGroupCommand.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.cli.commands; + +import org.apache.commons.cli.Options; +import org.apache.stratos.cli.Command; +import org.apache.stratos.cli.RestCommandLineService; +import org.apache.stratos.cli.StratosCommandContext; +import org.apache.stratos.cli.exception.CommandException; +import org.apache.stratos.cli.utils.CliConstants; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Un-deploy service group command. + */ +public class UndeployServiceGroupCommand implements Command { + + private static final Logger logger = LoggerFactory.getLogger(UndeployServiceGroupCommand.class); + + public UndeployServiceGroupCommand() { + } + + @Override + public String getName() { + return "undeploy-service-group"; + } + + @Override + public String getDescription() { + return "Undeploy service group"; + } + + @Override + public String getArgumentSyntax() { + return "[service-group-name]"; + } + + @Override + public Options getOptions() { + return null; + } + + @Override + public int execute(StratosCommandContext context, String[] args) throws CommandException { + if (logger.isDebugEnabled()) { + logger.debug("Executing command: ", getName()); + } + + if ((args == null) || (args.length <= 0)) { + context.getStratosApplication().printUsage(getName()); + return CliConstants.COMMAND_FAILED; + } + + String serviceGroupName = args[0]; + RestCommandLineService.getInstance().undeployServiceGroup(serviceGroupName); + return CliConstants.COMMAND_SUCCESSFULL; + } +} From 610c22d2d794badea4f51f6d52fb9b9d88593557 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 17:49:39 +0530 Subject: [PATCH 379/436] fixing an osgi issue in AS component and adding default ctor for ApplicationClusterContextDTO --- components/org.apache.stratos.autoscaler/pom.xml | 1 + .../controller/pojo/ApplicationClusterContextDTO.java | 11 +---------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml index 5ba1ebabcc..7ea4aca237 100644 --- a/components/org.apache.stratos.autoscaler/pom.xml +++ b/components/org.apache.stratos.autoscaler/pom.xml @@ -173,6 +173,7 @@ org.wso2.carbon org.wso2.carbon.ntask.core + provided 4.2.0 diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index 2b601e0d6a..ad15d4c63b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -38,16 +38,7 @@ public class ApplicationClusterContextDTO { // tenant rance private String tenantRange; - public ApplicationClusterContextDTO (String cartridgeType, String clusterId, String hostName, - String textPayload, String deploymentPolicyName, boolean isLbCluster) { - - this.cartridgeType = cartridgeType; - this.clusterId = clusterId; - this.hostName = hostName; - this.textPayload = textPayload; - this.deploymentPolicyName = deploymentPolicyName; - this.isLbCluster = isLbCluster; - this.tenantRange = "*"; + public ApplicationClusterContextDTO () { } public String getClusterId() { From a520063c77986361e10282622a8f2f29534a4472 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 18:05:52 +0530 Subject: [PATCH 380/436] fixing unknown listener issue and setting tenant id when adding and retreiving from registry --- .../AutoscalerTopologyEventReceiver.java | 4 ++-- .../autoscaler/registry/RegistryManager.java | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index dee3e97af6..525c73e368 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -415,7 +415,7 @@ protected void onEvent(Event event) { } });*/ - topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { + /*topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { @Override protected void onEvent(Event event) { @@ -541,7 +541,7 @@ protected void onEvent(Event event) { // releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); // } } - }); + });*/ /*topologyEventReceiver.addEventListener(new ApplicationTerminatingEventListener() { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 5e995dacd2..af2f795ccf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -36,10 +36,12 @@ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; +import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.Registry; 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.utils.multitenancy.MultitenantConstants; import java.util.ArrayList; import java.util.List; @@ -88,7 +90,11 @@ private RegistryManager() { * @param resourcePath resource path to be persisted. */ private void persist(Object dataObj, String resourcePath) throws AutoScalerException { - + PrivilegedCarbonContext ctx = PrivilegedCarbonContext + .getThreadLocalCarbonContext(); + ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + try { registryService.beginTransaction(); @@ -146,6 +152,10 @@ public void persistDeploymentPolicy(DeploymentPolicy deploymentPolicy) { public void persistApplication (Application application) { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext + .getThreadLocalCarbonContext(); + ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + "/" + application.getUniqueIdentifier(); @@ -157,6 +167,11 @@ public void persistApplication (Application application) { } public String [] getApplicationResourcePaths () { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext + .getThreadLocalCarbonContext(); + ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE); From 60429f4964f0b61a55cfa34bd0dd8b896fa0d91c Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 18:18:10 +0530 Subject: [PATCH 381/436] creating super tenant flows when writing/reading to/from registry --- .../autoscaler/registry/RegistryManager.java | 99 +++++++++++++------ 1 file changed, 68 insertions(+), 31 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index af2f795ccf..534d57de7a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -152,57 +152,94 @@ public void persistDeploymentPolicy(DeploymentPolicy deploymentPolicy) { public void persistApplication (Application application) { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext - .getThreadLocalCarbonContext(); - ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); - ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + - "/" + application.getUniqueIdentifier(); - persist(application, resourcePath); - if(log.isDebugEnabled()) { - log.debug("Application [ " + application.getUniqueIdentifier() + - " ] persisted successfully in the Autoscaler Registry"); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + + "/" + application.getUniqueIdentifier(); + persist(application, resourcePath); + if(log.isDebugEnabled()) { + log.debug("Application [ " + application.getUniqueIdentifier() + + " ] persisted successfully in the Autoscaler Registry"); + } + + } finally { + PrivilegedCarbonContext.endTenantFlow(); } } public String [] getApplicationResourcePaths () { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext - .getThreadLocalCarbonContext(); - ctx.setTenantId(MultitenantConstants.SUPER_TENANT_ID); - ctx.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); - Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + - AutoScalerConstants.APPLICATIONS_RESOURCE); + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); - if (obj != null) { - if (obj instanceof String []) { - return (String []) obj; - } else { - log.warn("Expected object type not found for Applications in Registry"); - return null; + Object obj = retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + + AutoScalerConstants.APPLICATIONS_RESOURCE); + + if (obj != null) { + if (obj instanceof String []) { + return (String []) obj; + } else { + log.warn("Expected object type not found for Applications in Registry"); + return null; + } } + + } finally { + PrivilegedCarbonContext.endTenantFlow(); } + return null; } public Application getApplication (String applicationResourcePath) { - Object obj = retrieve(applicationResourcePath); - if (obj != null) { - if (obj instanceof Application) { - return (Application) obj; - } else { - log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry"); - return null; + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + + Object obj = retrieve(applicationResourcePath); + + if (obj != null) { + if (obj instanceof Application) { + return (Application) obj; + } else { + log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry"); + return null; + } } + + } finally { + PrivilegedCarbonContext.endTenantFlow(); } + return null; } public void removeApplication (String applicationId) { - delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + - "/" + applicationId); + + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME); + carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); + + delete(AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + + "/" + applicationId); + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } public void persistServiceGroup(ServiceGroup servicegroup) { From c45a0ab20c99c5a91cba29eab6a18bd50cea8aa8 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 18:19:01 +0530 Subject: [PATCH 382/436] fixing task issue and adding debug logs --- .../main/java/org/apache/stratos/autoscaler/Constants.java | 4 ++-- .../autoscaler/applications/ApplicationSynchronizeTask.java | 4 +++- .../autoscaler/applications/topic/ApplicationBuilder.java | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java index ef7be70cc9..7ca6282718 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/Constants.java @@ -35,8 +35,8 @@ public class Constants { public static final int SCHEDULE_DEFAULT_PERIOD = 15; public static final String APPLICATION_SYNC_CRON = "1 * * * * ? *"; - public static final String APPLICATION_SYNC_TASK_NAME = "TOPOLOGY_SYNC_TASK"; - public static final String APPLICATION_SYNC_TASK_TYPE = "TOPOLOGY_SYNC_TASK_TYPE"; + public static final String APPLICATION_SYNC_TASK_NAME = "APPLICATION_SYNC_TASK"; + public static final String APPLICATION_SYNC_TASK_TYPE = "APPLICATION_SYNC_TASK_TYPE"; public static final String AUTOSCALER_CONFIG_FILE_NAME = "autoscaler.xml"; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java index 22a2805969..4fe942d4ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationSynchronizeTask.java @@ -44,7 +44,9 @@ public void execute() { @Override public void init() { - log.info("Applications Complete Event publisher task has been started..."); + if(log.isDebugEnabled()) { + log.debug("Applications Complete Event publisher task has been started..."); + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 53a8ca463d..0c8455f19d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -155,7 +155,10 @@ public class ApplicationBuilder { }*/ public static synchronized void handleCompleteApplication (Applications applications) { - log.info("Handling complete application"); + if(log.isDebugEnabled()) { + log.debug("Handling complete application"); + } + ApplicationHolder.acquireReadLock(); try { ApplicationsEventPublisher.sendCompleteApplicationsEvent(applications); From 05d5c30dfcbeb734f14c17d328a0a103fafec0b1 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 18:53:44 +0530 Subject: [PATCH 383/436] fixing error while starting app monitor --- .../autoscaler/monitor/ApplicationMonitorFactory.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index f6933101f6..225dea19c2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -24,6 +24,7 @@ import org.apache.stratos.autoscaler.MemberStatsContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; @@ -147,9 +148,9 @@ public static ApplicationMonitor getApplicationMonitor(String appId) throws DependencyBuilderException, TopologyInConsistentException { ApplicationMonitor applicationMonitor; - ApplicationManager.acquireReadLockForApplication(appId); + ApplicationHolder.acquireReadLock(); try { - Application application = ApplicationManager.getApplications().getApplication(appId); + Application application = ApplicationHolder.getApplications().getApplication(appId); if (application != null) { applicationMonitor = new ApplicationMonitor(application); applicationMonitor.setHasDependent(false); @@ -159,7 +160,8 @@ public static ApplicationMonitor getApplicationMonitor(String appId) throw new TopologyInConsistentException(msg); } } finally { - ApplicationManager.releaseReadLockForApplication(appId); + ApplicationHolder.releaseReadLock(); + } return applicationMonitor; From a9025aab6a820dbf66653220da08b9f85fac9f04 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Mon, 3 Nov 2014 19:10:16 +0530 Subject: [PATCH 384/436] Fixing autoscaler service stub bundle exports and stratos manager import statements --- .../AutoScalerServiceInterface.java | 12 +- .../client/AutoscalerServiceClient.java | 9 +- .../deployer/DefaultServiceGroupDeployer.java | 6 +- .../pom.xml | 3 + .../src/main/resources/AutoScalerService.wsdl | 1666 ++++++++--------- 5 files changed, 854 insertions(+), 842 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 74c9c8c2db..0b2bf43e4b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -29,6 +29,7 @@ import org.apache.stratos.autoscaler.exception.InvalidPolicyException; import org.apache.stratos.autoscaler.exception.NonExistingLBException; import org.apache.stratos.autoscaler.partition.PartitionGroup; +import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.Properties; @@ -209,5 +210,14 @@ public boolean updateKubernetesMaster(KubernetesMaster kubernetesMaster) * @param applicationId Id of the Application to be undeployed * @throws ApplicationDefinitionException if an error is encountered */ - public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException; + public void unDeployApplicationDefinition (String applicationId, int tenantId, String tenantDomain) + throws ApplicationDefinitionException; + + + /** + * Get service group by name + * @param name + * @return + */ + public ServiceGroup getServiceGroup(String name); } 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 27c1640924..d2737c6f8b 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 @@ -30,11 +30,8 @@ import org.apache.stratos.autoscaler.stub.kubernetes.KubernetesHost; import org.apache.stratos.autoscaler.stub.kubernetes.KubernetesMaster; import org.apache.stratos.autoscaler.stub.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.stub.*; -import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; +import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; +import org.apache.stratos.autoscaler.pojo.xsd.ServiceGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.internal.DataHolder; @@ -304,4 +301,6 @@ public boolean updateKubernetesHost(KubernetesHost kubernetesHost) public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException, AutoScalerServiceInvalidArgumentExceptionException { stub.updateClusterMonitor(clusterId, properties); } + + } 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 index 7244de402e..fc6e742fa3 100644 --- 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 @@ -22,11 +22,11 @@ import org.apache.axis2.AxisFault; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.stub.pojo.Dependencies; -import org.apache.stratos.autoscaler.stub.pojo.ServiceGroup; +import org.apache.stratos.autoscaler.pojo.xsd.ServiceGroup; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidServiceGroupExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidServiceGroupExceptionException; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +import org.apache.stratos.autoscaler.pojo.xsd.Dependencies; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.exception.ADCException; @@ -276,7 +276,7 @@ private ServiceGroupDefinition populateServiceGroupDefinitionPojo (ServiceGroup String [] cartridges = serviceGroup.getCartridges(); String [] subGroups = serviceGroup.getSubGroups(); - Dependencies deps = serviceGroup.getDependencies(); + org.apache.stratos.autoscaler.pojo.xsd.Dependencies deps = serviceGroup.getDependencies(); if (deps != null) { DependencyDefinitions depsDef = new DependencyDefinitions(); diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index f5966fa677..3478791278 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -91,12 +91,15 @@ ${project.artifactId} org.apache.stratos.autoscaler.stub.*; version=${project.version}, + org.apache.stratos.autoscaler.stub.pojo.*; version=${project.version}, + org.apache.stratos.autoscaler.applications.pojo.xsd.*; version=${project.version}, org.apache.stratos.autoscaler.deployment.policy.*; version=${project.version}, org.apache.stratos.autoscaler.policy.model.*; version=${project.version}, org.apache.stratos.autoscaler.exception.*; version=${project.version}, org.apache.stratos.autoscaler.partition.*; version=${project.version}, org.apache.stratos.autoscaler.api.*; version=${project.version}, org.apache.stratos.autoscaler.kubernetes.*; version=${project.version}, + org.apache.stratos.autoscaler.pojo.xsd.*; version=${project.version}, diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index 647c56048b..732fe38676 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,2440 +1,2440 @@ - + AutoScalerService - - - + + + - - - - - - + + + + + + - - - - - - - + + + + + + + - - - + + + - - + + - - - - - - + + + + + + - - + + - - - - - - - - + + + + + + + + - - - - + + + + - - + + - - - - - - + + + + + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + + + + + + + + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - - + + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + + + - - - - - - + - + - + - + - + - + - + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + \ No newline at end of file From 148fac56fb8d83793f7d18201fac80e8a69313c1 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 23:08:05 +0530 Subject: [PATCH 385/436] fixing registry serializing issue --- .../autoscaler/registry/RegistryManager.java | 236 +++++++++--------- 1 file changed, 124 insertions(+), 112 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 534d57de7a..93f26752e4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -35,7 +35,6 @@ import org.apache.stratos.autoscaler.util.ServiceReferenceHolder; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.Applications; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.Registry; import org.wso2.carbon.registry.core.Resource; @@ -48,10 +47,25 @@ public class RegistryManager { - private final static Log log = LogFactory.getLog(RegistryManager.class); + private final static Log log = LogFactory.getLog(RegistryManager.class); private static Registry registryService; private static RegistryManager registryManager; + private RegistryManager() { + try { + if (!registryService.resourceExists(AutoScalerConstants.AUTOSCALER_RESOURCE)) { + registryService.put(AutoScalerConstants.AUTOSCALER_RESOURCE, + registryService.newCollection()); + } + } catch (RegistryException e) { + String msg = + "Failed to create the registry resource " + + AutoScalerConstants.AUTOSCALER_RESOURCE; + log.error(msg, e); + throw new AutoScalerException(msg, e); + } + } + public static RegistryManager getInstance() { registryService = ServiceReferenceHolder.getInstance().getRegistry(); @@ -67,26 +81,11 @@ public static RegistryManager getInstance() { } return registryManager; } - - private RegistryManager() { - try { - if (!registryService.resourceExists(AutoScalerConstants.AUTOSCALER_RESOURCE)) { - registryService.put(AutoScalerConstants.AUTOSCALER_RESOURCE, - registryService.newCollection()); - } - } catch (RegistryException e) { - String msg = - "Failed to create the registry resource " + - AutoScalerConstants.AUTOSCALER_RESOURCE; - log.error(msg, e); - throw new AutoScalerException(msg, e); - } - } - + /** * Persist an object in the local registry. * - * @param dataObj object to be persisted. + * @param dataObj object to be persisted. * @param resourcePath resource path to be persisted. */ private void persist(Object dataObj, String resourcePath) throws AutoScalerException { @@ -99,15 +98,15 @@ private void persist(Object dataObj, String resourcePath) throws AutoScalerExcep registryService.beginTransaction(); Resource nodeResource = registryService.newResource(); - nodeResource.setContent(Serializer.serializeToByteArray(dataObj)); - + nodeResource.setContent(Serializer.serializeToByteArray(dataObj)); + registryService.put(resourcePath, nodeResource); registryService.commitTransaction(); } catch (Exception e) { try { registryService.rollbackTransaction(); } catch (RegistryException e1) { - if(log.isErrorEnabled()) { + if (log.isErrorEnabled()) { log.error("Could not rollback transaction", e); } } @@ -116,27 +115,27 @@ private void persist(Object dataObj, String resourcePath) throws AutoScalerExcep } public void persistPartition(Partition partition) { - String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.PARTITION_RESOURCE + "/"+partition.getId(); + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.PARTITION_RESOURCE + "/" + partition.getId(); persist(partition, resourcePath); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("Partition written to registry: [id] %s [provider] %s [min] %d [max] %d", partition.getId(), partition.getProvider(), partition.getPartitionMin(), partition.getPartitionMax())); } } - + public void persistNetworkPartitionIbHolder(NetworkPartitionLbHolder nwPartitionLbHolder) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants - .NETWORK_PARTITION_LB_HOLDER_RESOURCE + "/"+nwPartitionLbHolder.getNetworkPartitionId(); + .NETWORK_PARTITION_LB_HOLDER_RESOURCE + "/" + nwPartitionLbHolder.getNetworkPartitionId(); persist(nwPartitionLbHolder, resourcePath); - if(log.isDebugEnabled()) { - log.debug("NetworkPartitionContext written to registry: "+nwPartitionLbHolder.toString()); + if (log.isDebugEnabled()) { + log.debug("NetworkPartitionContext written to registry: " + nwPartitionLbHolder.toString()); } } public void persistAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId(); persist(autoscalePolicy, resourcePath); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("Autoscaler policy written to registry: [id] %s [name] %s [description] %s", autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription())); } @@ -145,13 +144,13 @@ public void persistAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { public void persistDeploymentPolicy(DeploymentPolicy deploymentPolicy) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE + "/" + deploymentPolicy.getId(); persist(deploymentPolicy, resourcePath); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(deploymentPolicy.toString()); } } - public void persistApplication (Application application) { + public void persistApplication(Application application) { try { PrivilegedCarbonContext.startTenantFlow(); @@ -162,7 +161,7 @@ public void persistApplication (Application application) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.APPLICATIONS_RESOURCE + "/" + application.getUniqueIdentifier(); persist(application, resourcePath); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("Application [ " + application.getUniqueIdentifier() + " ] persisted successfully in the Autoscaler Registry"); } @@ -172,7 +171,7 @@ public void persistApplication (Application application) { } } - public String [] getApplicationResourcePaths () { + public String[] getApplicationResourcePaths() { try { PrivilegedCarbonContext.startTenantFlow(); @@ -184,8 +183,8 @@ public void persistApplication (Application application) { AutoScalerConstants.APPLICATIONS_RESOURCE); if (obj != null) { - if (obj instanceof String []) { - return (String []) obj; + if (obj instanceof String[]) { + return (String[]) obj; } else { log.warn("Expected object type not found for Applications in Registry"); return null; @@ -199,7 +198,7 @@ public void persistApplication (Application application) { return null; } - public Application getApplication (String applicationResourcePath) { + public Application getApplication(String applicationResourcePath) { try { PrivilegedCarbonContext.startTenantFlow(); @@ -208,15 +207,28 @@ public Application getApplication (String applicationResourcePath) { carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID); Object obj = retrieve(applicationResourcePath); - if (obj != null) { + try { + Object dataObj = Deserializer + .deserializeFromByteArray((byte[]) obj); + if (dataObj instanceof Application) { + return (Application) dataObj; + } else { + return null; + } + } catch (Exception e) { + String msg = "Unable to retrieve data from Registry. Hence, any historical data will not get reflected."; + log.warn(msg, e); + } + } + /*if (obj != null) { if (obj instanceof Application) { return (Application) obj; } else { log.warn("Expected object type not found for Application " + applicationResourcePath + " in Registry"); return null; } - } + }*/ } finally { PrivilegedCarbonContext.endTenantFlow(); @@ -225,7 +237,7 @@ public Application getApplication (String applicationResourcePath) { return null; } - public void removeApplication (String applicationId) { + public void removeApplication(String applicationId) { try { PrivilegedCarbonContext.startTenantFlow(); @@ -243,21 +255,21 @@ public void removeApplication (String applicationId) { } public void persistServiceGroup(ServiceGroup servicegroup) { - if(servicegroup == null || StringUtils.isEmpty(servicegroup.getName())){ - throw new IllegalArgumentException("Service group or group name can not be null"); + if (servicegroup == null || StringUtils.isEmpty(servicegroup.getName())) { + throw new IllegalArgumentException("Service group or group name can not be null"); } String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + servicegroup.getName(); persist(servicegroup, resourcePath); - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("Persisted service group %s at path %s", servicegroup.getName(), resourcePath)); } } - public boolean serviceGroupExist(String serviceGroupName){ + public boolean serviceGroupExist(String serviceGroupName) { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + serviceGroupName; return this.resourceExist(resourcePath); } - + private Object retrieve(String resourcePath) { try { Resource resource = registryService.get(resourcePath); @@ -272,8 +284,8 @@ private Object retrieve(String resourcePath) { } } - private boolean resourceExist(String resourcePath){ - return this.retrieve(resourcePath) != null; + private boolean resourceExist(String resourcePath) { + return this.retrieve(resourcePath) != null; } public List retrievePartitions() { @@ -291,7 +303,7 @@ public List retrievePartitions() { Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); if (dataObj instanceof Partition) { partition = (Partition) dataObj; - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("Partition read from registry: [id] %s [provider] %s [min] %d [max] %d", partition.getId(), partition.getProvider(), partition.getPartitionMin(), partition.getPartitionMax())); } @@ -308,12 +320,12 @@ public List retrievePartitions() { } return partitionList; } - + public List retrieveNetworkPartitionLbHolders() { List nwPartitionLbHolderList = new ArrayList(); RegistryManager registryManager = RegistryManager.getInstance(); - String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + - AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE); + String[] partitionsResourceList = (String[]) registryManager.retrieve(AutoScalerConstants.AUTOSCALER_RESOURCE + + AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE); if (partitionsResourceList != null) { NetworkPartitionLbHolder nwPartitionLbHolder; @@ -325,7 +337,7 @@ public List retrieveNetworkPartitionLbHolders() { Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); if (dataObj instanceof NetworkPartitionLbHolder) { nwPartitionLbHolder = (NetworkPartitionLbHolder) dataObj; - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("NetworkPartitionLbHolder read from registry: " + nwPartitionLbHolder.toString())); } nwPartitionLbHolderList.add(nwPartitionLbHolder); @@ -356,7 +368,7 @@ public List retrieveASPolicies() { Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); if (dataObj instanceof AutoscalePolicy) { asPolicy = (AutoscalePolicy) dataObj; - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(String.format("Autoscaler policy read from registry: [id] %s [name] %s [description] %s", asPolicy.getId(), asPolicy.getDisplayName(), asPolicy.getDescription())); } @@ -388,7 +400,7 @@ public List retrieveDeploymentPolicies() { Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); if (dataObj instanceof DeploymentPolicy) { depPolicy = (DeploymentPolicy) dataObj; - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(depPolicy.toString()); } depPolicyList.add(depPolicy); @@ -405,36 +417,36 @@ public List retrieveDeploymentPolicies() { return depPolicyList; } - public ServiceGroup getServiceGroup(String name) throws Exception{ + public ServiceGroup getServiceGroup(String name) throws Exception { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.SERVICE_GROUP + "/" + name; Object serializedObj = registryManager.retrieve(resourcePath); ServiceGroup group = null; if (serializedObj != null) { - Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); - if (dataObj instanceof ServiceGroup) { - group = (ServiceGroup) dataObj; - if(log.isDebugEnabled()) { - log.debug(group.toString()); - } - } else { - return null; + Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); + if (dataObj instanceof ServiceGroup) { + group = (ServiceGroup) dataObj; + if (log.isDebugEnabled()) { + log.debug(group.toString()); } + } else { + return null; + } } return group; } - public ServiceGroup removeServiceGroup(String name) throws Exception{ + public ServiceGroup removeServiceGroup(String name) throws Exception { String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + - AutoScalerConstants.SERVICE_GROUP + "/" + name; + AutoScalerConstants.SERVICE_GROUP + "/" + name; Object serializedObj = registryManager.retrieve(resourcePath); ServiceGroup group = null; if (serializedObj != null) { Object dataObj = Deserializer.deserializeFromByteArray((byte[]) serializedObj); if (dataObj instanceof ServiceGroup) { group = (ServiceGroup) dataObj; - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(group.toString()); } } else { @@ -445,51 +457,51 @@ public ServiceGroup removeServiceGroup(String name) throws Exception{ return group; } - public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { - String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId(); - this.delete(resourcePath); - if(log.isDebugEnabled()) { - log.debug(String.format("Autoscaler policy deleted from registry: [id] %s [name] %s [description] %s", - autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription())); - } - - } - - public void removeDeploymentPolicy(DeploymentPolicy depPolicy){ - String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE; - this.delete(resourcePath); - if(log.isDebugEnabled()) { - log.debug(String.format("Deployment policy deleted from registry: [id] %s" , - depPolicy.getId())); - } - } - - public void removeNetworkPartition(String networkPartition){ - String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE; - this.delete(resourcePath); - if(log.isDebugEnabled()) { - log.debug(String.format("Network partition deleted from registry: [id] %s" , - networkPartition)); - } - } - - - private void delete(String resourcePath) { - try { - registryService.beginTransaction(); - registryService.delete(resourcePath); - registryService.commitTransaction(); - } catch (RegistryException e) { - try { - registryService.rollbackTransaction(); - } catch (RegistryException e1) { - if(log.isErrorEnabled()) { - log.error("Could not rollback transaction", e); - } - } - log.error("Could not delete resource at "+ resourcePath); - throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e); - } - - } + public void removeAutoscalerPolicy(AutoscalePolicy autoscalePolicy) { + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.AS_POLICY_RESOURCE + "/" + autoscalePolicy.getId(); + this.delete(resourcePath); + if (log.isDebugEnabled()) { + log.debug(String.format("Autoscaler policy deleted from registry: [id] %s [name] %s [description] %s", + autoscalePolicy.getId(), autoscalePolicy.getDisplayName(), autoscalePolicy.getDescription())); + } + + } + + public void removeDeploymentPolicy(DeploymentPolicy depPolicy) { + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.DEPLOYMENT_POLICY_RESOURCE; + this.delete(resourcePath); + if (log.isDebugEnabled()) { + log.debug(String.format("Deployment policy deleted from registry: [id] %s", + depPolicy.getId())); + } + } + + public void removeNetworkPartition(String networkPartition) { + String resourcePath = AutoScalerConstants.AUTOSCALER_RESOURCE + AutoScalerConstants.NETWORK_PARTITION_LB_HOLDER_RESOURCE; + this.delete(resourcePath); + if (log.isDebugEnabled()) { + log.debug(String.format("Network partition deleted from registry: [id] %s", + networkPartition)); + } + } + + + private void delete(String resourcePath) { + try { + registryService.beginTransaction(); + registryService.delete(resourcePath); + registryService.commitTransaction(); + } catch (RegistryException e) { + try { + registryService.rollbackTransaction(); + } catch (RegistryException e1) { + if (log.isErrorEnabled()) { + log.error("Could not rollback transaction", e); + } + } + log.error("Could not delete resource at " + resourcePath); + throw new AutoScalerException("Could not delete data in registry at " + resourcePath, e); + } + + } } From 93b0e165c4ddeb2334025cd5e4eefc3062c530ac Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 23:28:30 +0530 Subject: [PATCH 386/436] using ApplicationHolder instead of ApplicationManager in autoscaler since it is the publisher to applications topic --- .../topic/ApplicationsEventPublisher.java | 214 ++++-------------- .../monitor/ApplicationMonitorFactory.java | 7 +- .../status/checker/StatusChecker.java | 43 ++-- 3 files changed, 75 insertions(+), 189 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index 7ca224e6b8..66a35e7478 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -35,98 +35,46 @@ public static void sendApplicationUndeployedEvent (String appId, Set clusterData) { - try { - ApplicationManager.acquireReadLockForApplication(appId); - Application application = ApplicationManager.getApplications().getApplication(appId); - if (application != null) { - if (application.isStateTransitionValid(ApplicationStatus.Terminated)) { - if (log.isInfoEnabled()) { - log.info("Publishing Application terminated event for [application]: " + appId); - } - ApplicationTerminatedEvent applicationTerminatedEvent = - new ApplicationTerminatedEvent(appId, clusterData); - publishEvent(applicationTerminatedEvent); - } else { - log.warn("Terminated is not in the possible state list of [application] " + appId); - } - } - } finally { - ApplicationManager.releaseReadLockForApplication(appId); + if (log.isInfoEnabled()) { + log.info("Publishing Application terminated event for [application]: " + appId); } + ApplicationTerminatedEvent applicationTerminatedEvent = + new ApplicationTerminatedEvent(appId, clusterData); + publishEvent(applicationTerminatedEvent); } public static void publishEvent(Event event) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java index 225dea19c2..fbd446ed7d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ApplicationMonitorFactory.java @@ -104,10 +104,11 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Appl throws DependencyBuilderException, TopologyInConsistentException { GroupMonitor groupMonitor; - ApplicationManager.acquireReadLockForApplication(appId); + ApplicationHolder.acquireReadLock(); try { - Group group = ApplicationManager.getApplications().getApplication(appId).getGroupRecursively(context.getId()); + Group group = ApplicationHolder.getApplications(). + getApplication(appId).getGroupRecursively(context.getId()); groupMonitor = new GroupMonitor(group, appId); groupMonitor.setAppId(appId); if(parentMonitor != null) { @@ -128,7 +129,7 @@ public static Monitor getGroupMonitor(ParentComponentMonitor parentMonitor, Appl } } finally { - ApplicationManager.releaseReadLockForApplication(appId); + ApplicationHolder.releaseReadLock(); } return groupMonitor; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 35864207eb..87e4d6773f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -23,14 +23,15 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; +import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; -import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor; import org.apache.stratos.messaging.domain.applications.*; -import org.apache.stratos.messaging.domain.topology.*; -import org.apache.stratos.messaging.message.receiver.applications.ApplicationManager; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import java.util.Map; @@ -99,8 +100,8 @@ public void run() { if (cluster != null) { try { - ApplicationManager.acquireReadLockForApplication(appId); - Application application = ApplicationManager.getApplications().getApplication(appId); + ApplicationHolder.acquireReadLock(); + Application application = ApplicationHolder.getApplications().getApplication(appId); if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { if (application.getStatus() == ApplicationStatus.Terminating) { @@ -124,7 +125,7 @@ public void run() { }*/ } } finally { - ApplicationManager.releaseReadLockForApplication(appId); + ApplicationHolder.releaseReadLock(); } } } @@ -234,22 +235,22 @@ private void updateChild(final String idOfChild, final String groupId, final Str Runnable group = new Runnable() { public void run() { try { - ApplicationManager.acquireReadLockForApplication(appId); + ApplicationHolder.acquireReadLock(); ParentComponent component; if (groupId.equals(appId)) { //it is an application - component = ApplicationManager.getApplications(). + component = ApplicationHolder.getApplications(). getApplication(appId); } else { //it is a group - component = ApplicationManager.getApplications(). + component = ApplicationHolder.getApplications(). getApplication(appId).getGroupRecursively(groupId); } Map clusterIds = component.getClusterDataMap(); Map groups = component.getAliasToGroupMap(); updateChildStatus(appId, idOfChild, groups, clusterIds, component); } finally { - ApplicationManager.releaseReadLockForApplication(appId); + ApplicationHolder.releaseReadLock(); } @@ -287,12 +288,12 @@ private boolean updateChildStatus(String appId, String id, Map gr clusterStatus = getClusterStatus(clusterData); groupStatus = getGroupStatus(groups); try { - ApplicationManager.acquireReadLockForApplication(appId); - Application application = ApplicationManager.getApplications().getApplication(appId); + ApplicationHolder.acquireReadLock(); + Application application = ApplicationHolder.getApplications().getApplication(appId); - if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Active) || + if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Active) || clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Active) || - getAllClusterInSameState(clusterData,ClusterStatus.Active) && + getAllClusterInSameState(clusterData, ClusterStatus.Active) && getAllGroupInSameState(groups, GroupStatus.Active)) { //send activation event if (parent instanceof Application) { @@ -324,9 +325,9 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("sending group created : " + parent.getUniqueIdentifier()); ApplicationBuilder.handleGroupTerminatedEvent(appId, parent.getUniqueIdentifier()); } - } else if (groups.isEmpty() && getAllClusterInSameState(clusterData,ClusterStatus.Created) || + } else if (groups.isEmpty() && getAllClusterInSameState(clusterData, ClusterStatus.Created) || clusterData.isEmpty() && getAllGroupInSameState(groups, GroupStatus.Created) || - getAllClusterInSameState(clusterData,ClusterStatus.Created) && + getAllClusterInSameState(clusterData, ClusterStatus.Created) && getAllGroupInSameState(groups, GroupStatus.Created)) { if (parent instanceof Application) { log.info("[Application] " + appId + "couldn't change to Created, since it is" + @@ -353,7 +354,7 @@ private boolean updateChildStatus(String appId, String id, Map gr log.warn("Clusters/groups not found in this [component] " + appId); } } finally { - ApplicationManager.releaseReadLockForApplication(appId); + ApplicationHolder.releaseReadLock(); } @@ -452,7 +453,7 @@ private GroupStatus getGroupStatus(Map groups) { } } - if(groups == null || groups != null && groups.isEmpty()) { + if (groups == null || groups != null && groups.isEmpty()) { groupActive = false; groupTerminated = false; groupCreated = false; @@ -462,7 +463,7 @@ private GroupStatus getGroupStatus(Map groups) { status = GroupStatus.Active; } else if (groupTerminated) { status = GroupStatus.Terminated; - } else if(groupCreated) { + } else if (groupCreated) { status = GroupStatus.Created; } return status; @@ -498,7 +499,7 @@ private ClusterStatus getClusterStatus(Map clusterDat } } - if(clusterData == null || clusterData != null && clusterData.isEmpty()) { + if (clusterData == null || clusterData != null && clusterData.isEmpty()) { clusterActive = false; clusterTerminated = false; clusterCreated = false; @@ -508,7 +509,7 @@ private ClusterStatus getClusterStatus(Map clusterDat status = ClusterStatus.Active; } else if (clusterTerminated) { status = ClusterStatus.Terminated; - } else if(clusterCreated) { + } else if (clusterCreated) { status = ClusterStatus.Created; } return status; From fcbb662dfff53daed37bc9244ba21e4b702e323d Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 07:24:12 +0530 Subject: [PATCH 387/436] Moving properties domain classes to stratos.common module --- .../autoscaler/api/AutoScalerServiceImpl.java | 2 +- .../applications/ApplicationUtils.java | 2 +- .../applications/pojo/ApplicationContext.java | 12 + .../controller/CloudControllerClient.java | 4 +- .../AutoScalerServiceInterface.java | 2 +- .../ApplicationMonitorFactory.java | 4 +- .../cluster/AbstractClusterMonitor.java | 2 +- .../cluster/ClusterMonitorFactory.java | 4 +- .../KubernetesServiceClusterMonitor.java | 4 +- .../monitor/cluster/VMClusterMonitor.java | 2 +- .../cluster/VMServiceClusterMonitor.java | 4 +- .../autoscaler/partition/PartitionGroup.java | 1 - .../partition/deployers/PartitionReader.java | 2 +- .../deployers/DeploymentPolicyReader.java | 2 +- .../autoscaler/util/AutoscalerUtil.java | 8 +- .../deployment/partition/Partition.java | 4 +- ...erClusterContextToKubernetesContainer.java | 5 +- .../impl/CloudControllerServiceImpl.java | 7 +- .../pojo/ApplicationClusterContext.java | 2 + .../controller/pojo/CartridgeConfig.java | 2 + .../cloud/controller/pojo/CartridgeInfo.java | 1 + .../pojo/ContainerClusterContext.java | 2 + .../cloud/controller/pojo/IaasConfig.java | 4 +- .../controller/pojo/LoadbalancerConfig.java | 5 +- .../cloud/controller/pojo/MemberContext.java | 2 + .../cloud/controller/pojo/Properties.java | 52 -- .../cloud/controller/pojo/Property.java | 62 --- .../cloud/controller/pojo/Registrant.java | 2 + .../controller/util/CloudControllerUtil.java | 19 +- .../common/{kubernetes => }/Properties.java | 2 +- .../common/{kubernetes => }/Property.java | 2 +- .../common/kubernetes/KubernetesGroup.java | 2 + .../common/kubernetes/KubernetesHost.java | 1 + .../behaviour/CartridgeMgtBehaviour.java | 4 +- .../client/AutoscalerServiceClient.java | 7 +- .../client/CloudControllerServiceClient.java | 12 +- .../manager/deploy/service/Service.java | 2 +- .../service/ServiceDeploymentManager.java | 4 +- .../multitenant/lb/DefaultLBService.java | 2 +- .../multitenant/lb/ExistingLBService.java | 2 +- .../service/multitenant/lb/LBService.java | 2 +- .../multitenant/lb/MultiTenantLBService.java | 2 +- .../multitenant/lb/ServiceAwareLBService.java | 2 +- .../category/DefaultLoadBalancerCategory.java | 2 +- .../ExistingLoadBalancerCategory.java | 2 +- .../manager/lb/category/LBDataContext.java | 4 +- .../ServiceLevelLoadBalancerCategory.java | 2 +- .../manager/CartridgeSubscriptionManager.java | 4 +- .../subscription/CartridgeSubscription.java | 2 +- .../DataCartridgeSubscription.java | 2 +- .../subscription/LBCartridgeSubscription.java | 2 +- .../subscription/PersistenceContext.java | 2 +- .../subscription/SubscriptionData.java | 4 +- .../filter/LBCreationSubscriptionFilter.java | 4 +- .../filter/SubscriptionFilter.java | 2 +- .../SubscriptionMultiTenantBehaviour.java | 2 +- .../utils/CartridgeSubscriptionUtils.java | 3 +- .../utils/ApplicationManagementUtil.java | 4 +- .../bean/util/converter/PojoConverter.java | 94 ++-- .../rest/endpoint/services/ServiceUtils.java | 31 +- .../src/main/resources/AutoScalerService.wsdl | 153 +++--- .../resources/CloudControllerService.wsdl | 487 ++++++------------ 62 files changed, 425 insertions(+), 651 deletions(-) delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java delete mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/{kubernetes => }/Properties.java (98%) rename components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/{kubernetes => }/Property.java (98%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index fda23ca4db..4476b1a264 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -41,7 +41,7 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java index e82882c6ca..0886353e3e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.PortMapping; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Property; import java.util.*; import java.util.regex.Pattern; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java index 5d97ad5e62..5916a6ef5d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java @@ -19,6 +19,8 @@ package org.apache.stratos.autoscaler.applications.pojo; +import org.apache.stratos.common.Properties; + import java.io.Serializable; public class ApplicationContext implements Serializable { @@ -39,6 +41,8 @@ public class ApplicationContext implements Serializable { private SubscribableInfoContext[] subscribableInfoContexts; + private Properties properties; + public ApplicationContext() { } @@ -97,4 +101,12 @@ public String getTeantAdminUsername() { public void setTeantAdminUsername(String teantAdminUsername) { this.teantAdminUsername = teantAdminUsername; } + + public Properties getProperties() { + return properties; + } + + public void setProperties(Properties properties) { + this.properties = properties; + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 6f90516f67..c023ff4c00 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -46,8 +46,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.ContainerClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesMaster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 0b2bf43e4b..8dbf20fdf2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -32,7 +32,7 @@ import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java index 66891d03d1..d8d8514086 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java @@ -35,8 +35,8 @@ import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.topology.Cluster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index fa9736e372..f8e81b8748 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -31,7 +31,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index d2f45f783f..8c99d99ae2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -39,9 +39,9 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.common.constants.StratosConstants; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Member; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java index 1f17daab90..324da34c53 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java @@ -29,8 +29,8 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 19d3704c30..cd617ee2f0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -33,7 +33,7 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index cc351de2f6..a8b9329379 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -35,8 +35,8 @@ import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.GroupStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java index eb015522cc..8f959d1c30 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionGroup.java @@ -23,7 +23,6 @@ import java.util.Arrays; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; /** * The model class for PartitionGroup definition. diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java index 42fd33b378..85956cfbed 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java @@ -35,7 +35,7 @@ import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.jaxen.JaxenException; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java index 735758df03..704feaf1a9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java @@ -35,7 +35,7 @@ import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.autoscaler.util.AutoscalerUtil; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; /** * diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index 93aa988cf5..f9eea5ac7e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -28,16 +28,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.registry.RegistryManager; -import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; -import javax.xml.namespace.QName; -import java.util.*; - /** * This class contains utility methods used by Autoscaler. */ diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java index 2376fd9803..940bdea490 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/deployment/partition/Partition.java @@ -19,9 +19,9 @@ package org.apache.stratos.cloud.controller.deployment.partition; -import java.io.Serializable; +import org.apache.stratos.common.Properties; -import org.apache.stratos.cloud.controller.pojo.Properties; +import java.io.Serializable; /** * The model class for Partition definition. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java index 8837406ed5..cda9a89264 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java @@ -27,9 +27,10 @@ import org.apache.stratos.cloud.controller.pojo.ClusterContext; import org.apache.stratos.cloud.controller.pojo.ContainerClusterContext; import org.apache.stratos.cloud.controller.pojo.PortMapping; -import org.apache.stratos.cloud.controller.pojo.Property; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; import org.apache.stratos.cloud.controller.util.CloudControllerUtil; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.kubernetes.client.model.Container; import org.apache.stratos.kubernetes.client.model.EnvironmentVariable; @@ -102,7 +103,7 @@ private EnvironmentVariable[] getEnvironmentVars(ContainerClusterContext memberC addToEnvironment(envVars, ctxt.getPayload()); addToEnvironment(envVars, StratosConstants.KUBERNETES_CLUSTER_ID, kubernetesClusterId); if (memberCtxt.getProperties() != null) { - org.apache.stratos.cloud.controller.pojo.Properties props1 = memberCtxt.getProperties(); + Properties props1 = memberCtxt.getProperties(); if (props1 != null) { for (Property prop : props1.getProperties()) { addToEnvironment(envVars, prop.getName(), prop.getValue()); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 04e365aa4c..b38cf85337 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -46,6 +46,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.util.PodActivationWatcher; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; +import org.apache.stratos.common.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.kubernetes.client.KubernetesApiClient; import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException; @@ -452,9 +453,9 @@ public MemberContext startInstance(MemberContext memberContext) throws addToPayload(payload, "NETWORK_PARTITION_ID", memberContext.getNetworkPartitionId()); addToPayload(payload, "PARTITION_ID", partitionId); if(memberContext.getProperties() != null) { - org.apache.stratos.cloud.controller.pojo.Properties props1 = memberContext.getProperties(); - if (props1 != null) { - for (Property prop : props1.getProperties()) { + org.apache.stratos.common.Properties properties = memberContext.getProperties(); + if (properties != null) { + for (Property prop : properties.getProperties()) { addToPayload(payload, prop.getName(), prop.getValue()); } } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java index fb52ece60e..0bf3f0fed2 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContext.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.common.Properties; + import java.io.Serializable; public class ApplicationClusterContext implements Serializable { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java index 51e571ef80..91b3b065e9 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeConfig.java @@ -22,6 +22,8 @@ import java.io.Serializable; import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; /** * This class is used as the pojo for supporting the service at CC, diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeInfo.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeInfo.java index 58cb366efc..dd121ab760 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeInfo.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/CartridgeInfo.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Property; /** * Holds useful information for externals, regarding a Cartridge. diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ContainerClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ContainerClusterContext.java index 137488a2f8..6396c3f44b 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ContainerClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ContainerClusterContext.java @@ -18,6 +18,8 @@ */ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.common.Properties; + import java.io.Serializable; /** diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java index 0937c81e99..1a181b6599 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/IaasConfig.java @@ -22,6 +22,8 @@ import java.io.Serializable; import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; /** * This class is used to support CartridgeConfig @@ -145,7 +147,7 @@ private String getIaasProperties () { StringBuilder iaasPropertyBuilder = new StringBuilder(); if (properties != null) { - Property [] propertyArray = properties.getProperties(); + Property[] propertyArray = properties.getProperties(); if(propertyArray.length > 0) { for (Property property : propertyArray) { iaasPropertyBuilder.append(property.toString() + " | "); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LoadbalancerConfig.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LoadbalancerConfig.java index 18810b85d3..79df8f7aec 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LoadbalancerConfig.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/LoadbalancerConfig.java @@ -19,6 +19,9 @@ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; + import java.io.Serializable; /** @@ -58,7 +61,7 @@ private String getIaasProperties () { StringBuilder iaasPropertyBuilder = new StringBuilder(); if (properties != null) { - Property [] propertyArray = properties.getProperties(); + Property[] propertyArray = properties.getProperties(); if(propertyArray.length > 0) { for (Property property : propertyArray) { iaasPropertyBuilder.append(property.toString() + " | "); diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java index 72b4914416..a2a7d4bdef 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/MemberContext.java @@ -19,6 +19,8 @@ package org.apache.stratos.cloud.controller.pojo; import org.apache.stratos.cloud.controller.deployment.partition.Partition; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import java.io.Serializable; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.java deleted file mode 100644 index 38ec5fbfc3..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Properties.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.cloud.controller.pojo; - -import java.io.Serializable; -import java.util.Arrays; - -import org.apache.commons.lang3.ArrayUtils; - -/** - * Had to wrap {@link Property} array using a class, since there's a bug in current - * stub generation. - */ -public class Properties implements Serializable{ - - private static final long serialVersionUID = 1986895299288322592L; - private Property[] properties; - - public Property[] getProperties() { - return properties; - } - - public void setProperties(Property[] properties) { - if(properties == null) { - this.properties = new Property[0]; - } else { - this.properties = Arrays.copyOf(properties, properties.length); - } - } - - @Override - public String toString() { - return "Properties [properties=" + Arrays.toString(properties) + "]"; - } - -} \ No newline at end of file diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.java deleted file mode 100644 index e6de83d5e6..0000000000 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Property.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.cloud.controller.pojo; - -import java.io.Serializable; - -/** - * Holds a property - */ -public class Property implements Serializable{ - - private static final long serialVersionUID = -2191782657999410197L; - private String name; - private String value; - - public Property(){ - - } - - public Property(String name, String value){ - this.setName(name); - this.setValue(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; - } - - @Override - public String toString() { - return "Property [name=" + name + ", value=" + value + "]"; - } - -} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java index 2c3458a0ed..d18e695f25 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/Registrant.java @@ -18,6 +18,8 @@ */ package org.apache.stratos.cloud.controller.pojo; +import org.apache.stratos.common.Properties; + /** * Upon a new subscription, Stratos Manager would send this POJO. * @author nirmal diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java index 5cea0b7ae9..11d432b74a 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java @@ -30,6 +30,7 @@ import org.apache.stratos.cloud.controller.pojo.*; import org.apache.stratos.cloud.controller.registry.RegistryManager; import org.apache.stratos.cloud.controller.runtime.FasterLookUpDataHolder; +import org.apache.stratos.common.Property; import org.apache.stratos.messaging.domain.topology.Topology; import org.wso2.carbon.registry.core.exceptions.RegistryException; @@ -77,7 +78,7 @@ public static Cartridge toCartridge(CartridgeConfig config) { cartridge.setDefaultDeploymentPolicy(config.getDefaultDeploymentPolicy()); cartridge.setServiceGroup(config.getServiceGroup()); cartridge.setDeployerType(config.getDeployerType()); - org.apache.stratos.cloud.controller.pojo.Properties props = config.getProperties(); + org.apache.stratos.common.Properties props = config.getProperties(); if (props != null) { for (Property prop : props.getProperties()) { cartridge.addProperty(prop.getName(), prop.getValue()); @@ -144,7 +145,7 @@ public static Cartridge toCartridge(CartridgeConfig config) { iaasProvider.setPayload(payload); } - org.apache.stratos.cloud.controller.pojo.Properties props1 = + org.apache.stratos.common.Properties props1 = iaasConfig.getProperties(); if (props1 != null) { for (Property prop : props1.getProperties()) { @@ -310,20 +311,20 @@ public static String getProperty(Properties properties, String key) { return null; } - public static String getProperty(org.apache.stratos.cloud.controller.pojo.Properties properties, String key) { + public static String getProperty(org.apache.stratos.common.Properties properties, String key) { Properties props = toJavaUtilProperties(properties); return getProperty(props, key); } - public static org.apache.stratos.cloud.controller.pojo.Properties addProperty( - org.apache.stratos.cloud.controller.pojo.Properties properties, String key, String value) { + public static org.apache.stratos.common.Properties addProperty( + org.apache.stratos.common.Properties properties, String key, String value) { Property property = new Property(); property.setName(key); property.setValue(value); - org.apache.stratos.cloud.controller.pojo.Properties newProperties = - new org.apache.stratos.cloud.controller.pojo.Properties(); + org.apache.stratos.common.Properties newProperties = + new org.apache.stratos.common.Properties(); newProperties.setProperties(ArrayUtils.add(properties.getProperties(), property)); return newProperties; } @@ -334,12 +335,12 @@ public static org.apache.stratos.cloud.controller.pojo.Properties addProperty( * @return java.util.Properties */ public static Properties toJavaUtilProperties( - org.apache.stratos.cloud.controller.pojo.Properties properties) { + org.apache.stratos.common.Properties properties) { Properties javaProps = new Properties(); if (properties != null && properties.getProperties() != null) { - for (org.apache.stratos.cloud.controller.pojo.Property property : properties.getProperties()) { + for (Property property : properties.getProperties()) { if(property.getValue() != null){ javaProps.put(property.getName(), property.getValue()); } diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Properties.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java similarity index 98% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Properties.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java index 146f6cab51..25fea6e4c6 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Properties.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.common.kubernetes; +package org.apache.stratos.common; import java.io.Serializable; import java.util.Arrays; diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Property.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java similarity index 98% rename from components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Property.java rename to components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java index af02ccfc2f..2658916b61 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/Property.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.common.kubernetes; +package org.apache.stratos.common; import java.io.Serializable; diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesGroup.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesGroup.java index 7c42048f9a..1244ab41d9 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesGroup.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesGroup.java @@ -19,6 +19,8 @@ package org.apache.stratos.common.kubernetes; +import org.apache.stratos.common.Properties; + import java.io.Serializable; import java.util.Arrays; diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesHost.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesHost.java index bfb80b8400..60baa128c3 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesHost.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/kubernetes/KubernetesHost.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.Properties; import java.io.Serializable; 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 index d1063e7fc9..9c8ce047c2 100644 --- 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 @@ -22,8 +22,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; 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 d2737c6f8b..b3e092b820 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 @@ -33,9 +33,10 @@ import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; import org.apache.stratos.autoscaler.pojo.xsd.ServiceGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; import java.rmi.RemoteException; @@ -299,7 +300,9 @@ public boolean updateKubernetesHost(KubernetesHost kubernetesHost) } public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException, AutoScalerServiceInvalidArgumentExceptionException { - stub.updateClusterMonitor(clusterId, properties); + //TODO: To be fixed + throw new NotImplementedException(); + //stub.updateClusterMonitor(clusterId, properties); } 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 a4e21095f6..c2f017686b 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 @@ -24,9 +24,9 @@ import org.apache.axis2.transport.http.HTTPConstants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; @@ -73,15 +73,15 @@ public static CloudControllerServiceClient getServiceClient() throws AxisFault { return serviceClient; } - public void deployCartridgeDefinition (CartridgeConfig cartridgeConfig) - throws RemoteException, CloudControllerServiceInvalidCartridgeDefinitionExceptionException, - CloudControllerServiceInvalidIaasProviderExceptionException { + public void deployCartridgeDefinition (CartridgeConfig cartridgeConfig) + throws RemoteException, CloudControllerServiceInvalidCartridgeDefinitionExceptionException, + CloudControllerServiceInvalidIaasProviderExceptionException { stub.deployCartridgeDefinition(cartridgeConfig); } - public void unDeployCartridgeDefinition (String cartridgeType) throws RemoteException, CloudControllerServiceInvalidCartridgeTypeExceptionException{ + public void unDeployCartridgeDefinition (String cartridgeType) throws RemoteException, CloudControllerServiceInvalidCartridgeTypeExceptionException { stub.undeployCartridgeDefinition(cartridgeType); @@ -140,7 +140,7 @@ public boolean register(String clusterId, String cartridgeType, String key = (String) iterator.next(); String value = properties.getProperty(key); - Property prop = new Property(); + org.apache.stratos.common.xsd.Property prop = new org.apache.stratos.common.xsd.Property(); prop.setName(key); prop.setValue(value); 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 index 72176c3974..68dbdcc90d 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; 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 index c5921b646d..7337ed29af 100644 --- 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 @@ -24,8 +24,8 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; 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; 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 index 982535a3da..41aa92ff28 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 4a67d8b699..d81e7ed8dd 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; 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 index 1214c0e970..1cf172b575 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; 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 index c22c545328..ddb255024e 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.UnregisteredCartridgeException; 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 index 4f4cae7ff8..b50aadacab 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 75f68566be..0d45a8590b 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 594ad4ca02..0b41aea2bb 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; 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 index 5b8f827952..23998d7c37 100644 --- 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 @@ -21,8 +21,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import java.util.ArrayList; import java.util.List; 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 index b69ef6ab52..d374a06f0d 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 69919472af..99ba4c66db 100644 --- 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 @@ -25,8 +25,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.deploy.service.Service; 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 index a5d901d959..80cdee42fb 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.*; 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 index c97bcd3271..0b4e6019af 100644 --- 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 @@ -28,7 +28,7 @@ import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour; import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import java.util.HashMap; import java.util.Map; 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 index c0bd321ce3..5c5efa090b 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.exception.*; import org.apache.stratos.manager.lb.category.LoadBalancerCategory; 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 index 63a13a1fd2..7850275692 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Property; public class PersistenceContext { 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 index 56829e0fad..ff04ce30f7 100644 --- 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 @@ -19,8 +19,8 @@ package org.apache.stratos.manager.subscription; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import java.util.Collections; import java.util.HashSet; 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 index 6057243329..8a45c685e4 100644 --- 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 @@ -25,8 +25,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; import org.apache.stratos.manager.exception.DuplicateCartridgeAliasException; 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 index 0fea5abf0d..6b5a44e8a5 100644 --- 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 @@ -19,7 +19,7 @@ package org.apache.stratos.manager.subscription.filter; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.subscription.SubscriptionData; 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 index 664a2b3793..e0783beb54 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.*; 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 index 196e897108..0f897c2949 100644 --- 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 @@ -25,9 +25,10 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; -import org.apache.stratos.manager.composite.application.utils.ApplicationUtils; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; 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 7282253d1e..d004a328d3 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 @@ -37,8 +37,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.cloud.controller.stub.pojo.Properties; -import org.apache.stratos.cloud.controller.stub.pojo.Property; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 212a5d07f2..4be32e5b49 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -20,21 +20,15 @@ package org.apache.stratos.rest.endpoint.bean.util.converter; import org.apache.commons.lang.StringUtils; -import org.apache.stratos.autoscaler.stub.kubernetes.PropertiesE; -import org.apache.stratos.autoscaler.stub.kubernetes.PropertyE; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; -import org.apache.stratos.cloud.controller.pojo.application.xsd.ComponentContext; -import org.apache.stratos.cloud.controller.pojo.application.xsd.DependencyContext; -import org.apache.stratos.cloud.controller.pojo.application.xsd.GroupContext; -import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableContext; -import org.apache.stratos.cloud.controller.pojo.application.xsd.SubscribableInfoContext; -import org.apache.stratos.autoscaler.applications.pojo.stub.DependencyContext; -import org.apache.stratos.autoscaler.applications.pojo.stub.GroupContext; -import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableContext; -import org.apache.stratos.autoscaler.applications.pojo.stub.SubscribableInfoContext; +import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; +import org.apache.stratos.autoscaler.applications.pojo.xsd.DependencyContext; +import org.apache.stratos.autoscaler.applications.pojo.xsd.GroupContext; +import org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableInfoContext; import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.xsd.PropertiesE; +import org.apache.stratos.common.xsd.PropertyE; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; @@ -44,8 +38,8 @@ import org.apache.stratos.manager.grouping.definitions.ServiceGroupDefinition; import org.apache.stratos.manager.subscription.SubscriptionDomain; import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.rest.endpoint.bean.ApplicationBean; import org.apache.stratos.rest.endpoint.bean.GroupBean; import org.apache.stratos.rest.endpoint.bean.autoscaler.partition.Partition; @@ -59,12 +53,9 @@ import org.apache.stratos.rest.endpoint.bean.kubernetes.PortRange; import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.topology.Member; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Enumeration; -import java.util.List; +import java.util.*; public class PojoConverter { @@ -251,26 +242,28 @@ public static Properties getProperties(List propertyBeans) { } - public static org.apache.stratos.autoscaler.stub.kubernetes.PropertiesE getASProperties(List propertyBeans) { - if (propertyBeans == null || propertyBeans.isEmpty()) { - return null; - } - - //convert to an array - PropertyBean[] propertyBeansArray = new PropertyBean[propertyBeans.size()]; - propertyBeans.toArray(propertyBeansArray); - PropertyE[] propertyArray = new PropertyE[propertyBeansArray.length]; - - for (int j = 0; j < propertyBeansArray.length; j++) { - PropertyE property = new PropertyE(); - property.setName(propertyBeansArray[j].name); - property.setValue(propertyBeansArray[j].value); - propertyArray[j] = property; - } - - org.apache.stratos.autoscaler.stub.kubernetes.PropertiesE properties = new PropertiesE(); - properties.setProperties(propertyArray); - return properties; + public static PropertiesE getASProperties(List propertyBeans) { + //TODO: To be fixed + throw new NotImplementedException(); +// if (propertyBeans == null || propertyBeans.isEmpty()) { +// return null; +// } +// +// //convert to an array +// PropertyBean[] propertyBeansArray = new PropertyBean[propertyBeans.size()]; +// propertyBeans.toArray(propertyBeansArray); +// PropertyE[] propertyArray = new PropertyE[propertyBeansArray.length]; +// +// for (int j = 0; j < propertyBeansArray.length; j++) { +// PropertyE property = new PropertyE(); +// property.setName(propertyBeansArray[j].name); +// property.setValue(propertyBeansArray[j].value); +// propertyArray[j] = property; +// } +// +// PropertiesE properties = new PropertiesE(); +// properties.setProperties(propertyArray); +// return properties; } private static NetworkInterfaces getNetworkInterfaces(List networkInterfaceBeans) { @@ -899,13 +892,15 @@ private static PortRange populatePortRangePojo(org.apache.stratos.autoscaler.stu public static ApplicationContext convertApplicationBeanToApplicationContext (ApplicationDefinition compositeAppDefinition) { - org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext(); + org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext applicationContext = + new org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext(); applicationContext.setApplicationId(compositeAppDefinition.getApplicationId()); applicationContext.setAlias(compositeAppDefinition.getAlias()); // convert and set components if (compositeAppDefinition.getComponents() != null) { - org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext componentContext = new org.apache.stratos.autoscaler.applications.pojo.stub.ComponentContext(); + org.apache.stratos.autoscaler.applications.pojo.xsd.ComponentContext componentContext = + new org.apache.stratos.autoscaler.applications.pojo.xsd.ComponentContext(); // top level subscribables if (compositeAppDefinition.getComponents().getSubscribables() != null) { componentContext.setSubscribableContexts(getSubscribableContextArrayFromSubscribableDefinitions( @@ -964,7 +959,8 @@ private static DependencyContext getDependencyContextFromDependencyDefinition (D return dependencyContext; } - private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List groupDefinitions) { + private static org.apache.stratos.autoscaler.applications.pojo.xsd.GroupContext[] + getgroupContextArrayFromGroupDefinitions (List groupDefinitions) { GroupContext[] groupContexts = new GroupContext[groupDefinitions.size()]; int i = 0; @@ -976,7 +972,8 @@ private static GroupContext[] getgroupContextArrayFromGroupDefinitions (List subscribableDefinitions) { + private static org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableContext [] + getSubscribableContextArrayFromSubscribableDefinitions(List subscribableDefinitions) { - SubscribableContext[] subscribableContexts = new SubscribableContext[subscribableDefinitions.size()]; + org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableContext[] subscribableContexts = + new org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableContext[subscribableDefinitions.size()]; int i = 0; for (SubscribableDefinition subscribableDefinition : subscribableDefinitions) { - SubscribableContext subscribableContext = new SubscribableContext(); + org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableContext subscribableContext = + new org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableContext(); subscribableContext.setType(subscribableDefinition.getType()); subscribableContext.setAlias(subscribableDefinition.getAlias()); subscribableContexts[i++] = subscribableContext; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 38880d7f4d..c9de333e01 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -23,19 +23,17 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; -import org.apache.stratos.cloud.controller.pojo.application.xsd.ApplicationContext; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPolicyExceptionException; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.Property; -import org.apache.stratos.cloud.controller.stub.pojo.application.ApplicationContext; +import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager; @@ -81,6 +79,7 @@ import org.apache.stratos.rest.endpoint.bean.subscription.domain.SubscriptionDomainBean; import org.apache.stratos.rest.endpoint.bean.util.converter.PojoConverter; import org.apache.stratos.rest.endpoint.exception.RestAPIException; +import sun.reflect.generics.reflectiveObjects.NotImplementedException; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; @@ -138,21 +137,23 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co throw new RestAPIException(e1); } - org.apache.stratos.autoscaler.applications.pojo.stub.ApplicationContext applicationContext = + ApplicationContext applicationContext = PojoConverter.convertApplicationBeanToApplicationContext(appDefinition); applicationContext.setTenantId(ApplicationManagementUtil.getTenantId(ctxt)); applicationContext.setTenantDomain(tenantDomain); applicationContext.setTeantAdminUsername(userName); - Properties properties = new Properties(); if(appDefinition.getProperty() != null) { - for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { - Property property = new Property(); - property.setName(propertyBean.getName()); - property.setValue(propertyBean.getValue()); - properties.addProperties(property); - } - applicationContext.setProperties(properties); + //TODO: To be fixed + throw new NotImplementedException(); +// PropertiesE properties = new PropertiesE(); +// for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { +// PropertyE property = new PropertyE(); +// property.setName(propertyBean.getName()); +// property.setValue(propertyBean.getValue()); +// properties.addProperties(property); +// } +// applicationContext.setProperties(properties); } try { @@ -161,10 +162,6 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co throw new RestAPIException(e); } catch (RemoteException e) { throw new RestAPIException(e); - } catch (CloudControllerServiceInvalidIaasProviderExceptionException e) { - throw new RestAPIException(e); - } catch (CloudControllerServiceApplicationDefinitionExceptionException e) { - throw new RestAPIException(e); } } diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl index 732fe38676..bce9910f9b 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/src/main/resources/AutoScalerService.wsdl @@ -1,26 +1,28 @@ - + AutoScalerService - + - + - + - + + + @@ -73,7 +75,7 @@ - + @@ -92,15 +94,15 @@ - + - - - + + + @@ -122,17 +124,17 @@ - + - + - + @@ -146,36 +148,26 @@ - + - + + - - - - - - - - - - - - + - + @@ -186,10 +178,10 @@ - - - - + + + + @@ -199,9 +191,22 @@ - - + + + + + + + + + + + + + + + @@ -209,31 +214,31 @@ - + - + - + - + - + - + - + - + @@ -247,7 +252,7 @@ - + @@ -270,7 +275,7 @@ - + @@ -284,7 +289,7 @@ - + @@ -305,7 +310,7 @@ - + @@ -333,7 +338,7 @@ - + @@ -361,7 +366,7 @@ - + @@ -375,7 +380,7 @@ - + @@ -397,7 +402,7 @@ - + @@ -411,7 +416,7 @@ - + @@ -423,7 +428,7 @@ - + @@ -435,7 +440,7 @@ - + @@ -447,7 +452,7 @@ - + @@ -461,7 +466,7 @@ - + @@ -475,7 +480,7 @@ - + @@ -489,7 +494,7 @@ - + @@ -503,7 +508,7 @@ - + @@ -517,7 +522,7 @@ - + @@ -538,7 +543,7 @@ - + @@ -550,7 +555,7 @@ - + @@ -564,7 +569,7 @@ - + @@ -578,7 +583,7 @@ - + @@ -592,7 +597,7 @@ - + @@ -607,7 +612,7 @@ - + @@ -745,7 +750,7 @@ - + @@ -759,7 +764,7 @@ - + @@ -795,7 +800,7 @@ - + @@ -2419,22 +2424,22 @@ - + - + - + - + - + - + \ No newline at end of file diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 487b4ab2c3..319aeddca5 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,4 +1,4 @@ - + CloudControllerService @@ -6,59 +6,16 @@ - - - - - - - - - - - - - - - - - - - - - - + + - - + - + - - - - - - - - - - - - - - - - - - - - - - - + @@ -68,27 +25,22 @@ - - - - - - + - + - + - + @@ -108,7 +60,7 @@ - + @@ -119,207 +71,189 @@ - - + - + - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -333,7 +267,7 @@ - + @@ -356,24 +290,24 @@ - + - + - + - + - + @@ -387,14 +321,14 @@ - + - + @@ -408,7 +342,7 @@ - + @@ -423,14 +357,14 @@ - + - + @@ -444,39 +378,33 @@ - + - + - + - + - - - - - - - - + - + + - + @@ -484,8 +412,8 @@ - - + + @@ -493,25 +421,32 @@ - + - + + - + + + - - - - - + + + + + + + + + @@ -526,68 +461,37 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + - + - - + + - + - - - + + + + + + + + + - + @@ -596,13 +500,13 @@ - + - + - - - + + + @@ -624,16 +528,16 @@ - + - + - + @@ -643,6 +547,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -654,43 +599,16 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -752,12 +670,6 @@ - - - - - - @@ -795,9 +707,6 @@ - - - @@ -888,10 +797,6 @@ - - - - @@ -922,10 +827,6 @@ - - - - @@ -1062,15 +963,6 @@ - - - - - - - - - @@ -1143,15 +1035,6 @@ - - - - - - - - - @@ -1350,15 +1233,6 @@ - - - - - - - - - @@ -1431,15 +1305,6 @@ - - - - - - - - - @@ -1611,12 +1476,6 @@ - - - - - - @@ -1668,12 +1527,6 @@ - - - - - - @@ -1758,22 +1611,22 @@ - + - + - + - + - + - + \ No newline at end of file From 9e19c877051016e665e2ff4d89beb7926f296309 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 09:40:30 +0530 Subject: [PATCH 388/436] removing duplicate mincheck.drl file --- .../distribution/src/main/conf/mincheck.drl | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100755 products/stratos/modules/distribution/src/main/conf/mincheck.drl diff --git a/products/stratos/modules/distribution/src/main/conf/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/mincheck.drl deleted file mode 100755 index ceeab48756..0000000000 --- a/products/stratos/modules/distribution/src/main/conf/mincheck.drl +++ /dev/null @@ -1,84 +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.autoscaler.rule; - -import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.domain.topology.Cluster; -import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.Constants; -import org.apache.stratos.autoscaler.policy.PolicyManager; -import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.policy.model.RequestsInFlight; -import org.apache.stratos.autoscaler.policy.model.LoadThresholds; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.algorithm.AutoscaleAlgorithm; -import org.apache.stratos.autoscaler.algorithm.OneAfterAnother; -import org.apache.stratos.autoscaler.algorithm.RoundRobin; -import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.commons.logging.Log; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.partition.PartitionGroup; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; - -global org.apache.stratos.autoscaler.rule.RuleLog log; -global org.apache.stratos.autoscaler.policy.PolicyManager $manager; -global org.apache.stratos.autoscaler.AutoscalerContext $context; -global org.apache.stratos.autoscaler.rule.RuleTasksDelegator $delegator; -global org.apache.stratos.messaging.domain.topology.Topology $topology; -global java.util.Map partitionCtxts; -global java.lang.String clusterId; -global java.lang.String lbRef; -global java.lang.Boolean isPrimary; -global Integer primaryMemberCount; - -rule "Minimum Rule" -dialect "mvel" - when - $ctxt : PartitionContext () - eval(log.debug("Running minimum rule: [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId())) - eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Non terminated member count: " + $ctxt.getNonTerminatedMemberCount())) - eval(log.debug("[min-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Minimum member count: " + $ctxt.getMinimumMemberCount())) - eval ( (isPrimary && (primaryMemberCount < $ctxt.getMinimumMemberCount() )) || ( !isPrimary && ($ctxt.getNonTerminatedMemberCount() < $ctxt.getMinimumMemberCount() )) ) - then - if (isPrimary){ - log.debug("[min-check] true [primary] true [primary member count] " + primaryMemberCount); - } else{ - log.debug("[min-check] true [primary] false"); - } - $delegator.delegateSpawn($ctxt, clusterId, lbRef, isPrimary); -end - -rule "Terminate Obsoleted Instances" -dialect "mvel" - when - $ctxt : PartitionContext () - eval(log.debug("Running obsolete instances rule: [partition] " + $ctxt.getPartitionId() + " [network-partition] " + $ctxt.getNetworkPartitionId())) - eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() +" Obsolete member count: " + $ctxt.getObsoletedMembers().size())) - eval($ctxt.getObsoletedMembers().size() > 0) - memberId : String() from $ctxt.getObsoletedMembers() - eval(log.debug("[obsolete-check] [network-partition] " + $ctxt.getNetworkPartitionId() + " [partition] " + $ctxt.getPartitionId() + " Member id: " + memberId)) - eval($ctxt.removeObsoleteMember(memberId)) - then - $delegator.terminateObsoleteInstance(memberId); -end - From 384e38cc67d3d0c5b2ccd5a7e2b6adc5ea6e47ef Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 09:42:30 +0530 Subject: [PATCH 389/436] moving terminatedependency.drl to conf/drools --- .../src/main/conf/{ => drools}/terminatedependency.drl | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename products/stratos/modules/distribution/src/main/conf/{ => drools}/terminatedependency.drl (100%) diff --git a/products/stratos/modules/distribution/src/main/conf/terminatedependency.drl b/products/stratos/modules/distribution/src/main/conf/drools/terminatedependency.drl similarity index 100% rename from products/stratos/modules/distribution/src/main/conf/terminatedependency.drl rename to products/stratos/modules/distribution/src/main/conf/drools/terminatedependency.drl From 744ac998a48dd8e2d349e66d9b39701b32325451 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 12:19:10 +0530 Subject: [PATCH 390/436] adding clusters created event and handling it in autoscaler --- .../autoscaler/applications/topic/ApplicationBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 87b28102cd..d33e0ba26a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -167,6 +167,7 @@ public static synchronized void handleCompleteApplication(Applications applicati public static synchronized void handleApplicationCreated(Application application, Set appClusterContexts) { + ApplicationHolder.acquireWriteLock(); Applications applications = ApplicationHolder.getApplications(); @@ -176,7 +177,6 @@ public static synchronized void handleApplicationCreated(Application application CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); - // startApplicationMonitor(application.getUniqueIdentifier()); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); } From b9467d60623fa85c1fa4087f4dded3d5c5c99b61 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 12:55:48 +0530 Subject: [PATCH 391/436] updating the monitors with the status changes --- .../AutoscalerTopologyEventReceiver.java | 311 ++++++++++++------ 1 file changed, 214 insertions(+), 97 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index f47142d002..0e2a4f9948 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -19,22 +19,13 @@ package org.apache.stratos.autoscaler.message.receiver.topology; -import java.util.List; -import java.util.Set; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.MemberStatsContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; -import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; -import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; -import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; -import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; @@ -42,15 +33,11 @@ import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; -import org.apache.stratos.autoscaler.partition.PartitionManager; -import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; -import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; @@ -76,6 +63,8 @@ import org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; +import java.util.Set; + /** * Autoscaler topology receiver. */ @@ -325,28 +314,156 @@ protected void onEvent(Event event) { } }); + topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { + @Override + protected void onEvent(Event event) { + + log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); + + ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; + + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationUndeployedEvent.getApplicationId()); + + // if any of Cluster Monitors are not added yet, should send the + // Cluster Terminated event for those clusters + Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); + if (clusterDataHolders != null) { + for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { + VMClusterMonitor clusterMonitor = + ((VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterDataHolder.getClusterId())); + if (clusterMonitor == null) { + // Cluster Monitor not found; send Cluster Terminated event to cleanup + ClusterStatusEventPublisher.sendClusterTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), + clusterDataHolder.getServiceType(), + clusterDataHolder.getClusterId()); + } else { + // if the Cluster Monitor exists, mark it as destroyed to stop it from spawning + // more instances + clusterMonitor.setDestroyed(true); + } + } + } + + if (appMonitor != null) { + // set Application Monitor state to 'Terminating' + appMonitor.setStatus(ApplicationStatus.Terminating); + + } else { + // ApplicationMonitor is not found, send Terminating event to clean up + ApplicationsEventPublisher.sendApplicationTerminatedEvent( + applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData()); + } + +// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; +// +// // acquire reead locks for application and relevant clusters +// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// +// try { +// ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). +// getAppMonitor(applicationUndeployedEvent.getApplicationId()); +// +// if (appMonitor != null) { +// // update the status as Terminating +// appMonitor.setStatus(ApplicationStatus.Terminating); +// +//// List clusters = appMonitor. +//// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); +// +// boolean clusterMonitorsFound = false; +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// //stopping the cluster monitor and remove it from the AS +// ClusterMonitor clusterMonitor = +// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); +// if (clusterMonitor != null) { +// clusterMonitorsFound = true; +// clusterMonitor.setDestroyed(true); +// //clusterMonitor.terminateAllMembers(); +// if (clusterMonitor.getStatus() == ClusterStatus.Active) { +// // terminated gracefully +// clusterMonitor.setStatus(ClusterStatus.Terminating); +// InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId()); +// } else { +// // if not active, forcefully terminate +// clusterMonitor.setStatus(ClusterStatus.Terminating); +// clusterMonitor.terminateAllMembers(); +//// try { +//// // TODO: introduce a task to do this cleanup +//// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); +//// } catch (TerminationException e) { +//// log.error("Unable to terminate instances for [ cluster id ] " + +//// clusterData.getClusterId(), e); +//// } +// } +// } else { +// log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); +// // if Cluster Monitor is not found, still the Cluster Terminated +// // should be sent to update the parent Monitor +// StatusEventPublisher.sendClusterTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), +// clusterData.getServiceType(), clusterData.getClusterId()); +// } +// } +// +// // if by any chance, the cluster monitors have failed, we still need to undeploy this application +// // hence, check if the Cluster Monitors are not found and send the Application Terminated event +// if (!clusterMonitorsFound) { +// StatusEventPublisher.sendApplicationTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); +// } +// +// } else { +// log.warn("Application Monitor cannot be found for the undeployed [application] " +// + applicationUndeployedEvent.getApplicationId()); +// // send the App Terminated event to cleanup +// StatusEventPublisher.sendApplicationTerminatedEvent( +// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); +// } +// +// } finally { +// if (clusterDataHolders != null) { +// for (ClusterDataHolder clusterData : clusterDataHolders) { +// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), +// clusterData.getClusterId()); +// } +// } +// TopologyManager. +// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); +// } + } + }); + topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent) event; - String clusterId = memberReadyToShutdownEvent.getClusterId(); - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - AbstractClusterMonitor monitor; - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } - return; - } - monitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberReadyToShutdownEvent memberReadyToShutdownEvent = (MemberReadyToShutdownEvent) event; + String clusterId = memberReadyToShutdownEvent.getClusterId(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberReadyToShutdownEvent(memberReadyToShutdownEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); //TODO delete this if we don't want this // topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { @@ -423,75 +540,75 @@ protected void onEvent(Event event) { }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; - String clusterId = memberTerminatedEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } - return; - } - monitor.handleMemberTerminatedEvent(memberTerminatedEvent); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberTerminatedEvent memberTerminatedEvent = (MemberTerminatedEvent) event; + String clusterId = memberTerminatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberTerminatedEvent(memberTerminatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); topologyEventReceiver.addEventListener(new MemberActivatedEventListener() { - @Override - protected void onEvent(Event event) { - try { - MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; - String clusterId = memberActivatedEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } - return; - } - monitor.handleMemberActivatedEvent(memberActivatedEvent); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberActivatedEvent memberActivatedEvent = (MemberActivatedEvent) event; + String clusterId = memberActivatedEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberActivatedEvent(memberActivatedEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); topologyEventReceiver.addEventListener(new MemberMaintenanceListener() { - @Override - protected void onEvent(Event event) { - try { - MemberMaintenanceModeEvent maintenanceModeEvent = (MemberMaintenanceModeEvent) event; - String clusterId = maintenanceModeEvent.getClusterId(); - AbstractClusterMonitor monitor; - AutoscalerContext asCtx = AutoscalerContext.getInstance(); - monitor = asCtx.getClusterMonitor(clusterId); - if (null == monitor) { - if (log.isDebugEnabled()) { - log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); - } - return; - } - monitor.handleMemberMaintenanceModeEvent(maintenanceModeEvent); - } catch (Exception e) { - String msg = "Error processing event " + e.getLocalizedMessage(); - log.error(msg, e); - } - } + @Override + protected void onEvent(Event event) { + try { + MemberMaintenanceModeEvent maintenanceModeEvent = (MemberMaintenanceModeEvent) event; + String clusterId = maintenanceModeEvent.getClusterId(); + AbstractClusterMonitor monitor; + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + monitor.handleMemberMaintenanceModeEvent(maintenanceModeEvent); + } catch (Exception e) { + String msg = "Error processing event " + e.getLocalizedMessage(); + log.error(msg, e); + } + } }); } From d8874e28e85a83c8438a4d2b552f2c604dc1ac22 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 12:18:03 +0530 Subject: [PATCH 392/436] sending app cluster information to CC via a service call - initial stuff --- .../impl/CloudControllerServiceImpl.java | 69 +++++++++++++++---- .../pojo/ApplicationClusterContextDTO.java | 10 ++- .../controller/topology/TopologyBuilder.java | 4 +- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index d43cc8c469..21878ad234 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -1064,8 +1064,8 @@ public boolean registerService(Registrant registrant) String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; - ClusterContext ctxt = buildClusterContext(cartridge, clusterId, - payload, hostName, props, isLb, registrant.getPersistence()); + ClusterContext ctxt = null;//TODO buildClusterContext(cartridge, clusterId, + //payload, hostName, props, isLb, registrant.getPersistence()); dataHolder.addClusterContext(ctxt); @@ -1080,15 +1080,15 @@ public boolean registerService(Registrant registrant) private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, - Properties props, boolean isLb, Persistence persistence) { + org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) { - - // initialize ClusterContext + //TODO + /*// initialize ClusterContext ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, hostName, isLb, props); String property; - property = props.getProperty(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); + property = props.get(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); long timeout = property != null ? Long.parseLong(property) : 30000; boolean persistanceRequired = false; @@ -1103,7 +1103,8 @@ private ClusterContext buildClusterContext(Cartridge cartridge, ctxt.setVolumeRequired(false); } ctxt.setTimeoutInMillis(timeout); - return ctxt; + return ctxt;*/ + return null; } @Override @@ -1897,6 +1898,50 @@ private void handleNullObject(Object obj, String errorMsg) { throw new IllegalArgumentException(errorMsg); } } + public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + ApplicationClusterRegistrationException { + + // Create a Cluster Context obj. for each of the Clusters in the Application + if (appClustersContexts == null || appClustersContexts.length == 0) { + String errorMsg = "No application cluster information found, unable to create clusters" ; + LOG.error(errorMsg); + throw new ApplicationClusterRegistrationException(errorMsg); + } + + //TODO + + /*for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { + dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + } +*/ + persist(); + } + +// public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { +// +// ApplicationParser applicationParser = new DefaultApplicationParser(); +// Application application = applicationParser.parse(applicationContext); +// +// // Create a Cluster Context obj. for each of the Clusters in the Application +// for (ApplicationClusterContext applicationClusterContext : applicationParser.getApplicationClusterContexts()) { +// dataHolder.addClusterContext(new ClusterContext(applicationClusterContext.getClusterId(), +// applicationClusterContext.getCartridgeType(), applicationClusterContext.getTextPayload(), +// applicationClusterContext.getHostName(), applicationClusterContext.isLbCluster())); +// } +// +// /*TopologyBuilder.handleApplicationDeployed(application, applicationParser.getApplicationClusterContexts(), +// applicationParser.getPayloadData()); +//*/ +// persist(); +// } +// +// @Override +// public void unDeployApplicationDefinition(String applicationId, int tenantId, String tenantDomain) throws ApplicationDefinitionException { +// +// //TopologyBuilder.handleApplicationUndeployed(applicationId); +// } public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException { @@ -1904,7 +1949,7 @@ public void createApplicationClusters(String appId, ApplicationClusterContextDTO // Create a Cluster Context obj. for each of the Clusters in the Application if (appClustersContexts == null || appClustersContexts.length == 0) { String errorMsg = "No application cluster information found, unable to create clusters" ; - log.error(errorMsg); + LOG.error(errorMsg); throw new ApplicationClusterRegistrationException(errorMsg); } @@ -1912,9 +1957,10 @@ public void createApplicationClusters(String appId, ApplicationClusterContextDTO for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { // add the context data - dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + //TODO + /*dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));*/ // create Cluster objects Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); @@ -1922,7 +1968,7 @@ public void createApplicationClusters(String appId, ApplicationClusterContextDTO newCluster.setTenantRange("*"); newCluster.setStatus(ClusterStatus.Created); newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); - newCluster.setProperties(appClusterCtxt.getProperties()); + //newCluster.setProperties(appClusterCtxt.getProperties()); clusters.add(newCluster); } @@ -1954,7 +2000,6 @@ public void createApplicationClusters(String appId, ApplicationClusterContextDTO // // //TopologyBuilder.handleApplicationUndeployed(applicationId); // } ->>>>>>> 4.0.0-grouping } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index 1d4dda0498..875f7bc09c 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -19,7 +19,8 @@ package org.apache.stratos.cloud.controller.pojo; -import java.util.Properties; + +import org.apache.stratos.common.Properties; public class ApplicationClusterContextDTO { @@ -33,6 +34,8 @@ public class ApplicationClusterContextDTO { private String hostName; // flag to indicate LB cluster private boolean isLbCluster; + // flag to indicate Kubernetes cluster + private boolean isKubernetesCluster; // autoscaling policy private String autoscalePolicyName; // deployment policy @@ -46,6 +49,7 @@ public class ApplicationClusterContextDTO { public ApplicationClusterContextDTO () { } + public String getClusterId() { return clusterId; } @@ -116,7 +120,7 @@ public boolean equals(Object other) { return false; } - if(this == other) { + if (this == other) { return true; } @@ -126,7 +130,7 @@ public boolean equals(Object other) { this.clusterId.equals(that.clusterId); } - public int hashCode () { + public int hashCode() { return this.cartridgeType.hashCode() + this.clusterId.hashCode(); } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index dbb609846c..6015d87dd3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -174,6 +174,7 @@ public static void handleApplicationClustersCreated(String appId, List } TopologyEventPublisher.sendApplicationClustersCreated(appId, appClusters); + } @@ -441,7 +442,8 @@ public static void handleMemberActivated(InstanceActivatedEvent instanceActivate instanceActivatedEvent.getClusterId(), instanceActivatedEvent.getNetworkPartitionId(), instanceActivatedEvent.getPartitionId(), instanceActivatedEvent.getMemberId()); // grouping - set grouid - memberActivatedEvent.setGroupId(instanceActivatedEvent.getGroupId()); + //TODO + memberActivatedEvent.setApplicationId(null); try { TopologyManager.acquireWriteLock(); // try update lifecycle state From 03673cbe5e6aa70619536e307e73ffcbbdef7ca3 Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 13:10:33 +0530 Subject: [PATCH 393/436] calling createClusters in CC from AS --- .../autoscaler/applications/topic/ApplicationBuilder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index d33e0ba26a..24d6cc16d0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -177,6 +177,9 @@ public static synchronized void handleApplicationCreated(Application application CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); + // startApplicationMonitor(application.getUniqueIdentifier()); + CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), + appClusterContexts); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); } From 3a157dcf9386dc666e8757f35c5eabc5da732d4b Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 13:19:46 +0530 Subject: [PATCH 394/436] fixing a compilation failure --- .../autoscaler/applications/topic/ApplicationBuilder.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 24d6cc16d0..696fa3961e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -167,13 +167,12 @@ public static synchronized void handleCompleteApplication(Applications applicati public static synchronized void handleApplicationCreated(Application application, Set appClusterContexts) { - ApplicationHolder.acquireWriteLock(); Applications applications = ApplicationHolder.getApplications(); try { - if (applications.getApplication(application.getUniqueIdentifier()) == null) { + if (applications.getApplication(application.getUniqueIdentifier()) != null) { CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); From d45448f3e73f877dec196a732c1003614b1e7dee Mon Sep 17 00:00:00 2001 From: reka Date: Mon, 3 Nov 2014 14:35:34 +0530 Subject: [PATCH 395/436] udpating the cluster status --- .../impl/CloudControllerServiceImpl.java | 2183 +++++++++-------- 1 file changed, 1095 insertions(+), 1088 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index 21878ad234..d7d94008df 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.net.InetAddresses; - import org.apache.commons.collections.ListUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -54,6 +53,8 @@ import org.apache.stratos.kubernetes.client.model.Pod; import org.apache.stratos.kubernetes.client.model.ReplicationController; import org.apache.stratos.kubernetes.client.model.Service; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterStatus; @@ -68,7 +69,6 @@ import java.util.*; import java.util.Map.Entry; -import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -76,65 +76,64 @@ /** * Cloud Controller Service is responsible for starting up new server instances, * terminating already started instances, providing pending instance count etc. - * */ public class CloudControllerServiceImpl implements CloudControllerService { - private static final Log LOG = LogFactory - .getLog(CloudControllerServiceImpl.class); - private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder - .getInstance(); - - public CloudControllerServiceImpl() { - // acquire serialized data from registry - acquireData(); - } - - private void acquireData() { - - Object obj = RegistryManager.getInstance().retrieve(); - if (obj != null) { - try { - Object dataObj = Deserializer - .deserializeFromByteArray((byte[]) obj); - if (dataObj instanceof FasterLookUpDataHolder) { - FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj; - FasterLookUpDataHolder currentData = FasterLookUpDataHolder - .getInstance(); - - // assign necessary data - currentData.setClusterIdToContext(serializedObj.getClusterIdToContext()); - currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); - currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); - currentData.setCartridges(serializedObj.getCartridges()); - currentData.setKubClusterIdToKubClusterContext(serializedObj.getKubClusterIdToKubClusterContext()); - currentData.setServiceGroups(serializedObj.getServiceGroups()); - - if(LOG.isDebugEnabled()) { - - LOG.debug("Cloud Controller Data is retrieved from registry."); - } - } else { - if(LOG.isDebugEnabled()) { - - LOG.debug("Cloud Controller Data cannot be found in registry."); - } - } - } catch (Exception e) { - - String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected."; - LOG.warn(msg, e); - } - - } - } - - public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, - InvalidIaasProviderException { - + private static final Log LOG = LogFactory + .getLog(CloudControllerServiceImpl.class); + private FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder + .getInstance(); + + public CloudControllerServiceImpl() { + // acquire serialized data from registry + acquireData(); + } + + private void acquireData() { + + Object obj = RegistryManager.getInstance().retrieve(); + if (obj != null) { + try { + Object dataObj = Deserializer + .deserializeFromByteArray((byte[]) obj); + if (dataObj instanceof FasterLookUpDataHolder) { + FasterLookUpDataHolder serializedObj = (FasterLookUpDataHolder) dataObj; + FasterLookUpDataHolder currentData = FasterLookUpDataHolder + .getInstance(); + + // assign necessary data + currentData.setClusterIdToContext(serializedObj.getClusterIdToContext()); + currentData.setMemberIdToContext(serializedObj.getMemberIdToContext()); + currentData.setClusterIdToMemberContext(serializedObj.getClusterIdToMemberContext()); + currentData.setCartridges(serializedObj.getCartridges()); + currentData.setKubClusterIdToKubClusterContext(serializedObj.getKubClusterIdToKubClusterContext()); + currentData.setServiceGroups(serializedObj.getServiceGroups()); + + if (LOG.isDebugEnabled()) { + + LOG.debug("Cloud Controller Data is retrieved from registry."); + } + } else { + if (LOG.isDebugEnabled()) { + + LOG.debug("Cloud Controller Data cannot be found in registry."); + } + } + } catch (Exception e) { + + String msg = "Unable to acquire data from Registry. Hence, any historical data will not get reflected."; + LOG.warn(msg, e); + } + + } + } + + public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws InvalidCartridgeDefinitionException, + InvalidIaasProviderException { + handleNullObject(cartridgeConfig, "Invalid Cartridge Definition: Definition is null."); - if(LOG.isDebugEnabled()){ + if (LOG.isDebugEnabled()) { LOG.debug("Cartridge definition: " + cartridgeConfig.toString()); } @@ -144,16 +143,16 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In cartridge = CloudControllerUtil.toCartridge(cartridgeConfig); } catch (Exception e) { String msg = - "Invalid Cartridge Definition: Cartridge Type: " + - cartridgeConfig.getType()+ - ". Cause: Cannot instantiate a Cartridge Instance with the given Config. "+e.getMessage(); + "Invalid Cartridge Definition: Cartridge Type: " + + cartridgeConfig.getType() + + ". Cause: Cannot instantiate a Cartridge Instance with the given Config. " + e.getMessage(); LOG.error(msg, e); throw new InvalidCartridgeDefinitionException(msg, e); } List iaases = cartridge.getIaases(); - - if (!StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType())) { + + if (!StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType())) { if (iaases == null || iaases.isEmpty()) { String msg = "Invalid Cartridge Definition: Cartridge Type: " + cartridgeConfig.getType() @@ -177,19 +176,19 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In // TODO transaction begins String cartridgeType = cartridge.getType(); - if(dataHolder.getCartridge(cartridgeType) != null) { - Cartridge cartridgeToBeRemoved = dataHolder.getCartridge(cartridgeType); - // undeploy + if (dataHolder.getCartridge(cartridgeType) != null) { + Cartridge cartridgeToBeRemoved = dataHolder.getCartridge(cartridgeType); + // undeploy try { - undeployCartridgeDefinition(cartridgeToBeRemoved.getType()); - } catch (InvalidCartridgeTypeException e) { - //ignore - } + undeployCartridgeDefinition(cartridgeToBeRemoved.getType()); + } catch (InvalidCartridgeTypeException e) { + //ignore + } populateNewCartridge(cartridge, cartridgeToBeRemoved); } - + dataHolder.addCartridge(cartridge); - + // persist persist(); @@ -198,211 +197,211 @@ public void deployCartridgeDefinition(CartridgeConfig cartridgeConfig) throws In TopologyBuilder.handleServiceCreated(cartridgeList); // transaction ends - + LOG.info("Successfully deployed the Cartridge definition: " + cartridgeType); } private void populateNewCartridge(Cartridge cartridge, - Cartridge cartridgeToBeRemoved) { - - List newIaasProviders = cartridge.getIaases(); - Map oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider(); - - for (Entry entry : oldPartitionToIaasMap.entrySet()) { - if (entry == null) { - continue; - } - String partitionId = entry.getKey(); - IaasProvider oldIaasProvider = entry.getValue(); - if (newIaasProviders.contains(oldIaasProvider)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " - + "[partition id] : "+partitionId+" [cartridge type] "+cartridge.getType() ); - } - cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider))); - } - } - - } + Cartridge cartridgeToBeRemoved) { - public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException { + List newIaasProviders = cartridge.getIaases(); + Map oldPartitionToIaasMap = cartridgeToBeRemoved.getPartitionToIaasProvider(); + + for (Entry entry : oldPartitionToIaasMap.entrySet()) { + if (entry == null) { + continue; + } + String partitionId = entry.getKey(); + IaasProvider oldIaasProvider = entry.getValue(); + if (newIaasProviders.contains(oldIaasProvider)) { + if (LOG.isDebugEnabled()) { + LOG.debug("Copying a partition from the Cartridge that is undeployed, to the new Cartridge. " + + "[partition id] : " + partitionId + " [cartridge type] " + cartridge.getType()); + } + cartridge.addIaasProvider(partitionId, newIaasProviders.get(newIaasProviders.indexOf(oldIaasProvider))); + } + } + + } + + public void undeployCartridgeDefinition(String cartridgeType) throws InvalidCartridgeTypeException { Cartridge cartridge = null; - if((cartridge = dataHolder.getCartridge(cartridgeType)) != null) { + if ((cartridge = dataHolder.getCartridge(cartridgeType)) != null) { if (dataHolder.getCartridges().remove(cartridge)) { - // invalidate partition validation cache - dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType); - - if (LOG.isDebugEnabled()) { - LOG.debug("Partition cache invalidated for cartridge "+cartridgeType); - } - + // invalidate partition validation cache + dataHolder.removeFromCartridgeTypeToPartitionIds(cartridgeType); + + if (LOG.isDebugEnabled()) { + LOG.debug("Partition cache invalidated for cartridge " + cartridgeType); + } + persist(); - + // sends the service removed event List cartridgeList = new ArrayList(); cartridgeList.add(cartridge); TopologyBuilder.handleServiceRemoved(cartridgeList); - - if(LOG.isInfoEnabled()) { + + if (LOG.isInfoEnabled()) { LOG.info("Successfully undeployed the Cartridge definition: " + cartridgeType); } return; } } - String msg = "Cartridge [type] "+cartridgeType+" is not a deployed Cartridge type."; + String msg = "Cartridge [type] " + cartridgeType + " is not a deployed Cartridge type."; LOG.error(msg); throw new InvalidCartridgeTypeException(msg); } - + public void deployServiceGroup(ServiceGroup servicegroup) throws InvalidServiceGroupException { - - if (servicegroup == null) { + + if (servicegroup == null) { String msg = "Invalid ServiceGroup Definition: Definition is null."; LOG.error(msg); throw new IllegalArgumentException(msg); } - - if(LOG.isDebugEnabled()) { + + if (LOG.isDebugEnabled()) { LOG.debug("CloudControllerServiceImpl:deployServiceGroup:" + servicegroup.getName()); } - - String [] subGroups = servicegroup.getCartridges(); - - if(LOG.isDebugEnabled()) { + String[] subGroups = servicegroup.getCartridges(); + + + if (LOG.isDebugEnabled()) { LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups" + subGroups); if (subGroups != null) { - LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length); + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups:size" + subGroups.length); } else { - LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null"); + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:subGroups: is null"); } } - - - Dependencies dependencies = servicegroup.getDependencies(); - - if(LOG.isDebugEnabled()) { + + + Dependencies dependencies = servicegroup.getDependencies(); + + if (LOG.isDebugEnabled()) { LOG.debug("CloudControllerServiceImpl:deployServiceGroup:dependencies" + dependencies); } - - if (dependencies != null) { - String [] startupOrders = dependencies.getStartupOrders(); - - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); - - if (startupOrders != null) { - LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); - } else { - LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); - } - } - } - - dataHolder.addServiceGroup(servicegroup); - - this.persist(); - + + if (dependencies != null) { + String[] startupOrders = dependencies.getStartupOrders(); + + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrders" + startupOrders); + + if (startupOrders != null) { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder:size" + startupOrders.length); + } else { + LOG.debug("CloudControllerServiceImpl:deployServiceGroup:startupOrder: is null"); + } + } + } + + dataHolder.addServiceGroup(servicegroup); + + this.persist(); + } - + public void undeployServiceGroup(String name) throws InvalidServiceGroupException { - if(LOG.isDebugEnabled()) { + if (LOG.isDebugEnabled()) { LOG.debug("CloudControllerServiceImpl:undeployServiceGroup: " + name); } - + ServiceGroup serviceGroup = null; - + serviceGroup = dataHolder.getServiceGroup(name); - - if (serviceGroup != null) { + + if (serviceGroup != null) { if (dataHolder.getServiceGroups().remove(serviceGroup)) { persist(); - if(LOG.isInfoEnabled()) { + if (LOG.isInfoEnabled()) { LOG.info("Successfully undeployed the Service Group definition: " + serviceGroup); } return; } - } - + } + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; LOG.error(msg); throw new InvalidServiceGroupException(msg); - + } - + @Override - public ServiceGroup getServiceGroup (String name) throws InvalidServiceGroupException { - - if(LOG.isDebugEnabled()) { + public ServiceGroup getServiceGroup(String name) throws InvalidServiceGroupException { + + if (LOG.isDebugEnabled()) { LOG.debug("getServiceGroupDefinition:" + name); } - - ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); - - if (serviceGroup == null) { - if(LOG.isDebugEnabled()) { + + ServiceGroup serviceGroup = this.dataHolder.getServiceGroup(name); + + if (serviceGroup == null) { + if (LOG.isDebugEnabled()) { LOG.debug("getServiceGroupDefinition: no entry found for service group " + name); } - String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; - throw new InvalidServiceGroupException(msg); - } - - return serviceGroup; + String msg = "ServiceGroup " + name + " is not a deployed Service Group definition"; + throw new InvalidServiceGroupException(msg); + } + + return serviceGroup; } - - public String [] getServiceGroupSubGroups (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - - return serviceGroup.getSubGroups(); + + public String[] getServiceGroupSubGroups(String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + + return serviceGroup.getSubGroups(); } - + /** - * + * */ - public String [] getServiceGroupCartridges (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - String [] cs = serviceGroup.getCartridges(); - return cs; - + public String[] getServiceGroupCartridges(String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + String[] cs = serviceGroup.getCartridges(); + return cs; + } - - public Dependencies getServiceGroupDependencies (String name) throws InvalidServiceGroupException { - ServiceGroup serviceGroup = this.getServiceGroup(name); - if (serviceGroup == null) { - throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); - } - return serviceGroup.getDependencies(); + + public Dependencies getServiceGroupDependencies(String name) throws InvalidServiceGroupException { + ServiceGroup serviceGroup = this.getServiceGroup(name); + if (serviceGroup == null) { + throw new InvalidServiceGroupException("Invalid ServiceGroup " + serviceGroup); + } + return serviceGroup.getDependencies(); } @Override public MemberContext startInstance(MemberContext memberContext) throws - UnregisteredCartridgeException, InvalidIaasProviderException { + UnregisteredCartridgeException, InvalidIaasProviderException { - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:startInstance"); - } + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:startInstance"); + } - handleNullObject(memberContext, "Instance start-up failed. Member is null."); + handleNullObject(memberContext, "Instance start-up failed. Member is null."); String clusterId = memberContext.getClusterId(); Partition partition = memberContext.getPartition(); - if(LOG.isDebugEnabled()) { - LOG.debug("Received an instance spawn request : " + memberContext); + if (LOG.isDebugEnabled()) { + LOG.debug("Received an instance spawn request : " + memberContext); } Template template = null; handleNullObject(partition, "Instance start-up failed. Specified Partition is null. " + - memberContext); + memberContext); String partitionId = partition.getId(); ClusterContext ctxt = dataHolder.getClusterContext(clusterId); @@ -415,8 +414,8 @@ public MemberContext startInstance(MemberContext memberContext) throws if (cartridge == null) { String msg = - "Instance start-up failed. No matching Cartridge found [type] "+cartridgeType +". "+ - memberContext.toString(); + "Instance start-up failed. No matching Cartridge found [type] " + cartridgeType + ". " + + memberContext.toString(); LOG.error(msg); throw new UnregisteredCartridgeException(msg); } @@ -426,20 +425,20 @@ public MemberContext startInstance(MemberContext memberContext) throws IaasProvider iaasProvider = cartridge.getIaasProviderOfPartition(partitionId); if (iaasProvider == null) { - if (LOG.isDebugEnabled()) { - LOG.debug("IaasToPartitionMap "+cartridge.hashCode() - + " for cartridge "+cartridgeType+ " and for partition: "+partitionId); - } - String msg = "Instance start-up failed. " - + "There's no IaaS provided for the partition: " - + partitionId - + " and for the Cartridge type: " - + cartridgeType - + ". Only following " - + "partitions can be found in this Cartridge: " - + cartridge.getPartitionToIaasProvider().keySet() - .toString() + ". " + memberContext.toString() - + ". "; + if (LOG.isDebugEnabled()) { + LOG.debug("IaasToPartitionMap " + cartridge.hashCode() + + " for cartridge " + cartridgeType + " and for partition: " + partitionId); + } + String msg = "Instance start-up failed. " + + "There's no IaaS provided for the partition: " + + partitionId + + " and for the Cartridge type: " + + cartridgeType + + ". Only following " + + "partitions can be found in this Cartridge: " + + cartridge.getPartitionToIaasProvider().keySet() + .toString() + ". " + memberContext.toString() + + ". "; LOG.fatal(msg); throw new InvalidIaasProviderException(msg); } @@ -454,8 +453,8 @@ public MemberContext startInstance(MemberContext memberContext) throws addToPayload(payload, "LB_CLUSTER_ID", memberContext.getLbClusterId()); addToPayload(payload, "NETWORK_PARTITION_ID", memberContext.getNetworkPartitionId()); addToPayload(payload, "PARTITION_ID", partitionId); - if(memberContext.getProperties() != null) { - org.apache.stratos.common.Properties properties = memberContext.getProperties(); + if (memberContext.getProperties() != null) { + org.apache.stratos.common.Properties properties = memberContext.getProperties(); if (properties != null) { for (Property prop : properties.getProperties()) { addToPayload(payload, prop.getName(), prop.getValue()); @@ -464,27 +463,27 @@ public MemberContext startInstance(MemberContext memberContext) throws } Iaas iaas = iaasProvider.getIaas(); - + if (LOG.isDebugEnabled()) { LOG.debug("Payload: " + payload.toString()); } - + if (iaas == null) { - if(LOG.isDebugEnabled()) { - LOG.debug("Iaas is null of Iaas Provider: "+type+". Trying to build IaaS..."); + if (LOG.isDebugEnabled()) { + LOG.debug("Iaas is null of Iaas Provider: " + type + ". Trying to build IaaS..."); } try { iaas = CloudControllerUtil.getIaas(iaasProvider); } catch (InvalidIaasProviderException e) { - String msg ="Instance start up failed. "+memberContext.toString()+ - "Unable to build Iaas of this IaasProvider [Provider] : " + type+". Cause: "+e.getMessage(); + String msg = "Instance start up failed. " + memberContext.toString() + + "Unable to build Iaas of this IaasProvider [Provider] : " + type + ". Cause: " + e.getMessage(); LOG.error(msg, e); throw new InvalidIaasProviderException(msg, e); } - + } - if(ctxt.isVolumeRequired()) { + if (ctxt.isVolumeRequired()) { if (ctxt.getVolumes() != null) { for (Volume volume : ctxt.getVolumes()) { @@ -496,19 +495,19 @@ public MemberContext startInstance(MemberContext memberContext) throws } } - if(ctxt.isVolumeRequired()){ + if (ctxt.isVolumeRequired()) { addToPayload(payload, "PERSISTENCE_MAPPING", getPersistencePayload(ctxt, iaas).toString()); } iaasProvider.setPayload(payload.toString().getBytes()); iaas.setDynamicPayload(); template = iaasProvider.getTemplate(); - + if (template == null) { String msg = - "Failed to start an instance. " + - memberContext.toString() + - ". Reason : Jclouds Template is null for iaas provider [type]: "+iaasProvider.getType(); + "Failed to start an instance. " + + memberContext.toString() + + ". Reason : Jclouds Template is null for iaas provider [type]: " + iaasProvider.getType(); LOG.error(msg); throw new InvalidIaasProviderException(msg); } @@ -516,115 +515,114 @@ public MemberContext startInstance(MemberContext memberContext) throws //Start instance start up in a new thread ThreadExecutor exec = ThreadExecutor.getInstance(); if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller is starting the instance start up thread."); - } + LOG.debug("Cloud Controller is starting the instance start up thread."); + } exec.execute(new JcloudsInstanceCreator(memberContext, iaasProvider, cartridgeType)); - LOG.info("Instance is successfully starting up. "+memberContext.toString()); + LOG.info("Instance is successfully starting up. " + memberContext.toString()); return memberContext; } catch (Exception e) { - String msg = "Failed to start an instance. " + memberContext.toString()+" Cause: "+e.getMessage(); + String msg = "Failed to start an instance. " + memberContext.toString() + " Cause: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(msg, e); } } - private void createVolumeAndSetInClusterContext(Volume volume, - IaasProvider iaasProvider) { - // iaas cannot be null at this state #startInstance method - Iaas iaas = iaasProvider.getIaas(); - int sizeGB = volume.getSize(); - String snapshotId = volume.getSnapshotId(); - if(StringUtils.isNotEmpty(volume.getVolumeId())){ + private void createVolumeAndSetInClusterContext(Volume volume, + IaasProvider iaasProvider) { + // iaas cannot be null at this state #startInstance method + Iaas iaas = iaasProvider.getIaas(); + int sizeGB = volume.getSize(); + String snapshotId = volume.getSnapshotId(); + if (StringUtils.isNotEmpty(volume.getVolumeId())) { // volumeID is specified, so not creating additional volumes - if(LOG.isDebugEnabled()){ + if (LOG.isDebugEnabled()) { LOG.debug("Volume creation is skipping since a volume ID is specified. [Volume ID]" + volume.getVolumeId()); } volume.setId(volume.getVolumeId()); - }else{ + } else { String volumeId = iaas.createVolume(sizeGB, snapshotId); volume.setId(volumeId); } - - volume.setIaasType(iaasProvider.getType()); - } + + volume.setIaasType(iaasProvider.getType()); + } private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) { - StringBuilder persistencePayload = new StringBuilder(); - if(isPersistenceMappingAvailable(ctx)){ - for(Volume volume : ctx.getVolumes()){ - if(LOG.isDebugEnabled()){ - LOG.debug("Adding persistence mapping " + volume.toString()); - } - if(persistencePayload.length() != 0) { - persistencePayload.append("|"); + StringBuilder persistencePayload = new StringBuilder(); + if (isPersistenceMappingAvailable(ctx)) { + for (Volume volume : ctx.getVolumes()) { + if (LOG.isDebugEnabled()) { + LOG.debug("Adding persistence mapping " + volume.toString()); + } + if (persistencePayload.length() != 0) { + persistencePayload.append("|"); } - - persistencePayload.append(iaas.getIaasDevice(volume.getDevice())); - persistencePayload.append("|"); + + persistencePayload.append(iaas.getIaasDevice(volume.getDevice())); + persistencePayload.append("|"); persistencePayload.append(volume.getId()); persistencePayload.append("|"); persistencePayload.append(volume.getMappingPath()); - } - } - if(LOG.isDebugEnabled()){ + } + } + if (LOG.isDebugEnabled()) { LOG.debug("Persistence payload is" + persistencePayload.toString()); } - return persistencePayload; - } + return persistencePayload; + } - private boolean isPersistenceMappingAvailable(ClusterContext ctx) { - return ctx.getVolumes() != null && ctx.isVolumeRequired(); - } + private boolean isPersistenceMappingAvailable(ClusterContext ctx) { + return ctx.getVolumes() != null && ctx.isVolumeRequired(); + } - private void addToPayload(StringBuilder payload, String name, String value) { - payload.append(","); - payload.append(name+"=" + value); + private void addToPayload(StringBuilder payload, String name, String value) { + payload.append(","); + payload.append(name + "=" + value); } /** - * Persist data in registry. - */ - private void persist() { - try { - RegistryManager.getInstance().persist( - dataHolder); - } catch (RegistryException e) { - - String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; - LOG.fatal(msg); - throw new CloudControllerException(msg, e); - } - } + * Persist data in registry. + */ + private void persist() { + try { + RegistryManager.getInstance().persist( + dataHolder); + } catch (RegistryException e) { + + String msg = "Failed to persist the Cloud Controller data in registry. Further, transaction roll back also failed."; + LOG.fatal(msg); + throw new CloudControllerException(msg, e); + } + } private String generateMemberId(String clusterId) { UUID memberId = UUID.randomUUID(); - return clusterId + memberId.toString(); + return clusterId + memberId.toString(); } @Override - public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException - { + public void terminateInstance(String memberId) throws InvalidMemberException, InvalidCartridgeTypeException { handleNullObject(memberId, "Termination failed. Null member id."); - + MemberContext ctxt = dataHolder.getMemberContextOfMemberId(memberId); - - if(ctxt == null) { - String msg = "Termination failed. Invalid Member Id: "+memberId; + + if (ctxt == null) { + String msg = "Termination failed. Invalid Member Id: " + memberId; LOG.error(msg); throw new InvalidMemberException(msg); } - + ThreadExecutor exec = ThreadExecutor.getInstance(); exec.execute(new InstanceTerminator(ctxt)); - } - + } + private class InstanceTerminator implements Runnable { private MemberContext ctxt; @@ -647,14 +645,14 @@ public void run() { Cartridge cartridge = dataHolder.getCartridge(cartridgeType); LOG.info("Starting to terminate an instance with member id : " + memberId + - " in partition id: " + partitionId + " of cluster id: " + clusterId + - " and of cartridge type: " + cartridgeType); + " in partition id: " + partitionId + " of cluster id: " + clusterId + + " and of cartridge type: " + cartridgeType); if (cartridge == null) { String msg = - "Termination of Member Id: " + memberId + " failed. " + - "Cannot find a matching Cartridge for type: " + - cartridgeType; + "Termination of Member Id: " + memberId + " failed. " + + "Cannot find a matching Cartridge for type: " + + cartridgeType; LOG.error(msg); throw new InvalidCartridgeTypeException(msg); } @@ -663,8 +661,8 @@ public void run() { if (nodeId == null) { String msg = - "Termination failed. Cannot find a node id for Member Id: " + - memberId; + "Termination failed. Cannot find a node id for Member Id: " + + memberId; // log information logTermination(ctxt); @@ -682,7 +680,7 @@ public void run() { } catch (Exception e) { String msg = - "Instance termination failed. "+ctxt.toString(); + "Instance termination failed. " + ctxt.toString(); LOG.error(msg, e); throw new CloudControllerException(msg, e); } @@ -696,8 +694,8 @@ private class JcloudsInstanceCreator implements Runnable { private IaasProvider iaasProvider; private String cartridgeType; - public JcloudsInstanceCreator(MemberContext memberContext, IaasProvider iaasProvider, - String cartridgeType) { + public JcloudsInstanceCreator(MemberContext memberContext, IaasProvider iaasProvider, + String cartridgeType) { this.memberContext = memberContext; this.iaasProvider = iaasProvider; this.cartridgeType = cartridgeType; @@ -712,379 +710,380 @@ public void run() { ClusterContext ctxt = dataHolder.getClusterContext(clusterId); Iaas iaas = iaasProvider.getIaas(); String publicIp = null; - + NodeMetadata node = null; // generate the group id from domain name and sub domain name. // Should have lower-case ASCII letters, numbers, or dashes. // Should have a length between 3-15 String str = clusterId.length() > 10 ? clusterId.substring(0, 10) : clusterId.substring(0, clusterId.length()); String group = str.replaceAll("[^a-z0-9-]", ""); - + try { - ComputeService computeService = iaasProvider - .getComputeService(); - Template template = iaasProvider.getTemplate(); - - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller is delegating request to start an instance for " - + memberContext + " to Jclouds layer."); - } - // create and start a node - Set nodes = computeService - .createNodesInGroup(group, 1, template); - node = nodes.iterator().next(); - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller received a response for the request to start " - + memberContext + " from Jclouds layer."); - } - - if (node == null) { - String msg = "Null response received for instance start-up request to Jclouds.\n" + ComputeService computeService = iaasProvider + .getComputeService(); + Template template = iaasProvider.getTemplate(); + + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller is delegating request to start an instance for " + + memberContext + " to Jclouds layer."); + } + // create and start a node + Set nodes = computeService + .createNodesInGroup(group, 1, template); + node = nodes.iterator().next(); + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller received a response for the request to start " + + memberContext + " from Jclouds layer."); + } + + if (node == null) { + String msg = "Null response received for instance start-up request to Jclouds.\n" + memberContext.toString(); LOG.error(msg); throw new IllegalStateException(msg); - } - - // node id - String nodeId = node.getId(); - if (nodeId == null) { - String msg = "Node id of the starting instance is null.\n" - + memberContext.toString(); - LOG.fatal(msg); - throw new IllegalStateException(msg); - } - - memberContext.setNodeId(nodeId); - if (LOG.isDebugEnabled()) { - LOG.debug("Node id was set. " + memberContext.toString()); - } - - // attach volumes - if (ctxt.isVolumeRequired()) { - // remove region prefix - String instanceId = nodeId.indexOf('/') != -1 ? nodeId - .substring(nodeId.indexOf('/') + 1, nodeId.length()) - : nodeId; - memberContext.setInstanceId(instanceId); - if (ctxt.getVolumes() != null) { - for (Volume volume : ctxt.getVolumes()) { - try { - iaas.attachVolume(instanceId, volume.getId(), - volume.getDevice()); - } catch (Exception e) { - // continue without throwing an exception, since - // there is an instance already running - LOG.error("Attaching Volume to Instance [ " - + instanceId + " ] failed!", e); - } - } - } - } - + } + + // node id + String nodeId = node.getId(); + if (nodeId == null) { + String msg = "Node id of the starting instance is null.\n" + + memberContext.toString(); + LOG.fatal(msg); + throw new IllegalStateException(msg); + } + + memberContext.setNodeId(nodeId); + if (LOG.isDebugEnabled()) { + LOG.debug("Node id was set. " + memberContext.toString()); + } + + // attach volumes + if (ctxt.isVolumeRequired()) { + // remove region prefix + String instanceId = nodeId.indexOf('/') != -1 ? nodeId + .substring(nodeId.indexOf('/') + 1, nodeId.length()) + : nodeId; + memberContext.setInstanceId(instanceId); + if (ctxt.getVolumes() != null) { + for (Volume volume : ctxt.getVolumes()) { + try { + iaas.attachVolume(instanceId, volume.getId(), + volume.getDevice()); + } catch (Exception e) { + // continue without throwing an exception, since + // there is an instance already running + LOG.error("Attaching Volume to Instance [ " + + instanceId + " ] failed!", e); + } + } + } + } + } catch (Exception e) { - String msg = "Failed to start an instance. " + memberContext.toString()+" Cause: "+e.getMessage(); - LOG.error(msg, e); - throw new IllegalStateException(msg, e); + String msg = "Failed to start an instance. " + memberContext.toString() + " Cause: " + e.getMessage(); + LOG.error(msg, e); + throw new IllegalStateException(msg, e); } - try{ - if (LOG.isDebugEnabled()) { - LOG.debug("IP allocation process started for "+memberContext); - } + try { + if (LOG.isDebugEnabled()) { + LOG.debug("IP allocation process started for " + memberContext); + } String autoAssignIpProp = - iaasProvider.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY); - + iaasProvider.getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY); + String pre_defined_ip = iaasProvider.getProperty(CloudControllerConstants.FLOATING_IP_PROPERTY); - - // reset ip - String ip = ""; - - // default behavior is autoIpAssign=false - if (autoAssignIpProp == null || + + // reset ip + String ip = ""; + + // default behavior is autoIpAssign=false + if (autoAssignIpProp == null || (autoAssignIpProp != null && autoAssignIpProp.equals("false"))) { - - // check if floating ip is well defined in cartridge definition - if (pre_defined_ip != null) { - if (isValidIpAddress(pre_defined_ip)) { - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:IpAllocator:pre_defined_ip: invoking associatePredefinedAddress" + pre_defined_ip); - } - ip = iaas.associatePredefinedAddress(node, pre_defined_ip); - - if (ip == null || "".equals(ip) || !pre_defined_ip.equals(ip)) { - // throw exception and stop instance creation - String msg = "Error occurred while allocating predefined floating ip address: " + pre_defined_ip + - " / allocated ip:" + ip + - " - terminating node:" + memberContext.toString(); - LOG.error(msg); - // terminate instance - terminate(iaasProvider, - node.getId(), memberContext); - throw new CloudControllerException(msg); - } - } else { - String msg = "Invalid floating ip address configured: " + pre_defined_ip + - " - terminating node:" + memberContext.toString(); - LOG.error(msg); - // terminate instance - terminate(iaasProvider, - node.getId(), memberContext); - throw new CloudControllerException(msg); - } - + + // check if floating ip is well defined in cartridge definition + if (pre_defined_ip != null) { + if (isValidIpAddress(pre_defined_ip)) { + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:IpAllocator:pre_defined_ip: invoking associatePredefinedAddress" + pre_defined_ip); + } + ip = iaas.associatePredefinedAddress(node, pre_defined_ip); + + if (ip == null || "".equals(ip) || !pre_defined_ip.equals(ip)) { + // throw exception and stop instance creation + String msg = "Error occurred while allocating predefined floating ip address: " + pre_defined_ip + + " / allocated ip:" + ip + + " - terminating node:" + memberContext.toString(); + LOG.error(msg); + // terminate instance + terminate(iaasProvider, + node.getId(), memberContext); + throw new CloudControllerException(msg); + } } else { - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:IpAllocator:no (valid) predefined floating ip configured, " - + "selecting available one from pool"); - } - // allocate an IP address - manual IP assigning mode - ip = iaas.associateAddress(node); - - if (ip != null) { - memberContext.setAllocatedIpAddress(ip); - LOG.info("Allocated an ip address: " - + memberContext.toString()); - } - } - - if (ip == null) { - String msg = "No IP address found. IP allocation failed for "+memberContext; - LOG.error(msg); + String msg = "Invalid floating ip address configured: " + pre_defined_ip + + " - terminating node:" + memberContext.toString(); + LOG.error(msg); + // terminate instance + terminate(iaasProvider, + node.getId(), memberContext); throw new CloudControllerException(msg); - } - - // build the node with the new ip - node = NodeMetadataBuilder.fromNodeMetadata(node) - .publicAddresses(ImmutableSet.of(ip)).build(); - } - - - // public ip - if (node.getPublicAddresses() != null && - node.getPublicAddresses().iterator().hasNext()) { - ip = node.getPublicAddresses().iterator().next(); - publicIp = ip; - memberContext.setPublicIpAddress(ip); - LOG.info("Retrieving Public IP Address : " + memberContext.toString()); + } + + } else { + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:IpAllocator:no (valid) predefined floating ip configured, " + + "selecting available one from pool"); + } + // allocate an IP address - manual IP assigning mode + ip = iaas.associateAddress(node); + + if (ip != null) { + memberContext.setAllocatedIpAddress(ip); + LOG.info("Allocated an ip address: " + + memberContext.toString()); + } } - // private IP - if (node.getPrivateAddresses() != null && - node.getPrivateAddresses().iterator().hasNext()) { - ip = node.getPrivateAddresses().iterator().next(); - memberContext.setPrivateIpAddress(ip); - LOG.info("Retrieving Private IP Address. " + memberContext.toString()); + if (ip == null) { + String msg = "No IP address found. IP allocation failed for " + memberContext; + LOG.error(msg); + throw new CloudControllerException(msg); } - dataHolder.addMemberContext(memberContext); + // build the node with the new ip + node = NodeMetadataBuilder.fromNodeMetadata(node) + .publicAddresses(ImmutableSet.of(ip)).build(); + } - // persist in registry - persist(); + // public ip + if (node.getPublicAddresses() != null && + node.getPublicAddresses().iterator().hasNext()) { + ip = node.getPublicAddresses().iterator().next(); + publicIp = ip; + memberContext.setPublicIpAddress(ip); + LOG.info("Retrieving Public IP Address : " + memberContext.toString()); + } - // trigger topology - TopologyBuilder.handleMemberSpawned(cartridgeType, clusterId, - partition.getId(), ip, publicIp, memberContext); - - String memberID = memberContext.getMemberId(); + // private IP + if (node.getPrivateAddresses() != null && + node.getPrivateAddresses().iterator().hasNext()) { + ip = node.getPrivateAddresses().iterator().next(); + memberContext.setPrivateIpAddress(ip); + LOG.info("Retrieving Private IP Address. " + memberContext.toString()); + } - // update the topology with the newly spawned member - // publish data - CartridgeInstanceDataPublisher.publish(memberID, - memberContext.getPartition().getId(), - memberContext.getNetworkPartitionId(), - memberContext.getClusterId(), - cartridgeType, - MemberStatus.Created.toString(), - node); - if (LOG.isDebugEnabled()) { - LOG.debug("Node details: " + node.toString()); - } - - if (LOG.isDebugEnabled()) { - LOG.debug("IP allocation process ended for "+memberContext); - } + dataHolder.addMemberContext(memberContext); + + // persist in registry + persist(); + + + // trigger topology + TopologyBuilder.handleMemberSpawned(cartridgeType, clusterId, + partition.getId(), ip, publicIp, memberContext); + + String memberID = memberContext.getMemberId(); + + // update the topology with the newly spawned member + // publish data + CartridgeInstanceDataPublisher.publish(memberID, + memberContext.getPartition().getId(), + memberContext.getNetworkPartitionId(), + memberContext.getClusterId(), + cartridgeType, + MemberStatus.Created.toString(), + node); + if (LOG.isDebugEnabled()) { + LOG.debug("Node details: " + node.toString()); + } + + if (LOG.isDebugEnabled()) { + LOG.debug("IP allocation process ended for " + memberContext); + } } catch (Exception e) { String msg = "Error occurred while allocating an ip address. " + memberContext.toString(); LOG.error(msg, e); throw new CloudControllerException(msg, e); - } + } } } - - private boolean isValidIpAddress (String ip) { - boolean isValid = InetAddresses.isInetAddress(ip); - return isValid; + + private boolean isValidIpAddress(String ip) { + boolean isValid = InetAddresses.isInetAddress(ip); + return isValid; } - @Override - public void terminateAllInstances(String clusterId) throws InvalidClusterException { + @Override + public void terminateAllInstances(String clusterId) throws InvalidClusterException { + + LOG.info("Starting to terminate all instances of cluster : " + + clusterId); - LOG.info("Starting to terminate all instances of cluster : " - + clusterId); - - handleNullObject(clusterId, "Instance termination failed. Cluster id is null."); - - List ctxts = dataHolder.getMemberContextsOfClusterId(clusterId); - - if(ctxts == null) { - String msg = "Instance termination failed. No members found for cluster id: "+clusterId; - LOG.warn(msg); + handleNullObject(clusterId, "Instance termination failed. Cluster id is null."); + + List ctxts = dataHolder.getMemberContextsOfClusterId(clusterId); + + if (ctxts == null) { + String msg = "Instance termination failed. No members found for cluster id: " + clusterId; + LOG.warn(msg); return; - } - - ThreadExecutor exec = ThreadExecutor.getInstance(); - for (MemberContext memberContext : ctxts) { + } + + ThreadExecutor exec = ThreadExecutor.getInstance(); + for (MemberContext memberContext : ctxts) { exec.execute(new InstanceTerminator(memberContext)); } - } + } - /** - * A helper method to terminate an instance. + /** + * A helper method to terminate an instance. + * * @param iaasProvider * @param ctxt * @param nodeId * @return will return the IaaSProvider */ - private IaasProvider terminate(IaasProvider iaasProvider, - String nodeId, MemberContext ctxt) { - Iaas iaas = iaasProvider.getIaas(); - if (iaas == null) { - - try { - iaas = CloudControllerUtil.getIaas(iaasProvider); - } catch (InvalidIaasProviderException e) { - String msg = - "Instance termination failed. " +ctxt.toString() + - ". Cause: Unable to build Iaas of this " + iaasProvider.toString(); - LOG.error(msg, e); - throw new CloudControllerException(msg, e); - } - - } - - //detach volumes if any - detachVolume(iaasProvider, ctxt); - - // destroy the node - iaasProvider.getComputeService().destroyNode(nodeId); - - // release allocated IP address - if (ctxt.getAllocatedIpAddress() != null) { + private IaasProvider terminate(IaasProvider iaasProvider, + String nodeId, MemberContext ctxt) { + Iaas iaas = iaasProvider.getIaas(); + if (iaas == null) { + + try { + iaas = CloudControllerUtil.getIaas(iaasProvider); + } catch (InvalidIaasProviderException e) { + String msg = + "Instance termination failed. " + ctxt.toString() + + ". Cause: Unable to build Iaas of this " + iaasProvider.toString(); + LOG.error(msg, e); + throw new CloudControllerException(msg, e); + } + + } + + //detach volumes if any + detachVolume(iaasProvider, ctxt); + + // destroy the node + iaasProvider.getComputeService().destroyNode(nodeId); + + // release allocated IP address + if (ctxt.getAllocatedIpAddress() != null) { iaas.releaseAddress(ctxt.getAllocatedIpAddress()); - } - - LOG.info("Member is terminated: "+ctxt.toString()); - return iaasProvider; - } - - private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { - String clusterId = ctxt.getClusterId(); - ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId); - if (clusterCtxt.getVolumes() != null) { - for (Volume volume : clusterCtxt.getVolumes()) { - try { - String volumeId = volume.getId(); - if (volumeId == null) { - return; - } - Iaas iaas = iaasProvider.getIaas(); - iaas.detachVolume(ctxt.getInstanceId(), volumeId); - } catch (ResourceNotFoundException ignore) { - if(LOG.isDebugEnabled()) { - LOG.debug(ignore); - } - } - } - } - } - - private void logTermination(MemberContext memberContext) { - - if (memberContext == null) { - return; - } - - String partitionId = memberContext.getPartition() == null ? null : memberContext.getPartition().getId(); - + } + + LOG.info("Member is terminated: " + ctxt.toString()); + return iaasProvider; + } + + private void detachVolume(IaasProvider iaasProvider, MemberContext ctxt) { + String clusterId = ctxt.getClusterId(); + ClusterContext clusterCtxt = dataHolder.getClusterContext(clusterId); + if (clusterCtxt.getVolumes() != null) { + for (Volume volume : clusterCtxt.getVolumes()) { + try { + String volumeId = volume.getId(); + if (volumeId == null) { + return; + } + Iaas iaas = iaasProvider.getIaas(); + iaas.detachVolume(ctxt.getInstanceId(), volumeId); + } catch (ResourceNotFoundException ignore) { + if (LOG.isDebugEnabled()) { + LOG.debug(ignore); + } + } + } + } + } + + private void logTermination(MemberContext memberContext) { + + if (memberContext == null) { + return; + } + + String partitionId = memberContext.getPartition() == null ? null : memberContext.getPartition().getId(); + //updating the topology - TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), - memberContext.getClusterId(), memberContext.getNetworkPartitionId(), - partitionId, memberContext.getMemberId()); + TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), + memberContext.getClusterId(), memberContext.getNetworkPartitionId(), + partitionId, memberContext.getMemberId()); //publishing data CartridgeInstanceDataPublisher.publish(memberContext.getMemberId(), - partitionId, - memberContext.getNetworkPartitionId(), - memberContext.getClusterId(), - memberContext.getCartridgeType(), - MemberStatus.Terminated.toString(), - null); + partitionId, + memberContext.getNetworkPartitionId(), + memberContext.getClusterId(), + memberContext.getCartridgeType(), + MemberStatus.Terminated.toString(), + null); // update data holders dataHolder.removeMemberContext(memberContext.getMemberId(), memberContext.getClusterId()); - - // persist - persist(); - - } - - @Override - public boolean registerService(Registrant registrant) - throws UnregisteredCartridgeException { - - String cartridgeType = registrant.getCartridgeType(); - handleNullObject(cartridgeType, "Service registration failed. Cartridge Type is null."); - - String clusterId = registrant.getClusterId(); - handleNullObject(clusterId, "Service registration failed. Cluster id is null."); - + + // persist + persist(); + + } + + @Override + public boolean registerService(Registrant registrant) + throws UnregisteredCartridgeException { + + String cartridgeType = registrant.getCartridgeType(); + handleNullObject(cartridgeType, "Service registration failed. Cartridge Type is null."); + + String clusterId = registrant.getClusterId(); + handleNullObject(clusterId, "Service registration failed. Cluster id is null."); + String payload = registrant.getPayload(); handleNullObject(payload, "Service registration failed. Payload is null."); - + String hostName = registrant.getHostName(); handleNullObject(hostName, "Service registration failed. Hostname is null."); - + Cartridge cartridge = null; if ((cartridge = dataHolder.getCartridge(cartridgeType)) == null) { - String msg = "Registration of cluster: "+clusterId+ + String msg = "Registration of cluster: " + clusterId + " failed. - Unregistered Cartridge type: " + cartridgeType; LOG.error(msg); throw new UnregisteredCartridgeException(msg); } - + Properties props = CloudControllerUtil.toJavaUtilProperties(registrant.getProperties()); String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; ClusterContext ctxt = null;//TODO buildClusterContext(cartridge, clusterId, - //payload, hostName, props, isLb, registrant.getPersistence()); + //payload, hostName, props, isLb, registrant.getPersistence()); - dataHolder.addClusterContext(ctxt); - TopologyBuilder.handleClusterCreated(registrant, isLb); - - persist(); - - LOG.info("Successfully registered: "+registrant); - - return true; - } + dataHolder.addClusterContext(ctxt); + TopologyBuilder.handleClusterCreated(registrant, isLb); - private ClusterContext buildClusterContext(Cartridge cartridge, - String clusterId, String payload, String hostName, - org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) { + persist(); - //TODO - /*// initialize ClusterContext - ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, + LOG.info("Successfully registered: " + registrant); + + return true; + } + + private ClusterContext buildClusterContext(Cartridge cartridge, + String clusterId, String payload, String hostName, + org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) { + + //TODO + /*// initialize ClusterContext + ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, hostName, isLb, props); String property; @@ -1105,219 +1104,218 @@ private ClusterContext buildClusterContext(Cartridge cartridge, ctxt.setTimeoutInMillis(timeout); return ctxt;*/ return null; - } + } + + @Override + public String[] getRegisteredCartridges() { + // get the list of cartridges registered + List cartridges = dataHolder + .getCartridges(); + + if (cartridges == null) { + LOG.info("No registered Cartridge found."); + return new String[0]; + } + + String[] cartridgeTypes = new String[cartridges.size()]; + int i = 0; + + if (LOG.isDebugEnabled()) { + LOG.debug("Registered Cartridges : \n"); + } + for (Cartridge cartridge : cartridges) { + if (LOG.isDebugEnabled()) { + LOG.debug(cartridge); + } + cartridgeTypes[i] = cartridge.getType(); + i++; + } + + return cartridgeTypes; + } @Override - public String[] getRegisteredCartridges() { - // get the list of cartridges registered - List cartridges = dataHolder - .getCartridges(); - - if (cartridges == null) { - LOG.info("No registered Cartridge found."); - return new String[0]; - } - - String[] cartridgeTypes = new String[cartridges.size()]; - int i = 0; - - if (LOG.isDebugEnabled()) { - LOG.debug("Registered Cartridges : \n"); - } - for (Cartridge cartridge : cartridges) { - if (LOG.isDebugEnabled()) { - LOG.debug(cartridge); - } - cartridgeTypes[i] = cartridge.getType(); - i++; - } - - return cartridgeTypes; - } - - @Override - public CartridgeInfo getCartridgeInfo(String cartridgeType) - throws UnregisteredCartridgeException { - Cartridge cartridge = dataHolder - .getCartridge(cartridgeType); - - if (cartridge != null) { - - return CloudControllerUtil.toCartridgeInfo(cartridge); - - } - - String msg = "Cannot find a Cartridge having a type of " - + cartridgeType + ". Hence unable to find information."; - LOG.error(msg); - throw new UnregisteredCartridgeException(msg); - } + public CartridgeInfo getCartridgeInfo(String cartridgeType) + throws UnregisteredCartridgeException { + Cartridge cartridge = dataHolder + .getCartridge(cartridgeType); + + if (cartridge != null) { + + return CloudControllerUtil.toCartridgeInfo(cartridge); + + } + + String msg = "Cannot find a Cartridge having a type of " + + cartridgeType + ". Hence unable to find information."; + LOG.error(msg); + throw new UnregisteredCartridgeException(msg); + } @Override - public void unregisterService(String clusterId) throws UnregisteredClusterException { + public void unregisterService(String clusterId) throws UnregisteredClusterException { final String clusterId_ = clusterId; - + ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); - handleNullObject(ctxt, "Service unregistration failed. Invalid cluster id: "+clusterId); - + handleNullObject(ctxt, "Service unregistration failed. Invalid cluster id: " + clusterId); + String cartridgeType = ctxt.getCartridgeType(); Cartridge cartridge = dataHolder.getCartridge(cartridgeType); if (cartridge == null) { String msg = - "Service unregistration failed. No matching Cartridge found [type] "+cartridgeType +". "; + "Service unregistration failed. No matching Cartridge found [type] " + cartridgeType + ". "; LOG.error(msg); throw new UnregisteredClusterException(msg); } - + // if it's a kubernetes cluster if (StratosConstants.KUBERNETES_DEPLOYER_TYPE.equals(cartridge.getDeployerType())) { - unregisterDockerService(clusterId_); - + unregisterDockerService(clusterId_); + } else { - + // TopologyBuilder.handleClusterMaintenanceMode(dataHolder.getClusterContext(clusterId_)); - - Runnable terminateInTimeout = new Runnable() { - @Override - public void run() { - ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); - if(ctxt == null) { - String msg = "Service unregistration failed. Cluster not found: " + clusterId_; - LOG.error(msg); - return; - } - Collection members = TopologyManager.getTopology(). - getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); - //finding the responding members from the existing members in the topology. - int sizeOfRespondingMembers = 0; - for(Member member : members) { - if(member.getStatus().getCode() >= MemberStatus.Activated.getCode()) { - sizeOfRespondingMembers ++; - } - } - - long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * sizeOfRespondingMembers; - while(System.currentTimeMillis()< endTime) { - CloudControllerUtil.sleep(1000); - - } - - // if there're still alive members - if(members.size() > 0) { - //forcefully terminate them - for (Member member : members) { - - try { - terminateInstance(member.getMemberId()); - } catch (Exception e) { - // we are not gonna stop the execution due to errors. - LOG.warn("Instance termination failed of member [id] " + member.getMemberId(), e); - } - } - } - } - }; - Runnable unregister = new Runnable() { - public void run() { - ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); - if(ctxt == null) { - String msg = "Service unregistration failed. Cluster not found: " + clusterId_; - LOG.error(msg); - return; - } - Collection members = TopologyManager.getTopology(). - getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); - // TODO why end time is needed? - // long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size(); - - while(members.size() > 0) { - //waiting until all the members got removed from the Topology/ timed out - CloudControllerUtil.sleep(1000); - } - - LOG.info("Unregistration of service cluster: " + clusterId_); - deleteVolumes(ctxt); - onClusterRemoval(clusterId_); - } - - private void deleteVolumes(ClusterContext ctxt) { - if(ctxt.isVolumeRequired()) { - Cartridge cartridge = dataHolder.getCartridge(ctxt.getCartridgeType()); - if(cartridge != null && cartridge.getIaases() != null && ctxt.getVolumes() != null) { - for (Volume volume : ctxt.getVolumes()) { - if(volume.getId() != null) { - String iaasType = volume.getIaasType(); - //Iaas iaas = dataHolder.getIaasProvider(iaasType).getIaas(); - Iaas iaas = cartridge.getIaasProvider(iaasType).getIaas(); - if(iaas != null) { - try { - // delete the volumes if remove on unsubscription is true. - if(volume.isRemoveOntermination()) - { - iaas.deleteVolume(volume.getId()); - volume.setId(null); - } - } catch(Exception ignore) { - if(LOG.isErrorEnabled()) { - LOG.error("Error while deleting volume [id] "+ volume.getId(), ignore); - } - } - } - } - } - - } - } - } - }; - new Thread(terminateInTimeout).start(); - new Thread(unregister).start(); - } - } - + + Runnable terminateInTimeout = new Runnable() { + @Override + public void run() { + ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); + if (ctxt == null) { + String msg = "Service unregistration failed. Cluster not found: " + clusterId_; + LOG.error(msg); + return; + } + Collection members = TopologyManager.getTopology(). + getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); + //finding the responding members from the existing members in the topology. + int sizeOfRespondingMembers = 0; + for (Member member : members) { + if (member.getStatus().getCode() >= MemberStatus.Activated.getCode()) { + sizeOfRespondingMembers++; + } + } + + long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * sizeOfRespondingMembers; + while (System.currentTimeMillis() < endTime) { + CloudControllerUtil.sleep(1000); + + } + + // if there're still alive members + if (members.size() > 0) { + //forcefully terminate them + for (Member member : members) { + + try { + terminateInstance(member.getMemberId()); + } catch (Exception e) { + // we are not gonna stop the execution due to errors. + LOG.warn("Instance termination failed of member [id] " + member.getMemberId(), e); + } + } + } + } + }; + Runnable unregister = new Runnable() { + public void run() { + ClusterContext ctxt = dataHolder.getClusterContext(clusterId_); + if (ctxt == null) { + String msg = "Service unregistration failed. Cluster not found: " + clusterId_; + LOG.error(msg); + return; + } + Collection members = TopologyManager.getTopology(). + getService(ctxt.getCartridgeType()).getCluster(clusterId_).getMembers(); + // TODO why end time is needed? + // long endTime = System.currentTimeMillis() + ctxt.getTimeoutInMillis() * members.size(); + + while (members.size() > 0) { + //waiting until all the members got removed from the Topology/ timed out + CloudControllerUtil.sleep(1000); + } + + LOG.info("Unregistration of service cluster: " + clusterId_); + deleteVolumes(ctxt); + onClusterRemoval(clusterId_); + } + + private void deleteVolumes(ClusterContext ctxt) { + if (ctxt.isVolumeRequired()) { + Cartridge cartridge = dataHolder.getCartridge(ctxt.getCartridgeType()); + if (cartridge != null && cartridge.getIaases() != null && ctxt.getVolumes() != null) { + for (Volume volume : ctxt.getVolumes()) { + if (volume.getId() != null) { + String iaasType = volume.getIaasType(); + //Iaas iaas = dataHolder.getIaasProvider(iaasType).getIaas(); + Iaas iaas = cartridge.getIaasProvider(iaasType).getIaas(); + if (iaas != null) { + try { + // delete the volumes if remove on unsubscription is true. + if (volume.isRemoveOntermination()) { + iaas.deleteVolume(volume.getId()); + volume.setId(null); + } + } catch (Exception ignore) { + if (LOG.isErrorEnabled()) { + LOG.error("Error while deleting volume [id] " + volume.getId(), ignore); + } + } + } + } + } + + } + } + } + }; + new Thread(terminateInTimeout).start(); + new Thread(unregister).start(); + } + } + @Override - public void unregisterDockerService(String clusterId) - throws UnregisteredClusterException { - - // terminate all kubernetes units - try { - terminateAllContainers(clusterId); - } catch (InvalidClusterException e) { - String msg = "Docker instance termination fails for cluster: "+clusterId; - LOG.error(msg, e); - throw new UnregisteredClusterException(msg, e); - } - // send cluster removal notifications and update the state - onClusterRemoval(clusterId); - } + public void unregisterDockerService(String clusterId) + throws UnregisteredClusterException { + + // terminate all kubernetes units + try { + terminateAllContainers(clusterId); + } catch (InvalidClusterException e) { + String msg = "Docker instance termination fails for cluster: " + clusterId; + LOG.error(msg, e); + throw new UnregisteredClusterException(msg, e); + } + // send cluster removal notifications and update the state + onClusterRemoval(clusterId); + } @Override - public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) + public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partitions) throws InvalidPartitionException, InvalidCartridgeTypeException { - Map> validatedCache = dataHolder.getCartridgeTypeToPartitionIds(); - List validatedPartitions = new ArrayList(); - - if (validatedCache.containsKey(cartridgeType)) { - // cache hit for this cartridge - // get list of partitions - validatedPartitions = validatedCache.get(cartridgeType); - if (LOG.isDebugEnabled()) { - LOG.debug("Partition validation cache hit for cartridge type: "+cartridgeType); - } - - } - + Map> validatedCache = dataHolder.getCartridgeTypeToPartitionIds(); + List validatedPartitions = new ArrayList(); + + if (validatedCache.containsKey(cartridgeType)) { + // cache hit for this cartridge + // get list of partitions + validatedPartitions = validatedCache.get(cartridgeType); + if (LOG.isDebugEnabled()) { + LOG.debug("Partition validation cache hit for cartridge type: " + cartridgeType); + } + + } + Map partitionToIaasProviders = - new ConcurrentHashMap(); - + new ConcurrentHashMap(); + if (LOG.isDebugEnabled()) { - LOG.debug("Deployment policy validation started for cartridge type: "+cartridgeType); - } + LOG.debug("Deployment policy validation started for cartridge type: " + cartridgeType); + } Cartridge cartridge = dataHolder.getCartridge(cartridgeType); @@ -1326,138 +1324,138 @@ public boolean validateDeploymentPolicy(String cartridgeType, Partition[] partit LOG.error(msg); throw new InvalidCartridgeTypeException(msg); } - + Map> jobList = new HashMap>(); - for (Partition partition : partitions) { - - if (validatedPartitions.contains(partition.getId())) { - // partition cache hit - continue; - } - - Callable worker = new PartitionValidatorCallable( - partition, cartridge); - Future job = FasterLookUpDataHolder.getInstance() - .getExecutor().submit(worker); - jobList.put(partition.getId(), job); - } - + for (Partition partition : partitions) { + + if (validatedPartitions.contains(partition.getId())) { + // partition cache hit + continue; + } + + Callable worker = new PartitionValidatorCallable( + partition, cartridge); + Future job = FasterLookUpDataHolder.getInstance() + .getExecutor().submit(worker); + jobList.put(partition.getId(), job); + } + // Retrieve the results of the concurrently performed sanity checks. for (Entry> entry : jobList.entrySet()) { if (entry == null) { continue; } String partitionId = entry.getKey(); - Future job = entry.getValue(); + Future job = entry.getValue(); try { - // add to a temporary Map - partitionToIaasProviders.put(partitionId, job.get()); - - // add to cache - this.dataHolder.addToCartridgeTypeToPartitionIdMap(cartridgeType, partitionId); - - if (LOG.isDebugEnabled()) { - LOG.debug("Partition "+partitionId+" added to the cache against cartridge type: "+cartridgeType); - } + // add to a temporary Map + partitionToIaasProviders.put(partitionId, job.get()); + + // add to cache + this.dataHolder.addToCartridgeTypeToPartitionIdMap(cartridgeType, partitionId); + + if (LOG.isDebugEnabled()) { + LOG.debug("Partition " + partitionId + " added to the cache against cartridge type: " + cartridgeType); + } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new InvalidPartitionException(e.getMessage(), e); - } + } } // if and only if the deployment policy valid cartridge.addIaasProviders(partitionToIaasProviders); - + // persist data persist(); - - LOG.info("All partitions "+CloudControllerUtil.getPartitionIds(partitions)+ - " were validated successfully, against the Cartridge: "+cartridgeType); - + + LOG.info("All partitions " + CloudControllerUtil.getPartitionIds(partitions) + + " were validated successfully, against the Cartridge: " + cartridgeType); + return true; } - + private void onClusterRemoval(final String clusterId) { - ClusterContext ctxt = dataHolder.getClusterContext(clusterId); - TopologyBuilder.handleClusterRemoved(ctxt); - dataHolder.removeClusterContext(clusterId); - dataHolder.removeMemberContextsOfCluster(clusterId); - persist(); - } + ClusterContext ctxt = dataHolder.getClusterContext(clusterId); + TopologyBuilder.handleClusterRemoved(ctxt); + dataHolder.removeClusterContext(clusterId); + dataHolder.removeMemberContextsOfCluster(clusterId); + persist(); + } @Override public boolean validatePartition(Partition partition) throws InvalidPartitionException { handleNullObject(partition, "Partition validation failed. Partition is null."); String provider = partition.getProvider(); - handleNullObject(provider, "Partition ["+partition.getId()+"] validation failed. Partition provider is null."); + handleNullObject(provider, "Partition [" + partition.getId() + "] validation failed. Partition provider is null."); IaasProvider iaasProvider = dataHolder.getIaasProvider(provider); if (iaasProvider == null) { String msg = - "Invalid Partition - " + partition.toString()+". Cause: Iaas Provider " + - "is null for Partition Provider: "+provider; + "Invalid Partition - " + partition.toString() + ". Cause: Iaas Provider " + + "is null for Partition Provider: " + provider; LOG.error(msg); throw new InvalidPartitionException(msg); } - + Iaas iaas = iaasProvider.getIaas(); - + if (iaas == null) { - - try { + + try { iaas = CloudControllerUtil.getIaas(iaasProvider); } catch (InvalidIaasProviderException e) { String msg = "Invalid Partition - " + partition.toString() + - ". Cause: Unable to build Iaas of this IaasProvider [Provider] : " + provider+". "+e.getMessage(); + ". Cause: Unable to build Iaas of this IaasProvider [Provider] : " + provider + ". " + e.getMessage(); LOG.error(msg, e); throw new InvalidPartitionException(msg, e); } - + } PartitionValidator validator = iaas.getPartitionValidator(); validator.setIaasProvider(iaasProvider); validator.validate(partition.getId(), - CloudControllerUtil.toJavaUtilProperties(partition.getProperties())); - + CloudControllerUtil.toJavaUtilProperties(partition.getProperties())); + return true; } - public ClusterContext getClusterContext (String clusterId) { - + public ClusterContext getClusterContext(String clusterId) { + return dataHolder.getClusterContext(clusterId); } @Override - public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) - throws UnregisteredCartridgeException { - - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:startContainers"); - } - - handleNullObject(containerClusterContext, "Container start-up failed. ContainerClusterContext is null."); + public MemberContext[] startContainers(ContainerClusterContext containerClusterContext) + throws UnregisteredCartridgeException { + + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:startContainers"); + } + + handleNullObject(containerClusterContext, "Container start-up failed. ContainerClusterContext is null."); String clusterId = containerClusterContext.getClusterId(); handleNullObject(clusterId, "Container start-up failed. Cluster id is null."); - - if(LOG.isDebugEnabled()) { - LOG.debug("Received a container spawn request : " + containerClusterContext.toString()); + + if (LOG.isDebugEnabled()) { + LOG.debug("Received a container spawn request : " + containerClusterContext.toString()); } ClusterContext ctxt = dataHolder.getClusterContext(clusterId); handleNullObject(ctxt, "Container start-up failed. Invalid cluster id. " + containerClusterContext.toString()); - + String cartridgeType = ctxt.getCartridgeType(); Cartridge cartridge = dataHolder.getCartridge(cartridgeType); if (cartridge == null) { String msg = - "Instance start-up failed. No matching Cartridge found [type] "+cartridgeType +". "+ - containerClusterContext.toString(); + "Instance start-up failed. No matching Cartridge found [type] " + cartridgeType + ". " + + containerClusterContext.toString(); LOG.error(msg); throw new UnregisteredCartridgeException(msg); } @@ -1467,197 +1465,197 @@ public MemberContext[] startContainers(ContainerClusterContext containerClusterC String kubernetesClusterId = validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID, ctxt); String kubernetesMasterIp = validateProperty(StratosConstants.KUBERNETES_MASTER_IP, containerClusterContext); String kubernetesPortRange = validateProperty(StratosConstants.KUBERNETES_PORT_RANGE, containerClusterContext); - - KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId, kubernetesMasterIp, kubernetesPortRange); - - KubernetesApiClient kubApi = kubClusterContext.getKubApi(); - - // first let's create a replication controller. - ContainerClusterContextToReplicationController controllerFunction = new ContainerClusterContextToReplicationController(); - ReplicationController controller = controllerFunction.apply(containerClusterContext); - - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller is delegating request to start a replication controller "+controller+ - " for "+ containerClusterContext + " to Kubernetes layer."); - } - - kubApi.createReplicationController(controller); - - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller successfully started the controller " - + controller + " via Kubernetes layer."); - } - - // secondly let's create a kubernetes service proxy to load balance these containers - ContainerClusterContextToKubernetesService serviceFunction = new ContainerClusterContextToKubernetesService(); - Service service = serviceFunction.apply(containerClusterContext); - - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller is delegating request to start a service "+service+ - " for "+ containerClusterContext + " to Kubernetes layer."); - } - - kubApi.createService(service); - - // set host port and update - ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, service.getPort()); - dataHolder.addClusterContext(ctxt); - - if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller successfully started the service " - + controller + " via Kubernetes layer."); - } - - // create a label query - Label l = new Label(); - l.setName(clusterId); - // execute the label query - Pod[] newlyCreatedPods = new Pod[0]; - int expectedCount = Integer.parseInt(minReplicas); - - for (int i = 0; i < expectedCount ; i++) { - newlyCreatedPods = kubApi.getSelectedPods(new Label[]{l}); - - if (LOG.isDebugEnabled()) { - - LOG.debug("Pods Count: "+newlyCreatedPods.length+" for cluster: "+clusterId); - } - if(newlyCreatedPods.length == expectedCount) { - break; - } - Thread.sleep(10000); + + KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId, kubernetesMasterIp, kubernetesPortRange); + + KubernetesApiClient kubApi = kubClusterContext.getKubApi(); + + // first let's create a replication controller. + ContainerClusterContextToReplicationController controllerFunction = new ContainerClusterContextToReplicationController(); + ReplicationController controller = controllerFunction.apply(containerClusterContext); + + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller is delegating request to start a replication controller " + controller + + " for " + containerClusterContext + " to Kubernetes layer."); + } + + kubApi.createReplicationController(controller); + + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller successfully started the controller " + + controller + " via Kubernetes layer."); + } + + // secondly let's create a kubernetes service proxy to load balance these containers + ContainerClusterContextToKubernetesService serviceFunction = new ContainerClusterContextToKubernetesService(); + Service service = serviceFunction.apply(containerClusterContext); + + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller is delegating request to start a service " + service + + " for " + containerClusterContext + " to Kubernetes layer."); } - if (newlyCreatedPods.length == 0) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Pods are not created for cluster : %s, hence deleting the service", clusterId)); - } - terminateAllContainers(clusterId); - return new MemberContext[0]; - } - - if (LOG.isDebugEnabled()) { - - LOG.debug(String.format("Pods created : %s for cluster : %s",newlyCreatedPods.length, clusterId)); - } - - List memberContexts = new ArrayList(); - - PodToMemberContext podToMemberContextFunc = new PodToMemberContext(); - // generate Member Contexts - for (Pod pod : newlyCreatedPods) { + kubApi.createService(service); + + // set host port and update + ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, service.getPort()); + dataHolder.addClusterContext(ctxt); + + if (LOG.isDebugEnabled()) { + LOG.debug("Cloud Controller successfully started the service " + + controller + " via Kubernetes layer."); + } + + // create a label query + Label l = new Label(); + l.setName(clusterId); + // execute the label query + Pod[] newlyCreatedPods = new Pod[0]; + int expectedCount = Integer.parseInt(minReplicas); + + for (int i = 0; i < expectedCount; i++) { + newlyCreatedPods = kubApi.getSelectedPods(new Label[]{l}); + + if (LOG.isDebugEnabled()) { + + LOG.debug("Pods Count: " + newlyCreatedPods.length + " for cluster: " + clusterId); + } + if (newlyCreatedPods.length == expectedCount) { + break; + } + Thread.sleep(10000); + } + + if (newlyCreatedPods.length == 0) { + if (LOG.isDebugEnabled()) { + LOG.debug(String.format("Pods are not created for cluster : %s, hence deleting the service", clusterId)); + } + terminateAllContainers(clusterId); + return new MemberContext[0]; + } + + if (LOG.isDebugEnabled()) { + + LOG.debug(String.format("Pods created : %s for cluster : %s", newlyCreatedPods.length, clusterId)); + } + + List memberContexts = new ArrayList(); + + PodToMemberContext podToMemberContextFunc = new PodToMemberContext(); + // generate Member Contexts + for (Pod pod : newlyCreatedPods) { MemberContext context = podToMemberContextFunc.apply(pod); context.setCartridgeType(cartridgeType); context.setClusterId(clusterId); - + context.setProperties(CloudControllerUtil.addProperty(context - .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT, + .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT, String.valueOf(service.getPort()))); - + dataHolder.addMemberContext(context); - + // wait till Pod status turns to running and send member spawned. ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance(); if (LOG.isDebugEnabled()) { LOG.debug("Cloud Controller is starting the instance start up thread."); } dataHolder.addScheduledFutureJob(context.getMemberId(), exec.schedule(new PodActivationWatcher(pod.getId(), context, kubApi), 5000)); - + memberContexts.add(context); } - - // persist in registry - persist(); + + // persist in registry + persist(); LOG.info("Kubernetes entities are successfully starting up: " + memberContexts); return memberContexts.toArray(new MemberContext[0]); } catch (Exception e) { - String msg = "Failed to start an instance. " + containerClusterContext.toString()+" Cause: "+e.getMessage(); + String msg = "Failed to start an instance. " + containerClusterContext.toString() + " Cause: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(msg, e); } - } + } - private String validateProperty(String property, ClusterContext ctxt) { + private String validateProperty(String property, ClusterContext ctxt) { - String propVal = CloudControllerUtil.getProperty(ctxt.getProperties(), property); - handleNullObject(propVal, "Property validation failed. Cannot find '"+property+"' in " + ctxt); + String propVal = CloudControllerUtil.getProperty(ctxt.getProperties(), property); + handleNullObject(propVal, "Property validation failed. Cannot find '" + property + "' in " + ctxt); return propVal; } - - private String validateProperty(String property, ContainerClusterContext ctxt) { + + private String validateProperty(String property, ContainerClusterContext ctxt) { String propVal = CloudControllerUtil.getProperty(ctxt.getProperties(), property); - handleNullObject(propVal, "Property validation failed. '"+property+"' in " + ctxt); + handleNullObject(propVal, "Property validation failed. '" + property + "' in " + ctxt); return propVal; - + } private KubernetesClusterContext getKubernetesClusterContext( - String kubernetesClusterId, String kubernetesMasterIp, - String kubernetesPortRange) { - - KubernetesClusterContext origCtxt = dataHolder.getKubernetesClusterContext(kubernetesClusterId); - KubernetesClusterContext newCtxt = new KubernetesClusterContext(kubernetesClusterId, kubernetesPortRange, kubernetesMasterIp); - - if (origCtxt == null) { - dataHolder.addKubernetesClusterContext(newCtxt); - return newCtxt; - } - - if (!origCtxt.equals(newCtxt)) { - // if for some reason master IP etc. have changed - newCtxt.setAvailableHostPorts(origCtxt.getAvailableHostPorts()); - dataHolder.addKubernetesClusterContext(newCtxt); - return newCtxt; - } else { - return origCtxt; - } - } - - @Override - public MemberContext[] terminateAllContainers(String clusterId) - throws InvalidClusterException { - - ClusterContext ctxt = dataHolder.getClusterContext(clusterId); - handleNullObject(ctxt, "Kubernetes units temrination failed. Invalid cluster id. "+clusterId); - - String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(), - StratosConstants.KUBERNETES_CLUSTER_ID); - handleNullObject(kubernetesClusterId, "Kubernetes units termination failed. Cannot find '"+ - StratosConstants.KUBERNETES_CLUSTER_ID+"'. " + ctxt); - + String kubernetesClusterId, String kubernetesMasterIp, + String kubernetesPortRange) { + + KubernetesClusterContext origCtxt = dataHolder.getKubernetesClusterContext(kubernetesClusterId); + KubernetesClusterContext newCtxt = new KubernetesClusterContext(kubernetesClusterId, kubernetesPortRange, kubernetesMasterIp); + + if (origCtxt == null) { + dataHolder.addKubernetesClusterContext(newCtxt); + return newCtxt; + } + + if (!origCtxt.equals(newCtxt)) { + // if for some reason master IP etc. have changed + newCtxt.setAvailableHostPorts(origCtxt.getAvailableHostPorts()); + dataHolder.addKubernetesClusterContext(newCtxt); + return newCtxt; + } else { + return origCtxt; + } + } + + @Override + public MemberContext[] terminateAllContainers(String clusterId) + throws InvalidClusterException { + + ClusterContext ctxt = dataHolder.getClusterContext(clusterId); + handleNullObject(ctxt, "Kubernetes units temrination failed. Invalid cluster id. " + clusterId); + + String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(), + StratosConstants.KUBERNETES_CLUSTER_ID); + handleNullObject(kubernetesClusterId, "Kubernetes units termination failed. Cannot find '" + + StratosConstants.KUBERNETES_CLUSTER_ID + "'. " + ctxt); + KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId); - handleNullObject(kubClusterContext, "Kubernetes units termination failed. Cannot find a matching Kubernetes Cluster for cluster id: " - +kubernetesClusterId); - - KubernetesApiClient kubApi = kubClusterContext.getKubApi(); - // delete the service - try { - kubApi.deleteService(CloudControllerUtil.getCompatibleId(clusterId)); - } catch (KubernetesClientException e) { - // we're not going to throw this error, but proceed with other deletions - LOG.error("Failed to delete Kubernetes service with id: "+clusterId, e); - } - - // set replicas=0 for the replication controller - try { - kubApi.updateReplicationController(clusterId, 0); - } catch (KubernetesClientException e) { - // we're not going to throw this error, but proceed with other deletions - LOG.error("Failed to update Kubernetes Controller with id: "+clusterId, e); - } - - // delete pods forcefully + handleNullObject(kubClusterContext, "Kubernetes units termination failed. Cannot find a matching Kubernetes Cluster for cluster id: " + + kubernetesClusterId); + + KubernetesApiClient kubApi = kubClusterContext.getKubApi(); + // delete the service + try { + kubApi.deleteService(CloudControllerUtil.getCompatibleId(clusterId)); + } catch (KubernetesClientException e) { + // we're not going to throw this error, but proceed with other deletions + LOG.error("Failed to delete Kubernetes service with id: " + clusterId, e); + } + + // set replicas=0 for the replication controller + try { + kubApi.updateReplicationController(clusterId, 0); + } catch (KubernetesClientException e) { + // we're not going to throw this error, but proceed with other deletions + LOG.error("Failed to update Kubernetes Controller with id: " + clusterId, e); + } + + // delete pods forcefully try { // create a label query Label l = new Label(); l.setName(clusterId); // execute the label query Pod[] pods = kubApi.getSelectedPods(new Label[]{l}); - + for (Pod pod : pods) { try { // delete pods forcefully @@ -1669,154 +1667,154 @@ public MemberContext[] terminateAllContainers(String clusterId) } } catch (KubernetesClientException e) { // we're not going to throw this error, but proceed with other deletions - LOG.error("Failed to delete pods forcefully for cluster: "+clusterId, e); + LOG.error("Failed to delete pods forcefully for cluster: " + clusterId, e); } - - // delete the replication controller. - try { - kubApi.deleteReplicationController(clusterId); - } catch (KubernetesClientException e) { - String msg = "Failed to delete Kubernetes Controller with id: "+clusterId; - LOG.error(msg, e); - throw new InvalidClusterException(msg, e); - } - - String allocatedPort = CloudControllerUtil.getProperty(ctxt.getProperties(), - StratosConstants.ALLOCATED_SERVICE_HOST_PORT); - - if (allocatedPort != null) { - kubClusterContext.deallocateHostPort(Integer - .parseInt(allocatedPort)); - } else { - LOG.warn("Host port dealloacation failed due to a missing property: " - + StratosConstants.ALLOCATED_SERVICE_HOST_PORT); - } - - List membersToBeRemoved = dataHolder.getMemberContextsOfClusterId(clusterId); - - for (MemberContext memberContext : membersToBeRemoved) { + + // delete the replication controller. + try { + kubApi.deleteReplicationController(clusterId); + } catch (KubernetesClientException e) { + String msg = "Failed to delete Kubernetes Controller with id: " + clusterId; + LOG.error(msg, e); + throw new InvalidClusterException(msg, e); + } + + String allocatedPort = CloudControllerUtil.getProperty(ctxt.getProperties(), + StratosConstants.ALLOCATED_SERVICE_HOST_PORT); + + if (allocatedPort != null) { + kubClusterContext.deallocateHostPort(Integer + .parseInt(allocatedPort)); + } else { + LOG.warn("Host port dealloacation failed due to a missing property: " + + StratosConstants.ALLOCATED_SERVICE_HOST_PORT); + } + + List membersToBeRemoved = dataHolder.getMemberContextsOfClusterId(clusterId); + + for (MemberContext memberContext : membersToBeRemoved) { logTermination(memberContext); } - - // persist - persist(); - - return membersToBeRemoved.toArray(new MemberContext[0]); - } - @Override - public MemberContext[] updateContainers(String clusterId, int replicas) - throws UnregisteredCartridgeException { - - if(LOG.isDebugEnabled()) { - LOG.debug("CloudControllerServiceImpl:updateContainers for cluster : "+clusterId); + // persist + persist(); + + return membersToBeRemoved.toArray(new MemberContext[0]); + } + + @Override + public MemberContext[] updateContainers(String clusterId, int replicas) + throws UnregisteredCartridgeException { + + if (LOG.isDebugEnabled()) { + LOG.debug("CloudControllerServiceImpl:updateContainers for cluster : " + clusterId); } ClusterContext ctxt = dataHolder.getClusterContext(clusterId); handleNullObject(ctxt, "Container update failed. Invalid cluster id. " + clusterId); - + String cartridgeType = ctxt.getCartridgeType(); Cartridge cartridge = dataHolder.getCartridge(cartridgeType); if (cartridge == null) { String msg = - "Container update failed. No matching Cartridge found [type] "+cartridgeType - +". [cluster id] "+ clusterId; + "Container update failed. No matching Cartridge found [type] " + cartridgeType + + ". [cluster id] " + clusterId; LOG.error(msg); throw new UnregisteredCartridgeException(msg); } try { String kubernetesClusterId = validateProperty(StratosConstants.KUBERNETES_CLUSTER_ID, ctxt); - + KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId); - + if (kubClusterContext == null) { String msg = - "Instance start-up failed. No matching Kubernetes Context Found for [id] "+kubernetesClusterId - +". [cluster id] "+ clusterId; + "Instance start-up failed. No matching Kubernetes Context Found for [id] " + kubernetesClusterId + + ". [cluster id] " + clusterId; LOG.error(msg); throw new UnregisteredCartridgeException(msg); } - + KubernetesApiClient kubApi = kubClusterContext.getKubApi(); // create a label query Label l = new Label(); l.setName(clusterId); - + // get the current pods - useful when scale down Pod[] previousStatePods = kubApi.getSelectedPods(new Label[]{l}); - + // update the replication controller - cluster id = replication controller id if (LOG.isDebugEnabled()) { - LOG.debug("Cloud Controller is delegating request to update a replication controller "+clusterId+ + LOG.debug("Cloud Controller is delegating request to update a replication controller " + clusterId + " to Kubernetes layer."); } - + kubApi.updateReplicationController(clusterId, replicas); - + if (LOG.isDebugEnabled()) { LOG.debug("Cloud Controller successfully updated the controller " + clusterId + " via Kubernetes layer."); } - + // execute the label query Pod[] allPods = new Pod[0]; - + // wait replicas*5s time in the worst case ; best case = 0s - for (int i = 0; i < (replicas*previousStatePods.length+1) ; i++) { + for (int i = 0; i < (replicas * previousStatePods.length + 1); i++) { allPods = kubApi.getSelectedPods(new Label[]{l}); - + if (LOG.isDebugEnabled()) { - - LOG.debug("Pods Count: "+allPods.length+" for cluster: "+clusterId); + + LOG.debug("Pods Count: " + allPods.length + " for cluster: " + clusterId); } - if(allPods.length == replicas) { + if (allPods.length == replicas) { break; } Thread.sleep(10000); } - + if (LOG.isDebugEnabled()) { - - LOG.debug(String.format("Pods created : %s for cluster : %s",allPods.length, clusterId)); + + LOG.debug(String.format("Pods created : %s for cluster : %s", allPods.length, clusterId)); } - + List memberContexts = new ArrayList(); - + PodToMemberContext podToMemberContextFunc = new PodToMemberContext(); // generate Member Contexts for (Pod pod : allPods) { MemberContext context; // if member context does not exist -> a new member (scale up) if ((context = dataHolder.getMemberContextOfMemberId(pod.getId())) == null) { - + context = podToMemberContextFunc.apply(pod); context.setCartridgeType(cartridgeType); context.setClusterId(clusterId); - + context.setProperties(CloudControllerUtil.addProperty(context - .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT, - CloudControllerUtil.getProperty(ctxt.getProperties(), + .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT, + CloudControllerUtil.getProperty(ctxt.getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT))); - + // wait till Pod status turns to running and send member spawned. ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance(); if (LOG.isDebugEnabled()) { LOG.debug("Cloud Controller is starting the instance start up thread."); } dataHolder.addScheduledFutureJob(context.getMemberId(), exec.schedule(new PodActivationWatcher(pod.getId(), context, kubApi), 5000)); - + memberContexts.add(context); - + } // publish data // TODO // CartridgeInstanceDataPublisher.publish(context.getMemberId(), null, null, context.getClusterId(), cartridgeType, MemberStatus.Created.toString(), node); - + } - + if (memberContexts.isEmpty()) { // terminated members @SuppressWarnings("unchecked") @@ -1829,21 +1827,21 @@ public MemberContext[] updateContainers(String clusterId, int replicas) } } } - - + + // persist in registry persist(); - LOG.info("Kubernetes entities are successfully starting up. "+memberContexts); + LOG.info("Kubernetes entities are successfully starting up. " + memberContexts); return memberContexts.toArray(new MemberContext[0]); } catch (Exception e) { - String msg = "Failed to update containers belong to cluster " + clusterId+". Cause: "+e.getMessage(); + String msg = "Failed to update containers belong to cluster " + clusterId + ". Cause: " + e.getMessage(); LOG.error(msg, e); throw new IllegalStateException(msg, e); } - } + } @Override public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException { @@ -1862,48 +1860,49 @@ public MemberContext terminateContainer(String memberId) throws MemberTerminatio handleNullObject(ctxt, String.format("Failed to terminate member [Member id] %s. Invalid cluster id %s ", memberId, clusterId)); - - String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(), + + String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(), StratosConstants.KUBERNETES_CLUSTER_ID); - - handleNullObject(kubernetesClusterId, String.format("Failed to terminate member [Member id] %s. Cannot find '"+ - StratosConstants.KUBERNETES_CLUSTER_ID+"' in [cluster context] %s ", memberId, ctxt)); - + + handleNullObject(kubernetesClusterId, String.format("Failed to terminate member [Member id] %s. Cannot find '" + + StratosConstants.KUBERNETES_CLUSTER_ID + "' in [cluster context] %s ", memberId, ctxt)); + KubernetesClusterContext kubClusterContext = dataHolder.getKubernetesClusterContext(kubernetesClusterId); - + handleNullObject(kubClusterContext, String.format("Failed to terminate member [Member id] %s. Cannot find a matching Kubernetes Cluster in [cluster context] %s ", memberId, ctxt)); - + KubernetesApiClient kubApi = kubClusterContext.getKubApi(); // delete the Pod try { // member id = pod id kubApi.deletePod(memberId); - + MemberContext memberToBeRemoved = dataHolder.getMemberContextOfMemberId(memberId); - + logTermination(memberToBeRemoved); - + return memberToBeRemoved; - + } catch (KubernetesClientException e) { String msg = String.format("Failed to terminate member [Member id] %s", memberId); LOG.error(msg, e); throw new MemberTerminationFailedException(msg, e); } } - + private void handleNullObject(Object obj, String errorMsg) { if (obj == null) { LOG.error(errorMsg); throw new IllegalArgumentException(errorMsg); } } - public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + + public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException { // Create a Cluster Context obj. for each of the Clusters in the Application if (appClustersContexts == null || appClustersContexts.length == 0) { - String errorMsg = "No application cluster information found, unable to create clusters" ; + String errorMsg = "No application cluster information found, unable to create clusters"; LOG.error(errorMsg); throw new ApplicationClusterRegistrationException(errorMsg); } @@ -1912,12 +1911,20 @@ public void registerApplicationClusters(ApplicationClusterContextDTO[] appCluste /*for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { + /* TODO dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())) + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + // create Cluster objects + Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), + appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); + newCluster.setLbCluster(false); + newCluster.setTenantRange("*"); + newCluster.setStatus(ClusterStatus.Created); + newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); + clusters.add(newCluster);*/ } -*/ - persist(); - } // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // From 2d490c1c990be73493a07d193cbc4c602422c458 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Mon, 3 Nov 2014 17:49:39 +0530 Subject: [PATCH 396/436] fixing an osgi issue in AS component and adding default ctor for ApplicationClusterContextDTO --- .../cloud/controller/pojo/ApplicationClusterContextDTO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index 875f7bc09c..cbf1a2b596 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -45,6 +45,8 @@ public class ApplicationClusterContextDTO { // propertis private Properties properties; + public ApplicationClusterContextDTO () { + } public ApplicationClusterContextDTO () { } From c63d0552c8a005390dafdd86166cfc8b62ab43ac Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 11:53:01 +0530 Subject: [PATCH 397/436] fixing merging issue --- .../impl/CloudControllerServiceImpl.java | 83 +++++++------------ .../pojo/ApplicationClusterContextDTO.java | 5 +- .../cloud/controller/pojo/ClusterContext.java | 6 +- 3 files changed, 35 insertions(+), 59 deletions(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java index d7d94008df..fd4f172eeb 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/impl/CloudControllerServiceImpl.java @@ -45,7 +45,7 @@ import org.apache.stratos.cloud.controller.util.CloudControllerUtil; import org.apache.stratos.cloud.controller.util.PodActivationWatcher; import org.apache.stratos.cloud.controller.validate.interfaces.PartitionValidator; -import org.apache.stratos.common.Property; +import org.apache.stratos.common.*; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.kubernetes.client.KubernetesApiClient; import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException; @@ -69,6 +69,7 @@ import java.util.*; import java.util.Map.Entry; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -1063,11 +1064,12 @@ public boolean registerService(Registrant registrant) String property = props.getProperty(Constants.IS_LOAD_BALANCER); boolean isLb = property != null ? Boolean.parseBoolean(property) : false; - ClusterContext ctxt = null;//TODO buildClusterContext(cartridge, clusterId, - //payload, hostName, props, isLb, registrant.getPersistence()); + //TODO fix the properties issue + /*ClusterContext ctxt = buildClusterContext(cartridge, clusterId, + payload, hostName, props, isLb, registrant.getPersistence()); - dataHolder.addClusterContext(ctxt); + dataHolder.addClusterContext(ctxt);*/ TopologyBuilder.handleClusterCreated(registrant, isLb); persist(); @@ -1080,13 +1082,12 @@ public boolean registerService(Registrant registrant) private ClusterContext buildClusterContext(Cartridge cartridge, String clusterId, String payload, String hostName, org.apache.stratos.common.Properties props, boolean isLb, Persistence persistence) { - - //TODO - /*// initialize ClusterContext + //TODO fix properties issue + // initialize ClusterContext ClusterContext ctxt = new ClusterContext(clusterId, cartridge.getType(), payload, hostName, isLb, props); - String property; + /*String property; property = props.get(Constants.GRACEFUL_SHUTDOWN_TIMEOUT); long timeout = property != null ? Long.parseLong(property) : 30000; @@ -1102,7 +1103,8 @@ private ClusterContext buildClusterContext(Cartridge cartridge, ctxt.setVolumeRequired(false); } ctxt.setTimeoutInMillis(timeout); - return ctxt;*/ + return ctxt; + ;*/ return null; } @@ -1498,7 +1500,14 @@ public MemberContext[] startContainers(ContainerClusterContext containerClusterC kubApi.createService(service); // set host port and update - ctxt.addProperty(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, service.getPort()); + //TODO to clean the impl of properties + Property[] properties = new Property[1]; + Property property = new Property(StratosConstants.ALLOCATED_SERVICE_HOST_PORT, + String.valueOf(service.getPort())); + org.apache.stratos.common.Properties properties1 = new org.apache.stratos.common.Properties(); + properties1.setProperties(properties); + + ctxt.setProperties(properties1); dataHolder.addClusterContext(ctxt); if (LOG.isDebugEnabled()) { @@ -1897,7 +1906,8 @@ private void handleNullObject(Object obj, String errorMsg) { } } - public void registerApplicationClusters(ApplicationClusterContextDTO[] appClustersContexts) throws + @Override + public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws ApplicationClusterRegistrationException { // Create a Cluster Context obj. for each of the Clusters in the Application @@ -1906,25 +1916,27 @@ public void registerApplicationClusters(ApplicationClusterContextDTO[] appCluste LOG.error(errorMsg); throw new ApplicationClusterRegistrationException(errorMsg); } + List clusters = new ArrayList(); - //TODO - /*for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - /* TODO dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), + dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())) - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); + appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties())); // create Cluster objects Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); newCluster.setLbCluster(false); - newCluster.setTenantRange("*"); + newCluster.setTenantRange(appClusterCtxt.getTenantRange()); newCluster.setStatus(ClusterStatus.Created); newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); - clusters.add(newCluster);*/ + Cartridge cartridge = dataHolder.getCartridge(appClusterCtxt.getCartridgeType()); + if(cartridge.getDeployerType().equals(StratosConstants.KUBERNETES_DEPLOYER_TYPE)) { + newCluster.setKubernetesCluster(true); + } + clusters.add(newCluster); } + } // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // @@ -1950,39 +1962,6 @@ public void registerApplicationClusters(ApplicationClusterContextDTO[] appCluste // //TopologyBuilder.handleApplicationUndeployed(applicationId); // } - public void createApplicationClusters(String appId, ApplicationClusterContextDTO[] appClustersContexts) throws - ApplicationClusterRegistrationException { - - // Create a Cluster Context obj. for each of the Clusters in the Application - if (appClustersContexts == null || appClustersContexts.length == 0) { - String errorMsg = "No application cluster information found, unable to create clusters" ; - LOG.error(errorMsg); - throw new ApplicationClusterRegistrationException(errorMsg); - } - - List clusters = new ArrayList(); - - for (ApplicationClusterContextDTO appClusterCtxt : appClustersContexts) { - // add the context data - //TODO - /*dataHolder.addClusterContext(new ClusterContext(appClusterCtxt.getClusterId(), - appClusterCtxt.getCartridgeType(), appClusterCtxt.getTextPayload(), - appClusterCtxt.getHostName(), appClusterCtxt.isLbCluster(), appClusterCtxt.getProperties()));*/ - // create Cluster objects - Cluster newCluster = new Cluster(appClusterCtxt.getCartridgeType(), appClusterCtxt.getClusterId(), - appClusterCtxt.getDeploymentPolicyName(), appClusterCtxt.getAutoscalePolicyName(), appId); - newCluster.setLbCluster(false); - newCluster.setTenantRange("*"); - newCluster.setStatus(ClusterStatus.Created); - newCluster.setHostNames(Arrays.asList(appClusterCtxt.getHostName())); - //newCluster.setProperties(appClusterCtxt.getProperties()); - clusters.add(newCluster); - } - - TopologyBuilder.handleApplicationClustersCreated(appId, clusters); - - persist(); - } // public void deployApplicationDefinition (ApplicationContext applicationContext) throws ApplicationDefinitionException { // diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java index cbf1a2b596..9e3d046115 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ApplicationClusterContextDTO.java @@ -34,8 +34,6 @@ public class ApplicationClusterContextDTO { private String hostName; // flag to indicate LB cluster private boolean isLbCluster; - // flag to indicate Kubernetes cluster - private boolean isKubernetesCluster; // autoscaling policy private String autoscalePolicyName; // deployment policy @@ -45,8 +43,6 @@ public class ApplicationClusterContextDTO { // propertis private Properties properties; - public ApplicationClusterContextDTO () { - } public ApplicationClusterContextDTO () { } @@ -143,4 +139,5 @@ public Properties getProperties() { public void setProperties(Properties properties) { this.properties = properties; } + } diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java index cb48739d5c..5e0eebd80d 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/pojo/ClusterContext.java @@ -19,9 +19,9 @@ package org.apache.stratos.cloud.controller.pojo; import java.io.Serializable; -import java.util.Properties; import org.apache.commons.lang3.ArrayUtils; +import org.apache.stratos.common.Properties; /** * Holds runtime data of a Cluster. @@ -122,11 +122,11 @@ public void setProperties(Properties properties) { this.properties = properties; } - public void addProperty(String key, int value) { + /*public void addProperty(String key, int value) { this.properties.put(key, value); } public void addProperty(String key, String value) { this.properties.put(key, value); - } + }*/ } From 43c995a2355b3a287412c4f6ba4f96c4664f5b45 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 12:07:43 +0530 Subject: [PATCH 398/436] replacing CC wsdl --- .../resources/CloudControllerService.wsdl | 383 +++++++++--------- 1 file changed, 188 insertions(+), 195 deletions(-) diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 39d3da5d8a..4e1a67c810 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,15 +1,10 @@ - + CloudControllerService - - - - - - + @@ -20,32 +15,32 @@ - + - + - + - + - + - + @@ -60,7 +55,7 @@ - + @@ -76,126 +71,134 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + + + + + + + + - + - + - + - + - + - + @@ -237,28 +240,14 @@ - - - - - - - - - - - - - - - + - + @@ -272,7 +261,7 @@ - + @@ -295,24 +284,24 @@ - + - + - + - + - + @@ -326,14 +315,14 @@ - + - + @@ -347,7 +336,7 @@ - + @@ -362,14 +351,14 @@ - + - + @@ -383,56 +372,62 @@ - + - + - + - + - + + - + - - + - + - + - + - + - + - - + + + + + + + + - + @@ -441,32 +436,25 @@ - + - + - - + - - + - - - - - - - - - + + + + @@ -481,37 +469,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -520,13 +481,13 @@ - + - + - - - + + + @@ -548,16 +509,16 @@ - + - + - + @@ -569,10 +530,16 @@ - + + + + + + + @@ -582,7 +549,7 @@ - + @@ -591,11 +558,11 @@ - + - - - + + + @@ -619,12 +586,32 @@ - + - + + + + + + + + + + + + + + + + + + + + + @@ -633,16 +620,22 @@ + - - - - + + + + + + + + + @@ -656,6 +649,12 @@ + + + + + + @@ -665,12 +664,6 @@ - - - - - - @@ -806,14 +799,14 @@ + + + + - > - - - @@ -920,15 +913,6 @@ - - - - - - - - - @@ -941,6 +925,15 @@ + + + + + + + + + @@ -1199,15 +1192,6 @@ - - - - - - - - - @@ -1220,6 +1204,15 @@ + + + + + + + + + @@ -1478,12 +1471,6 @@ - - - - - - @@ -1493,6 +1480,12 @@ + + + + + + @@ -1679,22 +1672,22 @@ - + - + - + - + - + - + \ No newline at end of file From cae0b997a63954930b76be0b8f5b63a7a81775a8 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 12:12:19 +0530 Subject: [PATCH 399/436] fixing merging issue --- .../client/cloud/controller/CloudControllerClient.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 4e30a49cdd..42706692b9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -31,6 +31,7 @@ import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; +import org.apache.stratos.cloud.controller.stub.pojo.ApplicationClusterContextDTO; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ContainerClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; @@ -41,6 +42,8 @@ import org.apache.stratos.common.xsd.Property; import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.List; import java.util.Set; /** @@ -207,7 +210,7 @@ public synchronized void terminateAllInstances(String clusterId) throws Terminat public synchronized void createApplicationClusters(String appId, Set appClusterContexts) { - /*List contextDTOs = + List contextDTOs = new ArrayList(); for(ApplicationClusterContext context : appClusterContexts) { ApplicationClusterContextDTO dto = new ApplicationClusterContextDTO(); @@ -235,7 +238,7 @@ public synchronized void createApplicationClusters(String appId, //e.printStackTrace(); String msg = e.getMessage(); log.error(msg, e); - }*/ + } } From bd98999a48ff4e4e308a9908c57532d35b3e3a06 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 12:28:05 +0530 Subject: [PATCH 400/436] removing CC packages from AS stub ns2p mapping --- .../org.apache.stratos.autoscaler.service.stub/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 3478791278..0ecda8b5dd 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -50,7 +50,7 @@ + -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.exception,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.partition,http://kubernetes.common.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.kubernetes,http://api.autoscaler.stratos.apache.org=org.apache.stratos.autoscaler.stub.api"/> From e46350501b19ccc4e6a30428a790db218856d9c9 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 12:44:18 +0530 Subject: [PATCH 401/436] reverting AS stub ns2p changes --- .../org.apache.stratos.autoscaler.service.stub/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 0ecda8b5dd..4fec75042c 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -50,8 +50,8 @@ - + -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.partition,http://kubernetes.common.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.kubernetes,http://api.autoscaler.stratos.apache.org=org.apache.stratos.autoscaler.stub.api"/> + From fbe1137b06433d8cdab80caeb01c790a051ec648 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 13:55:42 +0530 Subject: [PATCH 402/436] removing un-used listener --- .../AutoscalerTopologyEventReceiver.java | 128 ------------------ 1 file changed, 128 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 0e2a4f9948..6a6a48e22e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -314,134 +314,6 @@ protected void onEvent(Event event) { } }); - topologyEventReceiver.addEventListener(new ApplicationUndeployedEventListener() { - @Override - protected void onEvent(Event event) { - - log.info("[ApplicationUndeployedEvent] Received: " + event.getClass()); - - ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; - - ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). - getAppMonitor(applicationUndeployedEvent.getApplicationId()); - - // if any of Cluster Monitors are not added yet, should send the - // Cluster Terminated event for those clusters - Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); - if (clusterDataHolders != null) { - for (ClusterDataHolder clusterDataHolder : clusterDataHolders) { - VMClusterMonitor clusterMonitor = - ((VMClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterDataHolder.getClusterId())); - if (clusterMonitor == null) { - // Cluster Monitor not found; send Cluster Terminated event to cleanup - ClusterStatusEventPublisher.sendClusterTerminatedEvent( - applicationUndeployedEvent.getApplicationId(), - clusterDataHolder.getServiceType(), - clusterDataHolder.getClusterId()); - } else { - // if the Cluster Monitor exists, mark it as destroyed to stop it from spawning - // more instances - clusterMonitor.setDestroyed(true); - } - } - } - - if (appMonitor != null) { - // set Application Monitor state to 'Terminating' - appMonitor.setStatus(ApplicationStatus.Terminating); - - } else { - // ApplicationMonitor is not found, send Terminating event to clean up - ApplicationsEventPublisher.sendApplicationTerminatedEvent( - applicationUndeployedEvent.getApplicationId(), applicationUndeployedEvent.getClusterData()); - } - -// ApplicationUndeployedEvent applicationUndeployedEvent = (ApplicationUndeployedEvent) event; -// -// // acquire reead locks for application and relevant clusters -// TopologyManager.acquireReadLockForApplication(applicationUndeployedEvent.getApplicationId()); -// Set clusterDataHolders = applicationUndeployedEvent.getClusterData(); -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.acquireReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } -// -// try { -// ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). -// getAppMonitor(applicationUndeployedEvent.getApplicationId()); -// -// if (appMonitor != null) { -// // update the status as Terminating -// appMonitor.setStatus(ApplicationStatus.Terminating); -// -//// List clusters = appMonitor. -//// findClustersOfApplication(applicationUndeployedEvent.getApplicationId()); -// -// boolean clusterMonitorsFound = false; -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// //stopping the cluster monitor and remove it from the AS -// ClusterMonitor clusterMonitor = -// ((ClusterMonitor) AutoscalerContext.getInstance().getMonitor(clusterData.getClusterId())); -// if (clusterMonitor != null) { -// clusterMonitorsFound = true; -// clusterMonitor.setDestroyed(true); -// //clusterMonitor.terminateAllMembers(); -// if (clusterMonitor.getStatus() == ClusterStatus.Active) { -// // terminated gracefully -// clusterMonitor.setStatus(ClusterStatus.Terminating); -// InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterData.getClusterId()); -// } else { -// // if not active, forcefully terminate -// clusterMonitor.setStatus(ClusterStatus.Terminating); -// clusterMonitor.terminateAllMembers(); -//// try { -//// // TODO: introduce a task to do this cleanup -//// CloudControllerClient.getInstance().terminateAllInstances(clusterData.getClusterId()); -//// } catch (TerminationException e) { -//// log.error("Unable to terminate instances for [ cluster id ] " + -//// clusterData.getClusterId(), e); -//// } -// } -// } else { -// log.warn("No Cluster Monitor found for cluster id " + clusterData.getClusterId()); -// // if Cluster Monitor is not found, still the Cluster Terminated -// // should be sent to update the parent Monitor -// StatusEventPublisher.sendClusterTerminatedEvent( -// applicationUndeployedEvent.getApplicationId(), -// clusterData.getServiceType(), clusterData.getClusterId()); -// } -// } -// -// // if by any chance, the cluster monitors have failed, we still need to undeploy this application -// // hence, check if the Cluster Monitors are not found and send the Application Terminated event -// if (!clusterMonitorsFound) { -// StatusEventPublisher.sendApplicationTerminatedEvent( -// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); -// } -// -// } else { -// log.warn("Application Monitor cannot be found for the undeployed [application] " -// + applicationUndeployedEvent.getApplicationId()); -// // send the App Terminated event to cleanup -// StatusEventPublisher.sendApplicationTerminatedEvent( -// applicationUndeployedEvent.getApplicationId(), clusterDataHolders); -// } -// -// } finally { -// if (clusterDataHolders != null) { -// for (ClusterDataHolder clusterData : clusterDataHolders) { -// TopologyManager.releaseReadLockForCluster(clusterData.getServiceType(), -// clusterData.getClusterId()); -// } -// } -// TopologyManager. -// releaseReadLockForApplication(applicationUndeployedEvent.getApplicationId()); -// } - } - }); - topologyEventReceiver.addEventListener(new MemberReadyToShutdownEventListener() { @Override protected void onEvent(Event event) { From 8c3096037479584f1343bfd00783631f23a9b226 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 14:29:15 +0530 Subject: [PATCH 403/436] refactoring Application Monitor Factory --- .../ApplicationMonitorFactory.java | 52 ++++--------------- 1 file changed, 9 insertions(+), 43 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java index 504167a5da..b14e4520a4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/application/ApplicationMonitorFactory.java @@ -18,8 +18,7 @@ */ package org.apache.stratos.autoscaler.monitor.application; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.applications.dependency.context.ClusterContext; @@ -32,10 +31,7 @@ import org.apache.stratos.autoscaler.monitor.ParentComponentMonitor; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitorFactory; -import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.monitor.group.GroupMonitor; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Group; import org.apache.stratos.messaging.domain.topology.Cluster; @@ -43,13 +39,10 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import java.util.Map; - /** * Factory class to get the Monitors. */ public class ApplicationMonitorFactory { - private static final Log log = LogFactory.getLog(ApplicationMonitorFactory.class); /** * Factor method used to create relevant monitors based on the given context @@ -66,15 +59,16 @@ public class ApplicationMonitorFactory { public static Monitor getMonitor(ParentComponentMonitor parentMonitor, ApplicationContext context, String appId) throws TopologyInConsistentException, DependencyBuilderException, PolicyValidationException, PartitionValidationException { + Monitor monitor; - if (context instanceof GroupContext) { monitor = getGroupMonitor(parentMonitor, context, appId); } else if (context instanceof ClusterContext) { monitor = getClusterMonitor(parentMonitor, (ClusterContext) context, appId); - //Start the thread - Thread th = new Thread((AbstractClusterMonitor) monitor); - th.start(); + if (monitor != null) { + ((AbstractClusterMonitor)monitor).startScheduler(); + AutoscalerContext.getInstance().addClusterMonitor((AbstractClusterMonitor)monitor); + } } else { monitor = getApplicationMonitor(appId); } @@ -169,17 +163,16 @@ public static ApplicationMonitor getApplicationMonitor(String appId) * @throws org.apache.stratos.autoscaler.exception.PolicyValidationException * @throws org.apache.stratos.autoscaler.exception.PartitionValidationException */ - public static VMClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor, + public static AbstractClusterMonitor getClusterMonitor(ParentComponentMonitor parentMonitor, ClusterContext context, String appId) throws PolicyValidationException, PartitionValidationException, TopologyInConsistentException { + //Retrieving the Cluster from Topology String clusterId = context.getId(); String serviceName = context.getServiceName(); - Cluster cluster; - AbstractClusterMonitor clusterMonitor; //acquire read lock for the service and cluster TopologyManager.acquireReadLockForCluster(serviceName, clusterId); try { @@ -188,11 +181,6 @@ public static VMClusterMonitor getClusterMonitor(ParentComponentMonitor parentMo Service service = topology.getService(serviceName); if (service.clusterExists(clusterId)) { cluster = service.getCluster(clusterId); - if (log.isDebugEnabled()) { - log.debug("Dependency check starting the [cluster]" + clusterId); - } - // startClusterMonitor(this, cluster); - //context.setCurrentStatus(Status.Created); } else { String msg = "[Cluster] " + clusterId + " cannot be found in the " + "Topology for [service] " + serviceName; @@ -201,32 +189,10 @@ public static VMClusterMonitor getClusterMonitor(ParentComponentMonitor parentMo } else { String msg = "[Service] " + serviceName + " cannot be found in the Topology"; throw new TopologyInConsistentException(msg); - } - - - clusterMonitor = ClusterMonitorFactory.getMonitor(cluster); - if (clusterMonitor instanceof VMClusterMonitor) { - return (VMClusterMonitor) clusterMonitor; - } else if (clusterMonitor != null) { - log.warn("Unknown cluster monitor found: " + clusterMonitor.getClass().toString()); - } - return null; + return ClusterMonitorFactory.getMonitor(cluster); } finally { TopologyManager.releaseReadLockForCluster(serviceName, clusterId); } } - - - private static Properties convertMemberPropsToMemberContextProps( - java.util.Properties properties) { - Properties props = new Properties(); - for (Map.Entry e : properties.entrySet()) { - Property prop = new Property(); - prop.setName((String) e.getKey()); - prop.setValue((String) e.getValue()); - props.addProperties(prop); - } - return props; - } } From aca1edf1a7c39a15b887fdd6a2ec37f341ea6417 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 14:45:44 +0530 Subject: [PATCH 404/436] fixing compilation --- .../stratos/autoscaler/api/AutoScalerServiceImpl.java | 11 ++++++++--- .../interfaces/AutoScalerServiceInterface.java | 2 +- .../endpoint/bean/util/converter/PojoConverter.java | 4 ++-- .../pom.xml | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 4476b1a264..91bbe76869 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -41,7 +41,7 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; @@ -341,8 +341,13 @@ public String getServiceLBClusterId(String serviceType, String deploymentPolicyN return null; } - - public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) { + + @Override + public void updateClusterMonitor(String clusterId, org.apache.stratos.common.Properties properties) throws InvalidArgumentException { + + } + + public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) { for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 8dbf20fdf2..554a818043 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -32,7 +32,7 @@ import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 4be32e5b49..7995916145 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -24,11 +24,11 @@ import org.apache.stratos.autoscaler.applications.pojo.xsd.DependencyContext; import org.apache.stratos.autoscaler.applications.pojo.xsd.GroupContext; import org.apache.stratos.autoscaler.applications.pojo.xsd.SubscribableInfoContext; +import org.apache.stratos.autoscaler.stub.pojo.PropertiesE; +import org.apache.stratos.autoscaler.stub.pojo.PropertyE; import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.common.xsd.Property; -import org.apache.stratos.common.xsd.PropertiesE; -import org.apache.stratos.common.xsd.PropertyE; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 4fec75042c..9f0bebe201 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -50,7 +50,7 @@ + -ns2p http://policy.deployment.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.deployment.policy,http://model.policy.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.policy.model,http://exception.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.exception,http://partition.deployment.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://pojo.stub.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://partition.autoscaler.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.partition,http://kubernetes.common.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.kubernetes,http://api.autoscaler.stratos.apache.org=org.apache.stratos.autoscaler.stub.api,http://common.stratos.apache.org/xsd=org.apache.stratos.autoscaler.stub.pojo"/> From c1e557b7ea86c42e87fe88b7ca25678f24aedc35 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 14:47:57 +0530 Subject: [PATCH 405/436] Removing unused dependencies in load balancer component --- .../org.apache.stratos.load.balancer/pom.xml | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/components/org.apache.stratos.load.balancer/pom.xml b/components/org.apache.stratos.load.balancer/pom.xml index ed3a0a2c62..165cc581f3 100644 --- a/components/org.apache.stratos.load.balancer/pom.xml +++ b/components/org.apache.stratos.load.balancer/pom.xml @@ -48,21 +48,6 @@ synapse-core ${synapse.core.version} - - org.wso2.carbon - org.wso2.carbon.logging - ${wso2carbon.version} - - - org.apache.axis2.wso2 - axis2 - ${axis2.wso2.version} - - - org.apache.axis2 - axis2-kernel - 1.6.1-wso2v9 - org.apache.stratos org.apache.stratos.messaging @@ -73,36 +58,6 @@ org.apache.stratos.load.balancer.common ${project.version} - - org.apache.thrift - libthrift - 0.9.1 - - - org.wso2.carbon - org.wso2.carbon.databridge.agent.thrift - 4.2.0 - - - org.wso2.carbon - org.wso2.carbon.databridge.commons.thrift - 4.2.0 - - - org.wso2.carbon - org.wso2.carbon.databridge.commons - 4.2.0 - - - commons-pool - commons-pool - 1.6 - - - org.eclipse.paho - mqtt-client - 0.4.0 - From 7db5adf0d0866feaa1ed63055aa7cdca65c33389 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 14:50:25 +0530 Subject: [PATCH 406/436] adding cluster monitor destroying and fixing un-deployment of application --- .../topic/ApplicationBuilder.java | 81 +++++++------------ .../topic/ApplicationsEventPublisher.java | 4 +- .../AutoscalerTopologyEventReceiver.java | 23 +----- 3 files changed, 33 insertions(+), 75 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index 696fa3961e..ed7e643f26 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -191,14 +191,29 @@ public static synchronized void handleApplicationCreated(Application application } public static void handleApplicationUndeployed(String applicationId) { + log.info("Un-deploying the [application] " + applicationId + "by marking it as terminating.."); - Applications applications = ApplicationHolder.getApplications(); + ApplicationHolder.acquireReadLock(); + try { + ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). + getAppMonitor(applicationId); - ApplicationHolder.acquireWriteLock(); - Application applicationToRemove = applications.getApplication(applicationId); - Set clusterData = null; + if (appMonitor != null) { + // update the status as Terminating + appMonitor.setStatus(ApplicationStatus.Terminating); - try { + } else { + log.warn("Application Monitor cannot be found for the undeployed [application] " + + applicationId); + } + + } finally { + ApplicationHolder.releaseReadLock(); + + } + /*Set clusterData = null; + + try { if (applicationToRemove != null) { clusterData = applicationToRemove.getClusterDataRecursively(); ApplicationHolder.removeApplication(applicationId); @@ -208,9 +223,9 @@ public static void handleApplicationUndeployed(String applicationId) { } finally { ApplicationHolder.releaseWriteLock(); - } + }*/ - ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); + ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); } public static void handleGroupTerminatedEvent(String appId, String groupId) { @@ -512,8 +527,6 @@ public static void handleApplicationTerminatedEvent(String appId) { if (!applications.applicationExists(appId)) { log.warn("Application with id [ " + appId + " ] doesn't exist in Applications"); - //ApplicationsEventPublisher.sendApplicationRemovedEvent(applicationId, tenantId, tenantDomain); - } else { Application application = applications.getApplication(appId); @@ -523,51 +536,11 @@ public static void handleApplicationTerminatedEvent(String appId) { // forcefully set status for now application.setStatus(ApplicationStatus.Terminated); updateApplicationMonitor(appId, ApplicationStatus.Terminated); - - int tenantId = application.getTenantId(); - String tenantDomain = application.getTenantDomain(); - Set clusterData = application.getClusterDataRecursively(); - // remove clusters - /*for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = applications.getService(clusterDataHolder.getServiceType()); - if (service != null) { - // remove Cluster - service.removeCluster(clusterDataHolder.getClusterId()); - - if (log.isDebugEnabled()) { - log.debug("Removed cluster with id " + clusterDataHolder.getClusterId()); - } - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] npt found"); - } - - // remove runtime data - FasterLookUpDataHolder dataHolder = FasterLookUpDataHolder.getInstance(); - dataHolder.removeClusterContext(clusterDataHolder.getClusterId()); - if (log.isDebugEnabled()) { - log.debug("Removed Cluster Context for Cluster id: " + clusterDataHolder.getClusterId()); - } - - try { - RegistryManager.getInstance().persist(dataHolder); - } catch (RegistryException e) { - log.error("Unable to persist data in Registry", e); - } - } - - - // remove application - applications.removeApplication(event.getAppId()); - ApplicationHolder.persistApplication(applications); - - deleteAppResourcesFromMetadataService(event); - - log.info("Removed application [ " + event.getAppId() + " ] from Applications"); - - ApplicationsEventPublisher.sendApplicationTerminatedEvent(new org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent(event.getAppId(), - clusterData, tenantId, tenantDomain))*/ - ; + //removing the monitor + AutoscalerContext.getInstance().removeAppMonitor(appId); + //Removing the application from memory and registry + ApplicationHolder.removeApplication(appId); + ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId); } } finally { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java index 66a35e7478..5cc87e5365 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationsEventPublisher.java @@ -117,12 +117,12 @@ public static void sendApplicationTerminatingEvent(String appId) { publishEvent(applicationTerminatingEvent); } - public static void sendApplicationTerminatedEvent(String appId, Set clusterData) { + public static void sendApplicationTerminatedEvent(String appId) { if (log.isInfoEnabled()) { log.info("Publishing Application terminated event for [application]: " + appId); } ApplicationTerminatedEvent applicationTerminatedEvent = - new ApplicationTerminatedEvent(appId, clusterData); + new ApplicationTerminatedEvent(appId, null); publishEvent(applicationTerminatedEvent); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index 6a6a48e22e..c22f3b875d 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -24,10 +24,8 @@ import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; -import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; @@ -35,7 +33,6 @@ import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.applications.Application; -import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.topology.ClusterStatus; @@ -43,28 +40,12 @@ import org.apache.stratos.messaging.domain.topology.Topology; import org.apache.stratos.messaging.event.Event; import org.apache.stratos.messaging.event.topology.*; -import org.apache.stratos.messaging.listener.applications.ApplicationUndeployedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterRemovedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterResetEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterTerminatedEventListener; -import org.apache.stratos.messaging.listener.topology.ClusterTerminatingEventListener; -import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; -import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener; -import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener; -import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; -import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; 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 org.drools.runtime.StatefulKnowledgeSession; import org.drools.runtime.rule.FactHandle; -import java.util.Set; - /** * Autoscaler topology receiver. */ @@ -310,6 +291,10 @@ protected void onEvent(Event event) { //changing the status in the monitor, will notify its parent monitor if (clusterMonitor != null) { clusterMonitor.setStatus(ClusterStatus.Terminated); + //Destroying and Removing the Cluster monitor + clusterMonitor.destroy(); + AutoscalerContext.getInstance().removeClusterMonitor(clusterId); + } } }); From c59b3911d5c0404a5bb865dbca72f32eded36b29 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Tue, 4 Nov 2014 15:01:49 +0530 Subject: [PATCH 407/436] Fixing inconsistency of metadata service name in pom --- components/org.apache.stratos.metadataservice/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.metadataservice/pom.xml b/components/org.apache.stratos.metadataservice/pom.xml index 3d82040b23..9e0b6d2867 100644 --- a/components/org.apache.stratos.metadataservice/pom.xml +++ b/components/org.apache.stratos.metadataservice/pom.xml @@ -26,7 +26,7 @@ 4.0.0 org.apache.stratos.metadataservice war - Apache Stratos -Meta Data Service + Apache Stratos - Meta Data Service From 13245dcc294923c036731c26e0ba22a35f36278a Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 15:06:29 +0530 Subject: [PATCH 408/436] code reactoring --- .../topic/ApplicationBuilder.java | 511 +++++------------- .../AutoscalerTopologyEventReceiver.java | 66 +-- 2 files changed, 128 insertions(+), 449 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index ed7e643f26..d5fc50ce44 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -40,117 +40,6 @@ public class ApplicationBuilder { private static final Log log = LogFactory.getLog(ApplicationBuilder.class); - - /*public static synchronized void handleApplicationDeployed(Application application, - Set applicationClusterContexts, - Set metaDataHolders) { - - - Applications applications = Appcation.getApplications(); - try { - ApplicationHolder.acquireWriteLock(); - - if (applications.applicationExists(application.getUniqueIdentifier())) { - log.warn("Application with id [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); - return; - } - List clusters = new ArrayList(); - for (ApplicationClusterContext applicationClusterContext : applicationClusterContexts) { - Cluster cluster = new Cluster(applicationClusterContext.getCartridgeType(), - applicationClusterContext.getClusterId(), applicationClusterContext.getDeploymentPolicyName(), - applicationClusterContext.getAutoscalePolicyName(), application.getUniqueIdentifier()); - //cluster.setStatus(Status.Created); - cluster.addHostName(applicationClusterContext.getHostName()); - cluster.setTenantRange(applicationClusterContext.getTenantRange()); - clusters.add(cluster); - - Service service = applications.getService(applicationClusterContext.getCartridgeType()); - if (service != null) { - service.addCluster(cluster); - log.info("Added Cluster " + cluster.toString() + " to Applications for Application with id: " + application.getUniqueIdentifier()); - } else { - log.error("Service " + applicationClusterContext.getCartridgeType() + " not found"); - return; - } - } - - // add to Applications and update - applications.addApplication(application); - ApplicationHolder.persistApplication(applications); - - log.info("Application with id [ " + application.getUniqueIdentifier() + " ] added to Applications successfully"); - org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationCreatedEvent = new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent(application, clusters); - ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationCreatedEvent); - - } finally { - ApplicationHolder.releaseWriteLock(); - } - }*/ - - /*public static synchronized void handleApplicationUndeployed(String applicationId) { - - Set clusterData; - - // update the Application and Cluster Statuses as 'Terminating' - ApplicationHolder.acquireWriteLock(); - - try { - - Applications applications = ApplicationHolder.getApplications(); - - if (!applications.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications"); - return; - } - - Application application = applications.getApplication(applicationId); - // check and update application status to 'Terminating' - if (!application.isStateTransitionValid(ApplicationStatus.Terminating)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(ApplicationStatus.Terminating); - - // update all the Clusters' statuses to 'Terminating' - clusterData = application.getClusterDataRecursively(); - for (ClusterDataHolder clusterDataHolder : clusterData) { - Service service = applications.getService(clusterDataHolder.getServiceType()); - if (service != null) { - Cluster aCluster = service.getCluster(clusterDataHolder.getClusterId()); - if (aCluster != null) { - // validate state transition - if (!aCluster.isStateTransitionValid(ClusterStatus.Terminating)) { - log.error("Invalid state transfer from " + aCluster.getStatus() + " to " - + ClusterStatus.Terminating); - } - // for now anyway update the status forcefully - aCluster.setStatus(ClusterStatus.Terminating); - - } else { - log.warn("Unable to find Cluster with cluster id " + clusterDataHolder.getClusterId() + - " in Applications"); - } - - } else { - log.warn("Unable to remove cluster with cluster id: " + clusterDataHolder.getClusterId() + " from Applications, " + - " associated Service [ " + clusterDataHolder.getServiceType() + " ] not found"); - } - } - - // update all Group's statuses to 'Terminating' - if (application.getGroups() != null) { - updateGroupStatusesRecursively(GroupStatus.Terminating, application.getGroups()); - } - - ApplicationHolder.persistApplication(applications); - - } finally { - ApplicationHolder.releaseWriteLock(); - } - - ApplicationsEventPublisher.sendApplicationUndeployedEvent(applicationId, clusterData); - }*/ - public static synchronized void handleCompleteApplication(Applications applications) { if (log.isDebugEnabled()) { log.debug("Handling complete application"); @@ -166,69 +55,156 @@ public static synchronized void handleCompleteApplication(Applications applicati public static synchronized void handleApplicationCreated(Application application, Set appClusterContexts) { + if (log.isInfoEnabled()) { + log.info("Handling Application creation for the [application]: " + + application.getUniqueIdentifier()); + } ApplicationHolder.acquireWriteLock(); - - Applications applications = ApplicationHolder.getApplications(); - try { + Applications applications = ApplicationHolder.getApplications(); if (applications.getApplication(application.getUniqueIdentifier()) != null) { CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); - // startApplicationMonitor(application.getUniqueIdentifier()); CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); } + } finally { + ApplicationHolder.releaseWriteLock(); + } + ApplicationsEventPublisher.sendApplicationCreatedEvent(application); + } + + public static void handleApplicationActivatedEvent(String appId) { + if (log.isInfoEnabled()) { + log.info("Handling Application activation for the [application]: " + appId); + } + + Applications applications = ApplicationHolder.getApplications(); + Application application = applications.getApplication(appId); + //update the status of the Group + if (application == null) { + log.warn(String.format("Application %s does not exist", + appId)); + return; + } + try { + ApplicationHolder.acquireWriteLock(); + ApplicationStatus status = ApplicationStatus.Active; + if (application.isStateTransitionValid(status)) { + application.setStatus(status); + updateApplicationMonitor(appId, status); + log.info("Application activated adding status started for Applications"); + ApplicationHolder.persistApplication(application); + //publishing data + ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); + } } finally { ApplicationHolder.releaseWriteLock(); } - ApplicationsEventPublisher.sendApplicationCreatedEvent(application); } public static void handleApplicationUndeployed(String applicationId) { - log.info("Un-deploying the [application] " + applicationId + "by marking it as terminating.."); + if (log.isInfoEnabled()) { + log.info("Un-deploying the [application] " + applicationId + "by marking it as terminating.."); + } ApplicationHolder.acquireReadLock(); try { ApplicationMonitor appMonitor = AutoscalerContext.getInstance(). getAppMonitor(applicationId); - if (appMonitor != null) { // update the status as Terminating + log.info("Application" + applicationId + " updated as terminating" ); appMonitor.setStatus(ApplicationStatus.Terminating); - } else { log.warn("Application Monitor cannot be found for the undeployed [application] " + applicationId); } - } finally { ApplicationHolder.releaseReadLock(); } - /*Set clusterData = null; + ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); + } + + public static void handleApplicationTerminatedEvent(String appId) { + if (log.isInfoEnabled()) { + log.info("Handling Application termination for the [application]: " + appId); + } - try { - if (applicationToRemove != null) { - clusterData = applicationToRemove.getClusterDataRecursively(); - ApplicationHolder.removeApplication(applicationId); + Applications applications = ApplicationHolder.getApplications(); + try { + ApplicationHolder.acquireWriteLock(); + + if (!applications.applicationExists(appId)) { + log.warn("Application with id [ " + appId + " ] doesn't exist in Applications"); } else { - log.warn("Application [ " + applicationId + " ] not found among existing Applications"); + Application application = applications.getApplication(appId); + + if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { + log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated); + } + // forcefully set status for now + application.setStatus(ApplicationStatus.Terminated); + updateApplicationMonitor(appId, ApplicationStatus.Terminated); + //removing the monitor + AutoscalerContext.getInstance().removeAppMonitor(appId); + //Removing the application from memory and registry + ApplicationHolder.removeApplication(appId); + log.info("[Application] " + appId + " is removed"); + ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId); } } finally { ApplicationHolder.releaseWriteLock(); - }*/ + } + } + + public static void handleApplicationTerminatingEvent(String applicationId) { + if (log.isInfoEnabled()) { + log.info("Handling Application terminating for the [application]: " + applicationId); + } + + ApplicationHolder.acquireWriteLock(); + + try { + Applications applications = ApplicationHolder.getApplications(); + if (!applications.applicationExists(applicationId)) { + log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications"); + return; + } + + Application application = applications.getApplication(applicationId); + // check and update application status to 'Terminating' + ApplicationStatus status = ApplicationStatus.Terminating; + if (!application.isStateTransitionValid(status)) { + log.error("Invalid state transfer from " + application.getStatus() + " to " + + ApplicationStatus.Terminating); + } + // for now anyway update the status forcefully + application.setStatus(status); + log.info("Application " + applicationId + "'s status updated to " + + ApplicationStatus.Terminating); + updateApplicationMonitor(applicationId, status); + ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); + } finally { + ApplicationHolder.releaseWriteLock(); + } - ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); } public static void handleGroupTerminatedEvent(String appId, String groupId) { + if (log.isInfoEnabled()) { + log.info("Handling Group termination for the [group]: " + groupId + + " in the [application] " + appId); + } + Applications applications = ApplicationHolder.getApplications(); Application application = applications.getApplication(appId); //update the status of the Group @@ -265,6 +241,11 @@ public static void handleGroupTerminatedEvent(String appId, String groupId) { } public static void handleGroupActivatedEvent(String appId, String groupId) { + if (log.isInfoEnabled()) { + log.info("Handling Group activation for the [group]: " + groupId + + " in the [application] " + appId); + } + Applications applications = ApplicationHolder.getApplications(); Application application = applications.getApplication(appId); //update the status of the Group @@ -301,6 +282,11 @@ public static void handleGroupActivatedEvent(String appId, String groupId) { } public static void handleGroupCreatedEvent(String appId, String groupId) { + if (log.isInfoEnabled()) { + log.info("Handling Group creation for the [group]: " + groupId + + " in the [application] " + appId); + } + Applications applications = ApplicationHolder.getApplications(); Application application = applications.getApplication(appId); //update the status of the Group @@ -338,6 +324,11 @@ public static void handleGroupCreatedEvent(String appId, String groupId) { } public static void handleGroupInActivateEvent(String appId, String groupId) { + if (log.isInfoEnabled()) { + log.info("Handling Group in-active for the [group]: " + groupId + + " in the [application] " + appId); + } + Applications applications = ApplicationHolder.getApplications(); Application application = applications.getApplication(appId); //update the status of the Group @@ -374,6 +365,11 @@ public static void handleGroupInActivateEvent(String appId, String groupId) { } public static void handleGroupTerminatingEvent(String appId, String groupId) { + if (log.isInfoEnabled()) { + log.info("Handling Group terminating for the [group]: " + groupId + + " in the [application] " + appId); + } + Applications applications = ApplicationHolder.getApplications(); Application application = applications.getApplication(appId); //update the status of the Group @@ -409,99 +405,6 @@ public static void handleGroupTerminatingEvent(String appId, String groupId) { } } - public static void handleApplicationActivatedEvent(String appId) { - Applications applications = ApplicationHolder.getApplications(); - Application application = applications.getApplication(appId); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - appId)); - return; - } - - try { - ApplicationHolder.acquireWriteLock(); - ApplicationStatus status = ApplicationStatus.Active; - if (application.isStateTransitionValid(status)) { - application.setStatus(status); - updateApplicationMonitor(appId, status); - log.info("Application activated adding status started for Applications"); - ApplicationHolder.persistApplication(application); - //publishing data - ApplicationsEventPublisher.sendApplicationActivatedEvent(appId); - } - } finally { - ApplicationHolder.releaseWriteLock(); - } - - } - - /*public static void handleApplicationCreatedEvent(ApplicationCreatedEvent event) { - Applications applications = ApplicationHolder.getApplications(); - Application application = applications.getApplication(event.getAppId()); - //update the status of the Group - if (application == null) { - log.warn(String.format("Application %s does not exist", - event.getAppId())); - return; - } - List clusters = new ArrayList(); - Set allClusters = application.getClusterDataRecursively(); - - for (ClusterDataHolder clusterDataHolder : allClusters) { - String clusterId = clusterDataHolder.getClusterId(); - String serviceName = clusterDataHolder.getServiceType(); - clusters.add(ApplicationHolder.getApplications().getService(serviceName).getCluster(clusterId)); - } - org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent applicationActivatedEvent = - new org.apache.stratos.messaging.event.applications.ApplicationCreatedEvent( - application, clusters); - try { - ApplicationHolder.acquireWriteLock(); - application.setStatus(ApplicationStatus.Created); - log.info("Application created adding status started for Applications"); - - ApplicationHolder.persistApplication(applications); - } finally { - ApplicationHolder.releaseWriteLock(); - } - //publishing data - ApplicationsEventPublisher.sendApplicationCreatedEvent(applicationActivatedEvent); - }*/ - - public static void handleApplicationTerminatingEvent(String appId) { - - String applicationId = appId; - - // update the Application Status as 'Terminating' - ApplicationHolder.acquireWriteLock(); - - try { - - Applications applications = ApplicationHolder.getApplications(); - - if (!applications.applicationExists(applicationId)) { - log.warn("Application with id [ " + applicationId + " ] doesn't exist in Applications"); - return; - } - - Application application = applications.getApplication(applicationId); - // check and update application status to 'Terminating' - ApplicationStatus status = ApplicationStatus.Terminating; - if (!application.isStateTransitionValid(status)) { - log.error("Invalid state transfer from " + application.getStatus() + " to " + ApplicationStatus.Terminating); - } - // for now anyway update the status forcefully - application.setStatus(status); - log.info("Application " + applicationId + "'s status updated to " + ApplicationStatus.Terminating); - updateApplicationMonitor(appId, status); - ApplicationsEventPublisher.sendApplicationTerminatingEvent(applicationId); - } finally { - ApplicationHolder.releaseWriteLock(); - } - - } - private static void updateGroupStatusesRecursively(GroupStatus groupStatus, Collection groups) { for (Group group : groups) { @@ -518,174 +421,13 @@ private static void updateGroupStatusesRecursively(GroupStatus groupStatus, Coll } } - public static void handleApplicationTerminatedEvent(String appId) { - - Applications applications = ApplicationHolder.getApplications(); - - try { - ApplicationHolder.acquireWriteLock(); - - if (!applications.applicationExists(appId)) { - log.warn("Application with id [ " + appId + " ] doesn't exist in Applications"); - } else { - Application application = applications.getApplication(appId); - - if (!application.isStateTransitionValid(ApplicationStatus.Terminated)) { - log.error("Invalid status change from " + application.getStatus() + " to " + ApplicationStatus.Terminated); - } - // forcefully set status for now - application.setStatus(ApplicationStatus.Terminated); - updateApplicationMonitor(appId, ApplicationStatus.Terminated); - //removing the monitor - AutoscalerContext.getInstance().removeAppMonitor(appId); - //Removing the application from memory and registry - ApplicationHolder.removeApplication(appId); - ApplicationsEventPublisher.sendApplicationTerminatedEvent(appId); - } - - } finally { - ApplicationHolder.releaseWriteLock(); - } - } - - - protected static synchronized void startApplicationMonitor(String appId) { - - ApplicationMonitor applicationMonitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - long start = System.currentTimeMillis(); - if (log.isDebugEnabled()) { - log.debug("application monitor is going to be started for [application] " + - appId); - } - applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); - - long end = System.currentTimeMillis(); - log.info("Time taken to start app monitor: " + (end - start) / 1000); - success = true; - } catch (DependencyBuilderException e) { - String msg = "Application monitor creation failed for Application: "; - log.warn(msg, e); - retries--; - } catch (TopologyInConsistentException e) { - String msg = "Application monitor creation failed for Application: "; - log.warn(msg, e); - retries--; - } - } while (!success && retries != 0); - - if (applicationMonitor == null) { - String msg = "Application monitor creation failed, even after retrying for 5 times, " - + "for Application: " + appId; - log.error(msg); - throw new RuntimeException(msg); - } - - AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); - - if (log.isInfoEnabled()) { - log.info(String.format("Application monitor has been added successfully: " + - "[application] %s", applicationMonitor.getId())); - } - } - - - /*Thread th = null; - if (!AutoscalerContext.getInstance() - .appMonitorExist(applicationId)) { - th = new Thread( - new ApplicationMonitorAdder(applicationId)); - } - - if (th != null) { - th.start(); - // try { - // th.join(); - // } catch (InterruptedException ignore) { - - if (log.isDebugEnabled()) { - log.debug(String - .format("Application monitor thread has been started successfully: " + - "[application] %s ", applicationId)); - } - } else { - if (log.isDebugEnabled()) { - log.debug(String - .format("Application monitor thread already exists: " + - "[application] %s ", applicationId)); - } - }*/ - - - private class ApplicationMonitorAdder implements Runnable { - private String appId; - - public ApplicationMonitorAdder(String appId) { - this.appId = appId; - } - - public void run() { - ApplicationMonitor applicationMonitor = null; - int retries = 5; - boolean success = false; - do { - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - } - try { - long start = System.currentTimeMillis(); - if (log.isDebugEnabled()) { - log.debug("application monitor is going to be started for [application] " + - appId); - } - applicationMonitor = ApplicationMonitorFactory.getApplicationMonitor(appId); - - long end = System.currentTimeMillis(); - log.info("Time taken to start app monitor: " + (end - start) / 1000); - success = true; - } catch (DependencyBuilderException e) { - String msg = "Application monitor creation failed for Application: "; - log.warn(msg, e); - retries--; - } catch (TopologyInConsistentException e) { - String msg = "Application monitor creation failed for Application: "; - log.warn(msg, e); - retries--; - } - } while (!success && retries != 0); - - if (applicationMonitor == null) { - String msg = "Application monitor creation failed, even after retrying for 5 times, " - + "for Application: " + appId; - log.error(msg); - throw new RuntimeException(msg); - } - - AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); - - if (log.isInfoEnabled()) { - log.info(String.format("Application monitor has been added successfully: " + - "[application] %s", applicationMonitor.getId())); - } - } - } - - private static void updateApplicationMonitor(String appId, ApplicationStatus status) { //Updating the Application Monitor ApplicationMonitor applicationMonitor = AutoscalerContext.getInstance().getAppMonitor(appId); if (applicationMonitor != null) { applicationMonitor.setStatus(status); } else { - //TODO + log.warn("Application monitor cannot be found for the [application] " + appId); } } @@ -698,7 +440,8 @@ private static void updateGroupMonitor(String appId, String groupId, GroupStatus if (monitor != null) { monitor.setStatus(status); } else { - //TODO + log.warn("Group monitor cannot be found for the [group] " + groupId + " for the " + + "[application] " + appId); } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index c22f3b875d..df5b6a2eae 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -322,71 +322,7 @@ protected void onEvent(Event event) { } } }); -//TODO delete this if we don't want this -// topologyEventReceiver.addEventListener(new ClusterRemovedEventListener() { -// @Override -// protected void onEvent(Event event) { -// -// ClusterRemovedEvent clusterRemovedEvent = null; -// try { -// clusterRemovedEvent = (ClusterRemovedEvent) event; -// //TopologyManager.acquireReadLock(); -// TopologyManager.acquireReadLockForCluster(clusterRemovedEvent.getServiceName(), -// clusterRemovedEvent.getClusterId()); -// -// String clusterId = clusterRemovedEvent.getClusterId(); -// String deploymentPolicy = clusterRemovedEvent.getDeploymentPolicy(); -// -// AbstractClusterMonitor monitor; -// -// if (clusterRemovedEvent.isLbCluster()) { -// DeploymentPolicy depPolicy = PolicyManager.getInstance(). -// getDeploymentPolicy(deploymentPolicy); -// if (depPolicy != null) { -// List lbHolders = PartitionManager.getInstance() -// .getNetworkPartitionLbHolders(depPolicy); -// -// for (NetworkPartitionLbHolder networkPartitionLbHolder : lbHolders) { -// // removes lb cluster ids -// boolean isRemoved = networkPartitionLbHolder.removeLbClusterId(clusterId); -// if (isRemoved) { -// log.info("Removed the lb cluster [id]:" -// + clusterId -// + " reference from Network Partition [id]: " -// + networkPartitionLbHolder -// .getNetworkPartitionId()); -// -// } -// if (log.isDebugEnabled()) { -// log.debug(networkPartitionLbHolder); -// } -// -// } -// } -// monitor = AutoscalerContext.getInstance() -// .removeLbMonitor(clusterId); -// -// } else { -// monitor = (AbstractClusterMonitor) AutoscalerContext.getInstance() -// .removeMonitor(clusterId); -// } -// -// // runTerminateAllRule(monitor); -// if (monitor != null) { -// monitor.destroy(); -// log.info(String.format("Cluster monitor has been removed successfully: [cluster] %s ", -// clusterId)); -// } -// } catch (Exception e) { -// log.error("Error processing event", e); -// } finally { -// //TopologyManager.releaseReadLock(); -// TopologyManager.releaseReadLockForCluster(clusterRemovedEvent.getServiceName(), -// clusterRemovedEvent.getClusterId()); -// } -// } -// -// }); + topologyEventReceiver.addEventListener(new MemberStartedEventListener() { @Override From 378a6e5c2c1bd97f264521699f1020c3bf427b2a Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 15:35:59 +0530 Subject: [PATCH 409/436] Introducing method org.apache.stratos.common.Properties.addProperty() and removing unused deployers in autoscaler component --- .../autoscaler/api/AutoScalerServiceImpl.java | 5 - .../applications/ApplicationUtils.java | 2 +- .../controller/CloudControllerClient.java | 4 +- .../cluster/AbstractClusterMonitor.java | 2 +- .../cluster/ClusterMonitorFactory.java | 12 +- .../KubernetesServiceClusterMonitor.java | 4 +- .../monitor/cluster/VMClusterMonitor.java | 2 +- .../cluster/VMServiceClusterMonitor.java | 4 +- .../deployers/PartitionDeployer.java | 117 ------------- .../partition/deployers/PartitionReader.java | 154 ------------------ .../deployers/AbstractPolicyReader.java | 93 ----------- .../deployers/DeploymentPolicyDeployer.java | 114 ------------- .../deployers/DeploymentPolicyReader.java | 130 --------------- .../autoscaler/util/AutoscalerUtil.java | 4 +- .../src/main/resources/META-INF/component.xml | 16 -- .../policy/DeploymentPolicyDeployerTest.java | 68 ++++---- .../org/apache/stratos/common/Properties.java | 59 ++++--- .../org/apache/stratos/common/Property.java | 12 +- 18 files changed, 93 insertions(+), 709 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java delete mode 100644 components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 91bbe76869..fb50681a0b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -342,11 +342,6 @@ public String getServiceLBClusterId(String serviceType, String deploymentPolicyN return null; } - @Override - public void updateClusterMonitor(String clusterId, org.apache.stratos.common.Properties properties) throws InvalidArgumentException { - - } - public boolean checkClusterLBExistenceAgainstPolicy(String clusterId, String deploymentPolicyId) { for (PartitionGroup partitionGroup : PolicyManager.getInstance().getDeploymentPolicy(deploymentPolicyId).getPartitionGroups()) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java index 0886353e3e..3479f2f6ae 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.PortMapping; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Property; import java.util.*; import java.util.regex.Pattern; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 42706692b9..374e092efb 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -38,8 +38,8 @@ import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesMaster; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import java.rmi.RemoteException; import java.util.ArrayList; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index f8e81b8748..14f02dd48a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -31,7 +31,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.Properties; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index 8c99d99ae2..3a164f32af 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -40,8 +40,8 @@ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Member; @@ -209,10 +209,10 @@ private static Properties convertMemberPropsToMemberContextProps( java.util.Properties properties) { Properties props = new Properties(); for (Map.Entry e : properties.entrySet()) { - Property prop = new Property(); - prop.setName((String) e.getKey()); - prop.setValue((String) e.getValue()); - props.addProperties(prop); + Property property = new Property(); + property.setName((String) e.getKey()); + property.setValue((String) e.getValue()); + props.addProperty(property); } return props; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java index 324da34c53..d6dc3a37f3 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java @@ -29,8 +29,8 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index cd617ee2f0..5931b881cc 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -33,7 +33,7 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.common.Properties; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index a8b9329379..2b0e4fdcbf 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -35,8 +35,8 @@ import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.GroupStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.java deleted file mode 100644 index 635fd09f00..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionDeployer.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.autoscaler.partition.deployers; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.deployment.AbstractDeployer; -import org.apache.axis2.deployment.DeploymentException; -import org.apache.axis2.deployment.repository.util.DeploymentFileData; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.partition.PartitionManager; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; - -import java.io.File; -import java.util.Iterator; -import java.util.List; - -/** - * - * The Axis2 deployer class for partition definitions definitions. - */ -public class PartitionDeployer extends AbstractDeployer { - - private static final Log log = LogFactory.getLog(PartitionDeployer.class); - - @SuppressWarnings("unused") - private String extension="xml"; //default - private static String deployDirectory=null; - - @Override - public void init(ConfigurationContext context) { - if(deployDirectory!=null){ - File deployDir = new File(new File(context.getAxisConfiguration().getRepository().getPath()),deployDirectory); - if(!deployDir.exists()){ - //create policies deployment directory if not exist - try { - deployDir.mkdirs(); - } catch (Exception e) { - log.error("Unable to create policies deployment directory", e); - } - } - } - } - - @Override - public void setDirectory(String dir) { - deployDirectory = dir; - } - - @Override - public void setExtension(String ext) { - extension = ext; - } - - @Override - public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { - - File partitionFile = deploymentFileData.getFile(); - log.debug("Started to deploy the partitions of file: " + partitionFile); - - try { - - PartitionReader reader = new PartitionReader(partitionFile); - - List partitionList = reader.getPartitionList(); - Iterator it = partitionList.iterator(); - - while (it.hasNext()) { - Partition partition = it.next(); - try { - PartitionManager.getInstance().addNewPartition(partition); - } catch (Exception e) { - String msg = - "Invalid partition: " + partition.getId() + " in file: " + - partitionFile.getAbsolutePath()+". Cause: "+ e.getMessage(); - log.error(msg, e); - continue; - } - } - - - } catch (Exception e) { - String msg = "Invalid partition definition file: " + deploymentFileData.getAbsolutePath(); - // back up the file - File fileToBeRenamed = partitionFile; - fileToBeRenamed.renameTo(new File(deploymentFileData.getAbsolutePath() + ".back")); - log.error(msg, e); - throw new DeploymentException(msg, e); - } - } - - @Override - public void undeploy(String fileName) throws DeploymentException { - //TODO undeploy logic - } - - - - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java deleted file mode 100644 index 85956cfbed..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/deployers/PartitionReader.java +++ /dev/null @@ -1,154 +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.autoscaler.partition.deployers; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.OMNode; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.axiom.om.xpath.AXIOMXPath; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.util.AutoScalerConstants; -import org.apache.stratos.autoscaler.util.AutoscalerUtil; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; -import org.jaxen.JaxenException; - -/** - * - * The Reader class for Deployment-policy definitions. - */ -public class PartitionReader{ - - private static final Log log = LogFactory.getLog(PartitionReader.class); - private static OMElement documentElement; - private File partitionFIle; - - public PartitionReader(File partitionFile){ - this.partitionFIle = partitionFile; - } - - public List getPartitionList(){ - this.parse(this.partitionFIle); - String partitionXpath = "/"+AutoScalerConstants.PARTITIONS_ELEMENT + "/"+AutoScalerConstants.PARTITION_ELEMENT; - List partitionXMLNodes = getMatchingNodes(partitionXpath); - Iterator itr = partitionXMLNodes.iterator(); - List partitonList = new ArrayList(); - while (itr.hasNext()) { - OMNode node = itr.next(); - Partition partition = this.getPartition(node); - if (partition != null) { - partitonList.add(partition); - } - } - return partitonList; - } - - private Partition getPartition(final OMNode item) { - Partition partition = null; - - if (item.getType() == OMNode.ELEMENT_NODE) { - - OMElement partitionElt = (OMElement) item; - String partitionId = partitionElt.getAttributeValue(new QName("id")); - - if (partitionId == null) { - String msg ="Essential " + AutoScalerConstants.ID_ELEMENT + "element " + - "has not specified."; - log.warn("Partition is ignored. "+msg); - return null; - } - - partition = new Partition(); - partition.setId(partitionId); - Properties properties = AutoscalerUtil.getProperties(partitionElt); - if (properties != null) { - partition.setProperties(properties); - } - String providerValue = readValue(partitionElt, "provider"); - if (providerValue != null) { - partition.setProvider(providerValue); - } - String maxValue = readValue(partitionElt, "max"); - if (maxValue != null) { - partition.setPartitionMax(Integer.valueOf(maxValue)); - } - String minValue = readValue(partitionElt, "min"); - if (minValue != null) { - partition.setPartitionMin(Integer.valueOf(minValue)); - } - - } - return partition; - } - - public void parse(File xmlSource){ - - if (xmlSource.exists()) { - try { - documentElement = new StAXOMBuilder(xmlSource.getPath()).getDocumentElement(); - - } catch (Exception ex) { - String msg = "Error occurred when parsing the " + xmlSource.getPath() + "."; - //handleException(msg, ex); - } - } else { - String msg = "Configuration file cannot be found : " + xmlSource.getPath(); - //handleException(msg); - } - } - /** - * @param xpath XPATH expression to be read. - * @return List matching OMNode list - */ - @SuppressWarnings("unchecked") - public List getMatchingNodes(final String xpath) { - - AXIOMXPath axiomXpath; - List nodeList = null; - try { - axiomXpath = new AXIOMXPath(xpath); - nodeList = axiomXpath.selectNodes(documentElement); - } catch (JaxenException e) { - String msg = "Error occurred while reading the Xpath (" + xpath + ")"; - //log.error(msg, e); - } - - return nodeList; - } - - - - protected String readValue(OMElement ele, String qName) { - OMElement valueContainer = ele.getFirstChildWithName(new QName(qName)); - if(valueContainer == null) { - return null; - } - String value = valueContainer.getText(); - return value; - } -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java deleted file mode 100644 index 52efa90b2b..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/AbstractPolicyReader.java +++ /dev/null @@ -1,93 +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.autoscaler.policy.deployers; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamReader; - -import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.builder.StAXOMBuilder; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.exception.InvalidPolicyException; - -/** - * Abstract super-class, with some common logic, for reading policies. The only - * method subclasses must implement is read(). - */ -public abstract class AbstractPolicyReader { - - private static final Log log = LogFactory.getLog(AbstractPolicyReader.class); - - protected File file; - private FileInputStream fStream; - - protected AbstractPolicyReader(File file) { - this.setFile(file); - } - - public File getFile() { - return file; - } - - public void setFile(File file) { - this.file = file; - } - - public abstract T read() throws InvalidPolicyException; - - protected OMElement getDocument() throws Exception { - fStream = new FileInputStream(file); - XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(fStream); - StAXOMBuilder builder = new StAXOMBuilder(parser); - return builder.getDocumentElement(); - } - - protected void closeStream() { - try { - if (fStream != null) { - fStream.close(); - } - } catch (IOException e) { - log.debug("Unable to close the input stream", e); - } - } - - protected String readValueAttr(OMElement ele, String qName) { - OMElement valueContainer = ele.getFirstChildWithName(new QName(qName)); - String value = valueContainer.getAttributeValue(new QName("value")); - return value; - } - - protected String readValue(OMElement ele, String qName) { - OMElement valueContainer = ele.getFirstChildWithName(new QName(qName)); - if(valueContainer == null) { - return null; - } - String value = valueContainer.getText(); - return value; - } - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java deleted file mode 100644 index a402915aeb..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyDeployer.java +++ /dev/null @@ -1,114 +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.autoscaler.policy.deployers; - -import java.io.File; - -import org.apache.axis2.context.ConfigurationContext; -import org.apache.axis2.deployment.AbstractDeployer; -import org.apache.axis2.deployment.DeploymentException; -import org.apache.axis2.deployment.repository.util.DeploymentFileData; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.policy.PolicyManager; - -/** - * - * The Axis2 deployer class for Deployment-Policy definitions. - */ -public class DeploymentPolicyDeployer extends AbstractDeployer { - - private static final Log log = LogFactory.getLog(DeploymentPolicyDeployer.class); - - @SuppressWarnings("unused") - private String extension ="xml"; //default - private static String deployDirectory=null; - - @Override - public void init(ConfigurationContext context) { - if(deployDirectory!=null){ - File deployDir = new File(new File(context.getAxisConfiguration().getRepository().getPath()),deployDirectory); - if(!deployDir.exists()){ - //create policies deployment directory if not exist - try { - deployDir.mkdirs(); - } catch (Exception e) { - log.error("Unable to create policies deployment directory", e); - } - } - } - } - - @Override - public void setDirectory(String dir) { - deployDirectory = dir; - } - - @Override - public void setExtension(String ext) { - extension = ext; - } - - @Override - public void deploy(DeploymentFileData deploymentFileData) throws DeploymentException { - - File policyFile = deploymentFileData.getFile(); - log.debug("Started to deploy the policy: " + policyFile); - - try { - - DeploymentPolicyReader reader = new DeploymentPolicyReader(policyFile); - - DeploymentPolicy policy = reader.read(); - PolicyManager.getInstance().addDeploymentPolicyToInformationModel(policy); - - log.info("Successfully deployed the policy specified at " - + deploymentFileData.getAbsolutePath()); - - } catch (Exception e) { - String msg = "Invalid policy artifact at " + deploymentFileData.getAbsolutePath(); - // back up the file - File fileToBeRenamed = policyFile; - fileToBeRenamed.renameTo(new File(deploymentFileData.getAbsolutePath() + ".back")); - log.error(msg, e); - throw new DeploymentException(msg, e); - } - } - - @Override - public void undeploy(String fileName) throws DeploymentException { - /* - File policyFile = new File(fileName); - String policyName = policyFile.getName().replaceAll("." + fileExt + "$", ""); - try { - PolicyManager.getInstance().removeDeploymentPolicy(policyFile); - log.info("Successfully undeployed the policy specified at " + fileName); - } catch (InvalidPolicyException e) { - log.error("unable to remove policy " + policyName , e); - throw new DeploymentException("unable to remove policy " + policyName ,e); - } - */ - } - - - - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java deleted file mode 100644 index 704feaf1a9..0000000000 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/deployers/DeploymentPolicyReader.java +++ /dev/null @@ -1,130 +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.autoscaler.policy.deployers; - -import java.io.File; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.xml.namespace.QName; - -import org.apache.axiom.om.OMElement; -import org.apache.axis2.deployment.DeploymentException; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.exception.InvalidPolicyException; -import org.apache.stratos.autoscaler.partition.PartitionGroup; -import org.apache.stratos.autoscaler.util.AutoscalerUtil; -import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; - -/** - * - * The Reader class for Deployment-policy definitions. - */ -public class DeploymentPolicyReader extends AbstractPolicyReader { - - private static final Log log = LogFactory.getLog(DeploymentPolicyReader.class); - - - public DeploymentPolicyReader(File file) { - super(file); - } - - public DeploymentPolicy read() throws InvalidPolicyException{ - DeploymentPolicy policy = new DeploymentPolicy(); - try { - OMElement docEle = getDocument(); - if("deploymentPolicy".equalsIgnoreCase(docEle.getLocalName())){ - policy.setId(docEle.getAttributeValue(new QName("id"))); - - //Partition-Groups - Iterator partitionGroupItr = docEle.getChildrenWithLocalName("partitionGroup"); - while(partitionGroupItr.hasNext()){ - List partitionGroups = new ArrayList(); - Object nextGroup = partitionGroupItr.next(); - if(nextGroup instanceof OMElement){ - OMElement groupEle = (OMElement) nextGroup; - PartitionGroup group = new PartitionGroup(); - group.setId(groupEle.getAttributeValue(new QName("id"))); - group.setPartitionAlgo(readValue(groupEle, "partitionAlgo")); - - List partitions = new ArrayList() ; - //Partitions - Iterator partitionItr = groupEle.getChildrenWithLocalName("partition"); - while(partitionItr.hasNext()){ - Object next = partitionItr.next(); - if(next instanceof OMElement){ - OMElement partitionElt = (OMElement) next; - - String partitionId = partitionElt.getAttributeValue(new QName("id")); - if (partitionId != null) { - Partition partition = new Partition(); - partition.setId(partitionId); - String maxValue = readValue(partitionElt, "max"); - if (maxValue != null) { - partition.setPartitionMax(Integer.valueOf(maxValue)); - } - String minValue = readValue(partitionElt, "min"); - if (minValue != null) { - partition.setPartitionMin(Integer.valueOf(minValue)); - } - String providerValue = readValue(partitionElt, "provider"); - if (providerValue != null) { - partition.setProvider(providerValue); - } - - Properties properties = AutoscalerUtil.getProperties(partitionElt); - if (properties != null) { - partition.setProperties(properties); - } - partitions.add(partition); - } else { - log.warn("Invalid Partition id: null. Partition will be ignored."); - } - } - } - if(group.getPartitions() == null) { - group.setPartitions(new Partition[0]); - } - group.setPartitions(partitions.toArray(group.getPartitions())); - partitionGroups.add(group); - } - if(policy.getPartitionGroups() == null) { - policy.setPartitionGroups(new PartitionGroup[0]); - } - policy.setPartitionGroups(partitionGroups.toArray(policy.getPartitionGroups())); - } - } else{ - throw new DeploymentException("File is not a valid deployment policy"); - } - - } catch (Exception e){ - log.error("Malformed deployment policy file", e); - throw new InvalidPolicyException("Malformed deployment policy file",e); - } finally{ - closeStream(); - } - return policy; - } - -} diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index f9eea5ac7e..c0ac1787e0 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.registry.RegistryManager; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; diff --git a/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/component.xml b/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/component.xml index 255bddeb35..24674806ac 100644 --- a/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/component.xml +++ b/components/org.apache.stratos.autoscaler/src/main/resources/META-INF/component.xml @@ -18,22 +18,6 @@ --> - diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java index b7ef179a67..fd341c0fa5 100644 --- a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java +++ b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java @@ -16,37 +16,37 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.deployment.policy; - -import static org.junit.Assert.*; - -import java.io.File; - -import org.apache.stratos.autoscaler.exception.InvalidPolicyException; -import org.apache.stratos.autoscaler.policy.deployers.DeploymentPolicyReader; -import org.junit.Before; -import org.junit.Test; - -/** - * @author nirmal - * - */ -public class DeploymentPolicyDeployerTest { - - DeploymentPolicyReader reader; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - reader = new DeploymentPolicyReader(new File("src/test/resources/deployment-policy.xml")); - } - - @Test - public void test() throws InvalidPolicyException { - - DeploymentPolicy policy = reader.read(); - } - -} +//package org.apache.stratos.autoscaler.deployment.policy; +// +//import static org.junit.Assert.*; +// +//import java.io.File; +// +//import org.apache.stratos.autoscaler.exception.InvalidPolicyException; +//import org.apache.stratos.autoscaler.policy.deployers.DeploymentPolicyReader; +//import org.junit.Before; +//import org.junit.Test; +// +///** +// * @author nirmal +// * +// */ +//public class DeploymentPolicyDeployerTest { +// +// DeploymentPolicyReader reader; +// +// /** +// * @throws java.lang.Exception +// */ +// @Before +// public void setUp() throws Exception { +// reader = new DeploymentPolicyReader(new File("src/test/resources/deployment-policy.xml")); +// } +// +// @Test +// public void test() throws InvalidPolicyException { +// +// DeploymentPolicy policy = reader.read(); +// } +// +//} diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java index 25fea6e4c6..1b8ef93bb8 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Properties.java @@ -18,8 +18,14 @@ */ package org.apache.stratos.common; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.List; /** * Had to wrap {@link Property} array using a class, since there's a bug in current @@ -27,54 +33,53 @@ */ public class Properties implements Serializable { - private Property[] properties; + private static final long serialVersionUID = -9094584151615076171L; + private static final Log log = LogFactory.getLog(Properties.class); + + private List properties; + + public Properties() { + this.properties = new ArrayList(); + } public Property[] getProperties() { - return properties; + return properties.toArray(new Property[properties.size()]); } - public void setProperties(Property[] properties) { - if(properties == null) { - this.properties = new Property[0]; - } else { - this.properties = Arrays.copyOf(properties, properties.length); + public void addProperty(Property property) { + try { + this.properties.add((Property) property.clone()); + } catch (CloneNotSupportedException e) { + log.error(e); } } + public void setProperties(Property[] properties) { + this.properties = new ArrayList(); + Collections.addAll(this.properties, properties.clone()); + } + @Override public String toString() { - return "Properties [properties=" + Arrays.toString(properties) + "]"; + return "Properties [properties=" + this.getProperties() + "]"; } @Override - public boolean equals(Object anObject) { - if (anObject == null) { - return false; - } - if (this == anObject) { + public boolean equals(Object object) { + if (object == null) { return false; } - if (!(anObject instanceof Properties)) { - return false; - } - Properties propertiesObj = (Properties) anObject; - if (this.properties == null) { - if (propertiesObj.getProperties() != null) { - return false; - } - } else if (!Arrays.equals(this.properties, propertiesObj.getProperties())) { + if (!(object instanceof Properties)) { return false; } - return true; + Properties propertiesObject = (Properties) object; + return Arrays.equals(propertiesObject.getProperties(), this.getProperties()); } @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((this.properties == null) ? 0 : Arrays.hashCode(this.properties)); - return result; + return this.hashCode(); } } \ No newline at end of file diff --git a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java index 2658916b61..7ac6b0291b 100644 --- a/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java +++ b/components/org.apache.stratos.common/src/main/java/org/apache/stratos/common/Property.java @@ -23,14 +23,14 @@ /** * Holds a property */ -public class Property implements Serializable { +public class Property implements Serializable, Cloneable { private static final long serialVersionUID = -2191782657999410197L; + private String name; private String value; public Property() { - } public Property(String name, String value) { @@ -54,6 +54,14 @@ public void setValue(String value) { this.value = value; } + @Override + protected Object clone() throws CloneNotSupportedException { + Property clone = new Property(); + clone.setName(this.getName()); + clone.setValue(this.getValue()); + return clone; + } + @Override public String toString() { return "Property [name=" + name + ", value=" + value + "]"; From 62d65fd734ce3f227781d3cd7cfad1127cccf477 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 15:38:28 +0530 Subject: [PATCH 410/436] adding application topic receiver in cloud controller --- .../internal/CloudControllerDSComponent.java | 21 +++++-- .../application/ApplicationTopicReceiver.java | 60 +++++++++++++++++++ .../status}/ClusterStatusTopicReceiver.java | 2 +- .../InstanceStatusEventMessageDelegator.java | 2 +- .../InstanceStatusEventMessageListener.java | 2 +- .../InstanceStatusEventMessageQueue.java | 2 +- .../controller/topology/TopologyBuilder.java | 27 +++++++++ .../topology/TopologyEventPublisher.java | 9 +++ 8 files changed, 116 insertions(+), 9 deletions(-) create mode 100644 components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/application/ApplicationTopicReceiver.java rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/{application/status/receiver => receiver/cluster/status}/ClusterStatusTopicReceiver.java (98%) rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/{topic => receiver}/instance/status/InstanceStatusEventMessageDelegator.java (98%) rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/{topic => receiver}/instance/status/InstanceStatusEventMessageListener.java (97%) rename components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/{topic => receiver}/instance/status/InstanceStatusEventMessageQueue.java (95%) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java index b286390c1b..26edbf122e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/internal/CloudControllerDSComponent.java @@ -23,13 +23,14 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.cloud.controller.application.status.receiver.ClusterStatusTopicReceiver; +import org.apache.stratos.cloud.controller.receiver.application.ApplicationTopicReceiver; +import org.apache.stratos.cloud.controller.receiver.cluster.status.ClusterStatusTopicReceiver; import org.apache.stratos.cloud.controller.exception.CloudControllerException; import org.apache.stratos.cloud.controller.impl.CloudControllerServiceImpl; import org.apache.stratos.cloud.controller.interfaces.CloudControllerService; import org.apache.stratos.cloud.controller.publisher.TopologySynchronizerTaskScheduler; -import org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageDelegator; -import org.apache.stratos.cloud.controller.topic.instance.status.InstanceStatusEventMessageListener; +import org.apache.stratos.cloud.controller.receiver.instance.status.InstanceStatusEventMessageDelegator; +import org.apache.stratos.cloud.controller.receiver.instance.status.InstanceStatusEventMessageListener; import org.apache.stratos.cloud.controller.util.CloudControllerConstants; import org.apache.stratos.cloud.controller.util.ServiceReferenceHolder; import org.apache.stratos.messaging.broker.publish.EventPublisherPool; @@ -65,6 +66,8 @@ public class CloudControllerDSComponent { private static final Log log = LogFactory.getLog(CloudControllerDSComponent.class); private ClusterStatusTopicReceiver clusterStatusTopicReceiver; + private ApplicationTopicReceiver applicationTopicReceiver; + protected void activate(ComponentContext context) { try { @@ -82,12 +85,20 @@ protected void activate(ComponentContext context) { log.info("Instance status message receiver thread started"); } + applicationTopicReceiver = new ApplicationTopicReceiver(); + Thread tApplicationTopicReceiver = new Thread(applicationTopicReceiver); + tApplicationTopicReceiver.start(); + + if (log.isInfoEnabled()) { + log.info("Application Receiver thread started"); + } + clusterStatusTopicReceiver = new ClusterStatusTopicReceiver(); Thread tClusterStatusTopicReceiver = new Thread(clusterStatusTopicReceiver); tClusterStatusTopicReceiver.start(); - if (log.isDebugEnabled()) { - log.debug("Cluster status Receiver thread started"); + if (log.isInfoEnabled()) { + log.info("Cluster status Receiver thread started"); } // Register cloud controller service diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/application/ApplicationTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/application/ApplicationTopicReceiver.java new file mode 100644 index 0000000000..7f8fd5634f --- /dev/null +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/application/ApplicationTopicReceiver.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.stratos.cloud.controller.receiver.application; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.cloud.controller.topology.TopologyBuilder; +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.event.applications.ApplicationTerminatedEvent; +import org.apache.stratos.messaging.listener.applications.ApplicationTerminatedEventListener; +import org.apache.stratos.messaging.message.receiver.applications.ApplicationsEventReceiver; + +/** + * This is to receive the application topic messages. + */ +public class ApplicationTopicReceiver implements Runnable { + private static final Log log = LogFactory.getLog(ApplicationTopicReceiver.class); + private ApplicationsEventReceiver applicationsEventReceiver; + private boolean terminated; + + @Override + public void run() { + this.applicationsEventReceiver = new ApplicationsEventReceiver(); + addEventListeners(); + + } + + private void addEventListeners() { + applicationsEventReceiver.addEventListener(new ApplicationTerminatedEventListener() { + @Override + protected void onEvent(Event event) { + //Remove the application related data + log.info("ApplicationTerminatedEvent received for [application]"); + ApplicationTerminatedEvent terminatedEvent = (ApplicationTerminatedEvent)event; + String appId = terminatedEvent.getAppId(); + TopologyBuilder.handleApplicationClustersRemoved(appId); + } + }); + } + + public void setTerminated(boolean terminated) { + this.terminated = terminated; + } +} diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/cluster/status/ClusterStatusTopicReceiver.java similarity index 98% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/cluster/status/ClusterStatusTopicReceiver.java index 4cc7599c7d..196e1e09bf 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/application/status/receiver/ClusterStatusTopicReceiver.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/cluster/status/ClusterStatusTopicReceiver.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.cloud.controller.application.status.receiver; +package org.apache.stratos.cloud.controller.receiver.cluster.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageDelegator.java similarity index 98% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageDelegator.java index dd279eded3..5adf58f517 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageDelegator.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageDelegator.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.cloud.controller.topic.instance.status; +package org.apache.stratos.cloud.controller.receiver.instance.status; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageListener.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageListener.java similarity index 97% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageListener.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageListener.java index 1f72e76dfe..352354489e 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageListener.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageListener.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.cloud.controller.topic.instance.status; +package org.apache.stratos.cloud.controller.receiver.instance.status; import javax.jms.JMSException; import javax.jms.TextMessage; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageQueue.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageQueue.java similarity index 95% rename from components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageQueue.java rename to components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageQueue.java index 4e69c16708..a978e624d6 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topic/instance/status/InstanceStatusEventMessageQueue.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/receiver/instance/status/InstanceStatusEventMessageQueue.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.cloud.controller.topic.instance.status; +package org.apache.stratos.cloud.controller.receiver.instance.status; import javax.jms.TextMessage; import java.util.concurrent.LinkedBlockingQueue; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index 6015d87dd3..b957b24113 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -40,6 +40,7 @@ import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient; import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -177,6 +178,32 @@ public static void handleApplicationClustersCreated(String appId, List } + public static void handleApplicationClustersRemoved(String appId) { + TopologyManager.acquireWriteLock(); + + List removedClusters = new ArrayList(); + try { + Topology topology = TopologyManager.getTopology(); + for(Service service : topology.getServices()) { + for(Cluster cluster : service.getClusters()) { + if(cluster.getAppId().equals(appId)) { + removedClusters.add(service.removeCluster(cluster.getClusterId())); + } + } + } + log.info("Application Cluster " + appId + " are removed from the topology"); + + TopologyManager.updateTopology(topology); + + } finally { + TopologyManager.releaseWriteLock(); + } + + TopologyEventPublisher.sendApplicationClustersRemoved(appId, removedClusters); + + } + + public static void handleClusterReset(ClusterStatusClusterResetEvent event) { diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java index df5cf823ee..76bdb5d0e4 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyEventPublisher.java @@ -129,6 +129,15 @@ public static void sendApplicationClustersCreated(String appId, List cl publishEvent(new ApplicationClustersCreatedEvent(clusters, appId)); } + public static void sendApplicationClustersRemoved(String appId, List clusters) { + + if (log.isInfoEnabled()) { + log.info("Publishing Application Clusters removed event for Application: " + appId); + } + + //TODO publishEvent(new ApplicationClustersCreatedEvent(clusters, appId)); + } + // public static void sendApplicationRemovedEvent(String applicationId, Set clusterData, // int tenantId, String tenantDomain) { // From bcf2e2b6c515764eba4a67505fe4956d077a4950 Mon Sep 17 00:00:00 2001 From: Udara Liyanage Date: Tue, 4 Nov 2014 15:44:49 +0530 Subject: [PATCH 411/436] publish to metadata service when applicaiton is parsed --- .../org.apache.stratos.autoscaler/pom.xml | 332 +++++++++--------- .../autoscaler/api/AutoScalerServiceImpl.java | 29 +- .../parser/ApplicationParser.java | 4 + .../parser/DefaultApplicationParser.java | 79 ++++- 4 files changed, 266 insertions(+), 178 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/pom.xml b/components/org.apache.stratos.autoscaler/pom.xml index 64ad76a338..394784eacb 100644 --- a/components/org.apache.stratos.autoscaler/pom.xml +++ b/components/org.apache.stratos.autoscaler/pom.xml @@ -18,140 +18,141 @@ under the License. --> - + - - org.apache.stratos - stratos-components-parent - 4.1.0-SNAPSHOT - + + org.apache.stratos + stratos-components-parent + 4.1.0-SNAPSHOT + - 4.0.0 - org.apache.stratos.autoscaler - bundle - Apache Stratos - Autoscaler - Autoscaler components - http://apache.org + 4.0.0 + org.apache.stratos.autoscaler + bundle + Apache Stratos - Autoscaler + Autoscaler components + http://apache.org - - - org.wso2.carbon - org.wso2.carbon.registry.core - ${carbon.platform.version} - provided - + + + org.wso2.carbon + org.wso2.carbon.registry.core + ${carbon.platform.version} + provided + - - org.drools - drools-core - ${drools.version} - - - org.drools - drools-compiler - ${drools.version} - - - com.thoughtworks.xstream - xstream - 1.4.1 - + + org.drools + drools-core + ${drools.version} + + + org.drools + drools-compiler + ${drools.version} + + + com.thoughtworks.xstream + xstream + 1.4.1 + commons-configuration commons-configuration 1.9 - - org.antlr - antlr - 3.3 - - - org.drools - drools-decisiontables - ${drools.version} - - - org.antlr - antlr-runtime - 3.3 - - - org.antlr - stringtemplate - 3.2.1 - - - org.drools - drools-jsr94 - ${drools.version} - - - org.drools - knowledge-internal-api - ${drools.version} - - - org.drools - knowledge-api - ${drools.version} - - - org.mvel - mvel2 - 2.1.3.Final - - - - org.drools - drools-verifier - ${drools.version} - - - org.drools - drools-templates - ${drools.version} - - - org.eclipse.jdt.core.compiler - ecj - 3.5.1 - - - xmlpull - xmlpull - 1.1.3.1 - - - xpp3 - xpp3_min - 1.1.4c - - - com.lowagie - itext - 2.1.2 - - - jsr94 - jsr94 - 1.1 - - - org.apache.stratos - org.apache.stratos.messaging - ${project.version} - provided - + + org.antlr + antlr + 3.3 + + + org.drools + drools-decisiontables + ${drools.version} + + + org.antlr + antlr-runtime + 3.3 + + + org.antlr + stringtemplate + 3.2.1 + + + org.drools + drools-jsr94 + ${drools.version} + + + org.drools + knowledge-internal-api + ${drools.version} + + + org.drools + knowledge-api + ${drools.version} + + + org.mvel + mvel2 + 2.1.3.Final + + + + org.drools + drools-verifier + ${drools.version} + + + org.drools + drools-templates + ${drools.version} + + + org.eclipse.jdt.core.compiler + ecj + 3.5.1 + + + xmlpull + xmlpull + 1.1.3.1 + + + xpp3 + xpp3_min + 1.1.4c + + + com.lowagie + itext + 2.1.2 + + + jsr94 + jsr94 + 1.1 + + + org.apache.stratos + org.apache.stratos.messaging + ${project.version} + provided + org.apache.stratos org.apache.stratos.common @@ -170,7 +171,7 @@ ${project.version} provided - + org.apache.stratos org.apache.stratos.manager.cleanup.notification.stub ${project.version} @@ -182,37 +183,44 @@ provided 4.2.0 + + org.apache.stratos + org.apache.stratos.metadata.client + ${project.version} + - - - - - org.apache.felix - maven-scr-plugin - - - org.apache.felix - maven-bundle-plugin + - true - - - ${project.artifactId} - ${project.artifactId} + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + + true + + + ${project.artifactId} + ${project.artifactId} org.apache.stratos.autoscaler.internal.* - !org.apache.stratos.autoscaler.internal.*,org.apache.stratos.autoscaler.* - - org.osgi.framework.*;resolution:=optional, - *;resolution:=optional + !org.apache.stratos.autoscaler.internal.*,org.apache.stratos.autoscaler.* + + + org.osgi.framework.*;resolution:=optional, + *;resolution:=optional - org.apache.stratos.autoscaler.internal.ASBundleActivater - * - *;scope=compile|runtime - lib - - - + org.apache.stratos.autoscaler.internal.ASBundleActivater + * + *;scope=compile|runtime + lib + + + org.apache.axis2 axis2-java2wsdl-maven-plugin @@ -229,17 +237,17 @@ - + - - src/main/rules - - - src/main/resources - - - - + + src/main/rules + + + src/main/resources + + + + 5.5.0.Final
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 4476b1a264..62f71f1776 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -41,14 +41,20 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; +import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.messaging.domain.applications.Application; +import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient; +import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient; +import org.apache.stratos.metadata.client.exception.MetaDataServiceClientException; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Map; +import java.util.Properties; /** * Auto Scaler Service API is responsible getting Partitions and Policies. @@ -288,6 +294,7 @@ public void deployApplicationDefinition(ApplicationContext applicationContext) ApplicationParser applicationParser = new DefaultApplicationParser(); Application application = applicationParser.parse(applicationContext); + publishMetadata(applicationParser, application.getUniqueIdentifier()); ApplicationBuilder.handleApplicationCreated(application, applicationParser.getApplicationClusterContexts()); } @@ -454,4 +461,24 @@ public void undeployServiceGroup(String name) throws AutoScalerException { } } + + private void publishMetadata(ApplicationParser applicationParser, String appId) { + MetaDataServiceClient metaDataServiceClien = null; + try { + metaDataServiceClien = new DefaultMetaDataServiceClient(); + for (Map.Entry entry : applicationParser.getAliasToProperties().entrySet()) { + String alias = entry.getKey(); + Properties properties = entry.getValue(); + Enumeration e = properties.propertyNames(); + + while (e.hasMoreElements()) { + String key = (String) e.nextElement(); + String value = properties.getProperty(key); + metaDataServiceClien.addPropertyToCluster(appId, alias, key, value); + } + } + } catch (MetaDataServiceClientException e) { + log.error("Could not publish to metadata service ", e); + } + } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java index f1f59e5682..08b515ecc2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java @@ -24,6 +24,8 @@ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.messaging.domain.applications.Application; +import java.util.Map; +import java.util.Properties; import java.util.Set; /** @@ -50,4 +52,6 @@ public interface ApplicationParser { * @throws ApplicationDefinitionException if any error occurs */ public Set getApplicationClusterContexts() throws ApplicationDefinitionException; + + public Map getAliasToProperties(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index ce68f8abc9..8295e90657 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -19,15 +19,6 @@ package org.apache.stratos.autoscaler.applications.parser; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -35,11 +26,7 @@ import org.apache.stratos.autoscaler.applications.ClusterInformation; import org.apache.stratos.autoscaler.applications.MTClusterInformation; import org.apache.stratos.autoscaler.applications.STClusterInformation; -import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; -import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; -import org.apache.stratos.autoscaler.applications.pojo.GroupContext; -import org.apache.stratos.autoscaler.applications.pojo.SubscribableContext; -import org.apache.stratos.autoscaler.applications.pojo.SubscribableInfoContext; +import org.apache.stratos.autoscaler.applications.pojo.*; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.autoscaler.exception.CartridgeInformationException; @@ -51,6 +38,12 @@ import org.apache.stratos.messaging.domain.applications.DependencyOrder; import org.apache.stratos.messaging.domain.applications.Group; +import java.util.*; +import javax.crypto.Cipher; +import javax.crypto.SecretKey; +import javax.crypto.spec.SecretKeySpec; +import org.apache.commons.codec.binary.Base64; + /** * Default implementation of the Application Parser. One Application should be processed by one * instance of the DefaultApplicationParser. @@ -60,10 +53,12 @@ public class DefaultApplicationParser implements ApplicationParser { private static Log log = LogFactory.getLog(DefaultApplicationParser.class); private Set applicationClusterContexts; + private Map aliasToProperties; public DefaultApplicationParser () { - this.applicationClusterContexts = new HashSet(); + this.setAliasToProperties(new HashMap()); + } @Override @@ -302,6 +297,31 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, } } + String alias; + Properties properties = new Properties(); + for (SubscribableInfoContext value : subscribableInfoCtxts.values()) { + alias = value.getAlias(); + String username = value.getRepoUsername(); + String password = value.getRepoPassword(); + String repoUrl = value.getRepoUrl(); + + if (StringUtils.isNotEmpty(username)) { + properties.setProperty("REPO_USERNAME", username); + } + + if (StringUtils.isNotEmpty(password)) { + String encryptedPassword = encryptPassword(password, application.getKey()); + properties.setProperty("REPO_PASSWORD", encryptedPassword); + } + + if (StringUtils.isNotEmpty(repoUrl)) { + properties.setProperty("REPO_URL", repoUrl); + } + + this.addProperties(alias, properties); + } + + log.info("Application with id " + appCtxt.getApplicationId() + " parsed successfully"); return application; @@ -663,4 +683,33 @@ private void handleError (String errorMsg) throws ApplicationDefinitionException throw new ApplicationDefinitionException(errorMsg); } + public Map getAliasToProperties() { + return aliasToProperties; + } + + public void setAliasToProperties(Map aliasToProperties) { + this.aliasToProperties = aliasToProperties; + } + public void addProperties(String alias, Properties properties) { + this.getAliasToProperties().put(alias, properties); + } + + 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; + } } From cc5aaf5fb4f2e208789f4ccfc5342d0c87fbc6f6 Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 15:59:40 +0530 Subject: [PATCH 412/436] referring correct Properties in manager --- .../controller/CloudControllerClient.java | 5 +- .../behaviour/CartridgeMgtBehaviour.java | 5 +- .../client/AutoscalerServiceClient.java | 2 +- .../client/CloudControllerServiceClient.java | 3 +- .../category/DefaultLoadBalancerCategory.java | 2 +- .../ExistingLoadBalancerCategory.java | 2 +- .../manager/lb/category/LBDataContext.java | 4 +- .../ServiceLevelLoadBalancerCategory.java | 2 +- .../manager/CartridgeSubscriptionManager.java | 7 +- .../subscription/CartridgeSubscription.java | 2 +- .../DataCartridgeSubscription.java | 2 +- .../subscription/LBCartridgeSubscription.java | 3 +- .../subscription/PersistenceContext.java | 2 +- .../subscription/SubscriptionData.java | 3 +- .../filter/SubscriptionFilter.java | 2 +- .../SubscriptionMultiTenantBehaviour.java | 2 +- .../utils/ApplicationManagementUtil.java | 4 +- .../bean/util/converter/PojoConverter.java | 3 +- .../rest/endpoint/services/ServiceUtils.java | 2 +- .../pom.xml | 2 +- .../resources/CloudControllerService.wsdl | 686 +++++++++--------- 21 files changed, 367 insertions(+), 378 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 374e092efb..41c61675c1 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -31,10 +31,7 @@ import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.cloud.controller.stub.pojo.ApplicationClusterContextDTO; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.ContainerClusterContext; -import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +import org.apache.stratos.cloud.controller.stub.pojo.*; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesMaster; 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 index 9c8ce047c2..12208b9830 100644 --- 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 @@ -22,8 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; @@ -92,7 +91,7 @@ protected PayloadData createPayload (CartridgeInfo cartridgeInfo, String subscri // 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()) { + for (org.apache.stratos.cloud.controller.stub.pojo.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. 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 b3e092b820..8572494bae 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 @@ -33,7 +33,7 @@ import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; import org.apache.stratos.autoscaler.pojo.xsd.ServiceGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; import sun.reflect.generics.reflectiveObjects.NotImplementedException; 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 c2f017686b..5424530c04 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 @@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; @@ -140,7 +139,7 @@ public boolean register(String clusterId, String cartridgeType, String key = (String) iterator.next(); String value = properties.getProperty(key); - org.apache.stratos.common.xsd.Property prop = new org.apache.stratos.common.xsd.Property(); + Property prop = new Property(); prop.setName(key); prop.setValue(value); 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 index 0d45a8590b..08bd3e1b82 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +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; 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 index 0b41aea2bb..4877046321 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +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; 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 index 23998d7c37..31cb7b9a3d 100644 --- 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 @@ -21,8 +21,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.common.Properties; +import org.apache.stratos.common.Property; import java.util.ArrayList; import java.util.List; 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 index d374a06f0d..8bc3dad4e6 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +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; 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 index 99ba4c66db..9f424a553b 100644 --- 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 @@ -22,11 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; -import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.*; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.deploy.service.Service; 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 index 80cdee42fb..a5d901d959 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.*; 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 index 0b4e6019af..c6a006d99a 100644 --- 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 @@ -20,6 +20,7 @@ package org.apache.stratos.manager.subscription; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.DataCartridge; import org.apache.stratos.manager.exception.ADCException; @@ -28,7 +29,6 @@ import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour; import org.apache.stratos.manager.utils.ApplicationManagementUtil; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; import java.util.HashMap; import java.util.Map; 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 index 5c5efa090b..c69abc5df2 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.exception.*; import org.apache.stratos.manager.lb.category.LoadBalancerCategory; @@ -32,7 +32,6 @@ import org.apache.stratos.manager.subscription.tenancy.SubscriptionTenancyBehaviour; import org.apache.stratos.manager.utils.ApplicationManagementUtil; -import java.util.Set; public class LBCartridgeSubscription extends CartridgeSubscription { 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 index 7850275692..63a13a1fd2 100644 --- 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 @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Property; public class PersistenceContext { 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 index ff04ce30f7..7dd1bf5060 100644 --- 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 @@ -19,8 +19,7 @@ package org.apache.stratos.manager.subscription; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import java.util.Collections; import java.util.HashSet; 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 index 6b5a44e8a5..0fea5abf0d 100644 --- 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 @@ -19,7 +19,7 @@ package org.apache.stratos.manager.subscription.filter; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.subscription.SubscriptionData; 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 index e0783beb54..626e5a38f4 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; +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.*; 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 d004a328d3..0f1e21f67b 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 @@ -37,9 +37,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.CartridgeSubscriptionInfo; import org.apache.stratos.manager.dao.DataCartridge; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 7995916145..9ae6fcb421 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -27,8 +27,7 @@ import org.apache.stratos.autoscaler.stub.pojo.PropertiesE; import org.apache.stratos.autoscaler.stub.pojo.PropertyE; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.composite.application.beans.ApplicationDefinition; import org.apache.stratos.manager.composite.application.beans.GroupDefinition; import org.apache.stratos.manager.composite.application.beans.SubscribableDefinition; diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index c9de333e01..0a373cf56d 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -33,7 +33,7 @@ import org.apache.stratos.cloud.controller.stub.*; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeConfig; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.deploy.cartridge.CartridgeDeploymentManager; diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml index 6f61083836..1f3c44fd6d 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/pom.xml @@ -48,7 +48,7 @@ + -ns2p http://policy.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.policy,http://partition.deployment.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.deployment.partition,http://exception.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.exception,http://pojo.controller.cloud.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo,http://impl.controller.cloud.stratos.apache.org=org.apache.stratos.cloud.controller.stub.impl,http://common.stratos.apache.org/xsd=org.apache.stratos.cloud.controller.stub.pojo"/> diff --git a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl index 4e1a67c810..469e5bb301 100644 --- a/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl +++ b/service-stubs/org.apache.stratos.cloud.controller.service.stub/src/main/resources/CloudControllerService.wsdl @@ -1,10 +1,10 @@ - + CloudControllerService - + @@ -15,12 +15,12 @@ - + - + @@ -30,22 +30,22 @@ - + - + - + - + @@ -55,12 +55,12 @@ - + - + @@ -71,106 +71,107 @@ - - + - + + - + - + - + - + - + - + - + - + - + + - + - + - + - + - + - + + - + - + - + - + - + - - + - + - + - + - + - + - + @@ -181,280 +182,294 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - - - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + - + - + - + - + - + + - + + - + - - - - - - - + + + + + + + + + + + + + - - - - - + + + + + + + + + - - - - - + + + + + + + + + @@ -469,77 +484,67 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + - - - + + + - - - - - - - - + - - - - - + - - - - - - - - - - - - - - - - - - + - - - - - - @@ -547,69 +552,63 @@ - + - + + + + - + - - - + + + - - - - - - - + - - - - - - - - - - - - - + + + - + - - + + + + + - + + + + + - + - - + - + - - + + + @@ -620,22 +619,23 @@ - + - + + + + - - - - - - - - - + + + + + + + @@ -913,6 +913,15 @@ + + + + + + + + + @@ -925,15 +934,6 @@ - - - - - - - - - @@ -973,6 +973,18 @@ + + + + + + + + + + + + @@ -997,20 +1009,8 @@ - - - - - - - - - - - - - - + + @@ -1021,8 +1021,8 @@ - - + + @@ -1033,31 +1033,31 @@ - - + + - - + + + + + - - + + - - - - - + + @@ -1159,26 +1159,26 @@ - - + + - - - - - + + + + + @@ -1192,6 +1192,15 @@ + + + + + + + + + @@ -1204,15 +1213,6 @@ - - - - - - - - - @@ -1252,6 +1252,18 @@ + + + + + + + + + + + + @@ -1276,20 +1288,8 @@ - - - - - - - - - - - - - - + + @@ -1300,8 +1300,8 @@ - - + + @@ -1312,31 +1312,31 @@ - - + + - - + + + + + - - + + - - - - - + + @@ -1438,26 +1438,26 @@ - - + + - - - - - + + + + + @@ -1471,6 +1471,12 @@ + + + + + + @@ -1480,12 +1486,6 @@ - - - - - - @@ -1513,6 +1513,12 @@ + + + + + + @@ -1531,14 +1537,8 @@ - - - - - - - - + + @@ -1546,8 +1546,8 @@ - - + + @@ -1555,8 +1555,8 @@ - - + + @@ -1564,8 +1564,8 @@ - - + + @@ -1645,8 +1645,8 @@ - - + + @@ -1654,8 +1654,8 @@ - - + + @@ -1672,22 +1672,22 @@ - + - + - + - + - + - + \ No newline at end of file From 2fd38c34e5347b70f0fd283cb8e4639305684aab Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 16:37:12 +0530 Subject: [PATCH 413/436] removing incorrect reference to Properties object --- .../stratos/autoscaler/applications/ApplicationUtils.java | 2 +- .../org/apache/stratos/manager/deploy/service/Service.java | 2 +- .../manager/deploy/service/ServiceDeploymentManager.java | 4 ++-- .../deploy/service/multitenant/lb/DefaultLBService.java | 2 +- .../deploy/service/multitenant/lb/ExistingLBService.java | 2 +- .../manager/deploy/service/multitenant/lb/LBService.java | 2 +- .../deploy/service/multitenant/lb/MultiTenantLBService.java | 2 +- .../deploy/service/multitenant/lb/ServiceAwareLBService.java | 2 +- .../org/apache/stratos/manager/lb/category/LBDataContext.java | 4 ++-- .../subscription/filter/LBCreationSubscriptionFilter.java | 4 ++-- .../subscription/utils/CartridgeSubscriptionUtils.java | 2 -- 11 files changed, 13 insertions(+), 15 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java index 3479f2f6ae..e82882c6ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.PortMapping; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import java.util.*; import java.util.regex.Pattern; 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 index 68dbdcc90d..72176c3974 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.behaviour.CartridgeMgtBehaviour; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; 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 index 7337ed29af..c5921b646d 100644 --- 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 @@ -24,8 +24,8 @@ import org.apache.stratos.cloud.controller.stub.CloudControllerServiceUnregisteredCartridgeExceptionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; 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; 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 index 41aa92ff28..982535a3da 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index d81e7ed8dd..4a67d8b699 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.dao.Cluster; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; 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 index 1cf172b575..1214c0e970 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; 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 index ddb255024e..c22c545328 100644 --- 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 @@ -20,7 +20,7 @@ package org.apache.stratos.manager.deploy.service.multitenant.lb; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.deploy.service.Service; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.UnregisteredCartridgeException; 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 index b50aadacab..4f4cae7ff8 100644 --- 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 @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; -import org.apache.stratos.common.xsd.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 31cb7b9a3d..5b8f827952 100644 --- 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 @@ -21,8 +21,8 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import java.util.ArrayList; import java.util.List; 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 index 8a45c685e4..6057243329 100644 --- 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 @@ -25,8 +25,8 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.LoadbalancerConfig; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.manager.exception.ADCException; import org.apache.stratos.manager.exception.AlreadySubscribedException; import org.apache.stratos.manager.exception.DuplicateCartridgeAliasException; 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 index 0f897c2949..6a45995320 100644 --- 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 @@ -25,8 +25,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; import org.apache.stratos.cloud.controller.stub.pojo.*; -import org.apache.stratos.common.xsd.Properties; -import org.apache.stratos.common.xsd.Property; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; From 69bfb270681659963df1658edad1b1f32b61c4c7 Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 16:41:25 +0530 Subject: [PATCH 414/436] Updating properties class references --- .../autoscaler/api/AutoScalerServiceImpl.java | 13 ++++--------- .../applications/ApplicationUtils.java | 2 +- .../applications/parser/ApplicationParser.java | 2 +- .../parser/DefaultApplicationParser.java | 17 ++++++++++++++--- .../applications/pojo/ApplicationContext.java | 2 +- .../cloud/controller/CloudControllerClient.java | 4 ++-- .../interfaces/AutoScalerServiceInterface.java | 2 +- .../monitor/cluster/AbstractClusterMonitor.java | 2 +- .../monitor/cluster/ClusterMonitorFactory.java | 6 +++--- .../KubernetesServiceClusterMonitor.java | 4 ++-- .../monitor/cluster/VMClusterMonitor.java | 2 +- .../cluster/VMServiceClusterMonitor.java | 4 ++-- .../stratos/autoscaler/util/AutoscalerUtil.java | 4 ++-- 13 files changed, 35 insertions(+), 29 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index 9fedf608c7..ed10b50023 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -41,11 +41,11 @@ import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; -import org.apache.stratos.common.xsd.Properties; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.metadata.client.defaults.DefaultMetaDataServiceClient; import org.apache.stratos.metadata.client.defaults.MetaDataServiceClient; @@ -55,7 +55,6 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Map; -import java.util.Properties; /** * Auto Scaler Service API is responsible getting Partitions and Policies. @@ -470,12 +469,8 @@ private void publishMetadata(ApplicationParser applicationParser, String appId) for (Map.Entry entry : applicationParser.getAliasToProperties().entrySet()) { String alias = entry.getKey(); Properties properties = entry.getValue(); - Enumeration e = properties.propertyNames(); - - while (e.hasMoreElements()) { - String key = (String) e.nextElement(); - String value = properties.getProperty(key); - metaDataServiceClien.addPropertyToCluster(appId, alias, key, value); + for(Property property : properties.getProperties()) { + metaDataServiceClien.addPropertyToCluster(appId, alias, property.getName(), property.getValue()); } } } catch (MetaDataServiceClientException e) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java index 3479f2f6ae..e82882c6ca 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/ApplicationUtils.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.PortMapping; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import java.util.*; import java.util.regex.Pattern; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java index 08b515ecc2..3bf8bb17f7 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/ApplicationParser.java @@ -22,10 +22,10 @@ import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.applications.Application; import java.util.Map; -import java.util.Properties; import java.util.Set; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java index 8295e90657..7c73d58d73 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/parser/DefaultApplicationParser.java @@ -33,10 +33,12 @@ import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.registry.RegistryManager; import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; import org.apache.stratos.messaging.domain.applications.DependencyOrder; import org.apache.stratos.messaging.domain.applications.Group; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import java.util.*; import javax.crypto.Cipher; @@ -306,16 +308,25 @@ private Application buildCompositeAppStructure (ApplicationContext appCtxt, String repoUrl = value.getRepoUrl(); if (StringUtils.isNotEmpty(username)) { - properties.setProperty("REPO_USERNAME", username); + Property property = new Property(); + property.setName("REPO_USERNAME"); + property.setValue(username); + properties.addProperties(property); } if (StringUtils.isNotEmpty(password)) { String encryptedPassword = encryptPassword(password, application.getKey()); - properties.setProperty("REPO_PASSWORD", encryptedPassword); + Property property = new Property(); + property.setName("REPO_PASSWORD"); + property.setValue(encryptedPassword); + properties.addProperties(property); } if (StringUtils.isNotEmpty(repoUrl)) { - properties.setProperty("REPO_URL", repoUrl); + Property property = new Property(); + property.setName("REPO_URL"); + property.setValue(repoUrl); + properties.addProperties(property); } this.addProperties(alias, properties); diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java index 5916a6ef5d..487afd2ec8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/pojo/ApplicationContext.java @@ -19,7 +19,7 @@ package org.apache.stratos.autoscaler.applications.pojo; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import java.io.Serializable; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 41c61675c1..560a7a5695 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -35,8 +35,8 @@ import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesMaster; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import java.rmi.RemoteException; import java.util.ArrayList; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 554a818043..0b2bf43e4b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -32,7 +32,7 @@ import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.common.kubernetes.KubernetesGroup; import org.apache.stratos.common.kubernetes.KubernetesHost; import org.apache.stratos.common.kubernetes.KubernetesMaster; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index 14f02dd48a..fa9736e372 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -31,7 +31,7 @@ import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.monitor.events.MonitorTerminateAllEvent; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index 3a164f32af..c049323e15 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -40,8 +40,8 @@ import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; import org.apache.stratos.common.constants.StratosConstants; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.ClusterStatus; import org.apache.stratos.messaging.domain.topology.Member; @@ -212,7 +212,7 @@ private static Properties convertMemberPropsToMemberContextProps( Property property = new Property(); property.setName((String) e.getKey()); property.setValue((String) e.getValue()); - props.addProperty(property); + props.addProperties(property); } return props; } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java index d6dc3a37f3..1f17daab90 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/KubernetesServiceClusterMonitor.java @@ -29,8 +29,8 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 5931b881cc..19d3704c30 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -33,7 +33,7 @@ import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index 2b0e4fdcbf..cc351de2f6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -35,8 +35,8 @@ import org.apache.stratos.autoscaler.util.AutoScalerConstants; import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.GroupStatus; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java index c0ac1787e0..0efd346ab2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/util/AutoscalerUtil.java @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.registry.RegistryManager; -import org.apache.stratos.common.Properties; -import org.apache.stratos.common.Property; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Property; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; From 77d1a7cbf5c9263a8a0de13b043e617241ec54da Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 16:45:31 +0530 Subject: [PATCH 415/436] Removing unused deployer tests --- .../policy/DeploymentPolicyDeployerTest.java | 52 --------------- .../policy/PartitionDeployerTest.java | 65 ------------------- 2 files changed, 117 deletions(-) delete mode 100644 components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java delete mode 100644 components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.java deleted file mode 100644 index fd341c0fa5..0000000000 --- a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicyDeployerTest.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.autoscaler.deployment.policy; -// -//import static org.junit.Assert.*; -// -//import java.io.File; -// -//import org.apache.stratos.autoscaler.exception.InvalidPolicyException; -//import org.apache.stratos.autoscaler.policy.deployers.DeploymentPolicyReader; -//import org.junit.Before; -//import org.junit.Test; -// -///** -// * @author nirmal -// * -// */ -//public class DeploymentPolicyDeployerTest { -// -// DeploymentPolicyReader reader; -// -// /** -// * @throws java.lang.Exception -// */ -// @Before -// public void setUp() throws Exception { -// reader = new DeploymentPolicyReader(new File("src/test/resources/deployment-policy.xml")); -// } -// -// @Test -// public void test() throws InvalidPolicyException { -// -// DeploymentPolicy policy = reader.read(); -// } -// -//} diff --git a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java b/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java deleted file mode 100644 index a796c1f6b2..0000000000 --- a/components/org.apache.stratos.autoscaler/src/test/java/org/apache/stratos/autoscaler/deployment/policy/PartitionDeployerTest.java +++ /dev/null @@ -1,65 +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.autoscaler.deployment.policy; - -import static org.junit.Assert.*; - -import java.io.File; - -import org.apache.stratos.autoscaler.exception.InvalidPolicyException; -import org.apache.stratos.autoscaler.partition.deployers.PartitionReader; -import org.apache.stratos.cloud.controller.stub.deployment.partition.*; -import org.junit.Before; -import org.junit.Test; - -/** - * @author nirmal - * - */ -public class PartitionDeployerTest { - - PartitionReader reader, reader1; - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception { - reader = new PartitionReader(new File("src/test/resources/partitions.xml")); - reader1 = new PartitionReader(new File("src/test/resources/partition.xml")); - } - - @Test - public void testPartitionCount() throws InvalidPolicyException { - - assertEquals(2, reader.getPartitionList().size()); - } - - @Test - public void testPartition() throws InvalidPolicyException { - - assertEquals(1, reader1.getPartitionList().size()); - - Partition p = reader1.getPartitionList().get(0); - assertEquals("P1", p.getId()); - assertEquals(3, p.getPartitionMax()); - assertEquals(2, p.getProperties().getProperties().length); - } - -} From 15056d53d4f9028e3c6845d2753ac46f0ecde3eb Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 16:50:21 +0530 Subject: [PATCH 416/436] handling member fault case in the member termination and removnig un-used code --- .../status/checker/StatusChecker.java | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index ea73f044ab..d46be5849f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -102,7 +102,8 @@ public void run() { ApplicationHolder.acquireReadLock(); Application application = ApplicationHolder.getApplications().getApplication(appId); - + //if all members removed from the cluster and cluster is in terminating, + // either it has to be terminated or Reset if (!clusterMonitorHasMembers && cluster.getStatus() == ClusterStatus.Terminating) { if (application.getStatus() == ApplicationStatus.Terminating) { ClusterStatusEventPublisher.sendClusterTerminatedEvent(appId, monitor.getServiceId(), @@ -113,16 +114,14 @@ public void run() { } } else { - log.info("Cluster has non terminated [members] and in the [status] " - + cluster.getStatus().toString()); - - /*if(!clusterActive && !(cluster.getStatus() == ClusterStatus.Inactive || - cluster.getStatus() == ClusterStatus.Terminating)) { - cluster.getStatus() - StatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(), - monitor.getServiceId(), clusterId); - - }*/ + //if the cluster is not active and, if it is in Active state + if (!clusterActive && cluster.getStatus() == ClusterStatus.Active) { + ClusterStatusEventPublisher.sendClusterInActivateEvent(monitor.getAppId(), + monitor.getServiceId(), clusterId); + } else { + log.info("Cluster has non terminated [members] and in the [status] " + + cluster.getStatus().toString()); + } } } finally { ApplicationHolder.releaseReadLock(); @@ -285,8 +284,6 @@ private boolean updateChildStatus(String appId, String id, Map gr log.info("cluster found: " + clusterFound); if (clusterFound || groups.containsKey(id)) { childFound = true; - clusterStatus = getClusterStatus(clusterData); - groupStatus = getGroupStatus(groups); try { ApplicationHolder.acquireReadLock(); Application application = ApplicationHolder.getApplications().getApplication(appId); @@ -425,7 +422,7 @@ private boolean getAllClusterInSameState(Map clusterD return clusterStat; } - private GroupStatus getGroupStatus(Map groups) { + /*private GroupStatus getGroupStatus(Map groups) { GroupStatus status = null; boolean groupActive = true; boolean groupTerminated = true; @@ -513,7 +510,7 @@ private ClusterStatus getClusterStatus(Map clusterDat status = ClusterStatus.Created; } return status; - } + }*/ private static class Holder { private static final StatusChecker INSTANCE = new StatusChecker(); From c857d0813cc43b54114ea3152ae79ea466f4ff66 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 16:50:53 +0530 Subject: [PATCH 417/436] removing cluster context in CC upon App terminated event --- .../stratos/cloud/controller/topology/TopologyBuilder.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java index b957b24113..4d953978c3 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/topology/TopologyBuilder.java @@ -188,6 +188,8 @@ public static void handleApplicationClustersRemoved(String appId) { for(Cluster cluster : service.getClusters()) { if(cluster.getAppId().equals(appId)) { removedClusters.add(service.removeCluster(cluster.getClusterId())); + FasterLookUpDataHolder.getInstance(). + removeClusterContext(cluster.getClusterId()); } } } From 2a6606f7fce63fad22bd6a69c5f5b9dee8efd96f Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 16:54:31 +0530 Subject: [PATCH 418/436] removing more incorrect Property object references --- .../apache/stratos/manager/client/AutoscalerServiceClient.java | 2 +- .../manager/lb/category/DefaultLoadBalancerCategory.java | 2 +- .../manager/lb/category/ServiceLevelLoadBalancerCategory.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 8572494bae..29225b6694 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 @@ -22,6 +22,7 @@ import org.apache.axis2.AxisFault; import org.apache.axis2.context.ConfigurationContext; import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.lang.NotImplementedException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.stub.*; @@ -36,7 +37,6 @@ import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.utils.CartridgeConstants; -import sun.reflect.generics.reflectiveObjects.NotImplementedException; import java.rmi.RemoteException; 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 index 08bd3e1b82..75f68566be 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; 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 index 8bc3dad4e6..b69ef6ab52 100644 --- 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 @@ -24,7 +24,7 @@ import org.apache.stratos.cloud.controller.stub.pojo.CartridgeInfo; import org.apache.stratos.cloud.controller.stub.pojo.ClusterContext; import org.apache.stratos.cloud.controller.stub.pojo.Persistence; -import org.apache.stratos.common.Properties; +import org.apache.stratos.cloud.controller.stub.pojo.Properties; import org.apache.stratos.manager.client.AutoscalerServiceClient; import org.apache.stratos.manager.client.CloudControllerServiceClient; import org.apache.stratos.manager.dao.Cluster; From c8dc8cc8cc9297c26867a0c05a6a0c7a0e9833ae Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 16:58:06 +0530 Subject: [PATCH 419/436] Removing not implemented exceptions --- .../client/AutoscalerServiceClient.java | 6 +-- .../bean/util/converter/PojoConverter.java | 40 +++++++++---------- .../rest/endpoint/services/ServiceUtils.java | 20 +++++----- 3 files changed, 30 insertions(+), 36 deletions(-) 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 8572494bae..2e87cbf273 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 @@ -300,10 +300,6 @@ public boolean updateKubernetesHost(KubernetesHost kubernetesHost) } public void updateClusterMonitor(String clusterId, Properties properties) throws RemoteException, AutoScalerServiceInvalidArgumentExceptionException { - //TODO: To be fixed - throw new NotImplementedException(); - //stub.updateClusterMonitor(clusterId, properties); + stub.updateClusterMonitor(clusterId, properties); } - - } diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java index 9ae6fcb421..a1fa9c6f64 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/bean/util/converter/PojoConverter.java @@ -242,27 +242,25 @@ public static Properties getProperties(List propertyBeans) { public static PropertiesE getASProperties(List propertyBeans) { - //TODO: To be fixed - throw new NotImplementedException(); -// if (propertyBeans == null || propertyBeans.isEmpty()) { -// return null; -// } -// -// //convert to an array -// PropertyBean[] propertyBeansArray = new PropertyBean[propertyBeans.size()]; -// propertyBeans.toArray(propertyBeansArray); -// PropertyE[] propertyArray = new PropertyE[propertyBeansArray.length]; -// -// for (int j = 0; j < propertyBeansArray.length; j++) { -// PropertyE property = new PropertyE(); -// property.setName(propertyBeansArray[j].name); -// property.setValue(propertyBeansArray[j].value); -// propertyArray[j] = property; -// } -// -// PropertiesE properties = new PropertiesE(); -// properties.setProperties(propertyArray); -// return properties; + if (propertyBeans == null || propertyBeans.isEmpty()) { + return null; + } + + //convert to an array + PropertyBean[] propertyBeansArray = new PropertyBean[propertyBeans.size()]; + propertyBeans.toArray(propertyBeansArray); + PropertyE[] propertyArray = new PropertyE[propertyBeansArray.length]; + + for (int j = 0; j < propertyBeansArray.length; j++) { + PropertyE property = new PropertyE(); + property.setName(propertyBeansArray[j].name); + property.setValue(propertyBeansArray[j].value); + propertyArray[j] = property; + } + + PropertiesE properties = new PropertiesE(); + properties.setProperties(propertyArray); + return properties; } private static NetworkInterfaces getNetworkInterfaces(List networkInterfaceBeans) { diff --git a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java index 0a373cf56d..4c75e6b73c 100644 --- a/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java +++ b/components/org.apache.stratos.rest.endpoint/src/main/java/org/apache/stratos/rest/endpoint/services/ServiceUtils.java @@ -26,6 +26,8 @@ import org.apache.stratos.autoscaler.applications.pojo.xsd.ApplicationContext; import org.apache.stratos.autoscaler.stub.*; import org.apache.stratos.autoscaler.stub.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.stub.pojo.PropertiesE; +import org.apache.stratos.autoscaler.stub.pojo.PropertyE; import org.apache.stratos.cloud.controller.stub.CloudControllerServiceInvalidCartridgeTypeExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceApplicationDefinitionExceptionException; import org.apache.stratos.autoscaler.stub.AutoScalerServiceInvalidPartitionExceptionException; @@ -144,16 +146,14 @@ static void deployApplicationDefinition (ApplicationDefinition appDefinition, Co applicationContext.setTeantAdminUsername(userName); if(appDefinition.getProperty() != null) { - //TODO: To be fixed - throw new NotImplementedException(); -// PropertiesE properties = new PropertiesE(); -// for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { -// PropertyE property = new PropertyE(); -// property.setName(propertyBean.getName()); -// property.setValue(propertyBean.getValue()); -// properties.addProperties(property); -// } -// applicationContext.setProperties(properties); + PropertiesE properties = new PropertiesE(); + for (org.apache.stratos.manager.composite.application.beans.PropertyBean propertyBean : appDefinition.getProperty()) { + PropertyE property = new PropertyE(); + property.setName(propertyBean.getName()); + property.setValue(propertyBean.getValue()); + properties.addProperties(property); + } + applicationContext.setProperties(properties); } try { From 1b385349f030df9f466eea297636272cb8ecfdf2 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 16:58:58 +0530 Subject: [PATCH 420/436] cleaning AutoscalerTopologyEventReceiver --- .../AutoscalerTopologyEventReceiver.java | 105 +++++++++++------- 1 file changed, 64 insertions(+), 41 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java index df5b6a2eae..de07b17c92 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -196,14 +196,18 @@ protected void onEvent(Event event) { ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; String clusterId = clusterActivatedEvent.getClusterId(); - AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getClusterMonitor(clusterId); - - //changing the status in the monitor, will notify its parent monitor - if (clusterMonitor != null) { - clusterMonitor.setStatus(ClusterStatus.Active); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; } - + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(ClusterStatus.Active); } }); @@ -215,12 +219,20 @@ protected void onEvent(Event event) { ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; String clusterId = clusterCreatedEvent.getCluster().getClusterId(); - AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getClusterMonitor(clusterId); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } //changing the status in the monitor, will notify its parent monitor - clusterMonitor.setStop(true); - clusterMonitor.setStatus(ClusterStatus.Created); + monitor.setStop(true); + monitor.setStatus(ClusterStatus.Created); } }); @@ -239,14 +251,18 @@ protected void onEvent(Event event) { ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; String clusterId = clusterInactivateEvent.getClusterId(); - AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getClusterMonitor(clusterId); - - //changing the status in the monitor, will notify its parent monitor - if (clusterMonitor != null) { - clusterMonitor.setStatus(ClusterStatus.Inactive); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; } - + //changing the status in the monitor, will notify its parent monitor + monitor.setStatus(ClusterStatus.Inactive); } }); @@ -258,22 +274,24 @@ protected void onEvent(Event event) { ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; String clusterId = clusterTerminatingEvent.getClusterId(); - AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getClusterMonitor(clusterId); - - //changing the status in the monitor, will notify its parent monitor - if (clusterMonitor != null) { - if (clusterMonitor.getStatus() == ClusterStatus.Active) { - // terminated gracefully - clusterMonitor.setStatus(ClusterStatus.Terminating); - InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId); - } else { - clusterMonitor.setStatus(ClusterStatus.Terminating); - clusterMonitor.terminateAllMembers(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); } - + return; + } + //changing the status in the monitor, will notify its parent monitor + if (monitor.getStatus() == ClusterStatus.Active) { + // terminated gracefully + monitor.setStatus(ClusterStatus.Terminating); + InstanceNotificationPublisher.sendInstanceCleanupEventForCluster(clusterId); } else { - log.warn("No Cluster Monitor found for cluster id " + clusterId); + monitor.setStatus(ClusterStatus.Terminating); + monitor.terminateAllMembers(); } } }); @@ -285,17 +303,22 @@ protected void onEvent(Event event) { ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; String clusterId = clusterTerminatedEvent.getClusterId(); - AbstractClusterMonitor clusterMonitor = - AutoscalerContext.getInstance().getClusterMonitor(clusterId); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } //changing the status in the monitor, will notify its parent monitor - if (clusterMonitor != null) { - clusterMonitor.setStatus(ClusterStatus.Terminated); - //Destroying and Removing the Cluster monitor - clusterMonitor.destroy(); - AutoscalerContext.getInstance().removeClusterMonitor(clusterId); - - } + monitor.setStatus(ClusterStatus.Terminated); + //Destroying and Removing the Cluster monitor + monitor.destroy(); + AutoscalerContext.getInstance().removeClusterMonitor(clusterId); } }); From 91624f9f1e8cbe6ab131db49d7862196786d3592 Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 17:01:53 +0530 Subject: [PATCH 421/436] adding comments --- .../status/checker/StatusChecker.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index d46be5849f..d30aa9535f 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -83,6 +83,13 @@ public void run() { groupThread.start(); } + /** + * This will calculate the status of the cluster upon a member termination. + * The possible states which cluster can change upon member termination are + * Active --> InActive, Terminating-->Terminated, Terminating-->Reset(Created) + * + * @param clusterId id of the cluster + */ public void onMemberTermination(final String clusterId) { Runnable group = new Runnable() { public void run() { @@ -141,6 +148,12 @@ public void run() { } + /** + * Calculate whether the cluster is active based on the minimum count available in each partition + * + * @param monitor Cluster monitor which has the member + * @return whether cluster is active or not + */ private boolean clusterActive(VMClusterMonitor monitor) { boolean clusterActive = false; for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { @@ -152,8 +165,7 @@ private boolean clusterActive(VMClusterMonitor monitor) { log.info("cluster already activated..."); clusterActive = true; } else { - clusterActive = false; - return clusterActive; + return false; } } } @@ -175,7 +187,9 @@ private boolean clusterMonitorHasMembers(VMClusterMonitor monitor) { } /** - * @param clusterId + * This will calculate the status of the cluster upon a member fault event + * + * @param clusterId id of the cluster * @param partitionId is to decide in which partition has less members while others have active members */ public void onMemberFaultEvent(final String clusterId, final String partitionId) { @@ -271,9 +285,7 @@ public void run() { */ private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { - ClusterStatus clusterStatus; - GroupStatus groupStatus; - boolean childFound = false; + boolean childFound; boolean clusterFound = false; for (ClusterDataHolder clusterDataHolder : clusterData.values()) { From 523b490097ac39db367307aa1544f14c2979874b Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 17:03:42 +0530 Subject: [PATCH 422/436] initializing the variable --- .../apache/stratos/autoscaler/status/checker/StatusChecker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index d30aa9535f..250cab3b98 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -285,7 +285,7 @@ public void run() { */ private boolean updateChildStatus(String appId, String id, Map groups, Map clusterData, ParentComponent parent) { - boolean childFound; + boolean childFound = false; boolean clusterFound = false; for (ClusterDataHolder clusterDataHolder : clusterData.values()) { From 226403ecd7e63ed0b9f81c68288ca1a7c8a1c935 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Tue, 4 Nov 2014 17:24:18 +0530 Subject: [PATCH 423/436] Fxing a typo --- .../autoscaler/deployment/policy/DeploymentPolicy.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java index 2fec9acd5c..6c5e0dc4f9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java @@ -135,14 +135,14 @@ public void setPartitionGroups(PartitionGroup[] partitionGroups) { } public Partition[] getAllPartitions() { - ArrayList partitionslist = new ArrayList(); + ArrayList partitionsList = new ArrayList(); for (PartitionGroup partitionGroup : this.getPartitionGroups()) { Partition[] partitions = partitionGroup.getPartitions(); if(partitions != null) { - partitionslist.addAll(Arrays.asList(partitions)); + partitionsList.addAll(Arrays.asList(partitions)); } } - return partitionslist.toArray(new Partition[0]); + return partitionsList.toArray(new Partition[partitionsList.size()]); } public Partition getPartitionById(String id){ From 390efc747a411e4344144c368a5e996037abecdf Mon Sep 17 00:00:00 2001 From: Imesh Gunaratne Date: Tue, 4 Nov 2014 17:29:05 +0530 Subject: [PATCH 424/436] Fixing null check in AutoScalerServiceImpl.publishMetadata() method --- .../stratos/autoscaler/api/AutoScalerServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index ed10b50023..a3f7903911 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -469,8 +469,10 @@ private void publishMetadata(ApplicationParser applicationParser, String appId) for (Map.Entry entry : applicationParser.getAliasToProperties().entrySet()) { String alias = entry.getKey(); Properties properties = entry.getValue(); - for(Property property : properties.getProperties()) { - metaDataServiceClien.addPropertyToCluster(appId, alias, property.getName(), property.getValue()); + if(properties != null) { + for (Property property : properties.getProperties()) { + metaDataServiceClien.addPropertyToCluster(appId, alias, property.getName(), property.getValue()); + } } } } catch (MetaDataServiceClientException e) { From 5d9905fa72d9543cf0a65b6b100395ace257386e Mon Sep 17 00:00:00 2001 From: Isuru Haththotuwa Date: Tue, 4 Nov 2014 17:44:05 +0530 Subject: [PATCH 425/436] fixing a merge issue in ApplicationBuilder --- .../autoscaler/applications/topic/ApplicationBuilder.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java index d5fc50ce44..3571ad5643 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java @@ -63,12 +63,10 @@ public static synchronized void handleApplicationCreated(Application application ApplicationHolder.acquireWriteLock(); try { Applications applications = ApplicationHolder.getApplications(); - if (applications.getApplication(application.getUniqueIdentifier()) != null) { + if (applications.getApplication(application.getUniqueIdentifier()) == null) { CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), appClusterContexts); ApplicationHolder.persistApplication(application); - CloudControllerClient.getInstance().createApplicationClusters(application.getUniqueIdentifier(), - appClusterContexts); } else { log.warn("Application [ " + application.getUniqueIdentifier() + " ] already exists in Applications"); } From e39ba22d9f187bd8520e146569679d24a72a5cff Mon Sep 17 00:00:00 2001 From: reka Date: Tue, 4 Nov 2014 17:52:34 +0530 Subject: [PATCH 426/436] exposing the correct package of stub --- .../org.apache.stratos.autoscaler.service.stub/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml index 9f0bebe201..90c967b667 100644 --- a/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml +++ b/service-stubs/org.apache.stratos.autoscaler.service.stub/pom.xml @@ -93,8 +93,8 @@ org.apache.stratos.autoscaler.stub.*; version=${project.version}, org.apache.stratos.autoscaler.stub.pojo.*; version=${project.version}, org.apache.stratos.autoscaler.applications.pojo.xsd.*; version=${project.version}, - org.apache.stratos.autoscaler.deployment.policy.*; version=${project.version}, - org.apache.stratos.autoscaler.policy.model.*; version=${project.version}, + org.apache.stratos.autoscaler.stub.deployment.policy.*; version=${project.version}, + org.apache.stratos.autoscaler.stub.policy.model.*; version=${project.version}, org.apache.stratos.autoscaler.exception.*; version=${project.version}, org.apache.stratos.autoscaler.partition.*; version=${project.version}, org.apache.stratos.autoscaler.api.*; version=${project.version}, From ed5feced6a6d8806cec8506fa1fdb424761221e9 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Tue, 4 Nov 2014 18:01:51 +0530 Subject: [PATCH 427/436] restructure event related classes --- .../publisher}/ClusterStatusEventPublisher.java | 2 +- .../publisher}/InstanceNotificationPublisher.java | 2 +- .../receiver/health/AutoscalerHealthStatEventReceiver.java | 3 ++- .../receiver/topology/AutoscalerTopologyEventReceiver.java | 4 ++-- .../autoscaler/internal/AutoscalerServerComponent.java | 4 ++-- .../stratos/autoscaler/monitor/ParentComponentMonitor.java | 2 +- .../autoscaler/monitor/cluster/VMServiceClusterMonitor.java | 2 +- .../stratos/autoscaler/status/checker/StatusChecker.java | 2 +- 8 files changed, 11 insertions(+), 10 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping/topic => event/publisher}/ClusterStatusEventPublisher.java (99%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{grouping/topic => event/publisher}/InstanceNotificationPublisher.java (97%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{message => event}/receiver/health/AutoscalerHealthStatEventReceiver.java (99%) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{message => event}/receiver/topology/AutoscalerTopologyEventReceiver.java (99%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/ClusterStatusEventPublisher.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/ClusterStatusEventPublisher.java index 631a999fd5..22d6eb9a53 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/ClusterStatusEventPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/ClusterStatusEventPublisher.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.grouping.topic; +package org.apache.stratos.autoscaler.event.publisher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/InstanceNotificationPublisher.java similarity index 97% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/InstanceNotificationPublisher.java index 80fa295b99..19c5e17e42 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/grouping/topic/InstanceNotificationPublisher.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/publisher/InstanceNotificationPublisher.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.grouping.topic; +package org.apache.stratos.autoscaler.event.publisher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java index a5c6577547..718cc160fd 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -16,7 +16,8 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.stratos.autoscaler.message.receiver.health; +package org.apache.stratos.autoscaler.event.receiver.health; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java similarity index 99% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java index de07b17c92..f01f8f9767 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/message/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.message.receiver.topology; +package org.apache.stratos.autoscaler.event.receiver.topology; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -26,7 +26,7 @@ import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.grouping.topic.InstanceNotificationPublisher; +import org.apache.stratos.autoscaler.event.publisher.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java index 203d6e0794..3da60ab124 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java @@ -25,8 +25,8 @@ import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.kubernetes.KubernetesManager; -import org.apache.stratos.autoscaler.message.receiver.health.AutoscalerHealthStatEventReceiver; -import org.apache.stratos.autoscaler.message.receiver.topology.AutoscalerTopologyEventReceiver; +import org.apache.stratos.autoscaler.event.receiver.health.AutoscalerHealthStatEventReceiver; +import org.apache.stratos.autoscaler.event.receiver.topology.AutoscalerTopologyEventReceiver; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java index bd36091af0..e7cfdb2d9a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/ParentComponentMonitor.java @@ -28,7 +28,7 @@ import org.apache.stratos.autoscaler.applications.dependency.DependencyTree; import org.apache.stratos.autoscaler.applications.dependency.context.ApplicationContext; import org.apache.stratos.autoscaler.applications.topic.ApplicationsEventPublisher; -import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; +import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.status.checker.StatusChecker; import org.apache.stratos.messaging.domain.applications.ParentComponent; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index cc351de2f6..a6ed9aa77b 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -28,7 +28,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; -import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; +import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java index 250cab3b98..195f53d7c5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/checker/StatusChecker.java @@ -25,7 +25,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; -import org.apache.stratos.autoscaler.grouping.topic.ClusterStatusEventPublisher; +import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.messaging.domain.applications.*; import org.apache.stratos.messaging.domain.topology.Cluster; From 2a4fec3a3b616c9f5f4c5018f832ff027e6e69c5 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Tue, 4 Nov 2014 18:28:15 +0530 Subject: [PATCH 428/436] Moving deployment policy to policy package --- .../apache/stratos/autoscaler/algorithm/OneAfterAnother.java | 2 +- .../apache/stratos/autoscaler/api/AutoScalerServiceImpl.java | 2 +- .../client/cloud/controller/CloudControllerClient.java | 2 +- .../stratos/autoscaler/commands/DeploymentPolicyCommands.java | 2 +- .../autoscaler/interfaces/AutoScalerServiceInterface.java | 2 +- .../stratos/autoscaler/internal/AutoscalerServerComponent.java | 2 +- .../autoscaler/monitor/cluster/ClusterMonitorFactory.java | 2 +- .../stratos/autoscaler/monitor/cluster/VMClusterMonitor.java | 2 +- .../stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java | 2 +- .../autoscaler/monitor/cluster/VMServiceClusterMonitor.java | 2 +- .../apache/stratos/autoscaler/partition/PartitionManager.java | 2 +- .../org/apache/stratos/autoscaler/policy/PolicyManager.java | 2 +- .../{deployment/policy => policy/model}/DeploymentPolicy.java | 2 +- .../org/apache/stratos/autoscaler/registry/RegistryManager.java | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) rename components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/{deployment/policy => policy/model}/DeploymentPolicy.java (98%) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java index 4c269395bb..e234713fe4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/algorithm/OneAfterAnother.java @@ -37,7 +37,7 @@ * This class is used for selecting a {@link Partition} one after another and checking availability of * partitions of a {@link NetworkPartitionContext} * One after another means it completes partitions in the order defined in - * {@link org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy}, and go to next if current one + * {@link org.apache.stratos.autoscaler.policy.model.DeploymentPolicy}, and go to next if current one * reached the max limit */ public class OneAfterAnother implements AutoscaleAlgorithm { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java index a3f7903911..90aac2d333 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/api/AutoScalerServiceImpl.java @@ -28,7 +28,7 @@ import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; import org.apache.stratos.autoscaler.applications.topic.ApplicationBuilder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.*; import org.apache.stratos.autoscaler.interfaces.AutoScalerServiceInterface; import org.apache.stratos.autoscaler.kubernetes.KubernetesManager; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java index 560a7a5695..eb3a1d9fe6 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/cloud/controller/CloudControllerClient.java @@ -25,7 +25,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.Constants; import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.*; import org.apache.stratos.autoscaler.kubernetes.KubernetesManager; import org.apache.stratos.autoscaler.util.ConfUtil; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java index 18fd027b60..9cd5d76652 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/commands/DeploymentPolicyCommands.java @@ -20,7 +20,7 @@ package org.apache.stratos.autoscaler.commands; import org.apache.commons.lang.StringUtils; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java index 0b2bf43e4b..204cc799d2 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/interfaces/AutoScalerServiceInterface.java @@ -22,7 +22,7 @@ package org.apache.stratos.autoscaler.interfaces; import org.apache.stratos.autoscaler.applications.pojo.ApplicationContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.*; import org.apache.stratos.autoscaler.exception.ApplicationDefinitionException; import org.apache.stratos.autoscaler.exception.InvalidPartitionException; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java index 3da60ab124..c8934e7425 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/internal/AutoscalerServerComponent.java @@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.applications.ApplicationSynchronizerTaskScheduler; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.kubernetes.KubernetesManager; import org.apache.stratos.autoscaler.event.receiver.health.AutoscalerHealthStatEventReceiver; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java index c049323e15..26a0118064 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitorFactory.java @@ -30,7 +30,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.PartitionValidationException; import org.apache.stratos.autoscaler.exception.PolicyValidationException; import org.apache.stratos.autoscaler.partition.PartitionGroup; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 19d3704c30..0990ead19c 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -26,7 +26,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.InvalidArgumentException; import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java index 3c82bdd4b3..b3dad4e485 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index a6ed9aa77b..0b460ab4d5 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -27,7 +27,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.event.publisher.ClusterStatusEventPublisher; import org.apache.stratos.autoscaler.monitor.events.MonitorStatusEvent; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java index 644cc22719..2d39ea00b8 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/partition/PartitionManager.java @@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; import org.apache.stratos.autoscaler.client.cloud.controller.CloudControllerClient; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.exception.InvalidPartitionException; import org.apache.stratos.autoscaler.exception.PartitionValidationException; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java index 6a918178a4..6ff2c2de29 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/PolicyManager.java @@ -25,7 +25,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.exception.InvalidPartitionException; import org.apache.stratos.autoscaler.exception.InvalidPolicyException; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/DeploymentPolicy.java similarity index 98% rename from components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java rename to components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/DeploymentPolicy.java index 6c5e0dc4f9..0676723a17 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/deployment/policy/DeploymentPolicy.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/policy/model/DeploymentPolicy.java @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.stratos.autoscaler.deployment.policy; +package org.apache.stratos.autoscaler.policy.model; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java index 94b3ecf10b..e0a676b5f4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/registry/RegistryManager.java @@ -25,7 +25,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.NetworkPartitionLbHolder; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.exception.AutoScalerException; import org.apache.stratos.autoscaler.pojo.ServiceGroup; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; From c2d9adfedac8d794f2f2d9a50083d10af43eaac1 Mon Sep 17 00:00:00 2001 From: Lahiru Sandaruwan Date: Tue, 4 Nov 2014 18:38:43 +0530 Subject: [PATCH 429/436] Fixing autoscaler test failures --- .../src/test/resources/autoscaler.drl | 2 +- .../src/test/resources/test-minimum-autoscaler-rule.drl | 2 +- .../test/resources/test-terminating-obsoleted-members-rule.drl | 2 +- .../modules/distribution/src/main/conf/drools/mincheck.drl | 2 +- .../modules/distribution/src/main/conf/drools/scaling.drl | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler.drl b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler.drl index a6d5051588..8b200cb3aa 100644 --- a/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler.drl +++ b/components/org.apache.stratos.autoscaler/src/test/resources/autoscaler.drl @@ -36,7 +36,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.commons.logging.Log; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl index 094d64a686..0dda4d4d98 100644 --- a/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl +++ b/components/org.apache.stratos.autoscaler/src/test/resources/test-minimum-autoscaler-rule.drl @@ -35,7 +35,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.commons.logging.Log; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; diff --git a/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl b/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl index bab4c0f1f4..11d74281c8 100644 --- a/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl +++ b/components/org.apache.stratos.autoscaler/src/test/resources/test-terminating-obsoleted-members-rule.drl @@ -35,7 +35,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.commons.logging.Log; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; diff --git a/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl b/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl index 71187d6d2b..29cd987ca4 100755 --- a/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl +++ b/products/stratos/modules/distribution/src/main/conf/drools/mincheck.drl @@ -35,7 +35,7 @@ import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.commons.logging.Log; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.partition.PartitionGroup; import org.apache.stratos.cloud.controller.stub.deployment.partition.Partition; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; diff --git a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl index bd331e7515..3d3bbbfc33 100644 --- a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl +++ b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl @@ -27,7 +27,7 @@ import org.apache.stratos.autoscaler.Constants; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.policy.PolicyManager; import org.apache.stratos.autoscaler.policy.model.AutoscalePolicy; -import org.apache.stratos.autoscaler.deployment.policy.DeploymentPolicy; +import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; import org.apache.stratos.autoscaler.policy.model.RequestsInFlight; import org.apache.stratos.autoscaler.policy.model.LoadThresholds; import org.apache.stratos.autoscaler.policy.model.MemoryConsumption; From 32b89e2ff9e382a526bf9d82486dea3bd0fdf2f4 Mon Sep 17 00:00:00 2001 From: R-Rajkumar Date: Tue, 4 Nov 2014 19:45:33 +0530 Subject: [PATCH 430/436] cleaning AS --- .../stratos/autoscaler/AutoscalerContext.java | 8 -- .../AutoscalerTopologyEventReceiver.java | 77 +++++++------------ 2 files changed, 27 insertions(+), 58 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java index 88ff3cf0fc..c75cf56b40 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/AutoscalerContext.java @@ -70,12 +70,4 @@ public ApplicationMonitor getAppMonitor(String applicationId) { public void removeAppMonitor(String applicationId) { applicationMonitors.remove(applicationId); } - - public boolean appMonitorExist(String applicationId) { - return applicationMonitors.containsKey(applicationId); - } - - public boolean clusterMonitorExist(String clusterId) { - return clusterMonitors.containsKey(clusterId); - } } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java index f01f8f9767..95d2b60e52 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/topology/AutoscalerTopologyEventReceiver.java @@ -22,16 +22,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; -import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.applications.ApplicationHolder; +import org.apache.stratos.autoscaler.event.publisher.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.exception.DependencyBuilderException; import org.apache.stratos.autoscaler.exception.TopologyInConsistentException; -import org.apache.stratos.autoscaler.event.publisher.InstanceNotificationPublisher; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitor; import org.apache.stratos.autoscaler.monitor.application.ApplicationMonitorFactory; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; -import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; -import org.apache.stratos.autoscaler.rule.AutoscalerRuleEvaluator; import org.apache.stratos.messaging.domain.applications.Application; import org.apache.stratos.messaging.domain.applications.Applications; import org.apache.stratos.messaging.domain.applications.ClusterDataHolder; @@ -39,12 +36,31 @@ import org.apache.stratos.messaging.domain.topology.Service; import org.apache.stratos.messaging.domain.topology.Topology; 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.event.topology.ApplicationClustersCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterActivatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterCreatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterInactivateEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatedEvent; +import org.apache.stratos.messaging.event.topology.ClusterTerminatingEvent; +import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; +import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; +import org.apache.stratos.messaging.event.topology.MemberReadyToShutdownEvent; +import org.apache.stratos.messaging.event.topology.MemberTerminatedEvent; +import org.apache.stratos.messaging.listener.topology.ApplicationClustersCreatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterCreatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterInActivateEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterResetEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterTerminatedEventListener; +import org.apache.stratos.messaging.listener.topology.ClusterTerminatingEventListener; +import org.apache.stratos.messaging.listener.topology.CompleteTopologyEventListener; +import org.apache.stratos.messaging.listener.topology.MemberActivatedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberMaintenanceListener; +import org.apache.stratos.messaging.listener.topology.MemberReadyToShutdownEventListener; +import org.apache.stratos.messaging.listener.topology.MemberStartedEventListener; +import org.apache.stratos.messaging.listener.topology.MemberTerminatedEventListener; import org.apache.stratos.messaging.message.receiver.topology.TopologyEventReceiver; import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; -import org.drools.runtime.StatefulKnowledgeSession; -import org.drools.runtime.rule.FactHandle; /** * Autoscaler topology receiver. @@ -193,7 +209,6 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { log.info("[ClusterActivatedEvent] Received: " + event.getClass()); - ClusterActivatedEvent clusterActivatedEvent = (ClusterActivatedEvent) event; String clusterId = clusterActivatedEvent.getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); @@ -214,9 +229,7 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterResetEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterCreatedEvent] Received: " + event.getClass()); - ClusterCreatedEvent clusterCreatedEvent = (ClusterCreatedEvent) event; String clusterId = clusterCreatedEvent.getCluster().getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); @@ -229,11 +242,9 @@ protected void onEvent(Event event) { } return; } - //changing the status in the monitor, will notify its parent monitor monitor.setStop(true); monitor.setStatus(ClusterStatus.Created); - } }); @@ -248,7 +259,6 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { log.info("[ClusterInActivateEvent] Received: " + event.getClass()); - ClusterInactivateEvent clusterInactivateEvent = (ClusterInactivateEvent) event; String clusterId = clusterInactivateEvent.getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); @@ -269,9 +279,7 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new ClusterTerminatingEventListener() { @Override protected void onEvent(Event event) { - log.info("[ClusterTerminatingEvent] Received: " + event.getClass()); - ClusterTerminatingEvent clusterTerminatingEvent = (ClusterTerminatingEvent) event; String clusterId = clusterTerminatingEvent.getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); @@ -300,7 +308,6 @@ protected void onEvent(Event event) { @Override protected void onEvent(Event event) { log.info("[ClusterTerminatedEvent] Received: " + event.getClass()); - ClusterTerminatedEvent clusterTerminatedEvent = (ClusterTerminatedEvent) event; String clusterId = clusterTerminatedEvent.getClusterId(); AutoscalerContext asCtx = AutoscalerContext.getInstance(); @@ -313,7 +320,6 @@ protected void onEvent(Event event) { } return; } - //changing the status in the monitor, will notify its parent monitor monitor.setStatus(ClusterStatus.Terminated); //Destroying and Removing the Cluster monitor @@ -350,9 +356,8 @@ protected void onEvent(Event event) { topologyEventReceiver.addEventListener(new MemberStartedEventListener() { @Override protected void onEvent(Event event) { - + } - }); topologyEventReceiver.addEventListener(new MemberTerminatedEventListener() { @@ -428,20 +433,6 @@ protected void onEvent(Event event) { }); } - @SuppressWarnings("unused") - private void runTerminateAllRule(VMClusterMonitor monitor) { - - FactHandle terminateAllFactHandle = null; - - StatefulKnowledgeSession terminateAllKnowledgeSession = null; - - for (NetworkPartitionContext networkPartitionContext : monitor.getNetworkPartitionCtxts().values()) { - terminateAllFactHandle = AutoscalerRuleEvaluator.evaluateTerminateAll(terminateAllKnowledgeSession - , terminateAllFactHandle, networkPartitionContext); - } - - } - /** * Terminate load balancer topology receiver thread. */ @@ -452,22 +443,11 @@ public void terminate() { protected synchronized void startApplicationMonitor(String applicationId) { Thread th = null; - if (!AutoscalerContext.getInstance().appMonitorExist(applicationId)) { - th = new Thread( - new ApplicationMonitorAdder(applicationId)); + if (AutoscalerContext.getInstance().getAppMonitor(applicationId) == null) { + th = new Thread(new ApplicationMonitorAdder(applicationId)); } - if (th != null) { th.start(); - // try { - // th.join(); - // } catch (InterruptedException ignore) { - - if (log.isDebugEnabled()) { - log.debug(String - .format("Application monitor thread has been started successfully: " + - "[application] %s ", applicationId)); - } } else { if (log.isDebugEnabled()) { log.debug(String @@ -523,13 +503,10 @@ public void run() { } AutoscalerContext.getInstance().addAppMonitor(applicationMonitor); - if (log.isInfoEnabled()) { log.info(String.format("Application monitor has been added successfully: " + "[application] %s", applicationMonitor.getId())); } } } - - } From e1cf308263217696e2dd02d3a8919feb6db04cb8 Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Tue, 4 Nov 2014 22:56:22 +0530 Subject: [PATCH 431/436] diff fixing 1 --- .../AverageRuestsServingCapabilityEvent.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java new file mode 100644 index 0000000000..97d7708fa2 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java @@ -0,0 +1,32 @@ +package org.apache.stratos.messaging.event.health.stat; + +/** + * Created by asiri on 8/10/14. + */ +import org.apache.stratos.messaging.event.Event; + +public class AverageRuestsServingCapabilityEvent extends Event { + private final String networkPartitionId; + private final String clusterId; + private final float value; + + public AverageRuestsServingCapabilityEvent(String networkPartitionId, String clusterId, float value) { + this.networkPartitionId = networkPartitionId; + this.clusterId = clusterId; + this.value = value; + + } + public String getClusterId() { + return clusterId; + } + + public float getValue() { + return value; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + +} From 4e7e7bb89e1605f5209b82120a43e9a6cf8d2999 Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Tue, 4 Nov 2014 23:01:17 +0530 Subject: [PATCH 432/436] fixing diff --- ...equestsServingCapabilityEventListener.java | 14 ++++++ ...estsServingCapabilityMessageProcessor.java | 49 +++++++++++++++++++ .../AverageServedRequestsEventFormatter.xml | 32 ++++++++++++ ...uestHandlingCapabilityWindowProcessor.java | 49 +++++++++++++++++++ 4 files changed, 144 insertions(+) create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java create mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java create mode 100644 extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml create mode 100644 extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java new file mode 100644 index 0000000000..3b7916404e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java @@ -0,0 +1,14 @@ +package org.apache.stratos.messaging.listener.health.stat; + +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by asiri on 8/10/14. + */ +public class AverageRequestsServingCapabilityEventListener extends EventListener { + @Override + protected void onEvent(Event event) { + + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java new file mode 100644 index 0000000000..724065ed85 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.messaging.message.processor.health.stat; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by asiri on 8/15/14. + */ +public class AverageRequestsServingCapabilityMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AverageRequestsServingCapabilityMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AverageRuestsServingCapabilityEvent.class.getName().equals(type)) { + + // Parse complete message and build event + AverageRuestsServingCapabilityEvent event = (AverageRuestsServingCapabilityEvent) Util.jsonToObject(message, AverageRuestsServingCapabilityEvent.class); + + // Notify event listeners + notifyEventListeners(event); + + if(log.isDebugEnabled()){ + log.debug(String.format("%s event processor notified listeners ... " , type)); + } + return true; + } + else { + if(nextProcessor != null) { + return nextProcessor.process(type, message, object); + } + else { + throw new RuntimeException(String.format("Failed to process health stat message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + + +} diff --git a/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml new file mode 100644 index 0000000000..5de01286e3 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml @@ -0,0 +1,32 @@ + + + + + + + {"org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","value":"{{average_served_count}}"}}} + + + summarized-health-stats + + diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java new file mode 100644 index 0000000000..c2536a53ce --- /dev/null +++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.cep.extension; + +/** + * Created by asiri on 8/9/14. + */ + +import org.wso2.siddhi.core.config.SiddhiContext; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.extension.annotation.SiddhiExtension; + +@SiddhiExtension(namespace = "stratos", function = "divider") +public class MemeberRequestHandlingCapabilityWindowProcessor extends FunctionExecutor { + + Attribute.Type returnType = Attribute.Type.DOUBLE; + + @Override + public void init(Attribute.Type[] types, SiddhiContext siddhiContext) { + } + + @Override + protected Object process(Object obj) { + + double[] value = new double[2]; + if (obj instanceof Object[]) { + int i=0; + for (Object aObj : (Object[]) obj) { + value[i]= Double.parseDouble(String.valueOf(aObj)); + i++; + } + }//to do avoid deviding zero number of active instances won't be zero cz there is min + Double unit = (value[0] / value[1]); + if(!unit.isNaN() && !unit.isInfinite()) + return unit; + else + return 0.0; + + } + + @Override + public void destroy() { + + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } +} From 5d6847141d84bd0645c2bc8129b6248517391a40 Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Tue, 4 Nov 2014 23:27:41 +0530 Subject: [PATCH 433/436] improvements to autoscaling --- .../autoscaler/NetworkPartitionContext.java | 19 ++++ .../AutoscalerHealthStatEventReceiver.java | 28 +++++- .../cluster/AbstractClusterMonitor.java | 1 + .../monitor/cluster/VMClusterMonitor.java | 50 +++++++---- .../monitor/cluster/VMLbClusterMonitor.java | 1 + .../cluster/VMServiceClusterMonitor.java | 2 + .../autoscaler/rule/RuleTasksDelegator.java | 86 +++++++++++++++++++ .../LoadBalancerStatisticsReader.java | 5 ++ .../LoadBalancerStatisticsNotifier.java | 11 ++- .../WSO2CEPInFlightRequestPublisher.java | 7 +- .../LoadBalancerStatisticsCollector.java | 38 ++++++++ .../stat/AverageRequestsInFlightEvent.java | 11 ++- .../stat/HealthStatMessageProcessorChain.java | 5 ++ .../AverageInFlightRequestsEventFormatter.xml | 2 +- .../AverageInFlightRequestsFinder.xml | 15 +++- .../stream-manager-config.xml | 20 ++++- .../extension/HAProxyStatisticsReader.java | 10 +++ .../src/main/conf/drools/scaling.drl | 25 +++++- 18 files changed, 307 insertions(+), 29 deletions(-) diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java index 3daf2c184f..c2b3bdf65e 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/NetworkPartitionContext.java @@ -41,6 +41,8 @@ public class NetworkPartitionContext implements Serializable{ private final String id; private int scaleDownWaitCount = 5; //TODO get from a config private int scaleDownRequestsCount = 0; + private float averageRequestsServedPerInstance; + private float requestsServedPerInstance; // private String defaultLbClusterId; // @@ -58,6 +60,8 @@ public class NetworkPartitionContext implements Serializable{ //boolean values to keep whether the load average parameters are reset or not private boolean loadAverageReset = false, averageLoadAverageReset = false, gradientLoadAverageReset = false, secondDerivativeLoadAverageRest = false; + //boolean values to keep whether average requests served per instance parameters are reset or not + private boolean averageRequestServedPerInstanceReset= false; //FIXME this should be populated via PartitionGroups a.k.a. NetworkPartitions private int minInstanceCount = 1, maxInstanceCount = 1; @@ -241,6 +245,21 @@ public void setCurrentPartitionIndex(int currentPartitionIndex) { this.currentPartitionIndex = currentPartitionIndex; } + public float getAverageRequestsServedPerInstance() { return averageRequestsServedPerInstance;} + + public void setAverageRequestsServedPerInstance(float averageRequestServedPerInstance) { + this.averageRequestsServedPerInstance = averageRequestServedPerInstance; + averageRequestServedPerInstanceReset = true; + + if(log.isDebugEnabled()){ + log.debug(String.format("Average Requesets Served Per Instance stats are reset, ready to do scale check [network partition] %s" + , this.id)); + + } + } + + public float getRequestsServedPerInstance() { return requestsServedPerInstance;} + public float getAverageRequestsInFlight() { return requestsInFlight.getAverage(); } diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java index 718cc160fd..e2eca170d4 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/event/receiver/health/AutoscalerHealthStatEventReceiver.java @@ -23,6 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor; +import org.apache.stratos.autoscaler.monitor.cluster.VMClusterMonitor; import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; @@ -41,9 +42,11 @@ import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfMemoryConsumptionEvent; import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfRequestsInFlightEvent; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; import org.apache.stratos.messaging.listener.health.stat.AverageLoadAverageEventListener; import org.apache.stratos.messaging.listener.health.stat.AverageMemoryConsumptionEventListener; import org.apache.stratos.messaging.listener.health.stat.AverageRequestsInFlightEventListener; +import org.apache.stratos.messaging.listener.health.stat.AverageRequestsServingCapabilityEventListener; import org.apache.stratos.messaging.listener.health.stat.GradientOfLoadAverageEventListener; import org.apache.stratos.messaging.listener.health.stat.GradientOfMemoryConsumptionEventListener; import org.apache.stratos.messaging.listener.health.stat.GradientOfRequestsInFlightEventListener; @@ -122,6 +125,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { } }); + healthStatEventReceiver.addEventListener(new AverageMemoryConsumptionEventListener() { @Override protected void onEvent(org.apache.stratos.messaging.event.Event event) { @@ -152,7 +156,7 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { if (null == monitor) { if (log.isDebugEnabled()) { log.debug(String.format("A cluster monitor is not found in autoscaler context " - + "[cluster] %s", clusterId)); + + "[cluster] %s", clusterId)); } return; } @@ -160,6 +164,28 @@ protected void onEvent(org.apache.stratos.messaging.event.Event event) { } }); + healthStatEventReceiver.addEventListener(new AverageRequestsServingCapabilityEventListener() { + @Override + protected void onEvent(org.apache.stratos.messaging.event.Event event) { + AverageRequestsServingCapabilityEvent averageRequestsServingCapabilityEvent = (AverageRequestsServingCapabilityEvent) event; + String clusterId = averageRequestsServingCapabilityEvent.getClusterId(); + AutoscalerContext asCtx = AutoscalerContext.getInstance(); + AbstractClusterMonitor monitor; + monitor = asCtx.getClusterMonitor(clusterId); + if (null == monitor) { + if (log.isDebugEnabled()) { + log.debug(String.format("A cluster monitor is not found in autoscaler context " + + "[cluster] %s", clusterId)); + } + return; + } + if(monitor instanceof VMClusterMonitor) { + VMClusterMonitor vmClusterMonitor = (VMClusterMonitor) monitor; + vmClusterMonitor.handleAverageRequestsServingCapabilityEvent(averageRequestsServingCapabilityEvent); + } + } + }); + healthStatEventReceiver.addEventListener(new GradientOfLoadAverageEventListener() { @Override protected void onEvent(org.apache.stratos.messaging.event.Event event) { diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java index fa9736e372..55748e1eb9 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/AbstractClusterMonitor.java @@ -36,6 +36,7 @@ import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; import org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; import org.apache.stratos.messaging.event.health.stat.GradientOfLoadAverageEvent; import org.apache.stratos.messaging.event.health.stat.GradientOfMemoryConsumptionEvent; import org.apache.stratos.messaging.event.health.stat.GradientOfRequestsInFlightEvent; diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java index 0990ead19c..d6dc27c569 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMClusterMonitor.java @@ -22,6 +22,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.MemberStatsContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; @@ -37,22 +38,7 @@ import org.apache.stratos.messaging.domain.topology.Cluster; import org.apache.stratos.messaging.domain.topology.Member; import org.apache.stratos.messaging.domain.topology.Service; -import org.apache.stratos.messaging.event.health.stat.AverageLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.AverageMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent; -import org.apache.stratos.messaging.event.health.stat.GradientOfLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.GradientOfMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.GradientOfRequestsInFlightEvent; -import org.apache.stratos.messaging.event.health.stat.MemberAverageLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.MemberAverageMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.MemberFaultEvent; -import org.apache.stratos.messaging.event.health.stat.MemberGradientOfLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.MemberGradientOfMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.MemberSecondDerivativeOfLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.MemberSecondDerivativeOfMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfLoadAverageEvent; -import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfMemoryConsumptionEvent; -import org.apache.stratos.messaging.event.health.stat.SecondDerivativeOfRequestsInFlightEvent; +import org.apache.stratos.messaging.event.health.stat.*; import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; import org.apache.stratos.messaging.event.topology.MemberActivatedEvent; import org.apache.stratos.messaging.event.topology.MemberMaintenanceModeEvent; @@ -193,7 +179,7 @@ public void handleGradientOfMemoryConsumptionEvent( } else { if (log.isDebugEnabled()) { log.debug(String.format("Network partition context is not available for :" + - " [network partition] %s", networkPartitionId)); + " [network partition] %s", networkPartitionId)); } } } @@ -220,12 +206,42 @@ public void handleSecondDerivativeOfMemoryConsumptionEvent( } } + public void handleAverageRequestsServingCapabilityEvent(AverageRequestsServingCapabilityEvent averageRequestsServingCapabilityEvent) { + + String clusterId = averageRequestsServingCapabilityEvent.getClusterId(); + String networkPartitionId = averageRequestsServingCapabilityEvent.getNetworkPartitionId(); + Float floatValue = averageRequestsServingCapabilityEvent.getValue(); + + if (log.isDebugEnabled()) { + log.debug(String.format("Average Requests Served per Instance event: [cluster] %s [network-partition] %s [value] %s", + clusterId, networkPartitionId, floatValue)); + } + + NetworkPartitionContext networkPartitionContext = getNetworkPartitionCtxt(networkPartitionId); + if(null != networkPartitionContext){ + networkPartitionContext.setAverageRequestsServedPerInstance(floatValue); + + } else { + if(log.isDebugEnabled()) { + log.debug(String.format("Network partition context is not available for :" + + " [network partition] %s", networkPartitionId)); + } + } + + } + @Override public void handleAverageRequestsInFlightEvent( AverageRequestsInFlightEvent averageRequestsInFlightEvent) { String networkPartitionId = averageRequestsInFlightEvent.getNetworkPartitionId(); String clusterId = averageRequestsInFlightEvent.getClusterId(); + Float servedCount = averageRequestsInFlightEvent.getServedCount(); + Float activeInstances = averageRequestsInFlightEvent.getActiveInstances(); + Float requestsServedPerInstance = servedCount/activeInstances; + if(requestsServedPerInstance.isInfinite()){ + requestsServedPerInstance = 0f; + } float value = averageRequestsInFlightEvent.getValue(); if (log.isDebugEnabled()) { log.debug(String.format("Average Rif event: [cluster] %s [network-partition] %s [value] %s", diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java index b3dad4e485..386197cd1a 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMLbClusterMonitor.java @@ -36,6 +36,7 @@ import org.apache.stratos.autoscaler.util.ConfUtil; import org.apache.stratos.common.constants.StratosConstants; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; import org.apache.stratos.messaging.event.topology.ClusterRemovedEvent; /** diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java index 0b460ab4d5..e5e8fe4654 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/VMServiceClusterMonitor.java @@ -25,6 +25,7 @@ import org.apache.commons.configuration.XMLConfiguration; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.autoscaler.AutoscalerContext; import org.apache.stratos.autoscaler.NetworkPartitionContext; import org.apache.stratos.autoscaler.PartitionContext; import org.apache.stratos.autoscaler.policy.model.DeploymentPolicy; @@ -41,6 +42,7 @@ import org.apache.stratos.messaging.domain.applications.ApplicationStatus; import org.apache.stratos.messaging.domain.applications.GroupStatus; import org.apache.stratos.messaging.domain.topology.ClusterStatus; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; /** * Is responsible for monitoring a service cluster. This runs periodically diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java index c0f493377f..8ab5308808 100644 --- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java +++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java @@ -36,6 +36,11 @@ import org.apache.stratos.autoscaler.exception.TerminationException; import org.apache.stratos.autoscaler.partition.PartitionManager; import org.apache.stratos.cloud.controller.stub.pojo.MemberContext; +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.domain.topology.Service; +import org.apache.stratos.messaging.message.receiver.topology.TopologyManager; /** * This will have utility methods that need to be executed from rule file... @@ -44,6 +49,7 @@ public class RuleTasksDelegator { public static final double SCALE_UP_FACTOR = 0.8; //get from config public static final double SCALE_DOWN_FACTOR = 0.2; + private static boolean arspiIsSet = false; private static final Log log = LogFactory.getLog(RuleTasksDelegator.class); @@ -59,6 +65,86 @@ public double getPredictedValueForNextMinute(float average, float gradient, floa return predictedValue; } + + public int getNumberOfInstancesRequiredBasedOnRif(float rifPredictedValue , float requestsServedPerInstance , float averageRequestsServedPerInstance , boolean arspiReset){ + + float requestsInstanceCanHandle = requestsServedPerInstance; + + if(arspiReset && averageRequestsServedPerInstance != 0){ + requestsInstanceCanHandle = averageRequestsServedPerInstance; + + } + float numberOfInstances = 0; + if(requestsInstanceCanHandle!=0) { + numberOfInstances = rifPredictedValue / requestsInstanceCanHandle; + arspiReset = true; + + }else{ + arspiReset = false; + } + return (int)Math.ceil(numberOfInstances); + } + + public int getNumberOfInstancesRequiredBasedOnLoadAndMemoryConsumption(float upperLimit , float lowerLimit ,double predictedValue , int activeMemberCount ){ + + double numberOfInstances = 0; + if(predictedValue > upperLimit){ + numberOfInstances = (activeMemberCount*predictedValue)/upperLimit; + }else if((upperLimit >= predictedValue) && (predictedValue >= lowerLimit)){ + numberOfInstances = activeMemberCount; + }else{ + numberOfInstances = (activeMemberCount*predictedValue)/lowerLimit; + } + + return (int)Math.ceil(numberOfInstances); + } + + public int getMaxNumberOfInstancesRequired(int numberOfInstancesReuquiredBasedOnRif , int numberOfInstancesReuquiredBasedOnMemoryConsumption , boolean mcReset , int numberOfInstancesReuquiredBasedOnLoadAverage , boolean laReset){ + int numberOfInstances = 0; + + int rifBasedRequiredInstances = 0; + int mcBasedRequiredInstances = 0; + int laBasedRequiredInstances = 0; + if(arspiIsSet){ + rifBasedRequiredInstances = numberOfInstancesReuquiredBasedOnRif; + } + if(mcReset){ + rifBasedRequiredInstances = numberOfInstancesReuquiredBasedOnMemoryConsumption; + } + if(laReset){ + rifBasedRequiredInstances = numberOfInstancesReuquiredBasedOnLoadAverage; + } + numberOfInstances = Math.max(Math.max(numberOfInstancesReuquiredBasedOnMemoryConsumption,numberOfInstancesReuquiredBasedOnLoadAverage),numberOfInstancesReuquiredBasedOnRif); + return numberOfInstances; + } + + public int getMemberCount(String clusterId , int scalingPara ){ + + int activeMemberCount = 0; + int memberCount = 0; + for( Service service : TopologyManager.getTopology().getServices()) { + if(service.clusterExists(clusterId)) { + Cluster cluster = service.getCluster(clusterId); + + for (Member member : cluster.getMembers()) { + if (member.isActive() || member.getStatus() == MemberStatus.Created || member.getStatus() == MemberStatus.Starting ) { + memberCount++; + if(member.isActive()) { + activeMemberCount++; + } + } + } + } + } + if(scalingPara == 1){ + return memberCount; + }else{ + return activeMemberCount; + } + + + } + public AutoscaleAlgorithm getAutoscaleAlgorithm(String partitionAlgorithm){ AutoscaleAlgorithm autoscaleAlgorithm = null; if(log.isDebugEnabled()){ diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java index 4a83aee69f..79386bd652 100644 --- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java +++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/LoadBalancerStatisticsReader.java @@ -19,6 +19,8 @@ package org.apache.stratos.load.balancer.common.statistics; +import org.apache.stratos.messaging.domain.topology.Cluster; + /** * Load balancer statistics reader interface. */ @@ -29,4 +31,7 @@ public interface LoadBalancerStatisticsReader { * @param clusterId */ int getInFlightRequestCount(String clusterId); + int getServedRequestCount(String clusterId); + int getActiveInstancesCount(Cluster cluster); + } diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java index 4fe2504b74..7d123e5060 100644 --- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java +++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/notifier/LoadBalancerStatisticsNotifier.java @@ -74,12 +74,21 @@ public void run() { try { TopologyManager.acquireReadLock(); int requestCount; + int servedRequestCount; + int activeInstancesCount; for (Service service : TopologyManager.getTopology().getServices()) { for (Cluster cluster : service.getClusters()) { if (!cluster.isLbCluster()) { // Publish in-flight request count of load balancer's network partition requestCount = statsReader.getInFlightRequestCount(cluster.getClusterId()); - inFlightRequestPublisher.publish(cluster.getClusterId(), networkPartitionId, requestCount); + servedRequestCount = statsReader.getServedRequestCount(cluster.getClusterId()); + if(requestCount == 0) { + servedRequestCount = 0; + } + activeInstancesCount = statsReader.getActiveInstancesCount(cluster); + inFlightRequestPublisher.publish(cluster.getClusterId(), networkPartitionId,activeInstancesCount, requestCount, servedRequestCount); + log.info(String.format("In-flight request count published to cep: [cluster-id] %s [network-partition] %s [value] %d [active instances] %d [RIF] %d ", + cluster.getClusterId(), networkPartitionId, servedRequestCount , activeInstancesCount ,requestCount )); if (log.isDebugEnabled()) { log.debug(String.format("In-flight request count published to cep: [cluster-id] %s [network-partition] %s [value] %d", cluster.getClusterId(), networkPartitionId, requestCount)); diff --git a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/publisher/WSO2CEPInFlightRequestPublisher.java b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/publisher/WSO2CEPInFlightRequestPublisher.java index 519a687b80..24d5257c15 100644 --- a/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/publisher/WSO2CEPInFlightRequestPublisher.java +++ b/components/org.apache.stratos.load.balancer.common/src/main/java/org/apache/stratos/load/balancer/common/statistics/publisher/WSO2CEPInFlightRequestPublisher.java @@ -47,7 +47,9 @@ private static StreamDefinition createStreamDefinition() { // Payload definition payloadData.add(new Attribute("cluster_id", AttributeType.STRING)); payloadData.add(new Attribute("network_partition_id", AttributeType.STRING)); + payloadData.add(new Attribute("active_instances_count", AttributeType.DOUBLE)); payloadData.add(new Attribute("in_flight_request_count", AttributeType.DOUBLE)); + payloadData.add(new Attribute("served_request_count", AttributeType.DOUBLE)); streamDefinition.setPayloadData(payloadData); return streamDefinition; } catch (Exception e) { @@ -65,13 +67,16 @@ public WSO2CEPInFlightRequestPublisher() { * @param clusterId * @param networkPartitionId * @param inFlightRequestCount + * @param servedRequestCount */ - public void publish(String clusterId, String networkPartitionId, int inFlightRequestCount) { + public void publish(String clusterId, String networkPartitionId,int activeInstancesCount, int inFlightRequestCount, int servedRequestCount) { List payload = new ArrayList(); // Payload values payload.add(clusterId); payload.add(networkPartitionId); + payload.add((double)activeInstancesCount); payload.add((double)inFlightRequestCount); + payload.add((double)servedRequestCount); super.publish(payload.toArray()); } } diff --git a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java index 3557d3a926..10e38f9364 100644 --- a/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java +++ b/components/org.apache.stratos.load.balancer/src/main/java/org/apache/stratos/load/balancer/statistics/LoadBalancerStatisticsCollector.java @@ -22,6 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.stratos.load.balancer.common.statistics.LoadBalancerStatisticsReader; +import org.apache.stratos.messaging.domain.topology.Cluster; +import org.apache.stratos.messaging.domain.topology.Member; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -35,9 +37,11 @@ public class LoadBalancerStatisticsCollector implements LoadBalancerStatisticsRe private static volatile LoadBalancerStatisticsCollector instance; // Map private Map clusterIdRequestCountMap; + private Map clusterIdServedRequestCountMap; private LoadBalancerStatisticsCollector() { clusterIdRequestCountMap = new ConcurrentHashMap(); + clusterIdServedRequestCountMap = new ConcurrentHashMap(); } public static LoadBalancerStatisticsCollector getInstance() { @@ -75,6 +79,33 @@ public int getInFlightRequestCount(String clusterId) { } } + /** + * Returns the number of requests served since the last time this function was called. + */ + public int getServedRequestCount(String clusterId){ + synchronized (LoadBalancerStatisticsCollector.class) { + if (clusterIdServedRequestCountMap.containsKey(clusterId)) { + Integer servedCount = clusterIdServedRequestCountMap.get(clusterId); + if (servedCount != null) { + clusterIdServedRequestCountMap.put(clusterId, 0); + return servedCount; + } + } + return 0; + } + } + + public int getActiveInstancesCount(Cluster cluster) { + int activeInstances = 0; + for( Member member :cluster.getMembers()){ + if(member.isActive()){ + activeInstances++; + } + + }return activeInstances; + + } + void incrementInFlightRequestCount(String clusterId) { synchronized (LoadBalancerStatisticsCollector.class) { if (StringUtils.isBlank(clusterId)) { @@ -118,6 +149,13 @@ void decrementInFlightRequestCount(String clusterId) { } clusterIdRequestCountMap.put(clusterId, count); + Integer servedCount = 0; + if (clusterIdServedRequestCountMap.containsKey(clusterId)) { + servedCount = clusterIdServedRequestCountMap.get(clusterId); + } + servedCount++; + clusterIdServedRequestCountMap.put(clusterId, servedCount); + if (log.isDebugEnabled()) { log.debug(String.format("In-flight request count decremented: [cluster] %s [count] %s ", clusterId, count)); diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsInFlightEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsInFlightEvent.java index 143ae03ce7..0e10af9cf5 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsInFlightEvent.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsInFlightEvent.java @@ -28,11 +28,15 @@ public class AverageRequestsInFlightEvent extends Event { private final String networkPartitionId; private final String clusterId; private final float value; + private final float servedCount; + private final float activeInstances; - public AverageRequestsInFlightEvent(String networkPartitionId, String clusterId, float value) { + public AverageRequestsInFlightEvent(String networkPartitionId, String clusterId,float activeInstances, float value, float servedCount ) { this.networkPartitionId = networkPartitionId; this.clusterId = clusterId; this.value = value; + this.servedCount = servedCount; + this.activeInstances = activeInstances; } @@ -47,4 +51,9 @@ public float getValue() { public String getNetworkPartitionId() { return networkPartitionId; } + + public float getServedCount() { return servedCount;} + + public float getActiveInstances() { return activeInstances;} + } diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/HealthStatMessageProcessorChain.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/HealthStatMessageProcessorChain.java index f9861f6e49..4da35a9bb8 100644 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/HealthStatMessageProcessorChain.java +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/HealthStatMessageProcessorChain.java @@ -44,6 +44,7 @@ public class HealthStatMessageProcessorChain extends MessageProcessorChain { private MemberGradientOfMemoryConsumptionMessageProcessor memberGradientOfMemoryConsumptionMessageProcessor; private MemberSecondDerivativeOfLoadAverageMessageProcessor memberSecondDerivativeOfLoadAverageMessageProcessor; private MemberSecondDerivativeOfMemoryConsumptionMessageProcessor memberSecondDerivativeOfMemoryConsumptionMessageProcessor; + private AverageRequestsServingCapabilityMessageProcessor averageRequestsServingCapabilityMessageProcessor; private MemberFaultMessageProcessor memberFaultMessageProcessor; @@ -66,6 +67,8 @@ protected void initialize() { averageRequestsInFlightMessageProcessor = new AverageRequestsInFlightMessageProcessor(); add(averageRequestsInFlightMessageProcessor); + averageRequestsServingCapabilityMessageProcessor = new AverageRequestsServingCapabilityMessageProcessor(); + add(averageRequestsServingCapabilityMessageProcessor); gradientOfRequestsInFlightMessageProcessor = new GradientOfRequestsInFlightMessageProcessor(); add(gradientOfRequestsInFlightMessageProcessor); secondDerivativeOfRequestsInFlightMessageProcessor = new SecondDerivativeOfRequestsInFlightMessageProcessor(); @@ -97,6 +100,8 @@ public void addEventListener(EventListener eventListener) { averageMemoryConsumptionMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof AverageRequestsInFlightEventListener) { averageRequestsInFlightMessageProcessor.addEventListener(eventListener); + } else if (eventListener instanceof AverageRequestsServingCapabilityEventListener) { + averageRequestsServingCapabilityMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GradientOfLoadAverageEventListener) { gradientOfLoadAverageMessageProcessor.addEventListener(eventListener); } else if (eventListener instanceof GradientOfMemoryConsumptionEventListener) { diff --git a/extensions/cep/artifacts/eventformatters/AverageInFlightRequestsEventFormatter.xml b/extensions/cep/artifacts/eventformatters/AverageInFlightRequestsEventFormatter.xml index 6e6ba967a2..84e95ae34c 100644 --- a/extensions/cep/artifacts/eventformatters/AverageInFlightRequestsEventFormatter.xml +++ b/extensions/cep/artifacts/eventformatters/AverageInFlightRequestsEventFormatter.xml @@ -24,7 +24,7 @@ statistics="disable" trace="enable" xmlns="http://wso2.org/carbon/eventformatter"> - {"org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","value":"{{count}}"}}} + {"org.apache.stratos.messaging.event.health.stat.AverageRequestsInFlightEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","activeInstances":"{{instances_count}}","value":"{{count}}" ,"servedCount":"{{served_count}}"}}} summarized-health-stats diff --git a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml index 6826dab89b..a8e890fd89 100644 --- a/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml +++ b/extensions/cep/artifacts/executionplans/AverageInFlightRequestsFinder.xml @@ -32,16 +32,25 @@ + partition by avg_rif_cluster_partition; + from average_in_flight_requests + select cluster_id, network_partition_id,instances_count, served_count, + stratos:divider(served_count , instances_count) as requests_per_instance + insert into served_requests_per_instance; + from served_requests_per_instance[requests_per_instance>0]#window.timeBatch(10 min) + select cluster_id,network_partition_id, avg(requests_per_instance) as average_served_count + insert into average_served_request_count;]]> + diff --git a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml index 64b5d85e3b..a9472efed7 100644 --- a/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml +++ b/extensions/cep/artifacts/streamdefinitions/stream-manager-config.xml @@ -32,7 +32,9 @@ + + @@ -60,9 +62,25 @@ + + - + + + + average served count per instance + average in-flight requests + + + + + + + + + + second derivative of in-flight request count diff --git a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java index f29e1c688e..5dec4d3992 100644 --- a/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java +++ b/extensions/load-balancer/haproxy-extension/src/main/java/org/apache/stratos/haproxy/extension/HAProxyStatisticsReader.java @@ -96,4 +96,14 @@ public int getInFlightRequestCount(String clusterId) { } return 0; } + + @Override + public int getServedRequestCount(String clusterId) { + return 0; + } + + @Override + public int getActiveInstancesCount(Cluster cluster) { + return 0; + } } diff --git a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl index 3d3bbbfc33..1d1ba5ddde 100644 --- a/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl +++ b/products/stratos/modules/distribution/src/main/conf/drools/scaling.drl @@ -55,6 +55,7 @@ global java.lang.Boolean mcReset; global java.lang.Boolean laReset; global java.lang.Boolean isPrimary; global java.util.List primaryMembers; +global java.lang.Boolean arspiReset; rule "Scaling Rule" dialect "mvel" @@ -94,8 +95,22 @@ dialect "mvel" loadAverageSecondDerivative : Float() from $networkPartitionContext.getLoadAverageSecondDerivative() laPredictedValue : Double() from $delegator.getPredictedValueForNextMinute(loadAverageAverage, loadAverageGradient, loadAverageSecondDerivative, 1) - scaleUp : Boolean() from ((rifReset && (rifPredictedValue > rifUpperLimit)) || (mcReset && (mcPredictedValue > mcUpperLimit)) || (laReset && (laPredictedValue > laUpperLimit))) - scaleDown : Boolean() from ((rifReset && (rifPredictedValue < rifLowerLimit )) && (mcReset && (mcPredictedValue < mcLowerLimit)) && (laReset && (laPredictedValue < laLowerLimit))) + activeInstancesCount : Integer() from $delegator.getMemberCount(clusterId , 0) + instancesCount : Integer() from $delegator.getMemberCount(clusterId , 1) + + requestsServedPerInstance : Float() from $networkPartitionContext.getRequestsServedPerInstance() + averageRequestsServedPerInstance : Float() from $networkPartitionContext.getAverageRequestsServedPerInstance() + + numberOfInstancesReuquiredBasedOnRif : Integer() from $delegator.getNumberOfInstancesRequiredBasedOnRif(rifPredictedValue, requestsServedPerInstance, averageRequestsServedPerInstance, arspiReset) + numberOfInstancesReuquiredBasedOnMemoryConsumption : Integer() from $delegator.getNumberOfInstancesRequiredBasedOnLoadAndMemoryConsumption(mcUpperLimit , mcLowerLimit, mcPredictedValue ,activeInstancesCount ) + numberOfInstancesReuquiredBasedOnLoadAverage : Integer() from $delegator.getNumberOfInstancesRequiredBasedOnLoadAndMemoryConsumption(laUpperLimit , laLowerLimit, laPredictedValue ,activeInstancesCount ) + + numberOfRequiredInstances : Integer() from $delegator.getMaxNumberOfInstancesRequired(numberOfInstancesReuquiredBasedOnRif, numberOfInstancesReuquiredBasedOnMemoryConsumption ,mcReset ,numberOfInstancesReuquiredBasedOnLoadAverage, laReset) + + + + scaleUp : Boolean() from (instancesCount < numberOfRequiredInstances ) + scaleDown : Boolean() from (activeInstancesCount > numberOfRequiredInstances ) eval(log.debug("[scaling] " + " [cluster] " + clusterId + " RIF Resetted?: " + rifReset)) eval(log.debug("[scaling] " + " [cluster] " + clusterId + " RIF predicted value: " + rifPredictedValue)) @@ -116,19 +131,23 @@ dialect "mvel" then if(scaleUp){ + int additionalInstances = numberOfRequiredInstances - instancesCount ; $networkPartitionContext.resetScaleDownRequestsCount(); + int count=0; + while(count != additionalInstances){ Partition partition = autoscaleAlgorithm.getNextScaleUpPartition($networkPartitionContext, clusterId); if(partition != null){ log.info("[scale-up] Partition available, hence trying to spawn an instance to scale up!" ); log.debug("[scale-up] " + " [partition] " + partition.getId() + " [cluster] " + clusterId ); $delegator.delegateSpawn($networkPartitionContext.getPartitionCtxt(partition.getId()), clusterId, lbRef, isPrimary); + count++; } + } } else if(scaleDown){ log.debug("[scale-down] Decided to Scale down [cluster] " + clusterId); if($networkPartitionContext.getScaleDownRequestsCount() > 5 ){ log.debug("[scale-down] Reached scale down requests threshold [cluster] " + clusterId + " Count " + $networkPartitionContext.getScaleDownRequestsCount()); - $networkPartitionContext.resetScaleDownRequestsCount(); MemberStatsContext selectedMemberStatsContext = null; double lowestOverallLoad = 0.0; boolean foundAValue = false; From 0c4fb186bcec7ca8f214f07b1fa150c0cc313545 Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Tue, 4 Nov 2014 23:35:04 +0530 Subject: [PATCH 434/436] clearing typos --- .../AverageRuestsServingCapabilityEvent.java | 32 ------------ ...equestsServingCapabilityEventListener.java | 14 ------ ...estsServingCapabilityMessageProcessor.java | 49 ------------------- .../AverageServedRequestsEventFormatter.xml | 32 ------------ ...uestHandlingCapabilityWindowProcessor.java | 49 ------------------- 5 files changed, 176 deletions(-) delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java delete mode 100644 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java delete mode 100644 extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml delete mode 100644 extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java deleted file mode 100644 index 97d7708fa2..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRuestsServingCapabilityEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.apache.stratos.messaging.event.health.stat; - -/** - * Created by asiri on 8/10/14. - */ -import org.apache.stratos.messaging.event.Event; - -public class AverageRuestsServingCapabilityEvent extends Event { - private final String networkPartitionId; - private final String clusterId; - private final float value; - - public AverageRuestsServingCapabilityEvent(String networkPartitionId, String clusterId, float value) { - this.networkPartitionId = networkPartitionId; - this.clusterId = clusterId; - this.value = value; - - } - public String getClusterId() { - return clusterId; - } - - public float getValue() { - return value; - } - - public String getNetworkPartitionId() { - return networkPartitionId; - } - - -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java deleted file mode 100644 index 3b7916404e..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.apache.stratos.messaging.listener.health.stat; - -import org.apache.stratos.messaging.event.Event; -import org.apache.stratos.messaging.listener.EventListener; - -/** - * Created by asiri on 8/10/14. - */ -public class AverageRequestsServingCapabilityEventListener extends EventListener { - @Override - protected void onEvent(Event event) { - - } -} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java deleted file mode 100644 index 724065ed85..0000000000 --- a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.stratos.messaging.message.processor.health.stat; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent; -import org.apache.stratos.messaging.message.processor.MessageProcessor; -import org.apache.stratos.messaging.util.Util; - -/** - * Created by asiri on 8/15/14. - */ -public class AverageRequestsServingCapabilityMessageProcessor extends MessageProcessor { - private static final Log log = LogFactory.getLog(AverageRequestsServingCapabilityMessageProcessor.class); - - private MessageProcessor nextProcessor; - - @Override - public void setNext(MessageProcessor nextProcessor) { - this.nextProcessor = nextProcessor; - } - - @Override - public boolean process(String type, String message, Object object) { - if (AverageRuestsServingCapabilityEvent.class.getName().equals(type)) { - - // Parse complete message and build event - AverageRuestsServingCapabilityEvent event = (AverageRuestsServingCapabilityEvent) Util.jsonToObject(message, AverageRuestsServingCapabilityEvent.class); - - // Notify event listeners - notifyEventListeners(event); - - if(log.isDebugEnabled()){ - log.debug(String.format("%s event processor notified listeners ... " , type)); - } - return true; - } - else { - if(nextProcessor != null) { - return nextProcessor.process(type, message, object); - } - else { - throw new RuntimeException(String.format("Failed to process health stat message using available message processors: [type] %s [body] %s", type, message)); - } - } - } - - - -} diff --git a/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml deleted file mode 100644 index 5de01286e3..0000000000 --- a/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - {"org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","value":"{{average_served_count}}"}}} - - - summarized-health-stats - - diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java deleted file mode 100644 index c2536a53ce..0000000000 --- a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.stratos.cep.extension; - -/** - * Created by asiri on 8/9/14. - */ - -import org.wso2.siddhi.core.config.SiddhiContext; -import org.wso2.siddhi.core.executor.function.FunctionExecutor; -import org.wso2.siddhi.query.api.definition.Attribute; -import org.wso2.siddhi.query.api.extension.annotation.SiddhiExtension; - -@SiddhiExtension(namespace = "stratos", function = "divider") -public class MemeberRequestHandlingCapabilityWindowProcessor extends FunctionExecutor { - - Attribute.Type returnType = Attribute.Type.DOUBLE; - - @Override - public void init(Attribute.Type[] types, SiddhiContext siddhiContext) { - } - - @Override - protected Object process(Object obj) { - - double[] value = new double[2]; - if (obj instanceof Object[]) { - int i=0; - for (Object aObj : (Object[]) obj) { - value[i]= Double.parseDouble(String.valueOf(aObj)); - i++; - } - }//to do avoid deviding zero number of active instances won't be zero cz there is min - Double unit = (value[0] / value[1]); - if(!unit.isNaN() && !unit.isInfinite()) - return unit; - else - return 0.0; - - } - - @Override - public void destroy() { - - } - - @Override - public Attribute.Type getReturnType() { - return returnType; - } -} From 31c69b39daacdd196b8d7741f5e1652e164bf96a Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Tue, 4 Nov 2014 23:35:43 +0530 Subject: [PATCH 435/436] clearing typos --- ...AverageRequestsServingCapabilityEvent.java | 31 ++++++++++++ ...equestsServingCapabilityEventListener.java | 14 ++++++ ...estsServingCapabilityMessageProcessor.java | 49 +++++++++++++++++++ .../AverageServedRequestsEventFormatter.xml | 32 ++++++++++++ ...uestHandlingCapabilityWindowProcessor.java | 49 +++++++++++++++++++ 5 files changed, 175 insertions(+) create mode 100755 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java create mode 100755 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java create mode 100755 components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java create mode 100755 extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml create mode 100755 extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java new file mode 100755 index 0000000000..011c75a4e1 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/event/health/stat/AverageRequestsServingCapabilityEvent.java @@ -0,0 +1,31 @@ +package org.apache.stratos.messaging.event.health.stat; + +/** + * Created by asiri on 8/10/14. + */ +import org.apache.stratos.messaging.event.Event; +public class AverageRequestsServingCapabilityEvent extends Event{ + private final String networkPartitionId; + private final String clusterId; + private final float value; + + public AverageRequestsServingCapabilityEvent(String networkPartitionId, String clusterId, float value) { + this.networkPartitionId = networkPartitionId; + this.clusterId = clusterId; + this.value = value; + + } + public String getClusterId() { + return clusterId; + } + + public float getValue() { + return value; + } + + public String getNetworkPartitionId() { + return networkPartitionId; + } + + +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java new file mode 100755 index 0000000000..3b7916404e --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/listener/health/stat/AverageRequestsServingCapabilityEventListener.java @@ -0,0 +1,14 @@ +package org.apache.stratos.messaging.listener.health.stat; + +import org.apache.stratos.messaging.event.Event; +import org.apache.stratos.messaging.listener.EventListener; + +/** + * Created by asiri on 8/10/14. + */ +public class AverageRequestsServingCapabilityEventListener extends EventListener { + @Override + protected void onEvent(Event event) { + + } +} diff --git a/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java new file mode 100755 index 0000000000..5d4f04e1e5 --- /dev/null +++ b/components/org.apache.stratos.messaging/src/main/java/org/apache/stratos/messaging/message/processor/health/stat/AverageRequestsServingCapabilityMessageProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.messaging.message.processor.health.stat; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stratos.messaging.event.health.stat.AverageRequestsServingCapabilityEvent; +import org.apache.stratos.messaging.message.processor.MessageProcessor; +import org.apache.stratos.messaging.util.Util; + +/** + * Created by asiri on 8/15/14. + */ +public class AverageRequestsServingCapabilityMessageProcessor extends MessageProcessor { + private static final Log log = LogFactory.getLog(AverageRequestsServingCapabilityMessageProcessor.class); + + private MessageProcessor nextProcessor; + + @Override + public void setNext(MessageProcessor nextProcessor) { + this.nextProcessor = nextProcessor; + } + + @Override + public boolean process(String type, String message, Object object) { + if (AverageRequestsServingCapabilityEvent.class.getName().equals(type)) { + + // Parse complete message and build event + AverageRequestsServingCapabilityEvent event = (AverageRequestsServingCapabilityEvent) Util.jsonToObject(message, AverageRequestsServingCapabilityEvent.class); + + // Notify event listeners + notifyEventListeners(event); + + if(log.isDebugEnabled()){ + log.debug(String.format("%s event processor notified listeners ... " , type)); + } + return true; + } + else { + if(nextProcessor != null) { + return nextProcessor.process(type, message, object); + } + else { + throw new RuntimeException(String.format("Failed to process health stat message using available message processors: [type] %s [body] %s", type, message)); + } + } + } + + + +} diff --git a/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml new file mode 100755 index 0000000000..5de01286e3 --- /dev/null +++ b/extensions/cep/artifacts/eventformatters/AverageServedRequestsEventFormatter.xml @@ -0,0 +1,32 @@ + + + + + + + {"org.apache.stratos.messaging.event.health.stat.AverageRuestsServingCapabilityEvent":{"message":{"clusterId":"{{cluster_id}}","networkPartitionId":"{{network_partition_id}}","value":"{{average_served_count}}"}}} + + + summarized-health-stats + + diff --git a/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java new file mode 100755 index 0000000000..c2536a53ce --- /dev/null +++ b/extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/MemeberRequestHandlingCapabilityWindowProcessor.java @@ -0,0 +1,49 @@ +package org.apache.stratos.cep.extension; + +/** + * Created by asiri on 8/9/14. + */ + +import org.wso2.siddhi.core.config.SiddhiContext; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.extension.annotation.SiddhiExtension; + +@SiddhiExtension(namespace = "stratos", function = "divider") +public class MemeberRequestHandlingCapabilityWindowProcessor extends FunctionExecutor { + + Attribute.Type returnType = Attribute.Type.DOUBLE; + + @Override + public void init(Attribute.Type[] types, SiddhiContext siddhiContext) { + } + + @Override + protected Object process(Object obj) { + + double[] value = new double[2]; + if (obj instanceof Object[]) { + int i=0; + for (Object aObj : (Object[]) obj) { + value[i]= Double.parseDouble(String.valueOf(aObj)); + i++; + } + }//to do avoid deviding zero number of active instances won't be zero cz there is min + Double unit = (value[0] / value[1]); + if(!unit.isNaN() && !unit.isInfinite()) + return unit; + else + return 0.0; + + } + + @Override + public void destroy() { + + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } +} From 156cac848a17a771eff74e8b0f4dab6cec39af22 Mon Sep 17 00:00:00 2001 From: Asiri LIyana Arachchi Date: Wed, 5 Nov 2014 12:27:26 +0530 Subject: [PATCH 436/436] improvements to autoscaling --- .../modules/distribution/src/main/conf/siddhi/siddhi.extension | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/products/stratos/modules/distribution/src/main/conf/siddhi/siddhi.extension b/products/stratos/modules/distribution/src/main/conf/siddhi/siddhi.extension index 470d66cc2c..18417871f3 100644 --- a/products/stratos/modules/distribution/src/main/conf/siddhi/siddhi.extension +++ b/products/stratos/modules/distribution/src/main/conf/siddhi/siddhi.extension @@ -1,4 +1,5 @@ +org.apache.stratos.cep.extension.ConcatWindowProcessor +org.apache.stratos.cep.extension.MemeberRequestHandlingCapabilityWindowProcessor org.apache.stratos.cep.extension.GradientFinderWindowProcessor org.apache.stratos.cep.extension.SecondDerivativeFinderWindowProcessor org.apache.stratos.cep.extension.FaultHandlingWindowProcessor -org.apache.stratos.cep.extension.ConcatWindowProcessor